Open Youssef1313 opened 1 year ago
Tagging subscribers to this area: @dotnet/area-meta See info in area-owners.md if you want to be subscribed.
Author: | Youssef1313 |
---|---|
Assignees: | - |
Labels: | `api-suggestion`, `area-Meta`, `untriaged` |
Milestone: | - |
Tagging subscribers to this area: @dotnet/area-system-runtime See info in area-owners.md if you want to be subscribed.
Author: | Youssef1313 |
---|---|
Assignees: | - |
Labels: | `api-suggestion`, `area-Meta`, `area-System.Runtime`, `untriaged` |
Milestone: | - |
@Youssef1313 you could remove the not applicable parts. It would be good to have some examples in API Usage
part like for example what the analyzer would flag and what the fix looks like. Any edge cases that need attention etc. Also, could propose the category and severity if you have any suggestions.
@buyaa-n Edited
While this is not an API-specific analyzer, it was suggested that it gets reviewed by dotnet/runtime team in https://github.com/dotnet/roslyn-analyzers/pull/6338
I think this is a very good analyzer to add. We struggle with this ourselves in dotnet/runtime.
If it's easy to add, the analyzer could look for duplicate strings with different resource IDs. I've only seen this two or three times so it's not worth it unless it's a few lines.
Note that this analyzer would need to be a compilation end analyzer as it would need to analyze the whole compilation to identify unused resource strings/backing properties. This would mean it cannot support a code fixer or be enabled by default in the IDE for live analysis, it will be a build-only analyzer. I still think it would be a useful analyzer, but just wanted to add this context.
This seems generally good as proposed, since it is focused on generated code (which is often ignored by other analyzers). Rather than using convention-based naming it probably wants to find the resx->cs options in the csproj and behave like the tooling would.
It's a little sad that a fixer isn't viable here, but c'est la vie.
Category: Maintainability Visibility: None (off by default) Code: TBD (by the roslyn-analyzers side)
Background and motivation
Too much of unused resources can add to assembly size and can (in some cases) be a maintenance cost. This proposes an analyzer to detect unused resources.
API Usage
The analyzer will analyze the generated C# code for resx files. Assuming resx files named
Resources1.resx
andResources2.resx
, the analyzer will flag the unused static properties of typestring
in classes namedResources1
andResources2
.Analyzer could be enabled by default as an IDE suggestion. Category: Maintainability (maybe Usage or Performance)? Not really sure.
Risks
.editorconfig
option will be exposed to suppress violations.NOTE: While this is not an API-specific analyzer, it was suggested that it gets reviewed by dotnet/runtime team in https://github.com/dotnet/roslyn-analyzers/pull/6338#issuecomment-1354580318