I am creating a NUnit test project and in the creation of that, MS Visual Studio has created a file called Usings.cs with the line
global using NUnit.Framework;
which tells the project to include the NUnit framework in every file.
I have been running StyleCopAnalyzers over this test project, and it keeps reporting
SA1200: Using directive should appear within a namespace declaration.
However, when I put the global using
within a namespace declaration
namespace TestProject
{
global using NUnit.Framework;
}
I get the error
CS8914: A global using directive cannot be used in a namespace declaration.
What is the correct approach? Should I use the Usings.cs file with global usings
?