dotnet / vscode-csharp

Official C# support for Visual Studio Code
MIT License
2.86k stars 671 forks source link

incorrect constructor generated for nested class #3828

Open voltcode opened 4 years ago

voltcode commented 4 years ago

Please paste the output from your cli## Issue Description ##

Steps to Reproduce

  1. create new class with nested class:

    public class Test {
    public class Nested {
    
    }
    }
  2. type ctor inside the nested class

    public class Test {
    public class Nested {
        ctor
    }
    }
  3. Allow vs code to hint at constructor generator, run it

Expected Behavior

generated code should be

public class Test {
    public class Nested {
        public  Nested(Parameters) 
       {
       }
    }
}

Actual Behavior

public class Test {
    public class Nested {
        public  test(Parameters) 
       {

       }
    }
}

Environment information

VSCode version: 1.45.1 C# Extension: 1.22.0

Dotnet Information .NET Core SDK (reflecting any global.json): Version: 3.1.300 Commit: b2475c1295 Runtime Environment: OS Name: Windows OS Version: 10.0.18363 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\3.1.300\ Host (useful for support): Version: 3.1.4 Commit: 0c2e69caa6 .NET Core SDKs installed: 2.1.503 [C:\Program Files\dotnet\sdk] 2.1.511 [C:\Program Files\dotnet\sdk] 2.2.108 [C:\Program Files\dotnet\sdk] 3.1.300 [C:\Program Files\dotnet\sdk] .NET Core runtimes installed: Microsoft.AspNetCore.All 2.1.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.1.15 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.2.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.App 2.1.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.1.15 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.2.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.1.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 2.1.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.15 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.2.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 3.1.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 3.1.4 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] To install additional .NET Core runtimes or SDKs: https://aka.ms/dotnet-download
Visual Studio Code Extensions |Extension|Author|Version| |---|---|---| |csharp|ms-dotnettools|1.22.0| |python|ms-python|2020.5.80290| |vscode-nxunit-test-adapter|wghats|0.1.3| |vscode-solution-explorer|fernandoescolar|0.3.10| |vscode-test-explorer|hbenl|2.19.1|;

pboard

ctolkien commented 12 months ago

Issue description isn't quite correct, the ctor snippet generates a constructor based on the name of the file you're in, it's not to do with the class being nested:

image

https://github.com/dotnet/vscode-csharp/blob/main/snippets/csharp.json#L471