Using Task<Response<T>> when T is a string does not work.
Description
Using Task<Response<T>> when T is a string does not work.
To Reproduce
public interface ITest
{
Task<string> CallGoogleAsync(CancellationToken token); // works
Task<Response<string>> CallGoogleAsync(CancellationToken token); // throws exception
}
The reason is probably that that the T in the second example is always deserialized as JSON, which fails if the string is just a string like "abc".
Version Info
- RestEase version: latest
- Target framework version: all
Fair point. I guess the same also applies to Response<Stream> (and also I suppose Task<HttpResponseMessage>, although I'm not sure there's much point in that).
I'm somewhat minded to just let the ResponseDeserializer handle bare strings. We can have a property on the deserializer to say whether it handles raw strings or not to avoid backwards compat issues, although I suppose there's still a problem where someone might have written a deserialize specifically for Response<T>, which intentionally handles raw strings.
Ah no, Response<Stream> makes no sense, as it ends up being read as a string anyway.