Error MVVMTK0015 when the desired NotifyPropertyChangedFor property is an explicit interface implementation
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 48/100
Hướng nghiên cứu
Bắt đầu bằng cách tái hiện triển khai giao diện tường minh được cung cấp với CommunityToolkit.Mvvm 8.4.0 và theo dõi quá trình xác thực NotifyPropertyChangedFor tạo ra MVVMTK0015. Xác nhận hành vi của mẫu, sau đó cập nhật quá trình xác thực để một thuộc tính giao diện được triển khai tường minh được chấp nhận, trong khi các đích không hợp lệ hiện có vẫn tiếp tục báo chẩn đoán.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Describe the bug
A compilation error results for a situation that we think should be valid. Specifically:
error MVVMTK0015: The target(s) of [NotifyPropertyChangedFor] must be a (different) accessible property, but "(the notify-for property name)" has no (other) matches in type (my type) (https://aka.ms/mvvmtoolkit/errors/mvvmtk0015)
It appears that the toolkit's conditions for NotifiyPropertyChangedFor are not satisfied when the property exists only as an explicitly-implemented interface property.
Regression
No response
Steps to reproduce
Given this simplified reproduction:
public interface IMenuItem
{
bool Enabled { get; }
}
public partial class MenuItem : ObservableObject, IMenuItem
{
[ObservableProperty]
[NotifyPropertyChangedFor(nameof(IMenuItem.Enabled))]
public partial int ValueThatAffectsEnabled { get; set; }
bool IMenuItem.Enabled => ValueThatAffectsEnabled > 0;
}
Compiling results in the following error:
error MVVMTK0015: The target(s) of [NotifyPropertyChangedFor] must be a (different) accessible property, but "Enabled" has no (other) matches in type MenuItem (https://aka.ms/mvvmtoolkit/errors/mvvmtk0015)
Expected behavior
We expect this to be allowed by the NotifyPropertyChangedFor attribute's validation because:
- There is a public property named
Enabled, it's simply of lessened visibility (only visible through the interface) - It is a very common for our views to work with their View Models as interfaces, not concrete types. This lets us swap in/out compatible view model types.
We can work around this:
- We could make those properties not explicit interface implementations (we'd rather not, we design member visibility very intentionally).
- We could add OnXXXXChanged() partial methods to manually call
OnPropertyChanged("the desired property").
but it would be better if the library would allow this.
Screenshots
No response
IDE and version
VS 2022
IDE version
17.14.10
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
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của CommunityToolkit/dotnet
-
RelayCommand<T>.CanExecute(null) returns false for value types without a predicateCó thể đã có người làm @apachezy đã nhận 84 ngày trước. Đang mởbug :bug:
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
CommunityToolkit/dotnet#1206 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
CommunityToolkit/dotnet#1186 ·
-
bug :bug:
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 68/100
CommunityToolkit/dotnet#648 ·
-
bug :bug:
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 68/100
CommunityToolkit/dotnet#1215 ·
-
Add segmented buffering and sequence reads to `ArrayPoolBufferWriter<T>`Có thể đã có người làm @paulomorgado đã nhận 21 ngày trước. Đang mởfeature request :mailbox_with_mail:
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 45/100
CommunityToolkit/dotnet#1214 ·
Tất cả issue của CommunityToolkit/dotnet
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
Devolutions/UniGetUI#5541 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[aw] PR Iteration Agent 🔧 failedĐang mởagentic-workflows Needs: Triage :mag:
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 1 ngày
-
[誤判定]Đang mởlinux アプリ: ブラウザー 再現済み 要トリアージ 誤判定
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
yksr-melt/Meltype#853 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
S: Untriaged
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Trauma-Station/Trauma-Station#5073 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày