This repository was archived by the owner on Sep 25, 2026. It is now read-only.
Repository navigation
Share GetConstructor intrinsic a lot of small fixes - #2725
Merged
Merged
Conversation
sbomer
approved these changes
Apr 5, 2022
|
|
||
| // Go over all types we've seen | ||
| foreach (var value in instanceValue) { | ||
| if (value is SystemTypeValue systemTypeValue && !BindingFlagsAreUnsupported (bindingFlags)) { |
Member
There was a problem hiding this comment.
Does this also need handling for null/empty inputs?
Member
Author
There was a problem hiding this comment.
Not really - we could add it, but it's not necessary. We need special handling only for intrinsics which set return value, those which don't can have empty foreach loops, it doesn't cause a problem.
Not sure what's better - be consistent with unnecessary lines of code, or keep it shorter.
Member
There was a problem hiding this comment.
Oh right, the difference is that it doesn't have a return value. My preference is consistency, but either way is fine.
| // GetMethod (string, int, BindingFlags, Binder?, CallingConventions, Type[], ParameterModifier[]?) | ||
| // | ||
| case IntrinsicId.Type_GetMethod: { | ||
| if (instanceValue.IsEmpty () || argumentValues[0].IsEmpty ()) { |
Member
There was a problem hiding this comment.
Thanks a lot for the null/empty handling cleanup in this PR!
agocke
pushed a commit
to dotnet/runtime
that referenced
this pull request
Nov 16, 2022
The main change is sharing of the GetConstructor intrinsic and related tests.
To make those tests work this also implements Type.EmptyTypes and String.Empty and Array.Empty intrinsics.
These are all treated as special cases:
* Type.EmptyTypes and String.Empty are actually field accesses, so we don't have infra to share these yet, no need to add one for now
* Array.Empty is a generic method where we need to know the generic instantiation. The current sharing doesn't propagate this information
so this forced the implementation to NOT be shared but instead done as a fallback which the shared one doesn't handle.
The rest of the changes are all about fixing how the shared intrinsic handling propagates return value from intrinsics.
Lot of small subtle bugs around null or emtpy inputs and forgetting to add return value and so on. The main changes are in GetMethod and GetNestedType intrinsics which had lot of issues.
Added tests for all of the corner cases.
NestedTypesUsedViaReflection test has been reworked as previously it didn't work correctly. Lot of the [Kept] attributes were fulfilled by some of the negative tests and thus the positive tests didn't have coverage (for example calling GetNestedType(unknownName) will mark all nested types on the type, so a subsequent call to GetNestedType("knownname") will not have an observable effect).
Commit migrated from dotnet/linker@e8b0ba0
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
The main change is sharing of the GetConstructor intrinsic and related tests.
To make those tests work this also implements Type.EmptyTypes and String.Empty and Array.Empty intrinsics.
These are all treated as special cases:
so this forced the implementation to NOT be shared but instead done as a fallback which the shared one doesn't handle.
The rest of the changes are all about fixing how the shared intrinsic handling propagates return value from intrinsics.
Lot of small subtle bugs around null or emtpy inputs and forgetting to add return value and so on. The main changes are in GetMethod and GetNestedType intrinsics which had lot of issues.
Added tests for all of the corner cases.
NestedTypesUsedViaReflection test has been reworked as previously it didn't work correctly. Lot of the [Kept] attributes were fulfilled by some of the negative tests and thus the positive tests didn't have coverage (for example calling GetNestedType(unknownName) will mark all nested types on the type, so a subsequent call to GetNestedType("knownname") will not have an observable effect).