Skip to content

SA1315: Include expected parameter names in diagnostics - #4351

Merged
AArnott merged 1 commit into
masterfrom
aarnott-reimagined-system
Oct 19, 2026
Merged

AArnott merged 1 commit into
masterfrom
aarnott-reimagined-system

Conversation

@AArnott

@AArnott AArnott commented Oct 19, 2026

Copy link
Copy Markdown
Contributor

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; out and ref parameters 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.

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

codecov Bot commented Oct 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.66%. Comparing base (37c4697) to head (7ffbc57).

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:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@AArnott
AArnott marked this pull request as ready for review October 19, 2026 22:45
Copilot AI balanced review requested due to automatic review settings October 19, 2026 22:45

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 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

@AArnott
AArnott merged commit abc4947 into master Oct 19, 2026
30 checks passed
@AArnott
AArnott deleted the aarnott-reimagined-system branch October 19, 2026 22:59
This was referenced Nov 11, 2026
This was referenced Nov 22, 2026
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.

2 participants