Skip to content

Make ParameterBuilder abstract #83831

Closed
@buyaa-n

Description

@buyaa-n

With Abstract System.Reflection.Emit public types we have abstracted other System.Reflection.Emit.XyzBuilder types, ParameterBuilder type left out from this effort (probably because it lives in different ref file).

The type also needs to be abstracted same as others because:

  • Because of internal constructor could not create an instance of it outside of CoreLib. (The new AsemblyBuilder implementation will be added outside of CoreLib)
  • Even if we workaround the internal constructor we could not get CustomAttributes info set to the ParameterBuilder instance, same for the default value.

Suggested API change:

namespace System.Reflection.Emit
{
-   public class ParameterBuilder
+   public abstract class ParameterBuilder
    {
-       internal ParameterBuilder() { }
+       protected ParameterBuilder() { }
        public virtual int Attributes { get { throw null; } }
        public bool IsIn { get { throw null; } }
        public bool IsOptional { get { throw null; } }
        public bool IsOut { get { throw null; } }
        public virtual string? Name { get { throw null; } }
        public virtual int Position { get { throw null; } }
        public virtual void SetConstant(object? defaultValue) { }
        public void SetCustomAttribute(ConstructorInfo con, byte[] binaryAttribute) { }
+       protected abstract void SetCustomAttributeCore(ConstructorInfo con, byte[] binaryAttribute);
        public void SetCustomAttribute(CustomAttributeBuilder customBuilder) { }
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions