DotNetAnalyzers / StyleCopAnalyzers

An implementation of StyleCop rules using the .NET Compiler Platform
MIT License
2.64k stars 507 forks source link

Using static directives should be placed at the correct location #3502

Open viceice opened 2 years ago

viceice commented 2 years ago

global imports need to be before normal imports.

global using NExpect;
global using NSubstitute;
global using NUnit.Framework;
#pragma warning disable SA1216 // Using static directives should be placed at the correct location
global using static NExpect.Expectations;
#pragma warning restore SA1216 // Using static directives should be placed at the correct location

using System;
using System.IO;
sharwell commented 2 years ago

This is closely related to #3404, particularly in regard to https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3404#issuecomment-969215968

viceice commented 2 years ago

how do I let them autogenerated from sdk?

sharwell commented 2 years ago

I'm not sure. There is a project item for them which can be added to an <ItemGroup>, but I don't use this feature so I'm not sure what the specific item is.

viceice commented 2 years ago

https://endjin.com/blog/2021/09/dotnet-csharp-10-implicit-global-using-directives https://docs.microsoft.com/en-us/dotnet/core/project-sdk/overview#implicit-using-directives

viceice commented 2 years ago

Will refactor to use implicit using 😏

https://docs.microsoft.com/en-us/dotnet/core/project-sdk/msbuild-props#using