Skip to content

feat!: Report operators that lead a wrapped line (NOTA0002) - #1

Closed
henrikottesorensen wants to merge 7 commits into
mainfrom
claude/homespool-hs0002-rule-6391b7
Closed

henrikottesorensen wants to merge 7 commits into
mainfrom
claude/homespool-hs0002-rule-6391b7

Conversation

@henrikottesorensen

@henrikottesorensen henrikottesorensen commented Oct 7, 2026 •

Copy link
Copy Markdown
Owner

What

Adds NOTA0002 (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, so dotnet format can bulk-convert). Both assemblies are packed into analyzers/dotnet/cs, and the package gains no dependencies. Built against Roslyn 4.8 so SDK 8 consumers don't skip them with CS9057.
  • Nota.CodeAnalysis.Analysers.Test: 40 unit tests. CI now runs dotnet test.
  • Globalconfig changes:
    • dotnet_style_operator_placement_when_wrapping flips from beginning_of_line to end_of_line.
    • Rider's csharp_wrap_before_binary_opsign / _binary_pattern_op / _ternary_opsigns are set to false.
    • csharp_style_expression_bodied_operators goes from false:silent to false:warning, so IDE0024 reports at build.

Breaking

Existing leading operators (NOTA0002) and expression-bodied operator overloads (IDE0024) start warning. Repos with TreatWarningsAsErrors will fail until converted. The README's new "Upgrading from 2.3" section has the commands:

dotnet format analyzers --diagnostics NOTA0002 --severity warn
dotnet format style --diagnostics IDE0024 --severity warn

Suggest releasing this as v3.0.0.

Verification

  • verify.sh: NOTA0002 must report on Samples/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: NOTA0002 must reach a consumer installing the packed package, which proves the assemblies were packed.
  • I broke each new check on purpose (severity none, an extra diagnostic on the trailing form, analysers left out of the package), and each one failed as intended.
  • dotnet format with the packed package cleared every NOTA0002. dotnet format style converted an IDE0024 case.

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

ddfreiling and others added 7 commits August 12, 2026 16:28
Ship the byte order mark removal script
MinVer computes Version from the nearest git tag (v-prefixed, per Directory.Build.props)
plus commit height, so packing by hand and CI publishing can no longer disagree, and the
workflow's own "take the version from the tag" step is now unnecessary.

verify-package.sh switches from -p:Version to -p:MinVerVersionOverride: MinVer recalculates
and overwrites Version itself, so -p:Version was silently ignored and every verification run
would have collided on the same package version - the exact bug that comment already warns
about.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
The "Working on this repository" section still described the version living in the tag
and a local-default <Version> in the csproj - true before this change, wrong after it now
that MinVer computes Version from the tag on every build and the property is gone.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…sen-add-minver-versioning

feat: Version the package with MinVer instead of a manual CI step
dotnet_sort_system_directives_first and dotnet_separate_import_directive_groups
are gone from the globalconfig. Not set to false - absent. Their presence at any
value arms the organize-imports stage of "dotnet format style", which reports as
"error IMPORTS: Fix imports ordering" and sorts flat-alphabetically after System,
putting Nota above the vendors. That is the inverse of what UA1000 requires.

The result is a loop rather than a wrong file. The style stage reorders, the
analyzers stage puts it back, the file on disk never changes - so dotnet format
reports nothing to do while dotnet format --verify-no-changes exits 2 forever,
and a consuming repository cannot make CI green by any means available to it.

The old note here reasoned that the per-vendor grouping was "checked by IDE0055
only, which is off here, so nothing reports it". That is true and beside the
point: the imports stage is not a diagnostic, has no severity, and setting
dotnet_diagnostic.IDE0055.severity = none does not reach it. It checked what
reports, not what enforces. Rider is unaffected, which is why this only ever
showed up for whoever formats from the command line.

Measured against a real consumer with both of its .editorconfig files, not
reasoned about: as shipped, three consecutive runs left the file byte-identical
and --verify-no-changes exited 2 every time; with the keys removed, one pass
produces the canonical layout and it exits 0.

verify.sh asserted SA1516 for the blank line after the System group, and that
only worked because the key was set - so removing it broke the suite, which is
the suite doing its job. UA1001 makes that check now, and knows first party from
vendor where SA1516 only ever saw first-level namespaces. Samples/Unseparated.cs
carries both faults so SA1516 stays asserted on member separation, which was
always its own job.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…at-imports-loop

Drop the two import keys that wedge dotnet format
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 NOTA0002 reports, and that
nothing reports the trailing form the fix produces.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@henrikottesorensen
henrikottesorensen force-pushed the claude/homespool-hs0002-rule-6391b7 branch from 62aea59 to f8dd79c Compare October 7, 2026 17:24
@henrikottesorensen

Copy link
Copy Markdown
Owner Author

Superseded by Notalib#15

@henrikottesorensen
henrikottesorensen deleted the claude/homespool-hs0002-rule-6391b7 branch October 7, 2026 17:28
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.

3 participants