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

AddSingleton does not work as expected

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

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

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
25/100
issue の種類
バグ
明瞭さ
説明が足りない
活発さ
停滞
技術スタック
csharp

調査の方向性

まず、SDK のサービス設定で報告されている AddSingleton(type, instance) と factory の登録を、提供されたツール型と Activator.CreateInstance パスを使って再現します。ツールの作成時に登録済みのインスタンスと factory のどちらが呼び出されるかを比較します。別のインスタンスを暗黙的に作成するのではなく、両方の登録形式が尊重されれば完了です。

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

説明

enhancement needs confirmation P3

Describe the bug
When we register tool like AddSingleton(type, instance) and pass a singleton instance, it seems that the instance is being ignored and the library creates a new instance when it needs it.
I tried also AddSingleton using a factory method like this:
services.AddSingleton(toolType, provider => Activator.CreateInstance(toolType, this.m_compositionService));
A breakpoint to Activator.CreateInstance was never hit and the tool just created the instance of the tool.

To Reproduce
Steps to reproduce the behavior:
1.

Expected behavior
A clear and concise description of what you expected to happen.

Logs
If applicable, add logs to help explain your problem.

Additional context
We discussed the issue over email. Please feel free to contact me there if you need additional information. Thanks!

主要言語
C#
スター
4.5k
フォーク
814
平均マージ
9日 19時間
マージ済み PR(30日)
4

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

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

modelcontextprotocol/csharp-sdk のほかの issue

modelcontextprotocol/csharp-sdk の issue をすべて見る

似ている issue

C# の issue をもっと見る

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

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