Repository navigation
feat!: Report operators that lead a wrapped line (NOTA0003) - #15
Merged
nanchen2483 merged 1 commit intoOct 8, 2026
Merged
Conversation
A new analyser, a code fix that moves only the operator, and their unit tests. Both assemblies ship inside the package under analyzers/dotnet/cs, built against Roslyn 4.8 so SDK 8 consumers do not skip them with CS9057. The convention flips to match: dotnet_style_operator_placement_when_wrapping is end_of_line, and Rider's three csharp_wrap_before_* keys are set the same way. IDE0024 is also raised to a warning, so operator overloads get block bodies. Breaking: existing leading operators and expression-bodied operators become warnings. dotnet format converts both; the README's upgrade section has the commands. verify.sh and verify-package.sh now assert NOTA0003 reports, and that nothing reports the trailing form the fix produces. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
nanchen2483
approved these changes
Oct 8, 2026
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.
What
Adds
NOTA0003(warning): when an expression wraps, the operator ends the line and the next line starts with the operand.Nota.CodeAnalysis.Analysers+.CodeFixes: the analyser and a code fix that moves only the operator (whitespace-only, sodotnet formatcan bulk-convert). Both assemblies are packed intoanalyzers/dotnet/cs, and the package gains no dependencies. Built against Roslyn 4.8 so SDK 8 consumers don't skip them withCS9057.Nota.CodeAnalysis.Analysers.Test: 40 unit tests. CI now runsdotnet test.dotnet_style_operator_placement_when_wrappingflips frombeginning_of_linetoend_of_line.csharp_wrap_before_binary_opsign/_binary_pattern_op/_ternary_opsignsare set tofalse.csharp_style_expression_bodied_operatorsgoes fromfalse:silenttofalse:warning, soIDE0024reports at build.Breaking
Existing leading operators (
NOTA0003) and expression-bodied operator overloads (IDE0024) start warning. Repos withTreatWarningsAsErrorswill fail until converted. The README's new "Upgrading from 2.3" section has the commands:Verification
verify.sh:NOTA0003must report onSamples/LeadingOperator.cs. The script also fails if anything reports on the trailing form the fix produces, so a StyleCop or IDE0055 rule can't start fighting the fix unnoticed.verify-package.sh:NOTA0003must reach a consumer installing the packed package, which proves the assemblies were packed.none, an extra diagnostic on the trailing form, analysers left out of the package), and each one failed as intended.dotnet formatwith the packed package cleared everyNOTA0003.dotnet format styleconverted anIDE0024case.Unverified
I haven't checked whether Rider reads the
csharp_wrap_before_*keys from a global analyzer config. If it doesn't, consumers need the three lines in their own.editorconfig. The README and a globalconfig comment both say so.🤖 Generated with Claude Code