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

Allow ObservableObject/INotifyPropertyChanged generator to work with interface specified

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

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

評価

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

調査の方向性

明示的に宣言したインターフェイスとともに [ObservableObject] または [INotifyPropertyChanged] を使用して WinUI のケースを再現し、警告 MVVMTK0049/0050 を確認します。まず、生成器がユーザー宣言インターフェイスをどのように処理するかを追跡し、次に生成された実装が引き続き利用可能であること、ならびに抽象型の継承に関する回避策を含めて AOT 警告が解消されていることを確認します。

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

説明

Currently, using [ObservableObject]/[INotifyPropertyChanged] generator in WinUI project causes warning MVVMTK0049/0050, since WinRT source generator can't see the implemented interface in MVVMTK source generator.

A workaround for this can be explicitly specify the interfaces in user written part, then they are visible to WInRT source generator:

[INotifyPropertyChanged]
public abstract partial class MyControlBase : UserControl, INotifyPropertyChanged
{
}

However, when the MVVMTK generator sees the interface specification, it will think the interface is implemented by user and remove its generation. If we can force it to provide its generation, then the AOT warning should be addressed.


I also find a workaround by introducing another level of inheritance:

[INotifyPropertyChanged]
public abstract partial class ObservableUserControl : UserControl
{
}

public partial class MyControl : ObservableUserControl, INotifyPropertyChanged

Then WinRT source generator will correctly see interfaces on MyControl, only ObservableUserControl is missing the interface info. Is it safe to ignore the warnings for abstract types?

主要言語
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 を短くまとめたダイジェスト。