Skip to content
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

Avoid name collision of analyzer class names and title resources #6346

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Youssef1313
Copy link
Member

Found during the work for unused resources analyzer.

The following line (as an example):

binds to the class, instead of binding to the resource:

<data name="DoNotAddArchiveItemPathToTheTargetFileSystemPath" xml:space="preserve">
<value>Do Not Add Archive Item's Path To The Target File System Path</value>
</data>

Causing an incorrect "unused resource" warning.

Having different names will avoid this warning and will let nameof(...) bind properly to the resource.

@Youssef1313 Youssef1313 requested a review from a team as a code owner December 13, 2022 16:18
@codecov
Copy link

codecov bot commented Dec 13, 2022

Codecov Report

Merging #6346 (79dcefc) into main (fde4933) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6346   +/-   ##
=======================================
  Coverage   96.08%   96.08%           
=======================================
  Files        1366     1366           
  Lines      315512   315512           
  Branches    10187    10187           
=======================================
+ Hits       303145   303146    +1     
+ Misses       9934     9933    -1     
  Partials     2433     2433           

@@ -10,7 +10,7 @@ namespace Microsoft.NetCore.Analyzers.Security
using static MicrosoftNetCoreAnalyzersResources;

[DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)]
public class DoNotAddArchiveItemPathToTheTargetFileSystemPath : SourceTriggeredTaintedDataAnalyzerBase
public class DoNotAddArchiveItemPathToTheTargetFileSystemPathAnalyzer : SourceTriggeredTaintedDataAnalyzerBase
Copy link
Member

Choose a reason for hiding this comment

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

Do we need to rename all the files to match the new type name?

@mavasani
Copy link
Member

Actually, I feel a better fix here is to rename the resource strings to always end with Title, Message or Description as appropriate. This will also avoid renaming the analyzer file names.

Copy link
Member

@mavasani mavasani left a comment

Choose a reason for hiding this comment

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

As per the last comment.

@Youssef1313 Youssef1313 self-assigned this Mar 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants