Ome*_*viv 5 c# mono.cecil async-await
我正在使用Mono.Cecil 0.9.5.3,并在安装VS2012 RC(导致.NET 4.0 System.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
Run Code Online (Sandbox Code Playgroud)
抛出异常
Mono.Cecil.ModuleDefinition.CheckFullName(string fullName = "")
Run Code Online (Sandbox Code Playgroud)
我的问题是 - 这是Mono.Cecil或System.Xml.DLL中的错误吗?规范是否允许"空"类型显示为ctor参数?
Jb *_*ain 10
在我看来塞西尔的一个错误,塞西尔应该在不崩溃的情况下阅读.
你可以在https://github.com/jbevain/cecil上提交一个错误并在某处上传4.5 System.XML.dll吗?然后我会看一下,然后报告它是一个真正的Cecil问题,还是System.XML中错误编码的自定义属性.
更新:
塞西尔确实是一个问题.它现在已在master中修复.您必须自己构建Cecil,直到发布新的nuget包.谢谢!
| 归档时间: |
|
| 查看次数: |
580 次 |
| 最近记录: |