Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why doesn't the "Namespace Provider" property get saved within a project file for a given subdirectory?

Sub directories within VS2008 projects are mainly used to physically represent on disk the namespace structure for the project. Each folder has a Boolean property called “Namespace Provider”, which when set to True causes ReSharper to validate that the physical location of a given class corresponds to the logical namespace location.

Occasionally I don’t want a folder to be used as a Namespace Provider, so I set this property to False, and ReSharper doesn’t perform the check.

Problem

This setting doesn’t get saved in the project file, and therefore reverts to the default value of True next time I open the solution. It’s not that big a deal but ReSharper does give you lots of warnings about incorrect namespaces.

Why doesn’t the property value get saved?

Versions...

ReSharper 4.0 with VS2008 SP1

like image 333
Andy McCluggage Avatar asked Apr 03 '09 10:04

Andy McCluggage


People also ask

How do I automatically add a namespace in Visual Studio?

If you are adding a new class in your code then you may need to add the correspondence namespaces. To do it, you may either manually type the Using Namespace or you just right click on the class name and select Resolve > Namespace. But using “Ctrl+.” you can automatically add the namespace in your code.

How do you change the namespace of a project in Visual Studio?

You can change the default namespace: -> Project -> XXX Properties... Instead of Find/Replace, you can also right click the namespace in code and Refactor->Rename.


3 Answers

For me this setting is saved in a .csproj.resharper file. We have had problems because some developers add an ignore pattern on this file, and don't check it in.

like image 57
Robert Patterson Avatar answered Oct 11 '22 11:10

Robert Patterson


@olivehour

This is a project-level setting that is saved in ProjectName.csproj.DotSettings file. Consider checking all project-level .DotSettings files to source control to persist this setting within your team.

like image 24
Jura Gorohovsky Avatar answered Oct 11 '22 10:10

Jura Gorohovsky


Quick answer: Before switching branches, close the solution you are switching. This prevents VS from prompting you to "reload" the solution because it has changed. Visual Studio will remove ReSharper's custom settings in the .suo file when it reloads it.

Long answer: I have found that to persist the "Namespace Provider" False setting (True setting always persists because it is the default state) is to make sure that before I switch branches (via ToirtoiseSVN), I remember to close Visual Studio or the solution.

The state is cleared any time you choose the option to "Reload" Visual Studio after Visual Studio prompts you with the message: "The project 'project.name.here' has been modified outside the environment. Press Reload to load the updated project from disk. Press ignore to ignore the external changes."

I assume that this behavior occurs because Visual Studio strips out all unknown values from the .suo file when it reloads it. This is where this ReSharper setting (Namespace Provider) is persisted.

like image 3
CodeDreamer68 Avatar answered Oct 11 '22 12:10

CodeDreamer68