Skip to content

ILTrim: Preserve implemented interfaces on constructed types - #133913

Draft
jtschuster wants to merge 1 commit into
dotnet:mainfrom
jtschuster:fix-iltrim-type-check-removal
Draft

jtschuster wants to merge 1 commit into
dotnet:mainfrom
jtschuster:fix-iltrim-type-check-removal

Conversation

@jtschuster

Copy link
Copy Markdown
Member

Summary

Fix ILTrim interface implementation emission to match ILLink when an implementing type is constructed and its interface type is marked. This preserves interface metadata and enables the associated interface members to remain reachable.

The fix updates TypeDefinitionNode.WriteInternal and removes the 13 interface-related entries from ILTrimExpectedFailures.txt that now pass.

Validation

  • dotnet build src/coreclr/tools/ILTrim.Tests/ILTrim.Tests.csproj
  • Full ILTrim suite: 409 passed, 518 skipped, 0 failed
  • git diff --check

The broader repository baseline build remains blocked by an unrelated generated-resource mismatch in crossgen2.

Note

This pull request description was generated with GitHub Copilot.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 5f633264-d8a6-4199-a816-4c0da8e63873
@github-actions github-actions Bot added the area-Tools-ILLink .NET linker development as well as trimming analyzers label Sep 14, 2026
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 4 pipeline(s).
12 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @agocke, @dotnet/illink
See info in area-owners.md if you want to be subscribed.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Interface tokens may remain unmarked, causing assertion failures or invalid metadata.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

This pull request updates ILTrim to preserve interface metadata for constructed types, aligning behavior with ILLink.

Changes:

  • Updates interface implementation emission in TypeDefinitionNode.cs.
  • Removes 13 obsolete expected failures.
File summaries
File Summary
src/coreclr/tools/ILTrim.Tests/ILTrimExpectedFailures.txt Removes interface-related expected failures.
src/coreclr/tools/ILTrim.Core/DependencyAnalysis/TokenBased/TypeDefinitionNode.cs Preserves eligible interface metadata; a critical token-marking issue remains unresolved.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 1
  • Review effort level: Lite

Comment on lines +165 to +168
if (interfaceType != null &&
(writeContext.Factory.InterfaceUse(interfaceType).Marked ||
(writeContext.Factory.ConstructedType((EcmaType)_module.GetObject(Handle)).Marked &&
writeContext.Factory.TypeDefinition(interfaceType.Module, interfaceType.Handle).Marked)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-Tools-ILLink .NET linker development as well as trimming analyzers

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants