Hacktoberfest 2026: die Issues, die Maintainer für den Oktober markiert haben – offen und einsteigerfreundlich. Hacktoberfest-Issues durchsuchen

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

Offen
#2,384 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Anfängerfreundlichkeit
45/100
Issue-Typ
Feature
Klarheit
Größtenteils klar
Aktivitätsstatus
Ruhig
Tech-Stack
csharp
Bereich
api, testing

Rechercherichtung

Lokalisieren Sie die Erweiterungsmethode ExecuteAsync sowie die Schnittstelle IRestClient und deren Implementierung im Repository. Prüfen Sie bestehende Aufrufe und Tests für typisierte Requests und ermitteln Sie anschließend, wie sich die Änderung der Schnittstelle auf Mocking und bestehende Nutzer der Erweiterungsmethode auswirkt. Erledigt ist die Aufgabe, wenn die typisierte Ausführung über IRestClient verfügbar ist und die relevanten Tests gemockte Antworten ohne Einrichtung eines Serializers abdecken.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

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

Vorherrschende Sprache
C#
Sterne
9.8k
Forks
2.3k
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Entwicklungsumgebung

In Codespaces öffnen

Startet den Dev-Container des Projekts im Browser, mit Ihrem eigenen GitHub-Konto.

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus restsharp/RestSharp

Alle Issues in restsharp/RestSharp

Ähnliche Issues

Weitere Issues zu C#

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.