csharpextensions
csharpextensions copied to clipboard
[Enhancement Request] Ability to Set Default Namespace
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.
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.
Yes, that's perfect. Thank you.
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:
- only tested on linux (!!)
- only works with the 'new' csproj
- borrows some classes from https://github.com/azz/vscode-csproj ((MIT)licence from said files is included)
Why is this closed? I don't see this working.
Would also appreciate this as well.
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.