swagger-codegen icon indicating copy to clipboard operation
swagger-codegen copied to clipboard

CSharp

Open sheltonc opened this issue 9 years ago • 7 comments

Description

The CSharpNet2 client does not work with dotnet core 2.0.

Swagger-codegen version

2.3.0-SNAPSHOT

Steps to reproduce

The generated code has a dependency on RestSharp.Net2 1.1.11, which in turn has a dependency on a 4.6.1 framework dependency (Newtonsoft.Json 4.5.1).

Given this, the CSharpNet2 package cannot be referenced via nuget in a dotnetcore 2.0 project.

Suggest a fix/enhancement

One possible fix would be that the generated code could instead depend upon RestSharp.NetCore 105.2.3

sheltonc avatar Oct 18 '17 05:10 sheltonc

@sheltonc instead of using csharp-dotnet2, what about using csharp to generate C# API client instead?

wing328 avatar Oct 18 '17 08:10 wing328

@wing328 I've also tried this, to the same effect.

Package 'RestSharp 105.1.0' was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework '.NETCoreApp,Version=v2.0'. This package may not be fully compatible with your project.

Are there any plans to implement a client compatible with NETCoreApp0 2.0?

sheltonc avatar Oct 18 '17 20:10 sheltonc

@sheltonc Did you try a different targetFramework (e.g. v5.0)?

	targetFramework
	    The target .NET framework version. (Default: v4.5)
	        v3.5 - .NET Framework 3.5 compatible
	        v4.5 - .NET Framework 4.5+ compatible
	        v5.0 - .NET Standard 1.3 compatible
	        uwp - Universal Windows Platform (IMPORTANT: this will be decommissioned and replaced by v5.0)

Ref: java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar config-help -l csharp

Also worth showing you the following option:

	netCoreProjectFile
	    Use the new format (.NET Core) for .NET project files (.csproj). (Default: false)

wing328 avatar Oct 19 '17 14:10 wing328

That was exactly what was needed. Thanks!

sheltonc avatar Oct 19 '17 20:10 sheltonc

@sheltonc np. let us know if you've more question.

wing328 avatar Oct 20 '17 02:10 wing328

Hi @wing328, hi @sheltonc ,

I'm also running on the same problematic. However I was not able to follow on the solution. I'm all new to the topic. Could you please describe more in detail what you did to solve this? Thanks.

munozm01 avatar Feb 20 '19 08:02 munozm01

I'm also running on the same problematic. However I was not able to follow on the solution. I'm all new to the topic. Could you please describe more in detail what you did to solve this? Thanks.

alexaurus avatar Sep 07 '22 19:09 alexaurus