Fix CA1516 diagnostic resource string mapping to display correct title and description#51299
Merged
stephentoub merged 4 commits intomainfrom Oct 16, 2025
Merged
Conversation
Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix CA1516 diagnostics to include proper title and description
Fix CA1516 diagnostic resource string mapping to display correct title and description
Oct 16, 2025
stephentoub
reviewed
Oct 16, 2025
...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
Contributor
There was a problem hiding this comment.
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 <2642209+stephentoub@users.noreply.github.com>
stephentoub
approved these changes
Oct 16, 2025
stephentoub
reviewed
Oct 16, 2025
...sts/Microsoft.CodeQuality.Analyzers/Maintainability/CSharpUseCrossPlatformIntrinsicsTests.cs
Outdated
Show resolved
Hide resolved
…alysis.NetAnalyzers.UnitTests/Microsoft.CodeQuality.Analyzers/Maintainability/CSharpUseCrossPlatformIntrinsicsTests.cs
tannergooding
approved these changes
Oct 16, 2025
Member
|
Does this need backporting? |
Member
I'll leave that to you and @jeffhandley. Before this fix, you'd see output like: and now you'll see: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.