-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement remaining ILGenertorImpl methods, excluding scope. Add max stack calculation for branching. #96362
Conversation
Tagging subscribers to this area: @dotnet/area-system-reflection-emit Issue Details
Contributes to #92975
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM; minor comments \ questions, Although there is a test failure related to this PR.
public override void UsingNamespace(string usingNamespace) => throw new NotImplementedException(); | ||
public override void UsingNamespace(string usingNamespace) | ||
{ | ||
// TODO: No-op, will be implemented wit PDB support |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not throw NIE?
src/libraries/System.Reflection.Emit/src/System/Reflection/Emit/AssemblyBuilderImpl.cs
Show resolved
Hide resolved
src/libraries/System.Reflection.Emit/src/System/Reflection/Emit/ILGeneratorImpl.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Reflection.Emit/src/System/Reflection/Emit/ILGeneratorImpl.cs
Show resolved
Hide resolved
ilg.Emit(OpCodes.Ldarg_0); | ||
ilg.Emit(OpCodes.Brfalse, lab); | ||
|
||
// The label is marked with a larger stack depth, one. This IL is invalid. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So we don't detect \ throw on these cases, and CreateTypeInfo() doesn't either?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These tests are imported from runtime ILGenerator tests
runtime/src/libraries/System.Reflection.Emit.ILGeneration/tests/ILGenerator/Emit5Tests.cs
Lines 250 to 251 in 9e57b6a
// The label is marked with a larger stack depth, one. This IL is invalid. | |
ilg.Emit(OpCodes.Ldc_I4_1); |
Personally, I am not sure this exact test makes sense, though runtime doesn't detect or throw ...
Note the test error: |
Emit(OpCode opcode, SignatureHelper signature)
,EmitCalli(OpCode opcode, CallingConvention unmanagedCallConv, Type? returnType, Type[]? parameterTypes)
andEmitCalli(OpCode opcode, CallingConventions callingConvention, Type? returnType, Type[]? parameterTypes, Type[]? optionalParameterTypes)
method+optionalParameters
reference scenario, also refactored/fixed allModuleBuilder.Get***MetadataToken
implementations as neededNotImplementedException
) forBeginScope()
,EndScope()
andUsingNamespace(string usingNamespace)
, their implementations will be added with PDB support.BadImageFormatException
when loading generated assemblies withAssembly.LoadFrom(path)
for run. Some tests now run the loaded assembly.Contributes to #92975