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

systemUsingDirectivesFirst false by default in Visual Studio Preview #3896

Closed
LWehmschulteAtRosenxt opened this issue Oct 18, 2024 · 6 comments
Labels

Comments

@LWehmschulteAtRosenxt
Copy link

I've updated my Visual Studio 2022 to Preview Version 17.12.0 Preview 3.0 and since then the systemUsingDirectivesFirst configuration seems to behave as if the default value was false, which is different to what is documented in the json schema

The following code gives me the following Warning in Visual Studio:
Using directives should be ordered alphabetically by the namespaces
image

using System.Text.Json;
using ANameSpace;

var aClass = new AClass();

Console.WriteLine(JsonSerializer.Serialize(aClass));

namespace ANameSpace
{
    class AClass();
}

stylecop.json:

{
  "$schema": "https://raw.githubusercontent.com/DotNetAnalyzers/StyleCopAnalyzers/master/StyleCop.Analyzers/StyleCop.Analyzers/Settings/stylecop.schema.json",
  "settings": { }
}

If I now manually set the systemUsingDirectivesFirst to true in the stylecop.json, the warning will disappear:
image

{
  "$schema": "https://raw.githubusercontent.com/DotNetAnalyzers/StyleCopAnalyzers/master/StyleCop.Analyzers/StyleCop.Analyzers/Settings/stylecop.schema.json",
  "settings": {
    "orderingRules": {
      "systemUsingDirectivesFirst": true
    }
  }
}
@bjornhellander
Copy link
Contributor

Thanks! I see it too.

If I don't add the setting to style.json, I notice this as well:

  • If I select Build Only in the Error List window after building, I actually see the expected behavior (based on which order the using directives are placed in).
  • If I look at the Output window after building, I also see the expected behavior.

So it only seems to misbehave when running as part of the intellisense.

Do you see the same behaviour, @LWehmschulteAtRosenxt?

@LWehmschulteAtRosenxt
Copy link
Author

@bjornhellander Yup, I have the same behavior

@bjornhellander
Copy link
Contributor

I just upgraded to VS preview 5 and it seems to work as expected again. Could you close this if you agree?

@LWehmschulteAtRosenxt
Copy link
Author

Yes. Same here. I'll close this. Thanks for your support

@sharwell
Copy link
Member

This was fixed by dotnet/roslyn#75317

@LWehmschulteAtRosenxt
Copy link
Author

This was fixed by dotnet/roslyn#75317

Thanks for your work 😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants