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

Partial ObservableProperty in ObservableObject shows error CS0229 ambiguity between property and property

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

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

評価

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

調査の方向性

リポジトリのファイルやテストは指定されていません。まず、CommunityToolkit.Mvvm 8.4.0 を使用した最小限の部分的な ObservableProperty の例を再現し、ObservableProperty のソース生成パスを調査してください。完了の条件は、生成されたプロパティが引き続きコンパイルされて正しく動作しながら、Item.Returned への外部アクセスで CS0229 が発生しなくなることです。

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

説明

bug :bug:
Describe the bug

I'm developing a WinUI application with Community Toolkit MVVM 8.4.0.
I switched the properties in my application to use the new format. Here's one example:

[ObservableProperty]
public partial bool Returned { get; set; } = returned;

And this is a simplified version of the constructor for the object:
public partial class Item(bool returned) : ObservableObject

This all works as expected and compiles fine but all uses of the property elsewhere show the Compiler Error CS0229. In this case it shows:
Ambiguity between Item.Returned and Item.Returned.
I only have the one property called Returned.
As I said, it all compiles fine and works correctly but I'm not able to get rid of the error.

Regression

No response

Steps to reproduce

Create a class with the type ObservableObject and create a partial Observable Property. Use it elsewhere in the app.

Example:

public partial class Item(bool returned) {
    [ObservableProperty]
    public partial bool Returned { get; set; } = returned;
}

Then access the property somewhere else in the app.

Example:

var newItem = new Item(false);
newItem.Returned = true;

This shows the compiler error.

Expected behavior

I would like to remove the false alarm.

Screenshots

Image

IDE and version

VS 2022

IDE version

Version 17.13.1

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

8.4.0

Additional context

No response

Help us help you

Yes, but only if others can assist

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