How do I prevent the name of the Solution Folder in a VS project from being appended to the namespace generated for new items added to the solution folder?
如何防止将VS项目中的解决方案文件夹的名称附加到为添加到解决方案文件夹的新项目生成的命名空间?
Example: C# project in a VS solution Default Namespace set in C# project properties: "BigClient.Domain"
示例:VS解决方案中的C#项目在C#项目属性中设置的默认命名空间:“BigClient.Domain”
If you create a solution folder in this project called "MySpecialStuff" and then add a new class to the 'MySpecialStuff" solution folder, VS creates the new .cs file with a "BigClient.Domain.MySpecialStuff" namespace. I want to find a way to allow the namespace of the newly-added class to retain just the 'project-level' namespace of "BigClient.Domain" instead of VS appending the "MySpecialStuff" solution-folder-name to the namespace.
如果在此项目中创建一个名为“MySpecialStuff”的解决方案文件夹,然后将新类添加到“MySpecialStuff”解决方案文件夹中,VS将使用“BigClient.Domain.MySpecialStuff”命名空间创建新的.cs文件。我想找到一个允许新添加的类的命名空间仅保留“BigClient.Domain”的“项目级”命名空间而不是VS将“MySpecialStuff”解决方案文件夹名称附加到命名空间的方法。
I seem to recall reading a blog post by someone that this was possible (either via options/settings in VS or a registry setting) but I cannot recall where or how now that I want it :)
我似乎记得有人认为这是可能的(通过VS中的选项/设置或注册表设置)阅读博客文章但我不记得现在我想要它在哪里或如何:)
My platform is VS 2008 if answer = different for different VS versions.
我的平台是VS 2008,如果对于不同的VS版本,答案=不同。
2 个解决方案
#1
Make a new class template or change Visual Studio's class template. See the MSDN documentation for how to this. In the template file, you quickly see the line that inserts the 'safe' namespace name.
创建一个新的类模板或更改Visual Studio的类模板。有关如何操作,请参阅MSDN文档。在模板文件中,您可以快速查看插入“安全”命名空间名称的行。
#2
If you have ReSharper installed, on the settings for the directory (F4), set Namespace Provider to false.
如果安装了ReSharper,则在目录(F4)的设置上,将Namespace Provider设置为false。
#1
Make a new class template or change Visual Studio's class template. See the MSDN documentation for how to this. In the template file, you quickly see the line that inserts the 'safe' namespace name.
创建一个新的类模板或更改Visual Studio的类模板。有关如何操作,请参阅MSDN文档。在模板文件中,您可以快速查看插入“安全”命名空间名称的行。
#2
If you have ReSharper installed, on the settings for the directory (F4), set Namespace Provider to false.
如果安装了ReSharper,则在目录(F4)的设置上,将Namespace Provider设置为false。