My current thought is to change the interface signature and make Download work differently. Right now, it returns Task<Stream?>, which prevents the user to inspect the response for errors. It crashes if the call wasn't successful.
So, the idea is to make ExecuteStreamAsync, which will return Task<RestStreamResponse>. The response will be like RestResponse but instead of Content it will have Stream?. Naturally, it requires to be IDisposable.
The first step there was to create a source generator to create instance of RestResponseBase child class, as copying those properties manually is error prone (adding a new prop requires many changes). That part is done, so now this thing should be relatively easy.
Originally posted by @alexeyzimarev in #2072 (comment)
My current thought is to change the interface signature and make Download work differently. Right now, it returns
Task<Stream?>, which prevents the user to inspect the response for errors. It crashes if the call wasn't successful.So, the idea is to make
ExecuteStreamAsync, which will returnTask<RestStreamResponse>. The response will be likeRestResponsebut instead ofContentit will haveStream?. Naturally, it requires to beIDisposable.The first step there was to create a source generator to create instance of
RestResponseBasechild class, as copying those properties manually is error prone (adding a new prop requires many changes). That part is done, so now this thing should be relatively easy.Originally posted by @alexeyzimarev in #2072 (comment)