-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ConstructorBuilder implementation, integrate TypeBuilder.GetXyz() static methods #94732
Conversation
…ns and use for TypeBuilderImpl
… constructed type
Tagging subscribers to this area: @dotnet/area-system-reflection-emit Issue DetailsConstributes to #92975
|
src/libraries/System.Reflection.Emit/src/System/Reflection/Emit/TypeBuilderImpl.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Reflection.Emit/src/System/Reflection/Emit/TypeBuilderImpl.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Reflection.Emit/src/System/Reflection/Emit/TypeBuilderImpl.cs
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems
Outdated
Show resolved
Hide resolved
...s/System.Private.CoreLib/src/System/Reflection/Emit/ConstructorOnTypeBuilderInstantiation.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some misc feedback but otherwise LGTM.
@@ -286,7 +286,7 @@ public override Type MakeArrayType(int rank) | |||
public override int GetArrayRank() | |||
{ | |||
if (!IsArray) | |||
throw new NotSupportedException(SR.NotSupported_SubclassOverride); | |||
throw new ArgumentException(SR.Argument_HasToBeArrayClass); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
InvalidOperationException instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Followed exception type and message for similar cases
runtime/src/coreclr/System.Private.CoreLib/src/System/Reflection/Emit/RuntimeModuleBuilder.cs
Lines 1142 to 1145 in 9f6ac8c
if (!arrayClass.IsArray) | |
{ | |
throw new ArgumentException(SR.Argument_HasToBeArrayClass); | |
} |
src/libraries/System.Reflection.Emit/src/System/Reflection/Emit/EnumBuilderImpl.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Reflection.Emit/src/System/Reflection/Emit/MethodBuilderImpl.cs
Outdated
Show resolved
Hide resolved
|
||
for (int i = 0; i < _parameterTypes.Length; i++) | ||
{ | ||
if (_parameterBuilders[i + 1] == null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When is the element null
in this case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When the parameters created with parameterTypes
array:
runtime/src/libraries/System.Reflection.Emit/src/System/Reflection/Emit/MethodBuilderImpl.cs
Lines 53 to 60 in ffd43b6
if (parameterTypes != null) | |
{ | |
_parameterTypes = new Type[parameterTypes.Length]; | |
_parameterBuilders = new ParameterBuilderImpl[parameterTypes.Length + 1]; // parameter 0 reserved for return type | |
for (int i = 0; i < parameterTypes.Length; i++) | |
{ | |
ArgumentNullException.ThrowIfNull(_parameterTypes[i] = parameterTypes[i], nameof(parameterTypes)); | |
} |
but not explicitly defined with
DefineParameterCore(...)
Constributes to #92975
ConstructorBuilder
implementationDefineConstructorCore
andDefineDefaultConstructorCore
protected members forTypeBuilderImpl
TypeBuilder.GetConstructor(...)
,TypeBuilder.GetMethod(...)
andTypeBuilder.GetField(...)
static methods so that they could be used for the newReflection.Emit.TypeBuilderImpl
TypeBuilderImpl
type (instances of*BuilderInstantiation
types, likeMethodBuilderInstantiation
)CreateTypeInfoCore()
. Refactor Assembly.Save IL emit logic to require referenced types to be created ("baked").