Skip to content

Conversation

@jtschuster
Copy link
Member

@jtschuster jtschuster commented Sep 17, 2025

Fixes #119780

We added a warning when we cannot find the backing field of an auto property in #119329 which caused some issues in illink->ilc scenarios when an auto property was stubbed out. Instead, we should just not propagate the DAM annotation.

@github-actions github-actions bot added the area-Tools-ILLink .NET linker development as well as trimming analyzers label Sep 17, 2025
@dotnet-policy-service dotnet-policy-service bot added the linkable-framework Issues associated with delivering a linker friendly framework label Sep 17, 2025
@jtschuster jtschuster marked this pull request as ready for review September 17, 2025 23:00
Copilot AI review requested due to automatic review settings September 17, 2025 23:00
Copy link
Contributor

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 addresses a warning issue in trim tools where IL2042 warnings were incorrectly generated when backing fields of auto properties couldn't be found, particularly in illink->ilc scenarios when auto properties were stubbed out. Instead of warning, the tools now simply skip propagating the DAM annotation when the backing field cannot be located.

Key Changes

  • Remove IL2042 warning generation when backing fields of auto properties cannot be found
  • Simplify backing field detection logic to silently handle missing fields
  • Update Roslyn analyzer to only check for auto properties when field has an associated property

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
PropertyDataFlow.cs Remove expected IL2042 warnings from test cases since these warnings are no longer generated
FlowAnnotations.cs (illink) Simplify backing field logic to skip warning when field not found and only propagate annotation when valid backing field exists
DiagnosticId.cs Mark IL2042 diagnostic ID as unused by prefixing with "unused_"
FlowAnnotations.cs (analyzer) Optimize property checking by combining auto property check with property symbol check
FlowAnnotations.cs (ilcompiler) Apply same backing field logic simplification as illink version

Copy link
Member

@sbomer sbomer left a comment

Choose a reason for hiding this comment

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

LGTM, thank you!

Copy link
Member

@agocke agocke left a comment

Choose a reason for hiding this comment

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

Thanks!

@agocke agocke enabled auto-merge (squash) September 18, 2025 18:30
@jtschuster jtschuster disabled auto-merge September 18, 2025 19:13
@jtschuster jtschuster enabled auto-merge (squash) September 18, 2025 19:29
@agocke
Copy link
Member

agocke commented Sep 22, 2025

/ba-g unknown failures were crashes in the infra

@jtschuster jtschuster merged commit b5718e2 into dotnet:main Sep 22, 2025
110 of 115 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Oct 23, 2025
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.

ILC warns when it fails to find trimmed-away backing field

3 participants