Skip to content

Mark generic arguments for unresolved generic types - #103844

Merged
sbomer merged 1 commit into
dotnet:mainfrom
sbomer:genericArgumentFix
Jun 24, 2024
Merged

sbomer merged 1 commit into
dotnet:mainfrom
sbomer:genericArgumentFix

Conversation

@sbomer

@sbomer sbomer commented Jun 21, 2024 •

Copy link
Copy Markdown
Member

Fixes an ILLink crash when a base generic type is not resolvable. See #93797 (comment) for context. The failure mode was this:

  • A generic type isn't resolvable because it's defined in an unreferenced assembly
  • But the generic arguments are resolvable. Before the fix, we wouldn't necessarily mark these when the generic type isn't resolvable.
  • When sweeping the assembly, we drop the typeref for the unmarked generic argument type.
  • When writing the assembly, we try to write out the generic type reference, but crash because the generic argument type doesn't exist anymore.

This fixes it by marking the generic argument types even when the generic type definition can't be resolved.

Fixes #93797

@dotnet/illink

@sbomer
sbomer requested a review from jtschuster June 21, 2024 22:40
@sbomer
sbomer requested a review from marek-safar as a code owner June 21, 2024 22:40
@ghost ghost added the area-Tools-ILLink .NET linker development as well as trimming analyzers label Jun 21, 2024
@dotnet-policy-service dotnet-policy-service Bot added the linkable-framework Issues associated with delivering a linker friendly framework label Jun 21, 2024

@jtschuster jtschuster left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, thank you!

@sbomer
sbomer merged commit 3a5a7da into dotnet:main Jun 24, 2024
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 25, 2024
@sbomer
sbomer deleted the genericArgumentFix branch June 26, 2026 18:08
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-Tools-ILLink .NET linker development as well as trimming analyzers linkable-framework Issues associated with delivering a linker friendly framework

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ILLink: argument exception in Cecil when writing assembly

2 participants