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#] csharp and csharp-dotnet2 needs new codegen #12366

Open
Fildrance opened this issue Mar 27, 2024 · 3 comments
Open

[c#] csharp and csharp-dotnet2 needs new codegen #12366

Fildrance opened this issue Mar 27, 2024 · 3 comments

Comments

@Fildrance
Copy link

Description

'csharp' and 'csharp-dotnet2' codegens are obsolete to say the least. While i do like very much what other parts of swagger-codegen-cli generate (as its default conventions and infrastructure seems very robust) generators needs updates / replacement to keep up with trending http-clients and language features.

  • Usage of M$-provided HttpClient is a safe pick for client implementation, no forced dependencies and optimal performance for pretty much most of stable .NET Core versions
  • System.Text.Json as serializer works pretty much fine on most cases when api works in a way that swagger can describe it.
  • usage of mono for building is not overly useful as dotnet is crossplatform without usage of mono right now
Swagger-codegen version

looking at 3.0.54

Suggest a fix/enhancement

Making some kind of clone for csharp-dotnet2 and refining code that generates clients and additional files would be nice.

@Fildrance
Copy link
Author

I can do it but i'd like to know

  1. How long such 'non-essential' feature will be waiting for PR to be merged? I know by amount of issues about csharp lang on repo that this is not really most demanded by users, or at least it looks so by a first glance.
  2. How should new generator be called? having csharp-dotnet2 that is tied to mono is aready huge pain. Calling it csharp-dotnet3 will be not even fun. Main target is create something compatible with netstandard2.0 but with options that will support c# 10 language features. Changing whole csharp-dotnet2 doesnt feel right as there wont be any backwards compatibility, and some people with ancient projects can be sad about it.

@widgetcollector
Copy link

OpenAPI Generator CLI (basically the successor to Swagger from my understanding) supports generating .Net Core to .Net 6/7/8 but at least for the APIs I'm generating SDK's for the output is mangled as parameters are merged into one without commas inserted in the method signatures, among numerous other issues. There is a huge .Net / C# audience but most are avoiding Swagger and OpenAPI for more recent .Net versions because the tooling is sooooo immature it is seemingly not worth the battle short of joining the dev team and building it right. My easiest path is generating to classic .Net libraries then porting to nestandard2.0 for the SDKs I require but it is tedious and heavy friction for auomating in a pipeline.

Any recommendations for other generators fully and properly supporting .Net 6/7/8 targets?

@Fildrance
Copy link
Author

Fildrance commented May 22, 2024

OpenAPI Generator CLI (basically the successor to Swagger from my understanding) supports generating .Net Core to .Net 6/7/8 but at least for the APIs I'm generating SDK's for the output is mangled as parameters are merged into one without commas inserted in the method signatures, among numerous other issues. There is a huge .Net / C# audience but most are avoiding Swagger and OpenAPI for more recent .Net versions because the tooling is sooooo immature it is seemingly not worth the battle short of joining the dev team and building it right. My easiest path is generating to classic .Net libraries then porting to nestandard2.0 for the SDKs I require but it is tedious and heavy friction for auomating in a pipeline.

Any recommendations for other generators fully and properly supporting .Net 6/7/8 targets?

NSwagStudio but sometimes it does its job really poorly. And problem is based inside property name decision logic. I made https://github.com/Fildrance/swagger-codegen-generators/blob/feature/issue-%2312366/src/main/java/io/swagger/codegen/v3/generators/dotnet/CsharpDotnetCoreClientCodegen.java and it works, but there are tests to be more work is required : D
https://github.com/Fildrance/keycloak-dotnet-client/tree/main/src/Keycloak.Client is generated by it.
I am thinking about PR-ing my generator at some point, but its not guaranteed.

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

2 participants