Skip to content

Use C# 14 extensions for polyfills in MetadataLoadContext.#126354

Merged
jkotas merged 3 commits intodotnet:mainfrom
teo-tsirpanis:mlc-polyfills
Apr 1, 2026
Merged

Use C# 14 extensions for polyfills in MetadataLoadContext.#126354
jkotas merged 3 commits intodotnet:mainfrom
teo-tsirpanis:mlc-polyfills

Conversation

@teo-tsirpanis
Copy link
Copy Markdown
Contributor

Inspired by #126280.

Copilot AI review requested due to automatic review settings March 31, 2026 13:52
@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates that the PR has been added by a community member label Mar 31, 2026
@dotnet-policy-service
Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @dotnet/area-system-reflection
See info in area-owners.md if you want to be subscribed.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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(), and IsSignatureType() extension-method calls with property-style access.
  • Replaced MakeSignatureGenericType(...) helper usage with Type.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.

Copy link
Copy Markdown
Member

@jkotas jkotas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@jkotas
Copy link
Copy Markdown
Member

jkotas commented Apr 1, 2026

/ba-g known issue #126354 that's not matched by build analysis for some reason

@jkotas jkotas merged commit bd7cab0 into dotnet:main Apr 1, 2026
89 of 95 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-System.Reflection community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants