问题标签 [clr-profiling-api]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
c# - .NET Profiler API 中泛型 MethodRefs 的签名
我正在使用 .NET profiler API 进行 IL 重写。我的目标之一是发出被调用方法参数的类型标记。但是,当涉及到泛型时,它会变得很棘手。例如,考虑以下代码段。
方法F(C<int>)
被编译成以下 IL:
这里,callvirt
offset 处的指令IL_0003
是 MemberRef 0x0a00000d
。我现在的目标是获取此方法唯一参数的类型标记。为此,我使用该IMetadataImport::GetMemberRefProps
函数查询方法签名,然后对其进行解析以获取方法参数的类型签名。但是,我得到了未实例化的方法签名:
blob 0000001B hasthis System.Void (!0)
至于我,这有点奇怪,因为 MethodRef0x0a00000d
对应的是实例化C<int>::A(int)
,类型变量!0
应该用 实例化int
。
问题:
有什么方法可以在 .NET profiler API 中获得专门的通用方法签名?特别是上面的例子如何获取int
结果中方法参数的类型?