You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Fix SA1134 code fix indentation on property accessors - #4262
When attributes are placed on accessors in multi-line properties, the SA1134 code fix previously placed the attribute or accessor at an incorrect indentation level (under-indented by one or two indentation steps, e.g. 4 or 8 spaces instead of 12). In addition, PR #4260 exempted all bodyless property accessors from SA1134, which inadvertently suppressed diagnostics on multi-line auto-property accessors sharing lines.
Changes
Scoped the auto-property exemption in SA1134AttributesMustNotShareLine to single-line auto-properties where the accessor list braces are on the same line.
Added GetIndentationSteps in SA1134CodeFixProvider to calculate correct indentation for accessors (containing type + 2 steps) as well as member and type declarations.
Updated documentation in SA1134.md and ru-ru/SA1134.md to reflect the single-line auto-property exemption.
Added unit test coverage covering single-line auto-properties, multi-line auto-properties, non-auto properties, interfaces, nested classes, and K&R brace styles across C# 6 and C# 7 test suites.
This branch excludes DelegateDeclarationSyntax. A top-level delegate therefore falls through to the generic path, which derives CompilationUnit + 1 and inserts four spaces before a split attribute instead of keeping it at column 1. Handle delegates with the same containment-based path (and cover a top-level delegate fix) so all type declarations receive the corrected indentation.
❌ Patch coverage is 98.42209% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 97.62%. Comparing base (c819dec) to head (3f808ec).
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
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.
Fixes #1938
Closes #3728
Motivation
When attributes are placed on accessors in multi-line properties, the SA1134 code fix previously placed the attribute or accessor at an incorrect indentation level (under-indented by one or two indentation steps, e.g. 4 or 8 spaces instead of 12). In addition, PR #4260 exempted all bodyless property accessors from SA1134, which inadvertently suppressed diagnostics on multi-line auto-property accessors sharing lines.
Changes
SA1134AttributesMustNotShareLineto single-line auto-properties where the accessor list braces are on the same line.GetIndentationStepsinSA1134CodeFixProviderto calculate correct indentation for accessors (containing type + 2 steps) as well as member and type declarations.SA1134.mdandru-ru/SA1134.mdto reflect the single-line auto-property exemption.