Skip to content

Indent the whole statement when the SA1503, SA1519 and SA1520 code fix adds braces - #4108

Merged
AArnott merged 5 commits into
DotNetAnalyzers:masterfrom
alexander-efremov:sa1503-indent-statement
Oct 7, 2026
Merged

AArnott merged 5 commits into
DotNetAnalyzers:masterfrom
alexander-efremov:sa1503-indent-statement

Conversation

@alexander-efremov

Copy link
Copy Markdown
Contributor

When the shared add-braces code fix (SA1503, SA1519, SA1520) wraps a statement that starts at its parent's indentation, every line of the statement now moves one indentation step. Before, only the first line moved, so nested using statements got their braces at the outer level. Indentation settings are respected, verbatim string contents are unchanged, and Fix All on nested statements does not double-indent.

The line indenter from the SA1116 fix moves to IndentationHelper and is shared. Depends on #4107: this branch contains its commit; the diff of this PR is the second commit.

Tests: four new SA1519 tests; two existing tests expected the broken layout and now expect the nested form. StyleCop.Analyzers.Test (net6.0) passes.

Fixes #2183

Ported from the StyleCopNext.Analyzers fork (see alexander-efremov#564). Draft until CI on this repository is running again.

@codecov

codecov Bot commented Oct 6, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.13333% with 22 lines in your changes missing coverage. Please review.
✅ Project coverage is 97.48%. Comparing base (513ba0f) to head (bc487e7).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4108      +/-   ##
==========================================
- Coverage   97.48%   97.48%   -0.01%     
==========================================
  Files        1026     1032       +6     
  Lines      119387   119800     +413     
  Branches     3476     3494      +18     
==========================================
+ Hits       116388   116789     +401     
- Misses       1986     1996      +10     
- Partials     1013     1015       +2     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@AArnott
AArnott marked this pull request as ready for review October 7, 2026 18:14
@AArnott
AArnott merged commit b5ee3cf into DotNetAnalyzers:master Oct 7, 2026
21 checks passed
@alexander-efremov
alexander-efremov deleted the sa1503-indent-statement branch October 9, 2026 05:34
This was referenced Nov 11, 2026
This was referenced Nov 23, 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.

Incorrect indentation in SA1519 code fix

2 participants