Using directives, a namespace, and an assembly reference - everything mixed in with StyleCop!

I like to follow the StyleCop formatting rules to make the code nice and clear, but I recently had a problem with one of its warnings:

All directives used must be placed inside the namespace.

My problem is that I use directives, an assembly reference (for mocking file deletion), and a namespace to juggle in one of my test classes:

using System;
using System.IO;
using Microsoft.Moles.Framework;
using Microsoft.VisualStudio.TestTools.UnitTesting;
[assembly: MoledType(typeof(System.IO.File))]

namespace MyNamespace
{
//Some Code
}

The above tests allow you to work fine, but StyleCop complains that using directives are not inside the namespace.

Entering values โ€‹โ€‹inside the namespace gives an error that is not recognized by "MoledType".

'assembly' . - . .

, , , - , , StyleCop!

- , ? StyleCop ?

+5
3

!

"MoledType" , :

[assembly: Microsoft.Moles.Framework.MoledType(typeof(System.IO.File))]
namespace MyNamespace
{
using System;
using System.IO;
using Microsoft.Moles.Framework;
using Microsoft.VisualStudio.TestTools.UnitTesting;

// Some Code...
}

, - !

+10

AssemblyInfo.cs. , .

+5

, AssemblyInfo.cs (Project โ†’ Properties).

! , AssemblyInfo.cs. , :

[assembly: InternalsVisibleTo("ClassA")]

AssemblyInfo.cs, ClassA. .

+1

All Articles