-
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
[API Proposal] Make System.Reflection.Emit.ILGenerator constructor protected #86110
Comments
Tagging subscribers to this area: @dotnet/area-system-reflection-emit Issue DetailsFor new persisting AssemblyBuilder.Save implementation we have abstracted out all other Reflection.Emit public APIs with #78542, similar treatment needed for ILGenerator in order to save IL using MetadataBuilder. Literally all public methods of this type are virtual, but the constructor is internal, so I could not implement it outside of CoreLib namespace System.Reflection.Emit
{
- public partial class ILGenerator
+ public abstract class ILGenerator // there is no abstract method, probably make abstract to avoid creating an instance
{
- internal ILGenerator() { }
+ protected ILGenerator() { }
public virtual int ILOffset { get { throw null; } }
public virtual void BeginCatchBlock(System.Type? exceptionType) { }
public virtual void BeginExceptFilterBlock() { }
// ... All public APIs a virtual except one, we can use the `byte arg` overload for this
[System.CLSCompliantAttribute(false)]
public void Emit(System.Reflection.Emit.OpCode opcode, sbyte arg) { }
}
} CC @AaronRobinsonMSFT @jkotas @steveharter
|
Looks good as proposed. The namespace System.Reflection.Emit
{
- public partial class ILGenerator
+ public abstract partial class ILGenerator
{
- internal ILGenerator() { }
+ protected ILGenerator() { }
}
} |
For new persisting AssemblyBuilder.Save implementation we have abstracted out all other Reflection.Emit public APIs with #78542, similar treatment needed for ILGenerator in order to save IL using MetadataBuilder. Literally all public methods of this type are virtual, but the constructor is internal, so I could not implement it outside of CoreLib
Contributes to #62956
CC @AaronRobinsonMSFT @jkotas @steveharter
The text was updated successfully, but these errors were encountered: