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

`[RelayCommand]` does not work with default/optional arguments as the command parameter

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

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

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
csharp
領域
tooling

調査の方向性

CommunityToolkit.Mvvm の [RelayCommand] の生成パスとアナライザーのパスから始め、続いてオプションの bool と既定の CancellationToken を持つ、報告されたコマンドを再現します。生成されたコマンドがオプションの引数を処理できるか確認します。コマンドが正しくディスパッチされるか、サポートされていないオプションの引数についてアナライザーが明確なコンパイラーエラーを報告すれば完了です。

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

説明

bug :bug:
Describe the bug

The following command compiles, but causes a runtime error when called.

public override async Task SomeCommandAsync(bool optional = false, CancellationToken cancellationToken = default)
{

}

The same command without the first optional argument does work, i.e. the optional CancellationToken is handled correctly, as far as I can tell.

If it isn't possible to dispatch the command with that default/optional argument, then the analyzer should probably produce a compiler error notifying the user that RelayCommands cannot have optional arguments.

Regression

No response

Steps to reproduce
  1. Paste the code above into a class inside a project that references the CommunityToolkit
  2. Run the application
Expected behavior

Either pass in the provided value or the default or generate a compiler error to notify the user that commands cannot have optional arguments.

Screenshots

No response

IDE and version

VS 2022

IDE version

No response

Nuget packages
  • CommunityToolkit.Common
  • CommunityToolkit.Diagnostics
  • CommunityToolkit.HighPerformance
  • CommunityToolkit.Mvvm (aka MVVM Toolkit)
Nuget package version(s)

CommunityToolkit.Mvvm 8.4.0

Additional context

No response

Help us help you

No, just wanted to report this

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

環境構築

はじめの一歩

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

CommunityToolkit/dotnet のほかの issue

CommunityToolkit/dotnet の issue をすべて見る

似ている issue

C# の issue をもっと見る

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

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