Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Support generic type parameter when created with TypeBuilder #112372
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
Support generic type parameter when created with TypeBuilder #112372
Changes from 3 commits
452eee6
668a960
71afb64
db3dbcd
b701473
20a7784
5098883
095ece6
10db98e
f0da313
c339bb9
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
Type.MakeGenericSignatureType(typeof(List<>), typeof(int)).GetGenericArguments()[0]
is going to betypeof(int)
, so this test does not seem to be actually testing IsValueType property on signature types.Should this rather be something like:
?
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.
Correct this is not verifying signature types but is verifying that when a non-signature type is used as a generic parameter then IsValueType works as expected. The test with
GetGenericArguments()
is done in MakeSignatureConstructedGenericType() as mentioned in the comment.I'm not sure if your feedback here came before or after I pushed a new commit that changed this and added the comment.
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.
Would it be better to verify that
GetGenericArguments()
returns the exact same Type instances as was passed into MakeGenericSignatureType?If we do that, we do not need to worry about testing individual properties of the types returned by
GetGenericArguments
. We can depend on that testing done elsewhere (e.g. as part of runtime Type testing)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.
My higher level concerns in both this and the other comment are:
SignatureConstructedGenericType.IsEnum
implementation is changed to return hardcodedfalse
, no test is going to fail. These test gaps should be fixed. They are kind of hard to see because they are muddied by the unnecessary tests.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.
I did remove newly added code that did not directly verify sig types.
Added tests for
IsEnum
for both true and false.Also I found that the validation in MakeGenericSignatureType() did not check it the incoming type was generic or not, so I updated that and compared against MakeGenericType() which I also updated since the parameter names were different in the exception text (the
internal override
changed the parameter name from thepublic abstract
). So in this case, I did add tests that are not sig-specific but it did catch this issue plus it's nice to see in one location.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.
This is technically a breaking change. Just pointing it out, I do not see a problem with it.
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.
I wonder if this breaking change meets the threshold to document it; I'll mark this breaking change for now and re-evaluate later as well as update the exception doc.