Skip to content

Fix generic type parameter resolution for fields (#1368, #1369)#1373

Merged
leculver merged 1 commit intomicrosoft:mainfrom
leculver:fix/issues-1368-1369
Feb 26, 2026
Merged

Fix generic type parameter resolution for fields (#1368, #1369)#1373
leculver merged 1 commit intomicrosoft:mainfrom
leculver:fix/issues-1368-1369

Conversation

@leculver
Copy link
Copy Markdown
Contributor

  • 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.

…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>
@leculver
Copy link
Copy Markdown
Contributor Author

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

This was linked to issues Feb 25, 2026
@leculver leculver merged commit 847dcd6 into microsoft:main Feb 26, 2026
8 checks passed
@leculver leculver deleted the fix/issues-1368-1369 branch February 26, 2026 01:59
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LinkedList<T> reading Dictionary Fields Reading

2 participants