Use C# 14 extensions for polyfills in MetadataLoadContext.#126354
Merged
jkotas merged 3 commits intodotnet:mainfrom Apr 1, 2026
Merged
Use C# 14 extensions for polyfills in MetadataLoadContext.#126354jkotas merged 3 commits intodotnet:mainfrom
MetadataLoadContext.#126354jkotas merged 3 commits intodotnet:mainfrom
Conversation
Contributor
|
Tagging subscribers to this area: @dotnet/area-system-reflection |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates System.Reflection.MetadataLoadContext to use C# extension members as polyfills, letting the codebase use modern Type APIs (e.g., IsSZArray, IsSignatureType) without helper extension-method calls.
Changes:
- Replaced
IsSZArray(),IsVariableBoundArray(),IsGenericMethodParameter(), andIsSignatureType()extension-method calls with property-style access. - Replaced
MakeSignatureGenericType(...)helper usage withType.MakeGenericSignatureType(...). - Introduced NetStandard polyfills for these members using C# extension blocks and removed the NetCore emulator extension-method shim.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Types/RoModifiedType.cs | Switches SZ-array detection to property access. |
| src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Types/RoDefinitionType.cs | Uses IsSignatureType property and Type.MakeGenericSignatureType. |
| src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/General/TypeExtensions.netstandard.cs | Adds C# extension-member polyfills for NetStandard. |
| src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/General/TypeExtensions.net.cs | Removes NetCore NetCoreApiEmulators extension-method layer (file remains for leveled base types). |
| src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/General/Assignability.cs | Converts SZ-array checks to property access. |
| src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/Runtime/SignatureTypeExtensions.cs | Converts signature-type and array-kind checks to property access. |
| src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/Runtime/BindingFlagSupport/MemberPolicies.cs | Converts SZ-array and generic-method-parameter checks to property access. |
| src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/DefaultBinder.cs | Converts signature-type checks to property access. |
....MetadataLoadContext/src/System/Reflection/TypeLoading/General/TypeExtensions.netstandard.cs
Outdated
Show resolved
Hide resolved
....MetadataLoadContext/src/System/Reflection/TypeLoading/General/TypeExtensions.netstandard.cs
Outdated
Show resolved
Hide resolved
This was referenced Apr 1, 2026
Open
Member
|
/ba-g known issue #126354 that's not matched by build analysis for some reason |
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Inspired by #126280.