Generating synchronous methods and generating response classes generates invalid code
See original GitHub issueIt seems that when selecting to generate sync methods along with response classes (/WrapResponses:true /GenerateSyncMethods:true) then the signature of the sync methods are wrong. The code simply does not build.
Example of some generated code (note that apart from the Task
the async and sync method differ in wrapping with SwaggerResponse
). Note that since the sync method simply uses the async method this will not build:
/// <param name="tags">tags to filter by</param>
/// <param name="limit">maximum number of results to return</param>
/// <returns>pet response</returns>
/// <exception cref="SwaggerException">A server side error occurred.</exception>
public System.Collections.ObjectModel.ObservableCollection<Pet> FindPets(System.Collections.Generic.IEnumerable<string> tags, int? limit)
{
return System.Threading.Tasks.Task.Run(async () => await FindPetsAsync(tags, limit, System.Threading.CancellationToken.None)).GetAwaiter().GetResult();
}
/// <param name="tags">tags to filter by</param>
/// <param name="limit">maximum number of results to return</param>
/// <returns>pet response</returns>
/// <exception cref="SwaggerException">A server side error occurred.</exception>
/// <param name="cancellationToken">A cancellation token that can be used by other objects or threads to receive notice of cancellation.</param>
public async System.Threading.Tasks.Task<SwaggerResponse<System.Collections.ObjectModel.ObservableCollection<Pet>>> FindPetsAsync(System.Collections.Generic.IEnumerable<string> tags, int? limit, System.Threading.CancellationToken cancellationToken)
{
Example files: ErrorExample.zip
Issue Analytics
- State:
- Created 6 years ago
- Comments:7 (2 by maintainers)
Top Results From Across the Web
Not implemented/supported/invalid operation async method
When calling a method that returns a Task , some parts of it are executed synchronously (even if the implementing method is defined...
Read more >Two Ways to Do Async/Await in ASP.NET Wrong (and How ...
The solution for this can be reduced to: don't use async wrappers for synchronous methods! Just call them synchronously; that's how they were ......
Read more >Generating HTTP API clients using Visual Studio ...
Visual Studio Connected Services can generate .NET client code directly from an OpenAPI spec. Learn how to build great HTTP clients quickly!
Read more >Retrofit — Synchronous and Asynchronous Requests
The following code snippets illustrate the synchronous request execution with Retrofit and assume that you're familiar with the ServiceGenerator ...
Read more >How to get an access token with Authorization Code Grant
This topic demonstrates how to generate an access token manually using Authorization Code Grant authentication or with a refresh token. In the Authorization ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Should be fixed in the next version 😃
Hello @RicoSuter . The bug still continue even with last version of NswagStudio(12.0.18.0) , I was wondering if you’d had a chance to replicate it. I noticed this bug still as Opened. Do I need to log a new bug?