Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

move "async Task<RestResponse<T>> ExecuteAsync<T>" from Extension to IRestClient

Aperta
#2,384 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
45/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Tranquilla
Stack tecnologico
csharp
Ambito
api, testing

Direzione di ricerca

Individua il metodo di estensione ExecuteAsync e l’interfaccia IRestClient con la relativa implementazione nel repository. Esamina le chiamate e i test esistenti relativi alle richieste tipizzate, quindi determina in che modo la modifica dell’interfaccia influisce sul mocking e sui consumer esistenti del metodo di estensione. L’attività è completata quando l’esecuzione tipizzata è disponibile tramite IRestClient e i test pertinenti coprono risposte mockate senza configurare un serializzatore.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

awaiting-feedback feature-request

The extension-method

async Task<RestResponse<T>> ExecuteAsync<T>

Is the "natural" way to do a Request: everyting is TypeSave. But If you try to Mock IRestClient, you can only mock the Non-Typed Request-Reponse method.

In a Test-Scenario, we have to add the Serializers and use compute to Serialize & Deserialize, there is no full control on the response - the deserializers try to do the work - and an easy workaround with own serializer/deserialiser is not easy.

I had a long look at the sources, but using a custom Serializer did not worked out well. So I ended up with this Blog-Post unittest-with-restsharp

Yes, this works but is not intuitive.

Describe the solution you'd like

Having Task<RestResponse<T>> ExecuteAsync<T> in IRestClient would enable us to simple Mock the call. No additional Setup, No Serialization during the Test.

As far as I see, the ExtensionMethod can be moved to the RestClient-Implementation without breaking anything. All other ExtensionMethods will work, IRestClient-Implementation / Mocks will work.

You could move the method to the IRestClient Implementaion, extend the interface and remove the ExtensionMethod- without any side effects.

Describe alternatives you've considered

Considered? Mocking the Tests is complex. I considered to remove RestSharp - but my time is limited ;-) I did a complex initialization and hope my (future) colleagues will understand this in 2 years...

If I was unclear / any questions - may need some days for me to answer, but I'm here

Lingua principale
C#
Stelle
9.8k
Fork
2.3k
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di restsharp/RestSharp

Tutte le issue di restsharp/RestSharp

Issue simili

Altre issue su C#

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.