Mono.Cecil 分析System.Xml DLL的.NET 4.5版本时引发异常,为什么



我正在使用Mono.Cecil 0.9.5.3,在安装VS2012 RC(导致.NET 4.0系统.XML.DLL被替换为其.NET 4.5对应项)后,我在某些代码中得到了一个System.ArugmentException,该代码迭代了每个方法的自定义属性。似乎原因是在某些情况下,AsyncStateMachine属性的 ctor 参数(应该是 Type)为空。

以下代码段重现了它:

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

异常从

Mono.Cecil.ModuleDefinition.CheckFullName(string fullName = "")

我的问题是 - 这是 Mono.Ceccil 还是 System.Xml.DLL 中的错误?规范是否允许"空"类型显示为 ctor 参数?

对我来说看起来像

塞西尔中的一个错误,从某种意义上说,塞西尔应该在不崩溃的情况下阅读它。

您可以在 https://github.com/jbevain/cecil 提交错误并将 4.5 系统.XML.dll上传到某个地方吗?然后我会看一下,并报告这是实际的 Cecil 问题,还是 System.XML 中错误编码的自定义属性。

更新

这确实是塞西尔的问题。它现在已修复在主控中。您必须自己构建 Cecil,直到发布新的 nuget 包。谢谢!

相关内容

最新更新