csharpextensions icon indicating copy to clipboard operation
csharpextensions copied to clipboard

[Enhancement Request] Ability to Set Default Namespace

Open dageniusal opened this issue 8 years ago • 6 comments

I would like to request the ability to set the default namespace for a folder, which might differ from the folder name.

Ideally, the plugin would read the value from project.json (maybe the "defaultNamespace" key in "tooling") and if not available, then default to the folder name.

dageniusal avatar Dec 05 '16 18:12 dageniusal

In the new/old csproj format, you can specify a root namespace using the <RootNamespace> property. I guess the request would be to read the value from there if it exists otherwise use the folder path.

partisanyc avatar Apr 19 '17 16:04 partisanyc

Yes, that's perfect. Thank you.

alex-bello avatar Apr 19 '17 16:04 alex-bello

i've made this (mainly) for my own convenience; https://github.com/dogguts/csharpextensions/tree/RootNamespace, i could send a pull request. What it does:

  • if "csharpextensions.useCsprojRootNamespace" is "true"
    • searches the project's csproj
    • takes the /Project/PropertyGroup/RootNamespace/ text
    • uses that as namespace *if 'RootNamespace' is not found, namespace will be "undefined"
  • if "csharpextensions.useCsprojRootNamespace" is "false"
    • same logic as in 1.3.0

Remarks:

dogguts avatar Jun 08 '17 12:06 dogguts

Why is this closed? I don't see this working.

ssg avatar Mar 14 '18 00:03 ssg

Would also appreciate this as well.

ot-alex-vance avatar Apr 09 '18 18:04 ot-alex-vance

as I understand you need to set csharpextensions.useCsprojRootNamespace to true in settings and set a root namespace in the csproj file in order to get this working, fyi.

ssg avatar Apr 09 '18 18:04 ssg