Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

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

Đang mở
#1,056 11 bình luận 1 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
35/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
csharp
Lĩnh vực
tooling

Hướng nghiên cứu

Không có tệp repository hoặc bài kiểm thử nào được nêu. Hãy bắt đầu bằng cách tái hiện ví dụ ObservableProperty một phần tối thiểu với CommunityToolkit.Mvvm 8.4.0 và kiểm tra đường dẫn tạo mã nguồn của ObservableProperty; được xem là hoàn tất khi các truy cập bên ngoài tới Item.Returned không còn tạo ra CS0229, trong khi thuộc tính được tạo vẫn biên dịch và hoạt động chính xác.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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

Ngôn ngữ chính
C#
Star
3.8k
Fork
403
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của CommunityToolkit/dotnet

Tất cả issue của CommunityToolkit/dotnet

Issue tương tự

Thêm issue về C#

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.