Skip to content

[feat][csharp][unity] Add unity 2019 support and update samples #21036

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

Conversation

tobocop2
Copy link
Contributor

@tobocop2 tobocop2 commented Apr 5, 2025

Summary

This PR adds support Unity 2019+ with some small updates to the api client and exception classes. The code here is also introducing a new awaiter extension in the Unity WebRequest library. This allows the generated client code to use concise and idiomatic await asyncOp syntax even in older Unity versions like 2019 LTS, where UnityWebRequestAsyncOperation does not natively support awaiting.

Motivation

I could not generate a client using Unity 2019 and the changes here have enabled me to generate openapi clients for the version of Unity that I am stuck with. I figured that this would also be very helpful to anyone else in a similar position.

Changes

  • Added a new supporting file: UnityWebRequestAwaiterExtension.mustache
  • Added preprocessor code to make the exception code and api client code compatible with older versions
  • Registered the supporting file in the UnityWebRequest block of CSharpClientCodegen.java
  • Ensured no runtime changes for Unity 2020+ (no regressions)
  • Included a comment in the generated extension explaining its rationale and version scope

Validation

  • Built openapi-generator-cli from source with changes
  • Regenerated C# client using -l csharp --library unityWebRequest
  • Verified the generated client builds and runs under Unity 2019.4.40f1
  • Confirmed await request.SendWebRequest(); compiles and functions as expected

PR checklist

@tobocop2 tobocop2 changed the title Add unity 2019 and update samples Add unity 2019 support and update samples Apr 5, 2025
@tobocop2 tobocop2 force-pushed the add-unity2019-support-to-unitywebrequest branch from 86eaf97 to 9f4a2b1 Compare April 5, 2025 02:36
@tobocop2 tobocop2 changed the title Add unity 2019 support and update samples [unity] Add unity 2019 support and update samples Apr 5, 2025
@tobocop2 tobocop2 changed the title [unity] Add unity 2019 support and update samples [feat][unity] Add unity 2019 support and update samples Apr 5, 2025
@tobocop2 tobocop2 force-pushed the add-unity2019-support-to-unitywebrequest branch from 9f4a2b1 to 02c6088 Compare April 5, 2025 03:07
@tobocop2 tobocop2 force-pushed the add-unity2019-support-to-unitywebrequest branch from 02c6088 to 2c51662 Compare April 5, 2025 03:32
@tobocop2 tobocop2 changed the title [feat][unity] Add unity 2019 support and update samples [feat][csharp][unity] Add unity 2019 support and update samples Apr 5, 2025
@wing328 wing328 added this to the 7.13.0 milestone Apr 6, 2025
@wing328
Copy link
Member

wing328 commented Apr 6, 2025

thanks for the PR

let's give it a try

@wing328 wing328 merged commit 047ceea into OpenAPITools:master Apr 6, 2025
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants