Description
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
Running VS client generation on a basic ASP.NET web template produces compilation errors.
Expected Behavior
Generating a Swagger client via VS client generation should not cause any compilation errors.
Steps To Reproduce
- In VS, File > New Project > ASP.NET Core Web API template.
- Update the
.csproj
to include the following so aswagger.json
file is generated on build.
<OpenApiGenerateDocumentsOnBuild>true</OpenApiGenerateDocumentsOnBuild>
- Build the project.
- Right click on project > Add > Connected Services > OpenAPI > select the file generated by the build in step 3.
- Open
obj/swaggerClient.cs
to view the generated code. - Build the project again and observe the following exceptions
C:\Users\safia\source\repos\WebApplication4\WeatherForecast.cs(3,18): error CS0260: Missing partial modifier on declara
tion of type 'WeatherForecast'; another partial declaration of this type exists [C:\Users\safia\source\repos\WebApplica
tion4\WebApplication4.csproj]
C:\Users\safia\source\repos\WebApplication4\obj\swaggerClient.cs(211,38): error CS0102: The type 'WeatherForecast' alre
ady contains a definition for 'Date' [C:\Users\safia\source\repos\WebApplication4\WebApplication4.csproj]
C:\Users\safia\source\repos\WebApplication4\obj\swaggerClient.cs(214,20): error CS0102: The type 'WeatherForecast' alre
ady contains a definition for 'TemperatureC' [C:\Users\safia\source\repos\WebApplication4\WebApplication4.csproj]
C:\Users\safia\source\repos\WebApplication4\obj\swaggerClient.cs(217,20): error CS0102: The type 'WeatherForecast' alre
ady contains a definition for 'TemperatureF' [C:\Users\safia\source\repos\WebApplication4\WebApplication4.csproj]
C:\Users\safia\source\repos\WebApplication4\obj\swaggerClient.cs(220,23): error CS0102: The type 'WeatherForecast' alre
ady contains a definition for 'Summary' [C:\Users\safia\source\repos\WebApplication4\WebApplication4.csproj]
Exceptions (if any)
No response
.NET Version
7.0.100-rc.2.22419.24
Anything else?
[System.CodeDom.Compiler.GeneratedCode("NSwag", "13.0.5.0 (NJsonSchema v10.0.22.0 (Newtonsoft.Json v11.0.0.0))")]
Microsoft Visual Studio Enterprise 2022
Version 17.4.0 Preview 1.0
VisualStudio.17.Preview/17.4.0-pre.1.0+32804.182
Microsoft .NET Framework
Version 4.8.04161
Installed Version: Enterprise
Visual C++ 2022 00476-80000-00000-AA685
Microsoft Visual C++ 2022
ASP.NET and Web Tools 17.4.86.38009
ASP.NET and Web Tools
Azure App Service Tools v3.0.0 17.4.86.38009
Azure App Service Tools v3.0.0
Azure Functions and Web Jobs Tools 17.4.86.38009
Azure Functions and Web Jobs Tools
C# Tools 4.4.0-1.22403.13+ebbf56c257fb4d3128d3487ef525d92e9f94b412
C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.
Common Azure Tools 1.10
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.
Microsoft Azure Tools for Visual Studio 2.9
Support for Azure Cloud Services projects
Microsoft JVM Debugger 1.0
Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines
NuGet Package Manager 6.4.0
NuGet Package Manager in Visual Studio. For more information about NuGet, visit https://docs.nuget.org/
Project System Tools 1.0
Tools for working with C#, VisualBasic, and F# projects.
Razor (ASP.NET Core) 17.0.0.2237602+b10895cdddd2286fe448ca44dfeb6f9c2c4f6abd
Provides languages services for ASP.NET Core Razor.
SQL Server Data Tools 17.0.62207.28050
Microsoft SQL Server Data Tools
Syntax Visualizer 1.0
An extension for visualizing Roslyn SyntaxTrees.
Test Adapter for Boost.Test 1.0
Enables Visual Studio's testing tools with unit tests written for Boost.Test. The use terms and Third Party Notices are available in the extension installation directory.
Test Adapter for Google Test 1.0
Enables Visual Studio's testing tools with unit tests written for Google Test. The use terms and Third Party Notices are available in the extension installation directory.
TypeScript Tools 17.0.10727.2001
TypeScript Tools for Microsoft Visual Studio
Visual Basic Tools 4.4.0-1.22403.13+ebbf56c257fb4d3128d3487ef525d92e9f94b412
Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.
Visual F# Tools 17.4.0-beta.22376.4+0e8a2053cc2fc7d3801205a873e0afd3b6a1235e
Microsoft Visual F# Tools
Visual Studio IntelliCode 2.2
AI-assisted development for Visual Studio.