Disabling Namespaces on folders in Visual Studio

posted on 26 Apr 2013

I just discovered this little trick I found in Visual Studio to turn off namespacing on a folder. Not sure how after 8 years I only just found this.

The Problem

Lets assume we're working with Entity Framework... (shiver)... We create a Data Model, add all our Entities and away we go.

Then we want to extend one of the Entities, maybe to add some methods and such, so we need to create some partial classes. So far we have:

We create a new Member.cs class in the Partials folder;

namespace SampleNamespacing.Models.Partials
{
    public partial class Member
    {
    }
}

Then we delete the Partials to put it in the same namespace as the Entities defined in the Data Model

namespace SampleNamespacing.Models
{
    public partial class Member
    {
    }
}

But now we have a ReSharper warning

Now we don't have a nice green file :(

The Solution!

This is so simple ><

Right click the folder and go to Properties:

BAM! Right there, Namespace Provider! Set that thing to False and we get:

No more warnings!

Wheres this feature come from?

Turns out this is a ReSharper setting! This setting is stored in the *project*.csproj.DotSettings file. So if you're using team settings then this setting would be picked up by everyone on the team.

comments powered by Disqus