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

Properties generated from private fields do not conflict/trigger CS0108 or any other warning

Đang mở
#1,092 0 bình luận 0 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

Bắt đầu từ phần triển khai source-generator của ObservableProperty và tìm các kiểm thử chẩn đoán hoặc cảnh báo của nó, sau đó tái hiện ví dụ TypeA/TypeB từ issue. Xác định cách các thuộc tính được tạo từ các trường private được kiểm tra qua quan hệ kế thừa, và coi trường hợp được báo cáo là hoàn tất khi nó tạo ra một chẩn đoán rõ ràng về việc che khuất, chẳng hạn như CS0108, hoặc một cảnh báo dành riêng cho MVVM.

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

Given two types, where one is derived from the other, adding a private field to the derived type with the same name as a private field on the base type will generate a property on each type's generated partial definition. Because code analysis is disabled on these generated files, no indication is given that the property on the derived type is hiding the property on the base type.

Regression

No response

Steps to reproduce

The following code should demonstrate the problem:

public class TypeA : ObservableObject
{
    [ObservableProperty]
    private bool _someField; // will generate TypeA.SomeField
}

public class TypeB : TypeA
{
    [ObservableProperty]
    private bool _someField; // will generate TypeB.SomeField, hiding TypeA.SomeField
}
Expected behavior

Some indication should be given that TypeB._someField causes hiding of the property generated for TypeA, either CS0108 on the field or some MVVM specific warning that explains exactly what is happening.

Screenshots

No response

IDE and version

VS 2022

IDE version

17.13.6

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

No, just wanted to report this

Ngôn ngữ chính
C#
Star
3.8k
Fork
401
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.