-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Virtual AttributeType property and signature generic types #19818
Conversation
https://github.com/dotnet/corefx/issues/31614 1. This will allow Reflection providers the option to supply the attribute type without building an entire constructor. https://github.com/dotnet/corefx/issues/31798 2. This will permit other Reflection providers to support Type.MakeGenericMethodParameter() in their implementations.
|
cc @steveharter |
| throw new ArgumentNullException(nameof(typeArguments)); | ||
| for (int i = 0; i < typeArguments.Length; i++) | ||
| { | ||
| if (typeArguments[i] == 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.
It would be a bit more robust to validate this after cloning.
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.
Yes, the validation here is intentionally minimal as the main use for this api is for MakeGenericType implementations which have already done the cloning.
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.
MakeGenericType implementations which have already done the cloning
Depends on the implementation. It is not required for MakeGenericType to clone the instantiation to call this. E.g. RtType.MakeGenericType does not clone the array before passing it to SignatureConstructedGenericType constructor.
What I meant is that the validation could be in SignatureConstructedGenericType constructor after the array is cloned.
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.
Hmm... that was an annoying oversight. Ok, replacing the debug.assert in the constructor with actual validation.
| { | ||
| internal sealed class SignatureConstructedGenericType : SignatureType | ||
| { | ||
| internal SignatureConstructedGenericType(Type genericTypeDefinition, Type[] genericTypeArguments) |
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.
Nit: Rename this to typeArguments so that it has the same name as the public factory method? (The name shows up in the exception message.)
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.
Ok, renamed.
https://github.com/dotnet/corefx/issues/31614
to supply the attribute type without building
an entire constructor.
https://github.com/dotnet/corefx/issues/31798
to support Type.MakeGenericMethodParameter()
in their implementations.