belav / csharpier

CSharpier is an opinionated code formatter for c#.
https://csharpier.com
MIT License
1.32k stars 88 forks source link

Additional Linebreak before `using static` #1279

Open samtrion opened 3 months ago

samtrion commented 3 months ago

Input:

namespace SomeLibrary;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Xml.Linq;
using static System.StringComparison;
public sealed class SomeClass {}

Output:

namespace SomeLibrary;

using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Xml.Linq;
using static System.StringComparison;

public sealed class SomeClass { }

Expected behavior:

namespace SomeLibrary;

using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Xml.Linq;

using static System.StringComparison;

public sealed class SomeClass { }
belav commented 3 months ago

CSharpier currently removes all blank lines between usings. See here

I agree that it would be nice to either automatically insert some lines, or retain existing lines. It may be that automatically inserting lines is quite a bit easier than retaining existing lines.

samtrion commented 3 months ago

Inserting is certainly the simpler option. But basically, this would be something that you would also want to control via the .csharpierrc configuration.

belav commented 3 months ago

this would be something that you would also want to control via the .csharpierrc configuration.

No.

CSharpier provides a few basic options that affect formatting and has no plans to add more. It follows the Option Philosophy of prettier.