Skip to content

Fix invalid csharp_space_around_declaration_statements option value#80996

Merged
JoeRobich merged 1 commit intodotnet:mainfrom
xtqqczze:csharp_space_around_declaration_statements
Mar 1, 2026
Merged

Fix invalid csharp_space_around_declaration_statements option value#80996
JoeRobich merged 1 commit intodotnet:mainfrom
xtqqczze:csharp_space_around_declaration_statements

Conversation

@xtqqczze
Copy link
Copy Markdown
Contributor

@xtqqczze xtqqczze commented Nov 3, 2025

The only valid option values are ignore and false.

https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/csharp-formatting-options#csharp_space_around_declaration_statements

public static Option2<bool> SpacesIgnoreAroundVariableDeclaration { get; } = CreateOption(
CSharpFormattingOptionGroups.Spacing, "csharp_space_around_declaration_statements",
CSharpSyntaxFormattingOptions.SpacingDefault.HasFlag(SpacePlacement.IgnoreAroundVariableDeclaration),
new EditorConfigValueSerializer<bool>(
s => DetermineIfIgnoreSpacesAroundVariableDeclarationIsSet(s),
v => v ? "ignore" : "false"))

The only valid option values are `ignore` and `false`.
@xtqqczze xtqqczze requested a review from a team as a code owner November 3, 2025 17:46
@dotnet-policy-service dotnet-policy-service Bot added Community The pull request was submitted by a contributor who is not a Microsoft employee. VSCode labels Nov 3, 2025
Copy link
Copy Markdown
Member

@JoeRobich JoeRobich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xtqqczze Thanks!

@xtqqczze
Copy link
Copy Markdown
Contributor Author

xtqqczze commented Nov 3, 2025

It should be noted that the invalid do_not_ignore option is widely used:

https://github.com/search?q=org%3Adotnet+%22csharp_space_around_declaration_statements+%3D+do_not_ignore%22+path%3A.editorconfig&type=code

It is also present in a test:

[Theory,
InlineData("do_not_ignore"),
InlineData(", "),
InlineData(" ignor ")]
public void TestDetermineIfIgnoreSpacesAroundVariableDeclarationIsSetFalse(string value)
=> Assert.False(CSharpFormattingOptions2.DetermineIfIgnoreSpacesAroundVariableDeclarationIsSet(value),
$"Expected option {value} to be un-set");
}

@xtqqczze
Copy link
Copy Markdown
Contributor Author

xtqqczze commented Mar 1, 2026

@agocke can you merge?

@JoeRobich JoeRobich merged commit 6bdca1d into dotnet:main Mar 1, 2026
26 checks passed
@dotnet-policy-service dotnet-policy-service Bot added this to the Next milestone Mar 1, 2026
@xtqqczze xtqqczze deleted the csharp_space_around_declaration_statements branch March 1, 2026 16:00
@xtqqczze
Copy link
Copy Markdown
Contributor Author

xtqqczze commented Mar 1, 2026

Opened dotnet/performance#5132

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area-IDE Community The pull request was submitted by a contributor who is not a Microsoft employee. VSCode

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants