Fixed issue with some dynamic getters
このコミットが含まれているのは:
1 親
b84a5b5fe7
コミット
7e2274219a
1ファイル変更
+8
-5
@@ -45,13 +45,16 @@ namespace ComputeSharp.Shaders.Translation.Models
|
||||
DynamicMethod method = new DynamicMethod($"Get{Id}", typeof(object), new[] { typeof(object) }, DeclaringType);
|
||||
ILGenerator il = method.GetILGenerator();
|
||||
|
||||
// Load the argument (the object instance) and cast it to the right type
|
||||
il.Emit(OpCodes.Ldarg_0);
|
||||
if (!IsStatic) il.Emit(DeclaringType.IsValueType ? OpCodes.Unbox : OpCodes.Castclass, DeclaringType);
|
||||
// Load the argument (the object instance) and cast it to the right type, if needed
|
||||
if (!IsStatic)
|
||||
{
|
||||
il.Emit(OpCodes.Ldarg_0);
|
||||
il.Emit(DeclaringType.IsValueType ? OpCodes.Unbox : OpCodes.Castclass, DeclaringType);
|
||||
}
|
||||
|
||||
// Get the member value with the appropriate method
|
||||
if (Property != null) il.EmitCall(OpCodes.Callvirt, Property.GetMethod, null);
|
||||
else if (Field != null) il.Emit(OpCodes.Ldfld, Field);
|
||||
if (Property != null) il.EmitCall(IsStatic ? OpCodes.Call : OpCodes.Callvirt, Property.GetMethod, null);
|
||||
else if (Field != null) il.Emit(IsStatic ? OpCodes.Ldsfld : OpCodes.Ldfld, Field);
|
||||
else throw new InvalidOperationException("Field and property can't both be null at the same time");
|
||||
|
||||
// Box the value, if needed
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする