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

Add the `partial` modifier to the generated property of the Relay Command

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

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

評価

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

調査の方向性

まず Relay Command のソース生成エントリポイントを特定し、生成されたプロパティの処理を Observable Property ジェネレーターと比較します。生成された command プロパティが、対応する手書きの partial 宣言をサポートしていること、また XAML/App Model のソース生成シナリオでそれがリフレクションなしにコンパイル時に解決されることを確認します。

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

説明

feature request :mailbox_with_mail:
Overview

Add the partial modifier to the generated property of the Relay Command.

Now, app models like .NET MAUI have introduced a source generation feature that allows XAML to be translated into C#. However, the issue remains that source generators cannot interact with one another, such that only handwritten code is accessible.

Since the Observable Property is partial, it can be referenced in XAML without any issues. However, the Relay Command property is not partial, which prevents XAML source generation from inferring it. To resolve this, update the generated Relay Command property partial so that its declaration can be added in the handwritten code, while the MVVM toolkit handles the implementation.

API breakdown

Providing the source-generated code for reference. The generated property needs to be partial.

User code:

public partial IRelayCommand IncrementCommand { get; }

Generated:

private global::CommunityToolkit.Mvvm.Input.RelayCommand? incrementCommand;
// The request is make this IncrementCommand property partial
// so that the developer can add a declaration part in the source type.
public global::CommunityToolkit.Mvvm.Input.IRelayCommand IncrementCommand => incrementCommand ??= new global::CommunityToolkit.Mvvm.Input.RelayCommand(new global::System.Action(Increment));
Usage example

The IncrementCommand is now visible to the App Model source generator.

Previously, the evaluation occurred at runtime; now, to support AOT, it is resolved at compile time. To avoid reflection, the C# expression API is used, requiring at least the declaration/definition to be part of the handwritten code.

<Button Command="{Binding IncrementCommand}" />
Breaking change?

I'm not sure

Alternatives

Manually create the command property, losing all the toolkit's benefits.

Additional context

Multiple source generators at work.

Help us help you

No, just wanted to propose this

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

環境構築

はじめの一歩

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

CommunityToolkit/dotnet のほかの issue

CommunityToolkit/dotnet の issue をすべて見る

似ている issue

C# の issue をもっと見る

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

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