Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Format document on save" incompatible with SA1000 #260

Open
ruffin-- opened this issue Feb 17, 2022 · 1 comment
Open

"Format document on save" incompatible with SA1000 #260

ruffin-- opened this issue Feb 17, 2022 · 1 comment

Comments

@ruffin--
Copy link

StyleCop's SA1000 wants you to have a space between new and () when you're using Type Inference.

We have some devs using PPT and VS 2019 on a .NET Core project that has SA1000 active. We haven't found a setting to turn off the new () to new() change when "Format document on save" is selected.

Expected after format

public static void TestMe()
{
    List<string> a = new ()     // Format document takes this back out!
    {
        "spam",
        "ham",
        "Sam"
    };

    System.Diagnostics.Debug.WriteLine(a[0]);
}

Actual after format

public static void TestMe()
{
    List<string> a = new()     // <<<< StyleCop SA1000 complains here
    {
        "spam",
        "ham",
        "Sam"
    };

    System.Diagnostics.Debug.WriteLine(a[0]);
}

A+ with garlands

In a perfect world, if you have SA1000 enabled, "format document on save" would leave the space after new and before ().


(Yes, I'm suspicious this is a "We're just calling VS' format from Edit >>> Advanced >>> Format Document" issue.)

@ruffin-- ruffin-- changed the title Need a "Format document on save" setting that matches SA1000 "Format document on save" incompatible with SA1000 Feb 17, 2022
@olegtk
Copy link
Member

olegtk commented Mar 8, 2022

Please file it on https://github.com/dotnet/roslyn/issues

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

No branches or pull requests

2 participants