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

[BUG] File Nesting Is not working for Class Library projects #1482

Open
PeterMarinov opened this issue Sep 19, 2024 · 1 comment
Open

[BUG] File Nesting Is not working for Class Library projects #1482

PeterMarinov opened this issue Sep 19, 2024 · 1 comment
Assignees
Labels
area-solution Solution explorer enhancement New feature or request

Comments

@PeterMarinov
Copy link

Describe the Issue

The Solution Explorer shipped with the C# DevKit already supports nesting, but it only works for Web projects. The feature is great as it allows developers to follow the single responsibility principle creating one c# class in a separate file, while still be able to group separate files/classes based of their high cohesion using a naming convention, e.g. all these classes have the same "Capture" group in the file name, e.g.

  • GetForms.cs
  • GetForms.Request.cs
  • GetForms.Response.cs
  • GetForms.Validator.cs

This feature already works for Web projects, but not for Class libraries.

If the csproj file has this declaration <Project Sdk="Microsoft.NET.Sdk.Web"> the nesting works. If the project is class library <Project Sdk="Microsoft.NET.Sdk"> , the nesting is not working. Looks like a quick fix, assuming you only need to enable same behavior for class libraries. That seems like a quick win

Suggestion for enhancement after the bug fix

VS Code's Explorer already supports file nesting as a setting called explorer.fileNesting. Documentation here. It's logical that a developer who uses VS Code and has this setting for the VS Code explorer will expect the same thing to work for C# DevKit's Solution Explorer. Suggestion is to provide a setting, which can read from these setting and apply them, but a quick win will be only to also enable file nesting for class libraries (it works in Web projects as of now).

Example of the setting below:

"explorer.fileNesting.enabled": true,
    "explorer.fileNesting.patterns": {
        "*.cs": "${capture}.*.cs",
        "I*.cs": "$(capture).cs"
    },

Steps To Reproduce

  1. Open *.sln file in VS Code using C# Dev Kit
  2. Create new Class Library project.
  3. Within the new Class library project, create a folder and create new Class and name it "Example"
  4. Create new Class in the same folder as step 3 and name it "Example.Request"
  5. Within the file editor, delete the Example part of the class name, so it's only named "Request". The file name will remain called "Example.Request.cs"
  6. Check how the file is displayed in Solution explorer

Expected Behavior

Solution Explorer should Nest the
image

Environment Information

  • OS: MacOS Sonoma 14.6.1 (23G93)
  • VS Code Version: 1.93.1 (Universal)
  • C# Dev Kit Version: v1.10.18
@PeterMarinov PeterMarinov added the bug Something isn't working label Sep 19, 2024
@AbhitejJohn AbhitejJohn added the area-solution Solution explorer label Sep 19, 2024
@Michael-Eng Michael-Eng added enhancement New feature or request and removed bug Something isn't working labels Oct 8, 2024
@Michael-Eng
Copy link
Member

As you have mentioned indirectly, this is not supported today.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-solution Solution explorer enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants