Repository navigation
Expand single-line with initializers for IDE0055 - #381
Merged
Merged
Conversation
Match IDE0055 wrapping when preservation mode allows a with initializer to expand. Refs #379
Carry preservation-mode fixture settings into the corpus so inherited widths still exercise the wrapping rules under test.
Mpdreamz
approved these changes
Nov 20, 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.
Curb expands
withinitializers that IDE0055 requires to span lines in preservation mode. The original repro now passes an IDE0055 build after Curb formats it.Prompt summary
Investigate the formatter disagreement in #379, fix it, and add regression tests that check both expansion and preservation.
Why
Curb only forced breaks inside a
withinitializer when its braces already spanned lines. In the reportedreturnstatement, Roslyn allows those breaks once both single-line preservation settings are disabled.What
Single-line wrapping
Curb checks whether a containing statement, declaration, or expression keeps the initializer on one line. It makes the expansion decision on the same pass when it opens an enclosing block.
Brace placement
Expanded initializers follow the initializer brace setting. An empty initializer can split its brace pair too.
Regression coverage
The tests cover populated and empty initializers, each preservation setting, an author-supplied break before the brace, and compact expression bodies. Each case checks that a second formatting pass gives the same result.
Corpus settings
The
withfixtures select preservation explicitly. The generator carries that setting into their source snippets, including runs where the corpus sets a width.Corpus measurements
Seed 1, 2,124 C# files. Each mode meets its conformance floor.
The default and 120-column runs report zero changes on the second pass. Second-pass counts in the preservation runs match the baseline.
Verify
dotnet run --project tests/Nullean.Curb.Tests -c Release -- --treenode-filter '/*/*/InitializerTests/*' ./build.sh verifyexpectations -sCloses #379