Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Trim analyzer should warn about assignment to get-only property #93277

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
sbomer opened this issue Apr 6, 2022 · 3 comments
Open

Trim analyzer should warn about assignment to get-only property #93277

sbomer opened this issue Apr 6, 2022 · 3 comments
Assignees
Labels
area-Tools-ILLink .NET linker development as well as trimming analyzers
Milestone

Comments

@sbomer
Copy link
Member

sbomer commented Apr 6, 2022

Opening this to track the follow-up items discussed in dotnet/linker#2728 - see that PR for full context.

The analyzer doesn't produce any warnings when assigning to a get-only property, because it doesn't know about the compiler-generated backing field. To fix this we could either:

  • continue using the same warning message, but with the property name instead of the compiler-generated field name that the linker see, or
  • reword the message to avoid mentioning "field" specifically, so it can be used for both the linker and analyzer.
@vitek-karas
Copy link
Member

The analyzer should basically talk about writing to the property. If it means adapting the message to make it reusable, let's go with that.

@vitek-karas vitek-karas transferred this issue from dotnet/linker Oct 10, 2023
@ghost ghost added needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners untriaged New issue has not been triaged by the area owner labels Oct 10, 2023
@vitek-karas vitek-karas added the area-Tools-ILLink .NET linker development as well as trimming analyzers label Oct 10, 2023
@ghost
Copy link

ghost commented Oct 10, 2023

Tagging subscribers to this area: @agocke, @sbomer, @vitek-karas
See info in area-owners.md if you want to be subscribed.

Issue Details

Opening this to track the follow-up items discussed in dotnet/linker#2728 - see that PR for full context.

The analyzer doesn't produce any warnings when assigning to a get-only property, because it doesn't know about the compiler-generated backing field. To fix this we could either:

  • continue using the same warning message, but with the property name instead of the compiler-generated field name that the linker see, or
  • reword the message to avoid mentioning "field" specifically, so it can be used for both the linker and analyzer.
Author: sbomer
Assignees: -
Labels:

untriaged, area-Tools-ILLink, needs-area-label

Milestone: -

@vitek-karas vitek-karas changed the title Analyzer should warn about assignment to get-only property Trim analyzer should warn about assignment to get-only property Oct 10, 2023
@vcsjones vcsjones removed the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Oct 10, 2023
@agocke agocke added this to AppModel Nov 28, 2023
@sbomer sbomer added this to the 9.0.0 milestone Apr 25, 2024
@sbomer sbomer removed the untriaged New issue has not been triaged by the area owner label Apr 25, 2024
@sbomer sbomer modified the milestones: 9.0.0, 10.0.0 Aug 8, 2024
sbomer added a commit to sbomer/runtime that referenced this issue Oct 1, 2024
@sbomer sbomer self-assigned this Apr 8, 2025
@agocke
Copy link
Member

agocke commented Apr 8, 2025

continue using the same warning message, but with the property name instead of the compiler-generated field name

I think that's the right move. It makes the most sense from the C# context.

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

No branches or pull requests

4 participants