Take UsingLayoutAnalyser 0.4.0, for UA1002 - #12
Merged
henrikottesorensen merged 1 commit intoAug 13, 2026
Merged
Conversation
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>
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.
Follow-on to #11. That removed the two
.editorconfigkeys that wedgeddotnet format; this takes the analyser version that stops them coming back.What 0.4.0 adds
UA1002reports, once per project, the settings that make something else rewrite the using block:dotnet_sort_system_directives_firstdotnet_separate_import_directive_groupsdotnet_diagnostic.SA1210.severitywarningorerrorPresence rather than value for the first two, because presence is the trigger —
= falsereads like switching the thing off and does exactly what= truedoes. That is the specific misunderstanding this package shipped for two releases.SA1210is in there because it is the same class of problem and the more expensive one. It has a fix of its own, so underdotnet formatits fix andUA1000'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 formatfor every consumer who formats from a command line, permanently, with no way for the consumer to fix it — an.editorconfigcannot unset a globalconfig key, and setting it tofalsemakes 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
UA1002is 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:That is
UA1002arriving through the installed package, not through a project reference.All three scripts pass, and the build is clean:
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
.editorconfigentry 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 seeUA1002, and underTreatWarningsAsErrorsits build stops.That is the rule working — their build was already broken in the way that mattered, and only
dotnet formatknew — but it should go out as a minor release rather than a patch, sov2.3.0rather thanv2.2.3.What it does not catch
SA1210left unset is StyleCop's own default, and no analyser can read another package's defaults, so unset is unknown rather than safe. Belowwarningit stays quiet on purpose:dotnet formatfixes atwarnand 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