Move managed type system APIs to UTF-8#122658
Merged
eduardo-vp merged 18 commits intodotnet:mainfrom Dec 22, 2025
Merged
Conversation
added 15 commits
December 16, 2025 07:55
This reverts commit ed668c3.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR moves managed type system APIs from string-based operations to UTF-8 byte spans to reduce string allocations during compilation. The changes update core interfaces (IPrefixMangledType, IPrefixMangledMethod, IPrefixMangledSignature, MetadataType.GetNestedType) and their implementations to use ReadOnlySpan<byte> instead of string.
Key Changes
- Interface signatures changed from
stringtoReadOnlySpan<byte>for name/prefix properties - GetNestedType methods now accept
ReadOnlySpan<byte>parameters - String literals converted to UTF-8 literals (e.g.,
"Boxed"→ `"Boxed"u8) - Switch statements replaced with if-else chains for span comparisons
Reviewed changes
Copilot reviewed 43 out of 43 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| IPrefixMangledType.cs | Changed Prefix property from string to ReadOnlySpan |
| IPrefixMangledMethod.cs | Changed Prefix property from string to ReadOnlySpan |
| IPrefixMangledSignature.cs | Changed Prefix property from string to ReadOnlySpan |
| MetadataType.cs | Changed GetNestedType parameter from string to ReadOnlySpan |
| CompilerTypeSystemContext.Mangling.cs | Updated Prefix implementations to return UTF-8 literals |
| CompilerTypeSystemContext.InterfaceThunks.cs | Added caching of UTF-8 prefix as byte array field |
| CompilerTypeSystemContext.BoxedTypes.cs | Updated GetNestedType signature |
| CompilerTypeSystemContext.GeneratedAssembly.cs | Updated GetNestedType signature |
| ReadyToRunCompilerContext.cs | Changed GetNestedType call to use UTF-8 literal |
| Compilation.cs | Changed GetKnownNestedType call to use UTF-8 literal |
| TypeRefTypeSystemType.cs | Updated GetNestedType with UTF-8 parameter, converts to string for dictionary lookup |
| EcmaType.cs | Updated GetNestedType to accept UTF-8, uses Append and GetString |
| EcmaModule.cs | Updated type reference resolution to use UTF-8 with Append |
| TypeSystemHelpers.cs | Changed GetFullName to return UTF-8, uses Append extension |
| SimpleArrayOfTRuntimeInterfacesAlgorithm.cs | Changed static array to ReadOnlyMemory[] for UTF-8 storage |
| UnmanagedCallingConventions.cs | Converted switch expression to if-else chain for UTF-8 comparisons |
| ComparerIntrinsics.cs | Changed methods to accept UTF-8 parameters, uses Append for type name construction |
| NativeAotILProvider.cs | Converted switch to if-else chain for UTF-8 name comparisons |
| Multiple *Mangling.cs files | Updated Prefix implementations to return UTF-8 literals |
| Multiple type stub files | Updated GetNestedType method signatures |
| CalliMarshallingMethodThunk.Mangling.cs | Added UTF-8 prefix logic with Append call |
| HelperExtensions.cs | Updated GetKnownNestedType signature |
| CustomAttributeTypeNameParser.cs | Updated nested type lookup to convert to UTF-8 |
| ProcessLinkerXmlBase.cs | Updated nested type lookup to convert to UTF-8 |
| Multiple partial type files | Updated GetNestedType signatures to accept UTF-8 |
| UnsafeIntrinsics.cs | Added TODO comment about avoiding string allocations |
src/coreclr/tools/Common/TypeSystem/IL/Stubs/CalliMarshallingMethodThunk.Mangling.cs
Outdated
Show resolved
Hide resolved
src/coreclr/tools/Common/TypeSystem/IL/Stubs/UnsafeIntrinsics.cs
Outdated
Show resolved
Hide resolved
src/coreclr/tools/Common/TypeSystem/Interop/UnmanagedCallingConventions.cs
Outdated
Show resolved
Hide resolved
MichalStrehovsky
approved these changes
Dec 22, 2025
This was referenced Jan 9, 2026
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.
Moved some APIs to UTF-8 when there was the chance to avoid some string allocations for at least some code paths.
Contributes to #122363.