Skip to content

Conversation

sbomer
Copy link
Member

@sbomer sbomer commented Aug 13, 2025

This moves the ILLink generic dataflow analysis out of MarkStep and into the scanner, unifying it with the logic (not actually sharing code) in ILC and ILLink.RoslynAnalyzer. It is essentially a port of the ILC logic into ILLink.

This ran into an issue with incorrect suppressions in DI (see #81358) that we have a workaround for in native AOT, so I've implemented a similar workaround in ILLink. I copied over the native AOT smoke test for that workaround and adjusted it to run as a shared testcase.

Fixes #113249

@sbomer sbomer requested review from a team and Copilot August 13, 2025 23:28
@github-actions github-actions bot added the area-Tools-ILLink .NET linker development as well as trimming analyzers label Aug 13, 2025
@dotnet-policy-service dotnet-policy-service bot added the linkable-framework Issues associated with delivering a linker friendly framework label Aug 13, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR moves ILLink's generic argument dataflow analysis from MarkStep into the scanner phase, aligning it with the implementations in ILC (Native AOT) and ILLink.RoslynAnalyzer. This change unifies the behavior across all three tools for handling generic parameter validation.

  • Generic dataflow analysis is moved from marking phase to scanning phase
  • Test expectations are updated to reflect consistent behavior across tools
  • Additional infrastructure is added to track generic instantiation patterns during scanning

Reviewed Changes

Copilot reviewed 19 out of 19 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
RequiresOnClass.cs Removes unexpected warning annotations that are now properly handled
RequiresExcludeStatics.cs Removes unexpected warning annotations for static/instance fields
UnresolvedMembers.cs Removes expected warning for local variable type
GenericParameterWarningLocation.cs Updates comments and warning expectations to reflect unified behavior
GenericParameterDataFlow.cs Updates comments and removes trimmer-specific warning expectations
CompilerGeneratedTypes.cs Removes trimmer-specific unexpected warnings for compiler-generated code
CompilerGeneratedCodeInPreservedAssemblyWithWarning.cs Removes expected warnings that are now properly suppressed
ApplyTypeAnnotations.cs Changes Kept attribute from trimmer-specific to general
MarkStep.cs Moves generic argument validation to scanner and adds type access validation
TrimAnalysisPatternStore.cs Adds support for tracking generic instantiation access patterns
TrimAnalysisGenericInstantiationAccessPattern.cs New pattern type for generic instantiation access tracking
RequireDynamicallyAccessedMembersAction.cs Adds generic argument dataflow processing for resolved types
ReflectionMethodBodyScanner.cs Adds token access handlers and generic dataflow processing
ReflectionMarker.cs Changes internal field to public property for scanner access
MethodBodyScanner.cs Adds abstract methods for token access handling
GenericArgumentDataFlow.cs Refactors to static class with unified processing methods
FlowAnnotations.cs Adds methods to check for generic parameter annotations

Copy link
Contributor

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

sbomer added 4 commits August 15, 2025 11:50
Seems native AOT trims some interface methods,
probably because it is doing some devirt.
Copy link
Member

@jtschuster jtschuster left a comment

Choose a reason for hiding this comment

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

Thank you!

@sbomer sbomer merged commit 212c438 into dotnet:main Aug 26, 2025
113 of 115 checks passed
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 linkable-framework Issues associated with delivering a linker friendly framework
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unnecessary trim analysis warnings from generics
3 participants