Repository navigation
SA1315: Include expected parameter names in diagnostics - #4351
Merged
Merged
Conversation
Show inherited parameter names even when a rename fix cannot be offered due to a local-name conflict. Preserve collision protection and cover by-reference parameters and multiple inherited names. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #4351 +/- ##
========================================
Coverage 97.65% 97.66%
========================================
Files 1334 1334
Lines 148966 149089 +123
Branches 5056 5056
========================================
+ Hits 145476 145603 +127
+ Misses 2212 2210 -2
+ Partials 1278 1276 -2 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
🟢 Approval recommended
Diagnostic arguments, localized placeholders, and regression expectations are consistent, with no unresolved findings.
No open issues 🎉
1 file not reviewed
src/StyleCop.Analyzers/Lightup/.generated/Microsoft.CodeAnalysis.ResxSourceGenerator.CSharp/Microsoft.CodeAnalysis.ResxSourceGenerator.CSharp.CSharpResxGenerator/NamingResources.Designer.cs: Generated file
What changed in this PR
Improves SA1315 diagnostics by showing valid inherited parameter names, including when rename fixes are unavailable.
Changes:
- Adds expected names to diagnostic messages.
- Updates English, Russian, and Simplified Chinese resources.
- Adds regression coverage for multiple names, by-reference parameters, and rename conflicts.
| File | Description |
|---|---|
| test/StyleCop.Analyzers.Test/NamingRules/SA1315UnitTests.cs | Updates expectations and adds regression tests. |
| src/StyleCop.Analyzers/NamingRules/SA1315ParametersShouldMatchInheritedNames.cs | Includes inherited names in diagnostic arguments. |
| src/StyleCop.Analyzers/NamingRules/NamingResources.zh-CN.resx | Updates the Simplified Chinese message. |
| src/StyleCop.Analyzers/NamingRules/NamingResources.ru-RU.resx | Updates the Russian message. |
| src/StyleCop.Analyzers/NamingRules/NamingResources.resx | Updates the English message. |
| src/StyleCop.Analyzers/Lightup/.generated/Microsoft.CodeAnalysis.ResxSourceGenerator.CSharp/Microsoft.CodeAnalysis.ResxSourceGenerator.CSharp.CSharpResxGenerator/NamingResources.Designer.cs | Synchronizes the generated accessor’s documentation. |
Review effort: Balanced
This was referenced Nov 11, 2026
Bump StyleCop.Analyzers from 1.2.0-beta.556 to 1.3.180
microsoftgraph/aspnetcore-webhooks-sample#436
Open
Closed
Open
This was referenced Nov 22, 2026
Open
[DPDBT] Bump Microsoft.CodeAnalysis.Analyzers and 6 others
sergey-rybalkin/CommandLine.Generators#63
Open
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.
SA1315 identifies mismatched parameter names without telling the user which name is expected. This is especially unhelpful when the rename fix is unavailable because an inherited name conflicts with a local variable.
Include the expected inherited name, or the comma-separated list of distinct valid names, in the diagnostic. Update the existing Russian and Simplified Chinese messages and regenerate the resource accessor. The code fix and its collision protection are unchanged;
outandrefparameters already work when no conflict exists.Validation: exact-message regressions fail against the original analyzer. All 15 SA1315 cases pass in each C# 6 through C# 15 test project, including multiple interface names, both rename choices, by-reference parameters, and local-name conflicts. Debug builds completed with zero warnings.
Performance: one additional string join only when reporting a diagnostic; no new callbacks or semantic analysis. Documentation changes were intentionally omitted at the user's request.