Restsharp: ExecuteAsync Does Not Fully Replace ExecuteTaskAsync

Created on 29 Jan 2020  路  6Comments  路  Source: restsharp/RestSharp

Expected Behavior

Prior to 106.10.1, following code returns a Task<IRestResponse>

Client.ExecuteTaskAsync(request);

Now that 106.10.1 has marked ExecuteTaskAsync as obsolete, following code is expected to also return Task<IRestResponse>

Client.ExecuteAsync(request);

Actual Behavior

Instead, following code produces a compilation error:

Client.ExecuteAsync(request);

Error CS0411 The type arguments for method 'IRestClient.ExecuteAsync<T>(IRestRequest, CancellationToken)' cannot be inferred from the usage. Try specifying the type arguments explicitly.

I have found that following code does compile and returns Task<IRestResponse>

Client.ExecuteAsync(request, request.Method);

Steps to Reproduce the Problem

  1. Write code as above, see compilation error.

Specifications

  • Version: 106.10.1
  • Platform: ASP.Net Core 3.1
bug

Most helpful comment

I found the issue. The ExecuteAsync non-generic overload that returns IRestRequest is not a part of the interface, but it is available on the RestClient. I already fixed it locally.

All 6 comments

Just yesterday I changed all the tests to use ExecuteAsync where ExecuteTaskAsync was previously used. There were no problems with compiling the code.

Can you provide more code?

Can confirm. There used to be an interface definition
IRestClient.ExecuteTaskAsync(IRestRequest), but in v106.10.1 this is marked as obsolete by IRestClient.ExecuteAsync.

However, there is no direct replacement for the IRestClient.ExecuteTaskAsync(IRestRequest) interface method. The closest one is IRestClient.ExecuteTaskAsync(IRestRequest, Method) as stricq mentions, where you also have to specify the HTTP Method.

This isn't a big deal, but if the method is already a part of the request, surely having an interface definition that reads it from the request makes sense? Especially since it was defined that way in the now obsoleted method 馃槂

I found the issue. The ExecuteAsync non-generic overload that returns IRestRequest is not a part of the interface, but it is available on the RestClient. I already fixed it locally.

Any estimate for the next release time?

Closing because of the latest release.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

vDeggial picture vDeggial  路  6Comments

nilesh-shah picture nilesh-shah  路  6Comments

maximuss picture maximuss  路  3Comments

abishekrsrikaanth picture abishekrsrikaanth  路  3Comments

nilsga picture nilsga  路  5Comments