DotNetAnalyzers / StyleCopAnalyzers

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

SA1200 Using directive should appear within a namespace declaration #3825

Closed daleao closed 5 months ago

daleao commented 5 months ago

Conflicts with CS8914 Error: A global using directive cannot be used in a namespace declaration.

bjornhellander commented 5 months ago

Could you provide an example so your situation is clear?

daleao commented 5 months ago

This causes SA1200:

global using static Foo.Bar;

namespace Foo;

using System;

class Bar {}

This causes CS8914:

namespace Foo;

global using static Foo.Bar;
using System;

class Bar {}

SA1200 is incorrectly applying to global using statements, which cannot be placed within namespace declarations.

bjornhellander commented 5 months ago

Duplicate of #3404 (still open)

sharwell commented 5 months ago

Duplicate of #3404