I'm using Mono.Cecil 0.9.5.3, and after installing VS2012 RC (which causes the .NET 4.0 System.XML.DLL to be replaced with its .NET 4.5 counterpart), I get an System.ArugmentException in some code that iterates each methods' custom attributes. It appears the cause is that in certain cases, the AsyncStateMachine
attribute's ctor argument, which should be a Type, is empty.
The following piece of code reproduces it:
string path = Assembly.Load("System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089").Location;
AssemblyDefinition systemXmlAssembly = AssemblyDefinition.ReadAssembly(path);
var query =
from ModuleDefinition module in systemXmlAssembly.Modules
from TypeDefinition td in module.Types
from MethodDefinition method in td.Methods
from CustomAttribute att in method.CustomAttributes
where method.Name == "System.Xml.IDtdParser.ParseInternalDtdAsync" &&
att.AttributeType.Name == "AsyncStateMachineAttribute"
select att;
CustomAttribute attribute = query.Single();
var args = attribute.ConstructorArguments; // <---- this line throws an ArgumentException
The exception is thrown from
Mono.Cecil.ModuleDefinition.CheckFullName(string fullName = "")
My question is - is this a bug in Mono.Cecil, or the System.Xml.DLL? Does the spec allow for an "empty" Type to appear as the ctor argument?
Looks like a bug in Cecil to me, in the sense that Cecil should read that without crashing.
Can you file a bug at https://github.com/jbevain/cecil and upload the 4.5 System.XML.dll somewhere? I'll have a look then, and report whether it's an actual Cecil issue, or a wrongly encoded custom attribute in System.XML.
Update:
It was indeed an issue with Cecil. It's now fixed in master. You'll have to build Cecil yourself until a new nuget package is released. Thanks!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With