Skip to content

Commit f42e965

Browse files
authored
Merge branch 'main' into user/crisl/add-ResourceTimeRange
2 parents 4b31156 + af7b884 commit f42e965

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/Microsoft.Performance.SDK/Processing/CodeGenerationContext.cs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,21 @@ private static Type CreateStructFunctionType(MethodInfo methodToCall)
110110
var resultType = methodToCall.ReturnType;
111111

112112
var type = moduleBuilder.DefineType(
113-
methodToCall.DeclaringType.FullName + "$." + methodToCall.Name,
113+
//
114+
// Notes:
115+
//
116+
// 1. `MethodInfo.MethodHandle.Value` is used in the name of the generated type as a unique identifier
117+
// to avoid type name collisions.
118+
//
119+
// `MethofInfo.DelaringType.FullName` and `MethofInfo.DelaringType.Name` are used there only for
120+
// easy attribution purposes and could, in principle, be removed. The exact `methodToCall` is
121+
// available in the code of the `get_Item` method of the generated dynamic type.
122+
//
123+
// 2. The `MethodInfo.MethodHandle.Value` cannot be reused while this generated type is still loaded
124+
// because `methodToCall` is referenced directly in the IL code of the `get_Item` method of the
125+
// generated dynamic type.
126+
//
127+
$"{methodToCall.DeclaringType.FullName}$.{methodToCall.Name}$.{methodToCall.MethodHandle.Value.ToInt64():x16}",
114128
TypeAttributes.Public,
115129
typeof(ValueType),
116130
new Type[]

0 commit comments

Comments
 (0)