Skip to content

Take UsingLayoutAnalyser 0.4.0, for UA1002 - #12

Merged
henrikottesorensen merged 1 commit into
Notalib:mainfrom
henrikottesorensen:claude/take-usinglayoutanalyser-0.4.0
Aug 13, 2026
Merged

Take UsingLayoutAnalyser 0.4.0, for UA1002#12
henrikottesorensen merged 1 commit into
Notalib:mainfrom
henrikottesorensen:claude/take-usinglayoutanalyser-0.4.0

Conversation

@henrikottesorensen

Copy link
Copy Markdown
Collaborator

Follow-on to #11. That removed the two .editorconfig keys that wedged dotnet format; this takes the analyser version that stops them coming back.

What 0.4.0 adds

UA1002 reports, once per project, the settings that make something else rewrite the using block:

Detected Condition
dotnet_sort_system_directives_first present at any value
dotnet_separate_import_directive_groups present at any value
dotnet_diagnostic.SA1210.severity warning or error

Presence rather than value for the first two, because presence is the trigger — = false reads like switching the thing off and does exactly what = true does. That is the specific misunderstanding this package shipped for two releases.

SA1210 is in there because it is the same class of problem and the more expensive one. It has a fix of its own, so under dotnet format its fix and UA1000's undo each other and the file changes on every run — a real diff every time anyone formats, rather than the stable-but-unpassable state the import keys produce.

Why this matters here rather than being a version bump

The globalconfig carried both keys with a comment explaining why they were harmless. They were not. They wedged dotnet format for every consumer who formats from a command line, permanently, with no way for the consumer to fix it — an .editorconfig cannot unset a globalconfig key, and setting it to false makes no difference. It took a downstream repository losing a day to find out, and #11 was the fix. This is the part that means nobody has to remember.

Verified, not assumed

The keys are gone from here, so UA1002 is silent in this repository — and silence is exactly what a rule that never arrived looks like, which is the failure mode this repository exists to be paranoid about. So it was checked both ways:

with dotnet_separate_import_directive_groups = false added to the verification project:
  warning UA1002: 'dotnet_separate_import_directive_groups' will fight the layout UA1000 enforces - remove the key, ...

with it removed again:
  UA1002 reports: 0

That is UA1002 arriving through the installed package, not through a project reference.

All three scripts pass, and the build is clean:

verify.sh:             All 7 rules reported.
verify-encoding.sh:    All source files are valid UTF-8 or BOM-marked UTF-16.
verify-package.sh:     All rules survive packaging.

Consumer impact — please read before merging

This is a behaviour change, not a dependency bump. Consumers get a new warning for configuration they already had.

An .editorconfig entry beats a global analyzer config entry, so setting either key in a consuming repository was always available and was, until recently, advice in UsingLayoutAnalyser's own README. Any repository that did so will now see UA1002, and under TreatWarningsAsErrors its build stops.

That is the rule working — their build was already broken in the way that mattered, and only dotnet format knew — but it should go out as a minor release rather than a patch, so v2.3.0 rather than v2.2.3.

What it does not catch

SA1210 left unset is StyleCop's own default, and no analyser can read another package's defaults, so unset is unknown rather than safe. Below warning it stays quiet on purpose: dotnet format fixes at warn and above unless told otherwise, so a suggestion puts no second fix in play. Both are in the README rather than implied away.

🤖 Generated with Claude Code

0.4.0 adds UA1002, which reports the settings that make something else rewrite
the using block. This package spent two releases getting that wrong by hand: the
globalconfig carried dotnet_sort_system_directives_first and
dotnet_separate_import_directive_groups with a comment explaining why they were
harmless, and they were not - they wedged dotnet format for every consumer who
formatted from a command line, and it took a downstream repository losing a day
to find out. Notalib#11 removed them. This is the part that stops them coming back.

The keys are gone from here, so UA1002 is silent in this repository, and silence
is exactly what a rule that never arrived looks like - which is the failure mode
this repository exists to be paranoid about. So it was checked rather than
assumed: adding dotnet_separate_import_directive_groups = false to the
verification project reports UA1002 through the installed package, and removing
it again returns to nothing reported.

Consumers get a new warning for configuration they already had, which is the
point and is still a behaviour change. Anyone who set either key in their own
.editorconfig - an .editorconfig entry beats this globalconfig, so that override
was always available - will see UA1002, and under TreatWarningsAsErrors their
build stops. Their build was already broken in the way that mattered; only
dotnet format knew. That makes this a minor release rather than a patch.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@henrikottesorensen
henrikottesorensen requested a review from a team August 13, 2026 17:26
@henrikottesorensen
henrikottesorensen merged commit 3db4ebb into Notalib:main Aug 13, 2026
1 check passed
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