Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

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

オープン
#2,384 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
45/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
静か
技術スタック
csharp
領域
api, testing

調査の方向性

リポジトリ内で ExecuteAsync 拡張メソッドと IRestClient インターフェースおよびその実装を特定します。型付きリクエストに関する既存の呼び出しとテストを確認し、そのうえでインターフェースの変更がモックと既存の拡張メソッド利用側にどのような影響を与えるかを判断します。完了条件は、型付き実行を IRestClient 経由で利用でき、関連するテストでシリアライザーのセットアップなしにモックされたレスポンスをカバーできることです。

索引モデルが issue の本文から書いたものです。

説明

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

主要言語
C#
スター
9.8k
フォーク
2.3k
PR マージ指標
30日以内にマージされた PR はありません

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

restsharp/RestSharp のほかの issue

restsharp/RestSharp の issue をすべて見る

似ている issue

C# の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。