-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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]: Abstract System.Reflection.Emit public types #78542
Comments
Tagging subscribers to this area: @dotnet/area-system-reflection Issue DetailsWe plan to abstract out Reflection.Emit APIs for adding namespace System.Reflection.Emit
{
- public sealed partial class AssemblyBuilder : System.Reflection.Assembly
+ public abstract partial class AssemblyBuilder : System.Reflection.Assembly
{
- internal AssemblyBuilder() { }
+ protected AssemblyBuilder() { }
- public System.Reflection.Emit.ModuleBuilder DefineDynamicModule(string name) { throw null; }
+ public abstract System.Reflection.Emit.ModuleBuilder DefineDynamicModule(string name);
- public System.Reflection.Emit.ModuleBuilder? GetDynamicModule(string name) { throw null; }
+ public abstract System.Reflection.Emit.ModuleBuilder? GetDynamicModule(string name);
- public void SetCustomAttribute(System.Reflection.ConstructorInfo con, byte[] binaryAttribute) { }
+ public abstract void SetCustomAttribute(System.Reflection.ConstructorInfo con, byte[] binaryAttribute);
- public void SetCustomAttribute(System.Reflection.Emit.CustomAttributeBuilder customBuilder) { }
+ public abstract void SetCustomAttribute(System.Reflection.Emit.CustomAttributeBuilder customBuilder);
}
- public sealed partial class ConstructorBuilder : System.Reflection.ConstructorInfo
+ public abstract partial class ConstructorBuilder : System.Reflection.ConstructorInfo
{
- internal ConstructorBuilder() { }
+ protected ConstructorBuilder() { }
- public bool InitLocals { get { throw null; } set { } }
+ public abstract bool InitLocals { get; set; }
- public System.Reflection.Emit.ParameterBuilder DefineParameter(int iSequence, System.Reflection.ParameterAttributes attributes, string? strParamName) { throw null; }
+ public abstract System.Reflection.Emit.ParameterBuilder DefineParameter(int iSequence, System.Reflection.ParameterAttributes attributes, string? strParamName);
- public System.Reflection.Emit.ILGenerator GetILGenerator() { throw null; }
+ public abstract ILGenerator GetILGenerator();
- public System.Reflection.Emit.ILGenerator GetILGenerator(int streamSize) { throw null; }
+ public abstract System.Reflection.Emit.ILGenerator GetILGenerator(int streamSize);
- public void SetCustomAttribute(System.Reflection.ConstructorInfo con, byte[] binaryAttribute) { }
+ public abstract void SetCustomAttribute(System.Reflection.ConstructorInfo con, byte[] binaryAttribute);
- public void SetCustomAttribute(System.Reflection.Emit.CustomAttributeBuilder customBuilder) { }
+ public abstract void SetCustomAttribute(System.Reflection.Emit.CustomAttributeBuilder customBuilder);
- public void SetImplementationFlags(System.Reflection.MethodImplAttributes attributes) { }
+ public abstract void SetImplementationFlags(System.Reflection.MethodImplAttributes attributes);
}
- public sealed partial class EnumBuilder : System.Reflection.TypeInfo
+ public abstract partial class EnumBuilder : System.Reflection.TypeInfo
{
- internal EnumBuilder() { }
+ protected EnumBuilder() { }
- public System.Reflection.Emit.FieldBuilder UnderlyingField { get { throw null; } }
+ public abstract System.Reflection.Emit.FieldBuilder UnderlyingField { get ; }
- public System.Reflection.TypeInfo CreateTypeInfo() { throw null; }
+ public abstract System.Reflection.TypeInfo CreateTypeInfo()
- public System.Reflection.Emit.FieldBuilder DefineLiteral(string literalName, object? literalValue) { throw null; }
+ public abstract System.Reflection.Emit.FieldBuilder DefineLiteral(string literalName, object? literalValue);
- public void SetCustomAttribute(System.Reflection.ConstructorInfo con, byte[] binaryAttribute) { }
+ public abstract void SetCustomAttribute(System.Reflection.Emit.CustomAttributeBuilder customBuilder);
- public void SetCustomAttribute(System.Reflection.ConstructorInfo con, byte[] binaryAttribute) { }
+ public abstract void SetCustomAttribute(System.Reflection.Emit.CustomAttributeBuilder customBuilder);
}
- public sealed partial class EventBuilder
+ public abstract partial class EventBuilder
{
- internal EventBuilder() { }
+ protected EventBuilder() { }
- public void AddOtherMethod(System.Reflection.Emit.MethodBuilder mdBuilder) { }
+ public abstract void AddOtherMethod(System.Reflection.Emit.MethodBuilder mdBuilder);
- public void SetAddOnMethod(System.Reflection.Emit.MethodBuilder mdBuilder) { }
+ public abstract void SetAddOnMethod(System.Reflection.Emit.MethodBuilder mdBuilder);
- public void SetCustomAttribute(System.Reflection.ConstructorInfo con, byte[] binaryAttribute) { }
+ public abstract void SetCustomAttribute(System.Reflection.ConstructorInfo con, byte[] binaryAttribute);
- public void SetCustomAttribute(System.Reflection.Emit.CustomAttributeBuilder customBuilder) { }
+ public abstract void SetCustomAttribute(System.Reflection.Emit.CustomAttributeBuilder customBuilder);
- public void SetRaiseMethod(System.Reflection.Emit.MethodBuilder mdBuilder) { }
+ public abstract void SetRaiseMethod(System.Reflection.Emit.MethodBuilder mdBuilder);
- public void SetRemoveOnMethod(System.Reflection.Emit.MethodBuilder mdBuilder) { }
+ public abstract void SetRemoveOnMethod(System.Reflection.Emit.MethodBuilder mdBuilder);
}
- public sealed partial class FieldBuilder : System.Reflection.FieldInfo
+ public abstract partial class FieldBuilder : System.Reflection.FieldInfo
{
- internal FieldBuilder() { }
+ protected FieldBuilder() { }
- public void SetConstant(object? defaultValue) { }
+ public abstract void SetConstant(object? defaultValue);
- public void SetCustomAttribute(System.Reflection.ConstructorInfo con, byte[] binaryAttribute) { }
+ public abstract void SetCustomAttribute(System.Reflection.ConstructorInfo con, byte[] binaryAttribute);
- public void SetCustomAttribute(System.Reflection.Emit.CustomAttributeBuilder customBuilder) { }
+ public abstract void SetCustomAttribute(System.Reflection.Emit.CustomAttributeBuilder customBuilder);
- public void SetOffset(int iOffset) { }
+ public abstract void SetOffset(int iOffset);
}
- public sealed partial class GenericTypeParameterBuilder : System.Reflection.TypeInfo
+ public abstract partial class GenericTypeParameterBuilder : System.Reflection.TypeInfo
{
- internal GenericTypeParameterBuilder() { }
+ protected GenericTypeParameterBuilder() { }
- public void SetBaseTypeConstraint([System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.All)] System.Type? baseTypeConstraint) { }
+ public abstract void SetBaseTypeConstraint([System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.All)] System.Type? baseTypeConstraint);
- public void SetCustomAttribute(System.Reflection.ConstructorInfo con, byte[] binaryAttribute) { }
+ public abstract void SetCustomAttribute(System.Reflection.ConstructorInfo con, byte[] binaryAttribute);
- public void SetCustomAttribute(System.Reflection.Emit.CustomAttributeBuilder customBuilder) { }
+ public abstract void SetCustomAttribute(System.Reflection.Emit.CustomAttributeBuilder customBuilder);
- public void SetGenericParameterAttributes(System.Reflection.GenericParameterAttributes genericParameterAttributes) { }
+ public abstract void SetGenericParameterAttributes(System.Reflection.GenericParameterAttributes genericParameterAttributes);
- public void SetInterfaceConstraints(params System.Type[]? interfaceConstraints) { }
+ public abstract void SetInterfaceConstraints(params System.Type[]? interfaceConstraints);
}
- public sealed partial class MethodBuilder : System.Reflection.MethodInfo
+ public abstract partial class MethodBuilder : System.Reflection.MethodInfo
{
- internal MethodBuilder() { }
+ protected MethodBuilder() { }
- public bool InitLocals { get { throw null; } set { } }
+ public abstract bool InitLocals { get; set; }
- public System.Reflection.Emit.GenericTypeParameterBuilder[] DefineGenericParameters(params string[] names) { throw null; }
+ public abstract System.Reflection.Emit.GenericTypeParameterBuilder[] DefineGenericParameters(params string[] names);
- public System.Reflection.Emit.ParameterBuilder DefineParameter(int position, System.Reflection.ParameterAttributes attributes, string? strParamName) { throw null; }
+ public abstract System.Reflection.Emit.ParameterBuilder DefineParameter(int position, System.Reflection.ParameterAttributes attributes, string? strParamName);
- public System.Reflection.Emit.ILGenerator GetILGenerator() { throw null; }
+ public abstract System.Reflection.Emit.ILGenerator GetILGenerator();
- public System.Reflection.Emit.ILGenerator GetILGenerator(int size) { throw null; }
+ public abstract System.Reflection.Emit.ILGenerator GetILGenerator(int size);
- public void SetCustomAttribute(System.Reflection.ConstructorInfo con, byte[] binaryAttribute) { }
+ public abstract void SetCustomAttribute(System.Reflection.ConstructorInfo con, byte[] binaryAttribute);
- public void SetCustomAttribute(System.Reflection.Emit.CustomAttributeBuilder customBuilder) { }
+ public abstract void SetCustomAttribute(System.Reflection.Emit.CustomAttributeBuilder customBuilder);
- public void SetImplementationFlags(System.Reflection.MethodImplAttributes attributes) { }
+ public abstract void SetImplementationFlags(System.Reflection.MethodImplAttributes attributes);
- public void SetParameters(params System.Type[] parameterTypes) { }
+ public abstract void SetParameters(params System.Type[] parameterTypes);
- public void SetReturnType(System.Type? returnType) { }
+ public abstract void SetReturnType(System.Type? returnType);
- public void SetSignature(System.Type? returnType, System.Type[]? returnTypeRequiredCustomModifiers, System.Type[]? returnTypeOptionalCustomModifiers, System.Type[]? parameterTypes, System.Type[][]? parameterTypeRequiredCustomModifiers, System.Type[][]? parameterTypeOptionalCustomModifiers) { }
+ public abstract void SetSignature(System.Type? returnType, System.Type[]? returnTypeRequiredCustomModifiers, System.Type[]? returnTypeOptionalCustomModifiers, System.Type[]? parameterTypes, System.Type[][]? parameterTypeRequiredCustomModifiers, System.Type[][]? parameterTypeOptionalCustomModifiers);
}
- public partial class ModuleBuilder : System.Reflection.Module
+ public abstract partial class ModuleBuilder : System.Reflection.Module
{
- internal ModuleBuilder() { }
+ protected ModuleBuilder() { }
- public void CreateGlobalFunctions() { }
+ public abstract void CreateGlobalFunctions();
- public System.Reflection.Emit.EnumBuilder DefineEnum(string name, System.Reflection.TypeAttributes visibility, System.Type underlyingType) { throw null; }
+ public abstract System.Reflection.Emit.EnumBuilder DefineEnum(string name, System.Reflection.TypeAttributes visibility, System.Type underlyingType);
- public System.Reflection.Emit.MethodBuilder DefineGlobalMethod(string name, System.Reflection.MethodAttributes attributes, System.Reflection.CallingConventions callingConvention, System.Type? returnType, System.Type[]? requiredReturnTypeCustomModifiers, System.Type[]? optionalReturnTypeCustomModifiers, System.Type[]? parameterTypes, System.Type[][]? requiredParameterTypeCustomModifiers, System.Type[][]? optionalParameterTypeCustomModifiers) { throw null; }
+ public abstract System.Reflection.Emit.MethodBuilder DefineGlobalMethod(string name, System.Reflection.MethodAttributes attributes, System.Reflection.CallingConventions callingConvention, System.Type? returnType, System.Type[]? requiredReturnTypeCustomModifiers, System.Type[]? optionalReturnTypeCustomModifiers, System.Type[]? parameterTypes, System.Type[][]? requiredParameterTypeCustomModifiers, System.Type[][]? optionalParameterTypeCustomModifiers);
- public System.Reflection.Emit.FieldBuilder DefineInitializedData(string name, byte[] data, System.Reflection.FieldAttributes attributes) { throw null; }
+ public abstract System.Reflection.Emit.FieldBuilder DefineInitializedData(string name, byte[] data, System.Reflection.FieldAttributes attributes);
- public System.Reflection.Emit.MethodBuilder DefinePInvokeMethod(string name, string dllName, string entryName, System.Reflection.MethodAttributes attributes, System.Reflection.CallingConventions callingConvention, System.Type? returnType, System.Type[]? parameterTypes, System.Runtime.InteropServices.CallingConvention nativeCallConv, System.Runtime.InteropServices.CharSet nativeCharSet) { throw null; }
+ public abstract System.Reflection.Emit.MethodBuilder DefinePInvokeMethod(string name, string dllName, string entryName, System.Reflection.MethodAttributes attributes, System.Reflection.CallingConventions callingConvention, System.Type? returnType, System.Type[]? parameterTypes, System.Runtime.InteropServices.CallingConvention nativeCallConv, System.Runtime.InteropServices.CharSet nativeCharSet);
- public System.Reflection.Emit.TypeBuilder DefineType(string name, System.Reflection.TypeAttributes attr, [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.All)] System.Type? parent, System.Reflection.Emit.PackingSize packingSize, int typesize) { throw null; }
+ public abstract System.Reflection.Emit.TypeBuilder DefineType(string name, System.Reflection.TypeAttributes attr, [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.All)] System.Type? parent, System.Reflection.Emit.PackingSize packingSize, int typesize);
- public System.Reflection.Emit.TypeBuilder DefineType(string name, System.Reflection.TypeAttributes attr, [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.All)] System.Type? parent, System.Type[]? interfaces) { throw null; }
+ public abstract System.Reflection.Emit.TypeBuilder DefineType(string name, System.Reflection.TypeAttributes attr, [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.All)] System.Type? parent, System.Type[]? interfaces);
- public System.Reflection.Emit.FieldBuilder DefineUninitializedData(string name, int size, System.Reflection.FieldAttributes attributes) { throw null; }
+ public abstract System.Reflection.Emit.FieldBuilder DefineUninitializedData(string name, int size, System.Reflection.FieldAttributes attributes);
- public System.Reflection.MethodInfo GetArrayMethod(System.Type arrayClass, string methodName, System.Reflection.CallingConventions callingConvention, System.Type? returnType, System.Type[]? parameterTypes) { throw null; }
+ public abstract System.Reflection.MethodInfo GetArrayMethod(System.Type arrayClass, string methodName, System.Reflection.CallingConventions callingConvention, System.Type? returnType, System.Type[]? parameterTypes);
- public void SetCustomAttribute(System.Reflection.ConstructorInfo con, byte[] binaryAttribute) { }
+ public abstract void SetCustomAttribute(System.Reflection.ConstructorInfo con, byte[] binaryAttribute);
- public void SetCustomAttribute(System.Reflection.Emit.CustomAttributeBuilder customBuilder) { }
+ public abstract void SetCustomAttribute(System.Reflection.Emit.CustomAttributeBuilder customBuilder);
}
- public sealed partial class PropertyBuilder : System.Reflection.PropertyInfo
+ public abstract partial class PropertyBuilder : System.Reflection.PropertyInfo
{
- internal PropertyBuilder() { }
+ protected PropertyBuilder() { }
- public void AddOtherMethod(System.Reflection.Emit.MethodBuilder mdBuilder) { }
+ public abstract void AddOtherMethod(System.Reflection.Emit.MethodBuilder mdBuilder);
- public void SetConstant(object? defaultValue) { }
+ public abstract void SetConstant(object? defaultValue);
- public void SetCustomAttribute(System.Reflection.ConstructorInfo con, byte[] binaryAttribute) { }
+ public abstract void SetCustomAttribute(System.Reflection.ConstructorInfo con, byte[] binaryAttribute);
- public void SetCustomAttribute(System.Reflection.Emit.CustomAttributeBuilder customBuilder) { }
+ public abstract void SetCustomAttribute(System.Reflection.Emit.CustomAttributeBuilder customBuilder);
- public void SetGetMethod(System.Reflection.Emit.MethodBuilder mdBuilder) { }
+ public abstract void SetGetMethod(System.Reflection.Emit.MethodBuilder mdBuilder);
- public void SetSetMethod(System.Reflection.Emit.MethodBuilder mdBuilder) { }
+ public abstract void SetSetMethod(System.Reflection.Emit.MethodBuilder mdBuilder);
}
- public sealed partial class TypeBuilder : System.Reflection.TypeInfo
+ public abstract partial class TypeBuilder : System.Reflection.TypeInfo
{
- internal TypeBuilder() { }
+ protected TypeBuilder() { }
- public System.Reflection.Emit.PackingSize PackingSize { get { throw null; } }
+ public abstract System.Reflection.Emit.PackingSize PackingSize { get; }
- public int Size { get { throw null; } }
+ public abstract int Size { get; }
- public void AddInterfaceImplementation([System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.All)] System.Type interfaceType) { }
+ public abstract void AddInterfaceImplementation([System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.All)] System.Type interfaceType);
- public System.Reflection.TypeInfo CreateTypeInfo() { throw null; }
+ public abstract System.Reflection.TypeInfo CreateTypeInfo();
- public System.Reflection.Emit.ConstructorBuilder DefineConstructor(System.Reflection.MethodAttributes attributes, System.Reflection.CallingConventions callingConvention, System.Type[]? parameterTypes, System.Type[][]? requiredCustomModifiers, System.Type[][]? optionalCustomModifiers) { throw null; }
+ public abstract System.Reflection.Emit.ConstructorBuilder DefineConstructor(System.Reflection.MethodAttributes attributes, System.Reflection.CallingConventions callingConvention, System.Type[]? parameterTypes, System.Type[][]? requiredCustomModifiers, System.Type[][]? optionalCustomModifiers);
- public System.Reflection.Emit.ConstructorBuilder DefineDefaultConstructor(System.Reflection.MethodAttributes attributes) { throw null; }
+ public abstract System.Reflection.Emit.ConstructorBuilder DefineDefaultConstructor(System.Reflection.MethodAttributes attributes);
- public System.Reflection.Emit.EventBuilder DefineEvent(string name, System.Reflection.EventAttributes attributes, System.Type eventtype) { throw null; }
+ public abstract System.Reflection.Emit.EventBuilder DefineEvent(string name, System.Reflection.EventAttributes attributes, System.Type eventtype);
- public System.Reflection.Emit.FieldBuilder DefineField(string fieldName, System.Type type, System.Type[]? requiredCustomModifiers, System.Type[]? optionalCustomModifiers, System.Reflection.FieldAttributes attributes) { throw null; }
+ public abstract System.Reflection.Emit.FieldBuilder DefineField(string fieldName, System.Type type, System.Type[]? requiredCustomModifiers, System.Type[]? optionalCustomModifiers, System.Reflection.FieldAttributes attributes);
- public System.Reflection.Emit.GenericTypeParameterBuilder[] DefineGenericParameters(params string[] names) { throw null; }
+ public abstract System.Reflection.Emit.GenericTypeParameterBuilder[] DefineGenericParameters(params string[] names);
- public System.Reflection.Emit.FieldBuilder DefineInitializedData(string name, byte[] data, System.Reflection.FieldAttributes attributes) { throw null; }
+ public abstract System.Reflection.Emit.FieldBuilder DefineInitializedData(string name, byte[] data, System.Reflection.FieldAttributes attributes);
- public System.Reflection.Emit.MethodBuilder DefineMethod(string name, System.Reflection.MethodAttributes attributes, System.Reflection.CallingConventions callingConvention, System.Type? returnType, System.Type[]? returnTypeRequiredCustomModifiers, System.Type[]? returnTypeOptionalCustomModifiers, System.Type[]? parameterTypes, System.Type[][]? parameterTypeRequiredCustomModifiers, System.Type[][]? parameterTypeOptionalCustomModifiers) { throw null; }
+ public abstract System.Reflection.Emit.MethodBuilder DefineMethod(string name, System.Reflection.MethodAttributes attributes, System.Reflection.CallingConventions callingConvention, System.Type? returnType, System.Type[]? returnTypeRequiredCustomModifiers, System.Type[]? returnTypeOptionalCustomModifiers, System.Type[]? parameterTypes, System.Type[][]? parameterTypeRequiredCustomModifiers, System.Type[][]? parameterTypeOptionalCustomModifiers);
- public void DefineMethodOverride(System.Reflection.MethodInfo methodInfoBody, System.Reflection.MethodInfo methodInfoDeclaration) { }
+ public abstract void DefineMethodOverride(System.Reflection.MethodInfo methodInfoBody, System.Reflection.MethodInfo methodInfoDeclaration);
- public System.Reflection.Emit.TypeBuilder DefineNestedType(string name, System.Reflection.TypeAttributes attr, [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.All)] System.Type? parent, System.Reflection.Emit.PackingSize packSize, int typeSize) { throw null; }
+ public abstract System.Reflection.Emit.TypeBuilder DefineNestedType(string name, System.Reflection.TypeAttributes attr, [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.All)] System.Type? parent, System.Reflection.Emit.PackingSize packSize, int typeSize);
- public System.Reflection.Emit.TypeBuilder DefineNestedType(string name, System.Reflection.TypeAttributes attr, [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.All)] System.Type? parent, System.Type[]? interfaces) { throw null; }
+ public abstract System.Reflection.Emit.TypeBuilder DefineNestedType(string name, System.Reflection.TypeAttributes attr, [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.All)] System.Type? parent, System.Type[]? interfaces);
- public System.Reflection.Emit.MethodBuilder DefinePInvokeMethod(string name, string dllName, string entryName, System.Reflection.MethodAttributes attributes, System.Reflection.CallingConventions callingConvention, System.Type? returnType, System.Type[]? returnTypeRequiredCustomModifiers, System.Type[]? returnTypeOptionalCustomModifiers, System.Type[]? parameterTypes, System.Type[][]? parameterTypeRequiredCustomModifiers, System.Type[][]? parameterTypeOptionalCustomModifiers, System.Runtime.InteropServices.CallingConvention nativeCallConv, System.Runtime.InteropServices.CharSet nativeCharSet) { throw null; }
+ public abstract System.Reflection.Emit.MethodBuilder DefinePInvokeMethod(string name, string dllName, string entryName, System.Reflection.MethodAttributes attributes, System.Reflection.CallingConventions callingConvention, System.Type? returnType, System.Type[]? returnTypeRequiredCustomModifiers, System.Type[]? returnTypeOptionalCustomModifiers, System.Type[]? parameterTypes, System.Type[][]? parameterTypeRequiredCustomModifiers, System.Type[][]? parameterTypeOptionalCustomModifiers, System.Runtime.InteropServices.CallingConvention nativeCallConv, System.Runtime.InteropServices.CharSet nativeCharSet);
- public System.Reflection.Emit.PropertyBuilder DefineProperty(string name, System.Reflection.PropertyAttributes attributes, System.Reflection.CallingConventions callingConvention, System.Type returnType, System.Type[]? returnTypeRequiredCustomModifiers, System.Type[]? returnTypeOptionalCustomModifiers, System.Type[]? parameterTypes, System.Type[][]? parameterTypeRequiredCustomModifiers, System.Type[][]? parameterTypeOptionalCustomModifiers) { throw null; }
+ public abstract System.Reflection.Emit.PropertyBuilder DefineProperty(string name, System.Reflection.PropertyAttributes attributes, System.Reflection.CallingConventions callingConvention, System.Type returnType, System.Type[]? returnTypeRequiredCustomModifiers, System.Type[]? returnTypeOptionalCustomModifiers, System.Type[]? parameterTypes, System.Type[][]? parameterTypeRequiredCustomModifiers, System.Type[][]? parameterTypeOptionalCustomModifiers);
- public System.Reflection.Emit.ConstructorBuilder DefineTypeInitializer() { throw null; }
+ public abstract System.Reflection.Emit.ConstructorBuilder DefineTypeInitializer();
- public System.Reflection.Emit.FieldBuilder DefineUninitializedData(string name, int size, System.Reflection.FieldAttributes attributes) { throw null; }
+ public abstract System.Reflection.Emit.FieldBuilder DefineUninitializedData(string name, int size, System.Reflection.FieldAttributes attributes);
- public bool IsCreated() { throw null; }
+ public abstract bool IsCreated();
- public void SetCustomAttribute(System.Reflection.ConstructorInfo con, byte[] binaryAttribute) { }
+ public abstract void SetCustomAttribute(System.Reflection.ConstructorInfo con, byte[] binaryAttribute);
- public void SetCustomAttribute(System.Reflection.Emit.CustomAttributeBuilder customBuilder) { }
+ public abstract void SetCustomAttribute(System.Reflection.Emit.CustomAttributeBuilder customBuilder);
- public void SetParent([System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.All)] System.Type? parent) { }
+ public abstract void SetParent([System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.All)] System.Type? parent);
}
} CC @jkotas @steveharter @AaronRobinsonMSFT @terrajobst
|
Tagging subscribers to this area: @dotnet/area-system-reflection-emit Issue DetailsWe plan to abstract out Reflection.Emit APIs for adding namespace System.Reflection.Emit
{
- public sealed partial class AssemblyBuilder : System.Reflection.Assembly
+ public abstract partial class AssemblyBuilder : System.Reflection.Assembly
{
- internal AssemblyBuilder() { }
+ protected AssemblyBuilder() { }
- public System.Reflection.Emit.ModuleBuilder DefineDynamicModule(string name) { throw null; }
+ public abstract System.Reflection.Emit.ModuleBuilder DefineDynamicModule(string name);
- public System.Reflection.Emit.ModuleBuilder? GetDynamicModule(string name) { throw null; }
+ public abstract System.Reflection.Emit.ModuleBuilder? GetDynamicModule(string name);
- public void SetCustomAttribute(System.Reflection.ConstructorInfo con, byte[] binaryAttribute) { }
+ public abstract void SetCustomAttribute(System.Reflection.ConstructorInfo con, byte[] binaryAttribute);
- public void SetCustomAttribute(System.Reflection.Emit.CustomAttributeBuilder customBuilder) { }
+ public abstract void SetCustomAttribute(System.Reflection.Emit.CustomAttributeBuilder customBuilder);
}
- public sealed partial class ConstructorBuilder : System.Reflection.ConstructorInfo
+ public abstract partial class ConstructorBuilder : System.Reflection.ConstructorInfo
{
- internal ConstructorBuilder() { }
+ protected ConstructorBuilder() { }
- public bool InitLocals { get { throw null; } set { } }
+ public abstract bool InitLocals { get; set; }
- public System.Reflection.Emit.ParameterBuilder DefineParameter(int iSequence, System.Reflection.ParameterAttributes attributes, string? strParamName) { throw null; }
+ public abstract System.Reflection.Emit.ParameterBuilder DefineParameter(int iSequence, System.Reflection.ParameterAttributes attributes, string? strParamName);
- public System.Reflection.Emit.ILGenerator GetILGenerator() { throw null; }
+ public abstract ILGenerator GetILGenerator();
- public System.Reflection.Emit.ILGenerator GetILGenerator(int streamSize) { throw null; }
+ public abstract System.Reflection.Emit.ILGenerator GetILGenerator(int streamSize);
- public void SetCustomAttribute(System.Reflection.ConstructorInfo con, byte[] binaryAttribute) { }
+ public abstract void SetCustomAttribute(System.Reflection.ConstructorInfo con, byte[] binaryAttribute);
- public void SetCustomAttribute(System.Reflection.Emit.CustomAttributeBuilder customBuilder) { }
+ public abstract void SetCustomAttribute(System.Reflection.Emit.CustomAttributeBuilder customBuilder);
- public void SetImplementationFlags(System.Reflection.MethodImplAttributes attributes) { }
+ public abstract void SetImplementationFlags(System.Reflection.MethodImplAttributes attributes);
}
- public sealed partial class EnumBuilder : System.Reflection.TypeInfo
+ public abstract partial class EnumBuilder : System.Reflection.TypeInfo
{
- internal EnumBuilder() { }
+ protected EnumBuilder() { }
- public System.Reflection.Emit.FieldBuilder UnderlyingField { get { throw null; } }
+ public abstract System.Reflection.Emit.FieldBuilder UnderlyingField { get ; }
- public System.Reflection.TypeInfo CreateTypeInfo() { throw null; }
+ public abstract System.Reflection.TypeInfo CreateTypeInfo()
- public System.Reflection.Emit.FieldBuilder DefineLiteral(string literalName, object? literalValue) { throw null; }
+ public abstract System.Reflection.Emit.FieldBuilder DefineLiteral(string literalName, object? literalValue);
- public void SetCustomAttribute(System.Reflection.ConstructorInfo con, byte[] binaryAttribute) { }
+ public abstract void SetCustomAttribute(System.Reflection.Emit.CustomAttributeBuilder customBuilder);
- public void SetCustomAttribute(System.Reflection.ConstructorInfo con, byte[] binaryAttribute) { }
+ public abstract void SetCustomAttribute(System.Reflection.Emit.CustomAttributeBuilder customBuilder);
}
- public sealed partial class EventBuilder
+ public abstract partial class EventBuilder
{
- internal EventBuilder() { }
+ protected EventBuilder() { }
- public void AddOtherMethod(System.Reflection.Emit.MethodBuilder mdBuilder) { }
+ public abstract void AddOtherMethod(System.Reflection.Emit.MethodBuilder mdBuilder);
- public void SetAddOnMethod(System.Reflection.Emit.MethodBuilder mdBuilder) { }
+ public abstract void SetAddOnMethod(System.Reflection.Emit.MethodBuilder mdBuilder);
- public void SetCustomAttribute(System.Reflection.ConstructorInfo con, byte[] binaryAttribute) { }
+ public abstract void SetCustomAttribute(System.Reflection.ConstructorInfo con, byte[] binaryAttribute);
- public void SetCustomAttribute(System.Reflection.Emit.CustomAttributeBuilder customBuilder) { }
+ public abstract void SetCustomAttribute(System.Reflection.Emit.CustomAttributeBuilder customBuilder);
- public void SetRaiseMethod(System.Reflection.Emit.MethodBuilder mdBuilder) { }
+ public abstract void SetRaiseMethod(System.Reflection.Emit.MethodBuilder mdBuilder);
- public void SetRemoveOnMethod(System.Reflection.Emit.MethodBuilder mdBuilder) { }
+ public abstract void SetRemoveOnMethod(System.Reflection.Emit.MethodBuilder mdBuilder);
}
- public sealed partial class FieldBuilder : System.Reflection.FieldInfo
+ public abstract partial class FieldBuilder : System.Reflection.FieldInfo
{
- internal FieldBuilder() { }
+ protected FieldBuilder() { }
- public void SetConstant(object? defaultValue) { }
+ public abstract void SetConstant(object? defaultValue);
- public void SetCustomAttribute(System.Reflection.ConstructorInfo con, byte[] binaryAttribute) { }
+ public abstract void SetCustomAttribute(System.Reflection.ConstructorInfo con, byte[] binaryAttribute);
- public void SetCustomAttribute(System.Reflection.Emit.CustomAttributeBuilder customBuilder) { }
+ public abstract void SetCustomAttribute(System.Reflection.Emit.CustomAttributeBuilder customBuilder);
- public void SetOffset(int iOffset) { }
+ public abstract void SetOffset(int iOffset);
}
- public sealed partial class GenericTypeParameterBuilder : System.Reflection.TypeInfo
+ public abstract partial class GenericTypeParameterBuilder : System.Reflection.TypeInfo
{
- internal GenericTypeParameterBuilder() { }
+ protected GenericTypeParameterBuilder() { }
- public void SetBaseTypeConstraint([System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.All)] System.Type? baseTypeConstraint) { }
+ public abstract void SetBaseTypeConstraint([System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.All)] System.Type? baseTypeConstraint);
- public void SetCustomAttribute(System.Reflection.ConstructorInfo con, byte[] binaryAttribute) { }
+ public abstract void SetCustomAttribute(System.Reflection.ConstructorInfo con, byte[] binaryAttribute);
- public void SetCustomAttribute(System.Reflection.Emit.CustomAttributeBuilder customBuilder) { }
+ public abstract void SetCustomAttribute(System.Reflection.Emit.CustomAttributeBuilder customBuilder);
- public void SetGenericParameterAttributes(System.Reflection.GenericParameterAttributes genericParameterAttributes) { }
+ public abstract void SetGenericParameterAttributes(System.Reflection.GenericParameterAttributes genericParameterAttributes);
- public void SetInterfaceConstraints(params System.Type[]? interfaceConstraints) { }
+ public abstract void SetInterfaceConstraints(params System.Type[]? interfaceConstraints);
}
- public sealed partial class MethodBuilder : System.Reflection.MethodInfo
+ public abstract partial class MethodBuilder : System.Reflection.MethodInfo
{
- internal MethodBuilder() { }
+ protected MethodBuilder() { }
- public bool InitLocals { get { throw null; } set { } }
+ public abstract bool InitLocals { get; set; }
- public System.Reflection.Emit.GenericTypeParameterBuilder[] DefineGenericParameters(params string[] names) { throw null; }
+ public abstract System.Reflection.Emit.GenericTypeParameterBuilder[] DefineGenericParameters(params string[] names);
- public System.Reflection.Emit.ParameterBuilder DefineParameter(int position, System.Reflection.ParameterAttributes attributes, string? strParamName) { throw null; }
+ public abstract System.Reflection.Emit.ParameterBuilder DefineParameter(int position, System.Reflection.ParameterAttributes attributes, string? strParamName);
- public System.Reflection.Emit.ILGenerator GetILGenerator() { throw null; }
+ public abstract System.Reflection.Emit.ILGenerator GetILGenerator();
- public System.Reflection.Emit.ILGenerator GetILGenerator(int size) { throw null; }
+ public abstract System.Reflection.Emit.ILGenerator GetILGenerator(int size);
- public void SetCustomAttribute(System.Reflection.ConstructorInfo con, byte[] binaryAttribute) { }
+ public abstract void SetCustomAttribute(System.Reflection.ConstructorInfo con, byte[] binaryAttribute);
- public void SetCustomAttribute(System.Reflection.Emit.CustomAttributeBuilder customBuilder) { }
+ public abstract void SetCustomAttribute(System.Reflection.Emit.CustomAttributeBuilder customBuilder);
- public void SetImplementationFlags(System.Reflection.MethodImplAttributes attributes) { }
+ public abstract void SetImplementationFlags(System.Reflection.MethodImplAttributes attributes);
- public void SetParameters(params System.Type[] parameterTypes) { }
+ public abstract void SetParameters(params System.Type[] parameterTypes);
- public void SetReturnType(System.Type? returnType) { }
+ public abstract void SetReturnType(System.Type? returnType);
- public void SetSignature(System.Type? returnType, System.Type[]? returnTypeRequiredCustomModifiers, System.Type[]? returnTypeOptionalCustomModifiers, System.Type[]? parameterTypes, System.Type[][]? parameterTypeRequiredCustomModifiers, System.Type[][]? parameterTypeOptionalCustomModifiers) { }
+ public abstract void SetSignature(System.Type? returnType, System.Type[]? returnTypeRequiredCustomModifiers, System.Type[]? returnTypeOptionalCustomModifiers, System.Type[]? parameterTypes, System.Type[][]? parameterTypeRequiredCustomModifiers, System.Type[][]? parameterTypeOptionalCustomModifiers);
}
- public partial class ModuleBuilder : System.Reflection.Module
+ public abstract partial class ModuleBuilder : System.Reflection.Module
{
- internal ModuleBuilder() { }
+ protected ModuleBuilder() { }
- public void CreateGlobalFunctions() { }
+ public abstract void CreateGlobalFunctions();
- public System.Reflection.Emit.EnumBuilder DefineEnum(string name, System.Reflection.TypeAttributes visibility, System.Type underlyingType) { throw null; }
+ public abstract System.Reflection.Emit.EnumBuilder DefineEnum(string name, System.Reflection.TypeAttributes visibility, System.Type underlyingType);
- public System.Reflection.Emit.MethodBuilder DefineGlobalMethod(string name, System.Reflection.MethodAttributes attributes, System.Reflection.CallingConventions callingConvention, System.Type? returnType, System.Type[]? requiredReturnTypeCustomModifiers, System.Type[]? optionalReturnTypeCustomModifiers, System.Type[]? parameterTypes, System.Type[][]? requiredParameterTypeCustomModifiers, System.Type[][]? optionalParameterTypeCustomModifiers) { throw null; }
+ public abstract System.Reflection.Emit.MethodBuilder DefineGlobalMethod(string name, System.Reflection.MethodAttributes attributes, System.Reflection.CallingConventions callingConvention, System.Type? returnType, System.Type[]? requiredReturnTypeCustomModifiers, System.Type[]? optionalReturnTypeCustomModifiers, System.Type[]? parameterTypes, System.Type[][]? requiredParameterTypeCustomModifiers, System.Type[][]? optionalParameterTypeCustomModifiers);
- public System.Reflection.Emit.FieldBuilder DefineInitializedData(string name, byte[] data, System.Reflection.FieldAttributes attributes) { throw null; }
+ public abstract System.Reflection.Emit.FieldBuilder DefineInitializedData(string name, byte[] data, System.Reflection.FieldAttributes attributes);
- public System.Reflection.Emit.MethodBuilder DefinePInvokeMethod(string name, string dllName, string entryName, System.Reflection.MethodAttributes attributes, System.Reflection.CallingConventions callingConvention, System.Type? returnType, System.Type[]? parameterTypes, System.Runtime.InteropServices.CallingConvention nativeCallConv, System.Runtime.InteropServices.CharSet nativeCharSet) { throw null; }
+ public abstract System.Reflection.Emit.MethodBuilder DefinePInvokeMethod(string name, string dllName, string entryName, System.Reflection.MethodAttributes attributes, System.Reflection.CallingConventions callingConvention, System.Type? returnType, System.Type[]? parameterTypes, System.Runtime.InteropServices.CallingConvention nativeCallConv, System.Runtime.InteropServices.CharSet nativeCharSet);
- public System.Reflection.Emit.TypeBuilder DefineType(string name, System.Reflection.TypeAttributes attr, [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.All)] System.Type? parent, System.Reflection.Emit.PackingSize packingSize, int typesize) { throw null; }
+ public abstract System.Reflection.Emit.TypeBuilder DefineType(string name, System.Reflection.TypeAttributes attr, [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.All)] System.Type? parent, System.Reflection.Emit.PackingSize packingSize, int typesize);
- public System.Reflection.Emit.TypeBuilder DefineType(string name, System.Reflection.TypeAttributes attr, [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.All)] System.Type? parent, System.Type[]? interfaces) { throw null; }
+ public abstract System.Reflection.Emit.TypeBuilder DefineType(string name, System.Reflection.TypeAttributes attr, [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.All)] System.Type? parent, System.Type[]? interfaces);
- public System.Reflection.Emit.FieldBuilder DefineUninitializedData(string name, int size, System.Reflection.FieldAttributes attributes) { throw null; }
+ public abstract System.Reflection.Emit.FieldBuilder DefineUninitializedData(string name, int size, System.Reflection.FieldAttributes attributes);
- public System.Reflection.MethodInfo GetArrayMethod(System.Type arrayClass, string methodName, System.Reflection.CallingConventions callingConvention, System.Type? returnType, System.Type[]? parameterTypes) { throw null; }
+ public abstract System.Reflection.MethodInfo GetArrayMethod(System.Type arrayClass, string methodName, System.Reflection.CallingConventions callingConvention, System.Type? returnType, System.Type[]? parameterTypes);
- public void SetCustomAttribute(System.Reflection.ConstructorInfo con, byte[] binaryAttribute) { }
+ public abstract void SetCustomAttribute(System.Reflection.ConstructorInfo con, byte[] binaryAttribute);
- public void SetCustomAttribute(System.Reflection.Emit.CustomAttributeBuilder customBuilder) { }
+ public abstract void SetCustomAttribute(System.Reflection.Emit.CustomAttributeBuilder customBuilder);
}
- public sealed partial class PropertyBuilder : System.Reflection.PropertyInfo
+ public abstract partial class PropertyBuilder : System.Reflection.PropertyInfo
{
- internal PropertyBuilder() { }
+ protected PropertyBuilder() { }
- public void AddOtherMethod(System.Reflection.Emit.MethodBuilder mdBuilder) { }
+ public abstract void AddOtherMethod(System.Reflection.Emit.MethodBuilder mdBuilder);
- public void SetConstant(object? defaultValue) { }
+ public abstract void SetConstant(object? defaultValue);
- public void SetCustomAttribute(System.Reflection.ConstructorInfo con, byte[] binaryAttribute) { }
+ public abstract void SetCustomAttribute(System.Reflection.ConstructorInfo con, byte[] binaryAttribute);
- public void SetCustomAttribute(System.Reflection.Emit.CustomAttributeBuilder customBuilder) { }
+ public abstract void SetCustomAttribute(System.Reflection.Emit.CustomAttributeBuilder customBuilder);
- public void SetGetMethod(System.Reflection.Emit.MethodBuilder mdBuilder) { }
+ public abstract void SetGetMethod(System.Reflection.Emit.MethodBuilder mdBuilder);
- public void SetSetMethod(System.Reflection.Emit.MethodBuilder mdBuilder) { }
+ public abstract void SetSetMethod(System.Reflection.Emit.MethodBuilder mdBuilder);
}
- public sealed partial class TypeBuilder : System.Reflection.TypeInfo
+ public abstract partial class TypeBuilder : System.Reflection.TypeInfo
{
- internal TypeBuilder() { }
+ protected TypeBuilder() { }
- public System.Reflection.Emit.PackingSize PackingSize { get { throw null; } }
+ public abstract System.Reflection.Emit.PackingSize PackingSize { get; }
- public int Size { get { throw null; } }
+ public abstract int Size { get; }
- public void AddInterfaceImplementation([System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.All)] System.Type interfaceType) { }
+ public abstract void AddInterfaceImplementation([System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.All)] System.Type interfaceType);
- public System.Reflection.TypeInfo CreateTypeInfo() { throw null; }
+ public abstract System.Reflection.TypeInfo CreateTypeInfo();
- public System.Reflection.Emit.ConstructorBuilder DefineConstructor(System.Reflection.MethodAttributes attributes, System.Reflection.CallingConventions callingConvention, System.Type[]? parameterTypes, System.Type[][]? requiredCustomModifiers, System.Type[][]? optionalCustomModifiers) { throw null; }
+ public abstract System.Reflection.Emit.ConstructorBuilder DefineConstructor(System.Reflection.MethodAttributes attributes, System.Reflection.CallingConventions callingConvention, System.Type[]? parameterTypes, System.Type[][]? requiredCustomModifiers, System.Type[][]? optionalCustomModifiers);
- public System.Reflection.Emit.ConstructorBuilder DefineDefaultConstructor(System.Reflection.MethodAttributes attributes) { throw null; }
+ public abstract System.Reflection.Emit.ConstructorBuilder DefineDefaultConstructor(System.Reflection.MethodAttributes attributes);
- public System.Reflection.Emit.EventBuilder DefineEvent(string name, System.Reflection.EventAttributes attributes, System.Type eventtype) { throw null; }
+ public abstract System.Reflection.Emit.EventBuilder DefineEvent(string name, System.Reflection.EventAttributes attributes, System.Type eventtype);
- public System.Reflection.Emit.FieldBuilder DefineField(string fieldName, System.Type type, System.Type[]? requiredCustomModifiers, System.Type[]? optionalCustomModifiers, System.Reflection.FieldAttributes attributes) { throw null; }
+ public abstract System.Reflection.Emit.FieldBuilder DefineField(string fieldName, System.Type type, System.Type[]? requiredCustomModifiers, System.Type[]? optionalCustomModifiers, System.Reflection.FieldAttributes attributes);
- public System.Reflection.Emit.GenericTypeParameterBuilder[] DefineGenericParameters(params string[] names) { throw null; }
+ public abstract System.Reflection.Emit.GenericTypeParameterBuilder[] DefineGenericParameters(params string[] names);
- public System.Reflection.Emit.FieldBuilder DefineInitializedData(string name, byte[] data, System.Reflection.FieldAttributes attributes) { throw null; }
+ public abstract System.Reflection.Emit.FieldBuilder DefineInitializedData(string name, byte[] data, System.Reflection.FieldAttributes attributes);
- public System.Reflection.Emit.MethodBuilder DefineMethod(string name, System.Reflection.MethodAttributes attributes, System.Reflection.CallingConventions callingConvention, System.Type? returnType, System.Type[]? returnTypeRequiredCustomModifiers, System.Type[]? returnTypeOptionalCustomModifiers, System.Type[]? parameterTypes, System.Type[][]? parameterTypeRequiredCustomModifiers, System.Type[][]? parameterTypeOptionalCustomModifiers) { throw null; }
+ public abstract System.Reflection.Emit.MethodBuilder DefineMethod(string name, System.Reflection.MethodAttributes attributes, System.Reflection.CallingConventions callingConvention, System.Type? returnType, System.Type[]? returnTypeRequiredCustomModifiers, System.Type[]? returnTypeOptionalCustomModifiers, System.Type[]? parameterTypes, System.Type[][]? parameterTypeRequiredCustomModifiers, System.Type[][]? parameterTypeOptionalCustomModifiers);
- public void DefineMethodOverride(System.Reflection.MethodInfo methodInfoBody, System.Reflection.MethodInfo methodInfoDeclaration) { }
+ public abstract void DefineMethodOverride(System.Reflection.MethodInfo methodInfoBody, System.Reflection.MethodInfo methodInfoDeclaration);
- public System.Reflection.Emit.TypeBuilder DefineNestedType(string name, System.Reflection.TypeAttributes attr, [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.All)] System.Type? parent, System.Reflection.Emit.PackingSize packSize, int typeSize) { throw null; }
+ public abstract System.Reflection.Emit.TypeBuilder DefineNestedType(string name, System.Reflection.TypeAttributes attr, [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.All)] System.Type? parent, System.Reflection.Emit.PackingSize packSize, int typeSize);
- public System.Reflection.Emit.TypeBuilder DefineNestedType(string name, System.Reflection.TypeAttributes attr, [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.All)] System.Type? parent, System.Type[]? interfaces) { throw null; }
+ public abstract System.Reflection.Emit.TypeBuilder DefineNestedType(string name, System.Reflection.TypeAttributes attr, [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.All)] System.Type? parent, System.Type[]? interfaces);
- public System.Reflection.Emit.MethodBuilder DefinePInvokeMethod(string name, string dllName, string entryName, System.Reflection.MethodAttributes attributes, System.Reflection.CallingConventions callingConvention, System.Type? returnType, System.Type[]? returnTypeRequiredCustomModifiers, System.Type[]? returnTypeOptionalCustomModifiers, System.Type[]? parameterTypes, System.Type[][]? parameterTypeRequiredCustomModifiers, System.Type[][]? parameterTypeOptionalCustomModifiers, System.Runtime.InteropServices.CallingConvention nativeCallConv, System.Runtime.InteropServices.CharSet nativeCharSet) { throw null; }
+ public abstract System.Reflection.Emit.MethodBuilder DefinePInvokeMethod(string name, string dllName, string entryName, System.Reflection.MethodAttributes attributes, System.Reflection.CallingConventions callingConvention, System.Type? returnType, System.Type[]? returnTypeRequiredCustomModifiers, System.Type[]? returnTypeOptionalCustomModifiers, System.Type[]? parameterTypes, System.Type[][]? parameterTypeRequiredCustomModifiers, System.Type[][]? parameterTypeOptionalCustomModifiers, System.Runtime.InteropServices.CallingConvention nativeCallConv, System.Runtime.InteropServices.CharSet nativeCharSet);
- public System.Reflection.Emit.PropertyBuilder DefineProperty(string name, System.Reflection.PropertyAttributes attributes, System.Reflection.CallingConventions callingConvention, System.Type returnType, System.Type[]? returnTypeRequiredCustomModifiers, System.Type[]? returnTypeOptionalCustomModifiers, System.Type[]? parameterTypes, System.Type[][]? parameterTypeRequiredCustomModifiers, System.Type[][]? parameterTypeOptionalCustomModifiers) { throw null; }
+ public abstract System.Reflection.Emit.PropertyBuilder DefineProperty(string name, System.Reflection.PropertyAttributes attributes, System.Reflection.CallingConventions callingConvention, System.Type returnType, System.Type[]? returnTypeRequiredCustomModifiers, System.Type[]? returnTypeOptionalCustomModifiers, System.Type[]? parameterTypes, System.Type[][]? parameterTypeRequiredCustomModifiers, System.Type[][]? parameterTypeOptionalCustomModifiers);
- public System.Reflection.Emit.ConstructorBuilder DefineTypeInitializer() { throw null; }
+ public abstract System.Reflection.Emit.ConstructorBuilder DefineTypeInitializer();
- public System.Reflection.Emit.FieldBuilder DefineUninitializedData(string name, int size, System.Reflection.FieldAttributes attributes) { throw null; }
+ public abstract System.Reflection.Emit.FieldBuilder DefineUninitializedData(string name, int size, System.Reflection.FieldAttributes attributes);
- public bool IsCreated() { throw null; }
+ public abstract bool IsCreated();
- public void SetCustomAttribute(System.Reflection.ConstructorInfo con, byte[] binaryAttribute) { }
+ public abstract void SetCustomAttribute(System.Reflection.ConstructorInfo con, byte[] binaryAttribute);
- public void SetCustomAttribute(System.Reflection.Emit.CustomAttributeBuilder customBuilder) { }
+ public abstract void SetCustomAttribute(System.Reflection.Emit.CustomAttributeBuilder customBuilder);
- public void SetParent([System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.All)] System.Type? parent) { }
+ public abstract void SetParent([System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.All)] System.Type? parent);
}
} CC @jkotas @steveharter @AaronRobinsonMSFT @terrajobst
|
It may be worth pointing out that a simple non-abstract -> abstract change is a potential breaking change. You are unlikely to see the break in C# since C# tends to call non-virtual methods using The proposed PR avoids the potential break change by defining the methods as Are we ok with having this permanent difference between reference and implementation assemblies? Or do we want to address this issue in some other way? cc @ericstj |
I think addressing the issue via the Template Method Pattern is better than a ref-vs-src divergence (and other trickery). For methods, it's a simple - public sealed partial class TypeBuilder : System.Reflection.TypeInfo
+ public abstract partial class TypeBuilder : System.Reflection.TypeInfo
{
- internal TypeBuilder()
+ private protected TypeBuilder()
{
...
}
- public System.Reflection.Emit.PackingSize PackingSize { get; }
+ public System.Reflection.Emit.PackingSize PackingSize => PackingSizeCore;
+ protected abstract System.Reflection.Emit.PackingSize PackingSizeCore { get; }
...
public void AddInterfaceImplementation(
[DynamicallyAccessedMembersAttribute(DynamicallyAccessedMemberTypes.All)] Type interfaceType)
{
ArgumentNullException.ThrowIfNull(interfaceType);
ThrowIfCreated();
- all the rest of the implementation
+ AddInterfaceImplementationCore(interfaceType);
+ }
+
+ protected abstract void AddInterfaceImplementationCore(
+ [DynamicallyAccessedMembersAttribute(DynamicallyAccessedMemberTypes.All)] Type interfaceType);
... |
Another option would be to just leave them virtual in the reference assembly. If we thought folks would forget to override them, we could add an analyzer. |
Is the Template Method Pattern really applicable here? There is no interesting algorithm implemented in the base class (I do not consider argument null checks to be an interesting algorithm.)
I like this option better. The idea behind this change is to open Reflection.Emit for custom implementations in similar way how System.Type is open for custom implementations. Do we think that it is a good idea? We need this capability for our own purposes as @buyaa-n described, but it is not strictly required to make this capability available through public surface. |
This will also cause infinite recursion if recursion sample
Options - (2) and (4) seem better: Does anyone foresee issues with option 2 with the different ref\impl, or have any reference implementations of that approach? If we go down that path and run into an issue in a future release, and have to make it truly abstract in the impl (i.e. move to option 1), then we would lose the binary compat since we'd have to remove the forwarding method. |
Do we have a sense how breaking this would be in practice? I'd rather we do the right thing, have them abstract and document a breaking change if we believe the impact is very fringe. |
I updated the above to say options (2) and (4) are the most feasible. Option (2) is the most "API-clean" approach and matches what we wish was there originally where the current members are changed to Option (4) avoids the trickery of (2) and leaves the current members as default\nonvirtual, but then clutters up the API by adding virtual "Impl" or "Core" methods which are called by the current members. |
And C#. 🙃 |
Do we need
Do we need a method to encode |
For C# I believe |
You are right, we are actually passing a constant instead, not needed
Yes, we need public abstract int GetMethodToken(MethodInfo method); Updating the description, thank you |
I do not think that's the case. C# generates |
namespace System.Reflection.Emit
{
- public sealed partial class AssemblyBuilder : System.Reflection.Assembly
+ public abstract partial class AssemblyBuilder : System.Reflection.Assembly
{
- internal AssemblyBuilder();
+ protected AssemblyBuilder();
- public System.Reflection.Emit.ModuleBuilder DefineDynamicModule(string name);
+ public virtual System.Reflection.Emit.ModuleBuilder DefineDynamicModule(string name);
- public System.Reflection.Emit.ModuleBuilder? GetDynamicModule(string name);
+ public virtual System.Reflection.Emit.ModuleBuilder? GetDynamicModule(string name);
- public void SetCustomAttribute(System.Reflection.ConstructorInfo con, byte[] binaryAttribute);
+ public virtual void SetCustomAttribute(System.Reflection.ConstructorInfo con, byte[] binaryAttribute);
- public void SetCustomAttribute(System.Reflection.Emit.CustomAttributeBuilder customBuilder);
+ public virtual void SetCustomAttribute(System.Reflection.Emit.CustomAttributeBuilder customBuilder);
}
- public sealed partial class ConstructorBuilder : System.Reflection.ConstructorInfo
+ public abstract partial class ConstructorBuilder : System.Reflection.ConstructorInfo
{
- internal ConstructorBuilder();
+ protected ConstructorBuilder();
- public bool InitLocals { get; set; }
+ public virtual bool InitLocals { get; set; }
- public System.Reflection.Emit.ParameterBuilder DefineParameter(int iSequence, System.Reflection.ParameterAttributes attributes, string? strParamName);
+ public virtual System.Reflection.Emit.ParameterBuilder DefineParameter(int iSequence, System.Reflection.ParameterAttributes attributes, string? strParamName);
- public System.Reflection.Emit.ILGenerator GetILGenerator();
+ public virtual ILGenerator GetILGenerator();
- public System.Reflection.Emit.ILGenerator GetILGenerator(int streamSize);
+ public virtual System.Reflection.Emit.ILGenerator GetILGenerator(int streamSize);
- public void SetCustomAttribute(System.Reflection.ConstructorInfo con, byte[] binaryAttribute);
+ public virtual void SetCustomAttribute(System.Reflection.ConstructorInfo con, byte[] binaryAttribute);
- public void SetCustomAttribute(System.Reflection.Emit.CustomAttributeBuilder customBuilder);
+ public virtual void SetCustomAttribute(System.Reflection.Emit.CustomAttributeBuilder customBuilder);
- public void SetImplementationFlags(System.Reflection.MethodImplAttributes attributes;
+ public virtual void SetImplementationFlags(System.Reflection.MethodImplAttributes attributes);
}
- public sealed partial class EnumBuilder : System.Reflection.TypeInfo
+ public abstract partial class EnumBuilder : System.Reflection.TypeInfo
{
- internal EnumBuilder();
+ protected EnumBuilder();
- public System.Reflection.Emit.FieldBuilder UnderlyingField { get; }
+ public virtual System.Reflection.Emit.FieldBuilder UnderlyingField { get ; }
- public System.Reflection.TypeInfo CreateTypeInfo();
+ public virtual System.Reflection.TypeInfo CreateTypeInfo();
- public System.Reflection.Emit.FieldBuilder DefineLiteral(string literalName, object? literalValue);
+ public virtual System.Reflection.Emit.FieldBuilder DefineLiteral(string literalName, object? literalValue);
- public void SetCustomAttribute(System.Reflection.ConstructorInfo con, byte[] binaryAttribute);
+ public virtual void SetCustomAttribute(System.Reflection.Emit.CustomAttributeBuilder customBuilder);
- public void SetCustomAttribute(System.Reflection.ConstructorInfo con, byte[] binaryAttribute);
+ public virtual void SetCustomAttribute(System.Reflection.Emit.CustomAttributeBuilder customBuilder);
}
- public sealed partial class EventBuilder
+ public abstract partial class EventBuilder
{
- internal EventBuilder();
+ protected EventBuilder();
- public void AddOtherMethod(System.Reflection.Emit.MethodBuilder mdBuilder);
+ public virtual void AddOtherMethod(System.Reflection.Emit.MethodBuilder mdBuilder);
- public void SetAddOnMethod(System.Reflection.Emit.MethodBuilder mdBuilder);
+ public virtual void SetAddOnMethod(System.Reflection.Emit.MethodBuilder mdBuilder);
- public void SetCustomAttribute(System.Reflection.ConstructorInfo con, byte[] binaryAttribute);
+ public virtual void SetCustomAttribute(System.Reflection.ConstructorInfo con, byte[] binaryAttribute);
- public void SetCustomAttribute(System.Reflection.Emit.CustomAttributeBuilder customBuilder);
+ public virtual void SetCustomAttribute(System.Reflection.Emit.CustomAttributeBuilder customBuilder);
- public void SetRaiseMethod(System.Reflection.Emit.MethodBuilder mdBuilder);
+ public virtual void SetRaiseMethod(System.Reflection.Emit.MethodBuilder mdBuilder);
- public void SetRemoveOnMethod(System.Reflection.Emit.MethodBuilder mdBuilder);
+ public virtual void SetRemoveOnMethod(System.Reflection.Emit.MethodBuilder mdBuilder);
}
- public sealed partial class FieldBuilder : System.Reflection.FieldInfo
+ public abstract partial class FieldBuilder : System.Reflection.FieldInfo
{
- internal FieldBuilder();
+ protected FieldBuilder();
- public void SetConstant(object? defaultValue);
+ public virtual void SetConstant(object? defaultValue);
- public void SetCustomAttribute(System.Reflection.ConstructorInfo con, byte[] binaryAttribute);
+ public virtual void SetCustomAttribute(System.Reflection.ConstructorInfo con, byte[] binaryAttribute);
- public void SetCustomAttribute(System.Reflection.Emit.CustomAttributeBuilder customBuilder)
+ public virtual void SetCustomAttribute(System.Reflection.Emit.CustomAttributeBuilder customBuilder);
- public void SetOffset(int iOffset);
+ public virtual void SetOffset(int iOffset);
}
- public sealed partial class GenericTypeParameterBuilder : System.Reflection.TypeInfo
+ public abstract partial class GenericTypeParameterBuilder : System.Reflection.TypeInfo
{
- internal GenericTypeParameterBuilder();
+ protected GenericTypeParameterBuilder();
- public void SetBaseTypeConstraint([System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.All)] System.Type? baseTypeConstraint);
+ public virtual void SetBaseTypeConstraint([System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.All)] System.Type? baseTypeConstraint);
- public void SetCustomAttribute(System.Reflection.ConstructorInfo con, byte[] binaryAttribute);
+ public virtual void SetCustomAttribute(System.Reflection.ConstructorInfo con, byte[] binaryAttribute);
- public void SetCustomAttribute(System.Reflection.Emit.CustomAttributeBuilder customBuilder);
+ public virtual void SetCustomAttribute(System.Reflection.Emit.CustomAttributeBuilder customBuilder);
- public void SetGenericParameterAttributes(System.Reflection.GenericParameterAttributes genericParameterAttributes);
+ public virtual void SetGenericParameterAttributes(System.Reflection.GenericParameterAttributes genericParameterAttributes);
- public void SetInterfaceConstraints(params System.Type[]? interfaceConstraints);
+ public virtual void SetInterfaceConstraints(params System.Type[]? interfaceConstraints);
}
- public sealed partial class MethodBuilder : System.Reflection.MethodInfo
+ public abstract partial class MethodBuilder : System.Reflection.MethodInfo
{
- internal MethodBuilder();
+ protected MethodBuilder();
- public bool InitLocals { get; set; }
+ public virtual bool InitLocals { get; set; }
- public System.Reflection.Emit.GenericTypeParameterBuilder[] DefineGenericParameters(params string[] names);
+ public virtual System.Reflection.Emit.GenericTypeParameterBuilder[] DefineGenericParameters(params string[] names);
- public System.Reflection.Emit.ParameterBuilder DefineParameter(int position, System.Reflection.ParameterAttributes attributes, string? strParamName);
+ public virtual System.Reflection.Emit.ParameterBuilder DefineParameter(int position, System.Reflection.ParameterAttributes attributes, string? strParamName);
- public System.Reflection.Emit.ILGenerator GetILGenerator();
+ public virtual System.Reflection.Emit.ILGenerator GetILGenerator();
- public System.Reflection.Emit.ILGenerator GetILGenerator(int size);
+ public virtual System.Reflection.Emit.ILGenerator GetILGenerator(int size);
- public void SetCustomAttribute(System.Reflection.ConstructorInfo con, byte[] binaryAttribute);
+ public virtual void SetCustomAttribute(System.Reflection.ConstructorInfo con, byte[] binaryAttribute);
- public void SetCustomAttribute(System.Reflection.Emit.CustomAttributeBuilder customBuilder);
+ public virtual void SetCustomAttribute(System.Reflection.Emit.CustomAttributeBuilder customBuilder);
- public void SetImplementationFlags(System.Reflection.MethodImplAttributes attributes);
+ public virtual void SetImplementationFlags(System.Reflection.MethodImplAttributes attributes);
- public void SetParameters(params System.Type[] parameterTypes);
+ public virtual void SetParameters(params System.Type[] parameterTypes);
- public void SetReturnType(System.Type? returnType);
+ public virtual void SetReturnType(System.Type? returnType);
- public void SetSignature(System.Type? returnType, System.Type[]? returnTypeRequiredCustomModifiers, System.Type[]? returnTypeOptionalCustomModifiers, System.Type[]? parameterTypes, System.Type[][]? parameterTypeRequiredCustomModifiers, System.Type[][]? parameterTypeOptionalCustomModifiers);
+ public virtual void SetSignature(System.Type? returnType, System.Type[]? returnTypeRequiredCustomModifiers, System.Type[]? returnTypeOptionalCustomModifiers, System.Type[]? parameterTypes, System.Type[][]? parameterTypeRequiredCustomModifiers, System.Type[][]? parameterTypeOptionalCustomModifiers);
}
- public partial class ModuleBuilder : System.Reflection.Module
+ public abstract partial class ModuleBuilder : System.Reflection.Module
{
- internal ModuleBuilder();
+ protected ModuleBuilder();
- public void CreateGlobalFunctions();
+ public virtual void CreateGlobalFunctions();
- public System.Reflection.Emit.EnumBuilder DefineEnum(string name, System.Reflection.TypeAttributes visibility, System.Type underlyingType);
+ public virtual System.Reflection.Emit.EnumBuilder DefineEnum(string name, System.Reflection.TypeAttributes visibility, System.Type underlyingType);
- public System.Reflection.Emit.MethodBuilder DefineGlobalMethod(string name, System.Reflection.MethodAttributes attributes, System.Reflection.CallingConventions callingConvention, System.Type? returnType, System.Type[]? requiredReturnTypeCustomModifiers, System.Type[]? optionalReturnTypeCustomModifiers, System.Type[]? parameterTypes, System.Type[][]? requiredParameterTypeCustomModifiers, System.Type[][]? optionalParameterTypeCustomModifiers);
+ public virtual System.Reflection.Emit.MethodBuilder DefineGlobalMethod(string name, System.Reflection.MethodAttributes attributes, System.Reflection.CallingConventions callingConvention, System.Type? returnType, System.Type[]? requiredReturnTypeCustomModifiers, System.Type[]? optionalReturnTypeCustomModifiers, System.Type[]? parameterTypes, System.Type[][]? requiredParameterTypeCustomModifiers, System.Type[][]? optionalParameterTypeCustomModifiers);
- public System.Reflection.Emit.FieldBuilder DefineInitializedData(string name, byte[] data, System.Reflection.FieldAttributes attributes) ;
+ public virtual System.Reflection.Emit.FieldBuilder DefineInitializedData(string name, byte[] data, System.Reflection.FieldAttributes attributes);
- public System.Reflection.Emit.MethodBuilder DefinePInvokeMethod(string name, string dllName, string entryName, System.Reflection.MethodAttributes attributes, System.Reflection.CallingConventions callingConvention, System.Type? returnType, System.Type[]? parameterTypes, System.Runtime.InteropServices.CallingConvention nativeCallConv, System.Runtime.InteropServices.CharSet nativeCharSet);
+ public virtual System.Reflection.Emit.MethodBuilder DefinePInvokeMethod(string name, string dllName, string entryName, System.Reflection.MethodAttributes attributes, System.Reflection.CallingConventions callingConvention, System.Type? returnType, System.Type[]? parameterTypes, System.Runtime.InteropServices.CallingConvention nativeCallConv, System.Runtime.InteropServices.CharSet nativeCharSet);
- public System.Reflection.Emit.TypeBuilder DefineType(string name, System.Reflection.TypeAttributes attr, [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.All)] System.Type? parent, System.Reflection.Emit.PackingSize packingSize, int typesize);
+ public virtual System.Reflection.Emit.TypeBuilder DefineType(string name, System.Reflection.TypeAttributes attr, [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.All)] System.Type? parent, System.Reflection.Emit.PackingSize packingSize, int typesize);
- public System.Reflection.Emit.TypeBuilder DefineType(string name, System.Reflection.TypeAttributes attr, [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.All)] System.Type? parent, System.Type[]? interfaces);
+ public virtual System.Reflection.Emit.TypeBuilder DefineType(string name, System.Reflection.TypeAttributes attr, [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.All)] System.Type? parent, System.Type[]? interfaces);
- public System.Reflection.Emit.FieldBuilder DefineUninitializedData(string name, int size, System.Reflection.FieldAttributes attributes);
+ public virtual System.Reflection.Emit.FieldBuilder DefineUninitializedData(string name, int size, System.Reflection.FieldAttributes attributes);
- public System.Reflection.MethodInfo GetArrayMethod(System.Type arrayClass, string methodName, System.Reflection.CallingConventions callingConvention, System.Type? returnType, System.Type[]? parameterTypes);
+ public virtual System.Reflection.MethodInfo GetArrayMethod(System.Type arrayClass, string methodName, System.Reflection.CallingConventions callingConvention, System.Type? returnType, System.Type[]? parameterTypes);
- public void SetCustomAttribute(System.Reflection.ConstructorInfo con, byte[] binaryAttribute);
+ public virtual void SetCustomAttribute(System.Reflection.ConstructorInfo con, byte[] binaryAttribute);
- public void SetCustomAttribute(System.Reflection.Emit.CustomAttributeBuilder customBuilder);
+ public virtual void SetCustomAttribute(System.Reflection.Emit.CustomAttributeBuilder customBuilder);
// New public APIs: these are existing internal methods used outside of the ModuleBuilder, so needs to make public
+ public virtual int GetTypeToken(Type type);
+ public virtual int GetMethodToken(MethodInfo method);
+ public virtual int GetFieldToken(FieldInfo field);
+ public virtual int GetConstructorToken(ConstructorInfo con);
+ public virtual int GetSignatureToken(SignatureHelper sigHelper);
+ public virtual int GetStringConstant(string str);
}
- public sealed partial class PropertyBuilder : System.Reflection.PropertyInfo
+ public abstract partial class PropertyBuilder : System.Reflection.PropertyInfo
{
- internal PropertyBuilder();
+ protected PropertyBuilder();
- public void AddOtherMethod(System.Reflection.Emit.MethodBuilder mdBuilder);
+ public virtual void AddOtherMethod(System.Reflection.Emit.MethodBuilder mdBuilder);
- public void SetConstant(object? defaultValue);
+ public virtual void SetConstant(object? defaultValue);
- public void SetCustomAttribute(System.Reflection.ConstructorInfo con, byte[] binaryAttribute);
+ public virtual void SetCustomAttribute(System.Reflection.ConstructorInfo con, byte[] binaryAttribute);
- public void SetCustomAttribute(System.Reflection.Emit.CustomAttributeBuilder customBuilder);
+ public virtual void SetCustomAttribute(System.Reflection.Emit.CustomAttributeBuilder customBuilder);
- public void SetGetMethod(System.Reflection.Emit.MethodBuilder mdBuilder);
+ public virtual void SetGetMethod(System.Reflection.Emit.MethodBuilder mdBuilder);
- public void SetSetMethod(System.Reflection.Emit.MethodBuilder mdBuilder);
+ public virtual void SetSetMethod(System.Reflection.Emit.MethodBuilder mdBuilder);
}
- public sealed partial class TypeBuilder : System.Reflection.TypeInfo
+ public abstract partial class TypeBuilder : System.Reflection.TypeInfo
{
- internal TypeBuilder();
+ protected TypeBuilder();
- public System.Reflection.Emit.PackingSize PackingSize { get; }
+ public virtual System.Reflection.Emit.PackingSize PackingSize { get; }
- public int Size { get; }
+ public virtual int Size { get; }
- public void AddInterfaceImplementation([System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.All)] System.Type interfaceType);
+ public virtual void AddInterfaceImplementation([System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.All)] System.Type interfaceType);
- public System.Reflection.TypeInfo CreateTypeInfo();
+ public virtual System.Reflection.TypeInfo CreateTypeInfo();
- public System.Reflection.Emit.ConstructorBuilder DefineConstructor(System.Reflection.MethodAttributes attributes, System.Reflection.CallingConventions callingConvention, System.Type[]? parameterTypes, System.Type[][]? requiredCustomModifiers, System.Type[][]? optionalCustomModifiers);
+ public virtual System.Reflection.Emit.ConstructorBuilder DefineConstructor(System.Reflection.MethodAttributes attributes, System.Reflection.CallingConventions callingConvention, System.Type[]? parameterTypes, System.Type[][]? requiredCustomModifiers, System.Type[][]? optionalCustomModifiers);
- public System.Reflection.Emit.ConstructorBuilder DefineDefaultConstructor(System.Reflection.MethodAttributes attributes);
+ public virtual System.Reflection.Emit.ConstructorBuilder DefineDefaultConstructor(System.Reflection.MethodAttributes attributes);
- public System.Reflection.Emit.EventBuilder DefineEvent(string name, System.Reflection.EventAttributes attributes, System.Type eventtype);
+ public virtual System.Reflection.Emit.EventBuilder DefineEvent(string name, System.Reflection.EventAttributes attributes, System.Type eventtype);
- public System.Reflection.Emit.FieldBuilder DefineField(string fieldName, System.Type type, System.Type[]? requiredCustomModifiers, System.Type[]? optionalCustomModifiers, System.Reflection.FieldAttributes attributes) { throw null; }
+ public virtual System.Reflection.Emit.FieldBuilder DefineField(string fieldName, System.Type type, System.Type[]? requiredCustomModifiers, System.Type[]? optionalCustomModifiers, System.Reflection.FieldAttributes attributes);
- public System.Reflection.Emit.GenericTypeParameterBuilder[] DefineGenericParameters(params string[] names);
+ public virtual System.Reflection.Emit.GenericTypeParameterBuilder[] DefineGenericParameters(params string[] names);
- public System.Reflection.Emit.FieldBuilder DefineInitializedData(string name, byte[] data, System.Reflection.FieldAttributes attributes);
+ public virtual System.Reflection.Emit.FieldBuilder DefineInitializedData(string name, byte[] data, System.Reflection.FieldAttributes attributes);
- public System.Reflection.Emit.MethodBuilder DefineMethod(string name, System.Reflection.MethodAttributes attributes, System.Reflection.CallingConventions callingConvention, System.Type? returnType, System.Type[]? returnTypeRequiredCustomModifiers, System.Type[]? returnTypeOptionalCustomModifiers, System.Type[]? parameterTypes, System.Type[][]? parameterTypeRequiredCustomModifiers, System.Type[][]? parameterTypeOptionalCustomModifiers);
+ public virtual System.Reflection.Emit.MethodBuilder DefineMethod(string name, System.Reflection.MethodAttributes attributes, System.Reflection.CallingConventions callingConvention, System.Type? returnType, System.Type[]? returnTypeRequiredCustomModifiers, System.Type[]? returnTypeOptionalCustomModifiers, System.Type[]? parameterTypes, System.Type[][]? parameterTypeRequiredCustomModifiers, System.Type[][]? parameterTypeOptionalCustomModifiers);
- public void DefineMethodOverride(System.Reflection.MethodInfo methodInfoBody, System.Reflection.MethodInfo methodInfoDeclaration);
+ public virtual void DefineMethodOverride(System.Reflection.MethodInfo methodInfoBody, System.Reflection.MethodInfo methodInfoDeclaration);
- public System.Reflection.Emit.TypeBuilder DefineNestedType(string name, System.Reflection.TypeAttributes attr, [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.All)] System.Type? parent, System.Reflection.Emit.PackingSize packSize, int typeSize);
+ public virtual System.Reflection.Emit.TypeBuilder DefineNestedType(string name, System.Reflection.TypeAttributes attr, [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.All)] System.Type? parent, System.Reflection.Emit.PackingSize packSize, int typeSize);
- public System.Reflection.Emit.TypeBuilder DefineNestedType(string name, System.Reflection.TypeAttributes attr, [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.All)] System.Type? parent, System.Type[]? interfaces);
+ public virtual System.Reflection.Emit.TypeBuilder DefineNestedType(string name, System.Reflection.TypeAttributes attr, [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.All)] System.Type? parent, System.Type[]? interfaces);
- public System.Reflection.Emit.MethodBuilder DefinePInvokeMethod(string name, string dllName, string entryName, System.Reflection.MethodAttributes attributes, System.Reflection.CallingConventions callingConvention, System.Type? returnType, System.Type[]? returnTypeRequiredCustomModifiers, System.Type[]? returnTypeOptionalCustomModifiers, System.Type[]? parameterTypes, System.Type[][]? parameterTypeRequiredCustomModifiers, System.Type[][]? parameterTypeOptionalCustomModifiers, System.Runtime.InteropServices.CallingConvention nativeCallConv, System.Runtime.InteropServices.CharSet nativeCharSet);
+ public virtual System.Reflection.Emit.MethodBuilder DefinePInvokeMethod(string name, string dllName, string entryName, System.Reflection.MethodAttributes attributes, System.Reflection.CallingConventions callingConvention, System.Type? returnType, System.Type[]? returnTypeRequiredCustomModifiers, System.Type[]? returnTypeOptionalCustomModifiers, System.Type[]? parameterTypes, System.Type[][]? parameterTypeRequiredCustomModifiers, System.Type[][]? parameterTypeOptionalCustomModifiers, System.Runtime.InteropServices.CallingConvention nativeCallConv, System.Runtime.InteropServices.CharSet nativeCharSet);
- public System.Reflection.Emit.PropertyBuilder DefineProperty(string name, System.Reflection.PropertyAttributes attributes, System.Reflection.CallingConventions callingConvention, System.Type returnType, System.Type[]? returnTypeRequiredCustomModifiers, System.Type[]? returnTypeOptionalCustomModifiers, System.Type[]? parameterTypes, System.Type[][]? parameterTypeRequiredCustomModifiers, System.Type[][]? parameterTypeOptionalCustomModifiers);
+ public virtual System.Reflection.Emit.PropertyBuilder DefineProperty(string name, System.Reflection.PropertyAttributes attributes, System.Reflection.CallingConventions callingConvention, System.Type returnType, System.Type[]? returnTypeRequiredCustomModifiers, System.Type[]? returnTypeOptionalCustomModifiers, System.Type[]? parameterTypes, System.Type[][]? parameterTypeRequiredCustomModifiers, System.Type[][]? parameterTypeOptionalCustomModifiers);
- public System.Reflection.Emit.ConstructorBuilder DefineTypeInitializer();
+ public virtual System.Reflection.Emit.ConstructorBuilder DefineTypeInitializer();
- public System.Reflection.Emit.FieldBuilder DefineUninitializedData(string name, int size, System.Reflection.FieldAttributes attributes);
+ public virtual System.Reflection.Emit.FieldBuilder DefineUninitializedData(string name, int size, System.Reflection.FieldAttributes attributes);
- public bool IsCreated();
+ public virtual bool IsCreated();
- public void SetCustomAttribute(System.Reflection.ConstructorInfo con, byte[] binaryAttribute);
+ public virtual void SetCustomAttribute(System.Reflection.ConstructorInfo con, byte[] binaryAttribute);
- public void SetCustomAttribute(System.Reflection.Emit.CustomAttributeBuilder customBuilder);
+ public virtual void SetCustomAttribute(System.Reflection.Emit.CustomAttributeBuilder customBuilder);
- public void SetParent([System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.All)] System.Type? parent);
+ public virtual void SetParent([System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.All)] System.Type? parent);
}
} |
We should also give |
Yep, defaulting the parameter less implementation.
Even though they are doing same thing we don't want to add a wrapper type for tokens and metadata token is int for all other reflection APIs, therefore we renamed the methods into ModuleBuilder.GetMetadataToken(Type) with different overloads.
Followed the suggestion, new API proposal below: namespace System.Reflection.Emit
{
- public sealed partial class AssemblyBuilder : System.Reflection.Assembly
+ public abstract partial class AssemblyBuilder : System.Reflection.Assembly
{
- internal AssemblyBuilder();
+ protected AssemblyBuilder();
+ protected abstract ModuleBuilder DefineDynamicModuleCore(string name);
+ protected abstract ModuleBuilder? GetDynamicModuleCore(string name);
+ protected abstract void SetCustomAttributeCore(ConstructorInfo con, byte[] binaryAttribute);
+ protected abstract void SetCustomAttributeCore(CustomAttributeBuilder customBuilder);
}
- public sealed partial class ConstructorBuilder : System.Reflection.ConstructorInfo
+ public abstract partial class ConstructorBuilder : System.Reflection.ConstructorInfo
{
- internal ConstructorBuilder();
+ protected ConstructorBuilder();
+ protected abstract bool InitLocalsCore { get; set; }
+ protected abstract ParameterBuilder DefineParameterCore(int iSequence, ParameterAttributes attributes, string strParamName);
+ protected abstract ILGenerator GetILGeneratorCore(int streamSize);
+ protected abstract void SetCustomAttributeCore(ConstructorInfo con, byte[] binaryAttribute);
+ protected abstract void SetCustomAttributeCore(CustomAttributeBuilder customBuilder);
+ protected abstract void SetImplementationFlagsCore(MethodImplAttributes attributes);
}
- public sealed partial class EnumBuilder : System.Reflection.TypeInfo
+ public abstract partial class EnumBuilder : System.Reflection.TypeInfo
{
- internal EnumBuilder();
+ protected EnumBuilder();
+ protected abstract FieldBuilder UnderlyingFieldCore { get; }
+ protected abstract TypeInfo CreateTypeInfoCore();
+ protected abstract FieldBuilder DefineLiteralCore(string literalName, object? literalValue);
+ protected abstract void SetCustomAttributeCore(ConstructorInfo con, byte[] binaryAttribute);
+ protected abstract void SetCustomAttributeCore(CustomAttributeBuilder customBuilder);
}
- public sealed partial class EventBuilder
+ public abstract class EventBuilder
{
- internal EventBuilder();
+ protected EventBuilder();
+ protected abstract void AddOtherMethodCore(MethodBuilder mdBuilder);
+ protected abstract void SetAddOnMethodCore(MethodBuilder mdBuilder);
+ protected abstract void SetCustomAttributeCore(ConstructorInfo con, byte[] binaryAttribute);
+ protected abstract void SetCustomAttributeCore(CustomAttributeBuilder customBuilder);
+ protected abstract void SetRaiseMethodCore(MethodBuilder mdBuilder);
+ protected abstract void SetRemoveOnMethodCore(MethodBuilder mdBuilder);
}
- public sealed partial class FieldBuilder : System.Reflection.FieldInfo
+ public abstract partial class FieldBuilder : System.Reflection.FieldInfo
{
- internal FieldBuilder();
+ protected FieldBuilder();
+ protected abstract void SetConstantCore(object? defaultValue);
+ protected abstract void SetCustomAttributeCore(ConstructorInfo con, byte[] binaryAttribute);
+ protected abstract void SetCustomAttributeCore(CustomAttributeBuilder customBuilder);
+ protected abstract void SetOffsetCore(int iOffset);
}
- public sealed partial class GenericTypeParameterBuilder : System.Reflection.TypeInfo
+ public abstract partial class GenericTypeParameterBuilder : System.Reflection.TypeInfo
{
- internal GenericTypeParameterBuilder();
+ protected GenericTypeParameterBuilder();
+ protected abstract void SetBaseTypeConstraintCore([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type? baseTypeConstraint);
+ protected abstract void SetCustomAttributeCore(ConstructorInfo con, byte[] binaryAttribute);
+ protected abstract void SetCustomAttributeCore(CustomAttributeBuilder customBuilder);
+ protected abstract void SetGenericParameterAttributesCore(GenericParameterAttributes genericParameterAttributes);
+ protected abstract void SetInterfaceConstraintsCore(params Type[]? interfaceConstraints);
}
- public sealed partial class MethodBuilder : System.Reflection.MethodInfo
+ public abstract partial class MethodBuilder : System.Reflection.MethodInfo
{
- internal MethodBuilder();
+ protected MethodBuilder();
+ protected abstract bool InitLocalsCore { get; set; }
+ protected abstract GenericTypeParameterBuilder[] DefineGenericParametersCore(params string[] names);
+ protected abstract ParameterBuilder DefineParameterCore(int position, ParameterAttributes attributes, string? strParamName);
+ protected abstract ILGenerator GetILGeneratorCore(int size);
+ protected abstract void SetCustomAttributeCore(ConstructorInfo con, byte[] binaryAttribute);
+ protected abstract void SetCustomAttributeCore(CustomAttributeBuilder customBuilder);
+ protected abstract void SetImplementationFlagsCore(MethodImplAttributes attributes);
+ protected abstract void SetSignatureCore(Type? returnType, Type[]? returnTypeRequiredCustomModifiers, Type[]? returnTypeOptionalCustomModifiers, Type[]? parameterTypes, Type[][]? parameterTypeRequiredCustomModifiers, Type[][]? parameterTypeOptionalCustomModifiers);
}
- public partial class ModuleBuilder : System.Reflection.Module
+ public abstract partial class ModuleBuilder : System.Reflection.Module
{
- internal ModuleBuilder();
+ protected ModuleBuilder();
+ protected abstract void CreateGlobalFunctionsCore();
+ protected abstract EnumBuilder DefineEnumCore(string name, TypeAttributes visibility, Type underlyingType);
+ protected abstract MethodBuilder DefineGlobalMethodCore(string name, MethodAttributes attributes, CallingConventions callingConvention, Type? returnType, Type[]? requiredReturnTypeCustomModifiers, Type[]? optionalReturnTypeCustomModifiers, Type[]? parameterTypes, Type[][]? requiredParameterTypeCustomModifiers, Type[][]? optionalParameterTypeCustomModifiers);
+ protected abstract FieldBuilder DefineInitializedDataCore(string name, byte[] data, FieldAttributes attributes);
+ protected abstract MethodBuilder DefinePInvokeMethodCore(string name, string dllName, string entryName, MethodAttributes attributes, CallingConventions callingConvention, Type? returnType, Type[]? parameterTypes, CallingConvention nativeCallConv, CharSet nativeCharSet);
+ protected abstract TypeBuilder DefineTypeCore(string name, TypeAttributes attr, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type? parent, Type[]? interfaces, PackingSize packingSize, int typesize);
+ protected abstract FieldBuilder DefineUninitializedDataCore(string name, int size, FieldAttributes attributes);
+ protected abstract MethodInfo GetArrayMethodCore(Type arrayClass, string methodName, CallingConventions callingConvention, Type? returnType, Type[]? parameterTypes);
+ protected abstract void SetCustomAttributeCore(ConstructorInfo con, byte[] binaryAttribute);
+ protected abstract void SetCustomAttributeCore(CustomAttributeBuilder customBuilder);
// New public APIs
+ public abstract int GetMetadataToken(Type type);
+ public abstract int GetMetadataToken(FieldInfo field);
+ public abstract int GetMetadataToken(MethodInfo method);
+ public abstract int GetMetadataToken(ConstructorInfo constructor);
+ public abstract int GetMetadataToken(SignatureHelper sigHelper);
+ public abstract int GetMetadataToken(string str);
}
- public sealed partial class PropertyBuilder : System.Reflection.PropertyInfo
+ public abstract partial class PropertyBuilder : System.Reflection.PropertyInfo
{
- internal PropertyBuilder();
+ protected PropertyBuilder();
+ protected abstract void AddOtherMethodCore(MethodBuilder mdBuilder);
+ protected abstract void SetConstantCore(object defaultValue);
+ protected abstract void SetCustomAttributeCore(ConstructorInfo con, byte[] binaryAttribute);
+ protected abstract void SetCustomAttributeCore(CustomAttributeBuilder customBuilder);
+ protected abstract void SetGetMethodCore(MethodBuilder mdBuilder);
+ protected abstract void SetSetMethodCore(MethodBuilder mdBuilder);
}
- public sealed partial class TypeBuilder : System.Reflection.TypeInfo
+ public abstract partial class TypeBuilder : System.Reflection.TypeInfo
{
- internal TypeBuilder();
+ protected TypeBuilder();
+ protected abstract PackingSize PackingSizeCore { get; }
+ protected abstract void AddInterfaceImplementationCore([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type interfaceType);
+ protected abstract TypeInfo CreateTypeInfoCore();
+ protected abstract ConstructorBuilder DefineConstructorCore(MethodAttributes attributes, CallingConventions callingConvention, Type[]? parameterTypes, Type[][]? requiredCustomModifiers, Type[][]? optionalCustomModifiers);
+ protected abstract ConstructorBuilder DefineDefaultConstructorCore(MethodAttributes attributes);
+ protected abstract EventBuilder DefineEventCore(string name, EventAttributes attributes, Type eventtype);
+ protected abstract FieldBuilder DefineFieldCore(string fieldName, Type type, Type[]? requiredCustomModifiers, Type[]? optionalCustomModifiers, FieldAttributes attributes);
+ protected abstract GenericTypeParameterBuilder[] DefineGenericParametersCore(params string[] names);
+ protected abstract FieldBuilder DefineInitializedDataCore(string name, byte[] data, FieldAttributes attributes);
+ protected abstract MethodBuilder DefineMethodCore(string name, MethodAttributes attributes, CallingConventions callingConvention, Type? returnType, Type[]? returnTypeRequiredCustomModifiers, Type[]? returnTypeOptionalCustomModifiers, Type[]? parameterTypes, Type[][]? parameterTypeRequiredCustomModifiers, Type[][]? parameterTypeOptionalCustomModifiers);
+ protected abstract void DefineMethodOverrideCore(MethodInfo methodInfoBody, MethodInfo methodInfoDeclaration);
+ protected abstract TypeBuilder DefineNestedTypeCore(string name, TypeAttributes attr, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type? parent, Type[]? interfaces, PackingSize packSize, int typeSize);
+ protected abstract MethodBuilder DefinePInvokeMethodCore(string name, string dllName, string entryName, MethodAttributes attributes, CallingConventions callingConvention, Type? returnType, Type[]? returnTypeRequiredCustomModifiers, Type[]? returnTypeOptionalCustomModifiers, Type[]? parameterTypes, Type[][]? parameterTypeRequiredCustomModifiers, Type[][]? parameterTypeOptionalCustomModifiers, CallingConvention nativeCallConv, CharSet nativeCharSet);
+ protected abstract PropertyBuilder DefinePropertyCore(string name, PropertyAttributes attributes, CallingConventions callingConvention, Type returnType, Type[]? returnTypeRequiredCustomModifiers, Type[]? returnTypeOptionalCustomModifiers, Type[]? parameterTypes, Type[][]? parameterTypeRequiredCustomModifiers, Type[][]? parameterTypeOptionalCustomModifiers);
+ protected abstract ConstructorBuilder DefineTypeInitializerCore();
+ protected abstract FieldBuilder DefineUninitializedDataCore(string name, int size, FieldAttributes attributes);
+ protected abstract bool IsCreatedCore();
+ protected abstract void SetCustomAttributeCore(ConstructorInfo con, byte[] binaryAttribute);
+ protected abstract void SetCustomAttributeCore(CustomAttributeBuilder customBuilder);
+ protected abstract void SetParentCore([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type? parent);
}
} |
Looks good as proposed except for the We should have distinct method groups to avoid the (conceptual) ambiguity around what the string-based one does:
|
We plan to abstract out Reflection.Emit APIs as preparation for adding
AssemblyBuilder.Save()
equivalent in .NET Core. So that we can have two implementations, one that having old code to support all downlevel runtime, and a new implementation that replaces the current Reflection.Emit implementation.UPDATE: Link to Updated Proposal
CC @jkotas @steveharter @AaronRobinsonMSFT @terrajobst
The text was updated successfully, but these errors were encountered: