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

CSharp client generator - Implementing Async Pattern on PrepareRequest and ProcessResponse #3248

Merged
merged 4 commits into from
Jan 15, 2021

Conversation

francozuca
Copy link
Contributor

Issue #3247

@francozuca francozuca changed the title Added the ability to generate PrepareRequest and ProcessResponse call… CSharp client generator - Implementing Async Pattern on PrepareRequest and ProcessResponse Jan 13, 2021
@RicoSuter
Copy link
Owner

We would also need to expose the new config wia CLI command and in the UI (XAML).. can do that tomorrow or you update the PR for that as well. But looks good to me. Thanks.

@francozuca
Copy link
Contributor Author

We would also need to expose the new config wia CLI command and in the UI (XAML).. can do that tomorrow or you update the PR for that as well. But looks good to me. Thanks.

I just added GeneratePrepareRequestAndProcessResponseAsAsyncMethods to CLI and UI. Please let me know if you want me to rephrase the option description/label. Thanks.

cmd
ui

@RicoSuter
Copy link
Owner

Lgtm, thank you very much.

@jclijmans
Copy link

There seems to be an error in this PR.
In /src/NSwag.CodeGeneration.CSharp/Templates/Client.Class.liquid when GeneratePrepareRequestAndProcessResponseAsAsyncMethods == true, no partial method definition for PrepareRequestAsync is generated
This results in a generated class that doesn't compile because the PrepareRequestAsync is used later on.

@francozuca
Copy link
Contributor Author

There seems to be an error in this PR.
In /src/NSwag.CodeGeneration.CSharp/Templates/Client.Class.liquid when GeneratePrepareRequestAndProcessResponseAsAsyncMethods == true, no partial method definition for PrepareRequestAsync is generated
This results in a generated class that doesn't compile because the PrepareRequestAsync is used later on.

Hi @jclijmans!
You're right: if GeneratePrepareRequestAndProcessResponseAsAsyncMethods == true, no partial method definition for PrepareRequestAsync is generated.

That is because partial methods cannot be marked as async. So what you should do is to create a partial definition of your client class and then implement those methods in that particular. You can take a look to #3247 where I tried to explain this properly.

Thanks!

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

Successfully merging this pull request may close these issues.

3 participants