-
Couldn't load subscription status.
- Fork 1.2k
Fix CA1516 diagnostic resource string mapping to display correct title and description #51299
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
Conversation
Co-authored-by: stephentoub <[email protected]>
...tAnalyzers/Microsoft.CodeQuality.Analyzers/xlf/MicrosoftCodeQualityAnalyzersResources.cs.xlf
Outdated
Show resolved
Hide resolved
...sts/Microsoft.CodeQuality.Analyzers/Maintainability/CSharpUseCrossPlatformIntrinsicsTests.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this 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 fixes CA1516 analyzer diagnostics to display correct titles and descriptions by correcting resource key mismatches between the analyzer code and resource files.
Key Changes:
- Renamed 12 message resource keys in .resx files to match the
RuleKindenum format (adding underscores: e.g.,opAddition→op_Addition) - Fixed typo in resource key:
opDivison→op_Division - Updated all localization (.xlf) files using
/t:UpdateXlftarget - Added test to validate diagnostic descriptors have correct title and description
Reviewed Changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| MicrosoftCodeQualityAnalyzersResources.resx | Renamed 12 message resource keys to match enum format with underscores |
| CSharpUseCrossPlatformIntrinsicsTests.cs | Added test validating diagnostic descriptors have expected title and description |
| *.xlf (14 files) | Updated all localization files with new resource key names and marked translations for review |
Co-authored-by: stephentoub <[email protected]>
...sts/Microsoft.CodeQuality.Analyzers/Maintainability/CSharpUseCrossPlatformIntrinsicsTests.cs
Outdated
Show resolved
Hide resolved
…alysis.NetAnalyzers.UnitTests/Microsoft.CodeQuality.Analyzers/Maintainability/CSharpUseCrossPlatformIntrinsicsTests.cs
|
Does this need backporting? |
I'll leave that to you and @jeffhandley. Before this fix, you'd see output like: and now you'll see: |
Fix CA1516 Diagnostic Title and Description Issue
Fixed the CA1516 analyzer so diagnostics now display the correct title and description in MSBuild output and error lists.
Changes Made:
op_Additioninstead ofopAddition)opDivison→op_DivisionRoot Cause:
The analyzer code builds resource keys from the
RuleKindenum using string interpolation:This creates keys like
UseCrossPlatformIntrinsicsMessage_op_Addition(with underscore between "op" and operation name).However, the .resx file had keys without that underscore:
UseCrossPlatformIntrinsicsMessage_opAddition.This mismatch caused the resource lookup to fail, resulting in diagnostics without proper titles and descriptions.
Solution:
Renamed all 12 resource keys in the .resx file to match the enum format by adding the underscore. In xlf files, only the IDs were changed while preserving all existing translations and target states.
Original prompt
This pull request was created as a result of the following prompt from Copilot chat.
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.