Fix generic type parameter resolution for fields (#1368, #1369)#1373
Merged
leculver merged 1 commit intomicrosoft:mainfrom Feb 26, 2026
Merged
Fix generic type parameter resolution for fields (#1368, #1369)#1373leculver merged 1 commit intomicrosoft:mainfrom
leculver merged 1 commit intomicrosoft:mainfrom
Conversation
…rosoft#1369) - Filter out System.__Canon types from field type resolution in CacheFields. When a field's MethodTable resolves to __Canon (the canonical type used for shared generic instantiations), set the type to null to trigger the metadata signature fallback path. - Add concrete generic type argument resolution in ClrField.InitData(). Parse the parent type's name to extract concrete generic type arguments (e.g., 'LinkedListNode<System.String>' -> [System.String]) and pass them to GetOrCreateTypeFromSignature for Var/MVar substitution. - Extend GetOrCreateTypeFromSignature to accept optional concrete type arguments. When resolving Var(index) in field signatures, use the concrete type instead of creating a ClrGenericType placeholder. - Improve GenericInstantiation resolution to attempt looking up concrete generic types by name when concrete type arguments are available. - Fix ClrValueType.TryReadStringField missing _interior parameter in GetAddress call. - Add regression tests for LinkedListNode<string>.item field type resolution and Dictionary<string,int>._entries array reading. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
Author
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
This was
linked to
issues
Feb 25, 2026
Closed
brianrob
approved these changes
Feb 25, 2026
max-charlamb
pushed a commit
that referenced
this pull request
Apr 10, 2026
…eholder When __Canon filtering (introduced in #1373) nulls a field's type and the metadata signature fallback resolves to a ClrGenericType placeholder (e.g. 'TStateMachine' with no fields), fall back to resolving via the field's MethodTable directly. This handles compiler-generated types nested inside open generic classes (e.g. async state machines in local functions) where GetTypeByName fails because it compares closed-generic names against open-generic TypeDefs. The MethodTable resolves to __Canon, which restores the pre-#1373 behavior: the field reports IsObjectReference=true, so consumers use ReadObjectField to get the concrete type from the heap. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
Filter out System.__Canon types from field type resolution in CacheFields. When a field's MethodTable resolves to __Canon (the canonical type used for shared generic instantiations), set the type to null to trigger the metadata signature fallback path.
Add concrete generic type argument resolution in ClrField.InitData(). Parse the parent type's name to extract concrete generic type arguments (e.g., 'LinkedListNode<System.String>' -> [System.String]) and pass them to GetOrCreateTypeFromSignature for Var/MVar substitution.
Extend GetOrCreateTypeFromSignature to accept optional concrete type arguments. When resolving Var(index) in field signatures, use the concrete type instead of creating a ClrGenericType placeholder.
Improve GenericInstantiation resolution to attempt looking up concrete generic types by name when concrete type arguments are available.
Fix ClrValueType.TryReadStringField missing _interior parameter in GetAddress call.
Add regression tests for LinkedListNode.item field type resolution and Dictionary<string,int>._entries array reading.