-
Notifications
You must be signed in to change notification settings - Fork 4.5k
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
Analyzer proposal: Remove unused resources #79765
Comments
Tagging subscribers to this area: @dotnet/area-meta Issue DetailsBackground and motivationToo 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 ProposalNot applicable for an analyzer suggestion. API UsageNot applicable for an analyzer suggestion. Alternative DesignsRisksNOTE: While this is not an API-specific analyzer, it was suggested that it gets reviewed by dotnet/runtime team in dotnet/roslyn-analyzers#6338 (comment)
|
Tagging subscribers to this area: @dotnet/area-system-runtime Issue DetailsBackground and motivationToo 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 ProposalNot applicable for an analyzer suggestion. API UsageNot applicable for an analyzer suggestion. Alternative DesignsRisksNOTE: While this is not an API-specific analyzer, it was suggested that it gets reviewed by dotnet/runtime team in dotnet/roslyn-analyzers#6338 (comment)
|
@Youssef1313 you could remove the not applicable parts. It would be good to have some examples in |
@buyaa-n Edited |
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 |
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 dotnet/roslyn-analyzers#6338 (comment)
The text was updated successfully, but these errors were encountered: