有没有可能得到类型为System.Type
变量的TypeReference
或TypeDefinition
?
更具体地说,我尝试从以下属性定义中获取String
类型:
Custom(Value=typeof(String))]
public string SomeProperty {get; set;}
发布于 2018-06-09 03:21:42
您可以使用ModuleDefinition.ImportReference()
var a = AssemblyDefinition.ReadAssembly(typeof(Program).Assembly.Location);
var type = typeof(string);
var tr = a.MainModule.ImportReference(type);
var td = tr.Resolve();
Console.WriteLine($"tr = {tr}\ntd = {td}");
https://stackoverflow.com/questions/48497956
复制相似问题