Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C# item templates don't have namespace configuration #6719

Closed
smitpatel opened this issue Jun 12, 2023 · 3 comments
Closed

C# item templates don't have namespace configuration #6719

smitpatel opened this issue Jun 12, 2023 · 3 comments

Comments

@smitpatel
Copy link
Contributor

Is your feature request related to a problem? Please describe.

The new C# item templates (class, enum etc) doesn't have namespace configuration. It picks up root namespace always at present. This is somewhat unexpected when creating a new class inside a folder as expected namespace would include folder name as sub-namespace.

Describe the solution you'd like.

If templating engine can gather relative path from project file to folder and convert it to namespace to be used for the class that would be most ideal. We already evaluate the project file so computing this should be best experience for user rather than typing long namespace which is error-prone.

If not, then --namespace switch on the template like Razor Page template would allow users to specify namespace.

Additional context

No response

@HBA114
Copy link

HBA114 commented Jun 13, 2023

This is not a problem but it is different from Visual Studio's default namespace declaration on created C# files

Folder Structure Of Sample Project:

ConsoleApp1.sln
ConsoleApp1/
    ConsoleApp1.csproj
    Entities/
        Entity.cs
    Program.cs

In this case i am using a namespace in Entity.cs file like following:

namespace ConsoleApp1.Entities;

Creating that class in Entities folder with Visual Studio uses this namespace too. But creating that class in Entities folder with C# Dev Kit Extension is using a namespace that only contains project base. In my sample project:

namespace ConsoleApp1;
public class Entity
{

}

And whenever i add a class with C# Dev Kit extension, i am renaming namespace that created with extension.
This is not a problem but in my opinion, default namespace should include folder name like in Visual Studio.

@YuliiaKovalova
Copy link
Member

Hi @smitpatel,

It looks like we have a ticket for tracking this issue: #6010.
If it represents your issue please upvote it and feel free to add details in it.

@smitpatel
Copy link
Contributor Author

Closing as duplicate.

@smitpatel smitpatel closed this as not planned Won't fix, can't repro, duplicate, stale Jun 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants