在.NET 2.0/C#中,泛型方法上的元数据的签名格式是什么?
例如,使用C#中的在.NET 2.0/C#中,泛型方法上的元数据的签名格式是什么?,c#,.net,clr,cil,C#,.net,Clr,Cil,例如,使用C#中的out关键字的方法中的参数将显示在元数据签名中,前面有一个符号&。我正在尝试为一个泛型方法创建签名,但我不想使用元数据API来解决这个问题,肯定在什么地方有文档记录 下面是我在Socket类上对BeginReceiveFrom的一个示例: System.IAsyncResult([]System.Byte,System.Int32,System.Int32, System.Net.Sockets.SocketFlags,&System.Net.E
out
关键字的方法中的参数将显示在元数据签名中,前面有一个符号&
。我正在尝试为一个泛型方法创建签名,但我不想使用元数据API来解决这个问题,肯定在什么地方有文档记录
下面是我在Socket类上对BeginReceiveFrom的一个示例:
System.IAsyncResult([]System.Byte,System.Int32,System.Int32,
System.Net.Sockets.SocketFlags,&System.Net.EndPoint,
System.AsyncCallback,System.Object)
对于未构造类型,后面有一个倒勾,后跟参数的数量,例如
List`1
Dictionary`2
来自ECMA 335
10.7.2类型名称和算术编码
符合CLS的泛型类型名称使用格式“name[`arity]”进行编码,其中[…]表示严重重音字符“`”和arity一起是可选的。编码名称应遵循以下规则:
不确定构造的类型…来声明您使用的泛型方法
!!T
参考通用参数:
.method public static void Method<T1, T2>(!!T1 arg1, !!T2 arg2) {
// ...
}
.method public static void Method<T1, T2>(!!0 arg1, !!1 arg2)
ldc.i4.1
newobj instance void [mscorlib]System.Object::.ctor()
// !!0 and !!1 refer to the generic parameters of Method<T1, T2>,
// not any generic method this call instruction is part of
call void Method<int32, object>(!!0,!!1)
call instance void MyGenericType`1<int32>::Method(!0)