Skip to content

Fall back to MethodTable when generic type resolution produces a placeholder#1416

Merged
max-charlamb merged 1 commit intomicrosoft:mainfrom
max-charlamb:fix/canon-fallback-type
Apr 10, 2026
Merged

Fall back to MethodTable when generic type resolution produces a placeholder#1416
max-charlamb merged 1 commit intomicrosoft:mainfrom
max-charlamb:fix/canon-fallback-type

Conversation

@max-charlamb
Copy link
Copy Markdown
Contributor

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.

@max-charlamb max-charlamb marked this pull request as ready for review April 10, 2026 01:38
@max-charlamb max-charlamb requested a review from leculver April 10, 2026 01:38
…eholder

When __Canon filtering (introduced in microsoft#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-microsoft#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>
@max-charlamb max-charlamb force-pushed the fix/canon-fallback-type branch from 2b49b0f to db58d1a Compare April 10, 2026 15:23
@max-charlamb max-charlamb merged commit 58dadbc into microsoft:main Apr 10, 2026
8 checks passed
@max-charlamb max-charlamb deleted the fix/canon-fallback-type branch April 10, 2026 15:29
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.

2 participants