Incorrect partial method prototypes for generated observable properties
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
- 62/100
Hướng nghiên cứu
Bắt đầu với việc tái hiện trên .NET 9 bằng CommunityToolkit.Mvvm 8.4.0, so sánh các khai báo partial methods được tạo cho field và property [ObservableProperty]. Xác minh các prototype của OnChanging và OnChanged, đặc biệt là tham số nullable oldValue; hoàn tất khi cả hai dạng khớp nhau và không có CS8826.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Describe the bug
When decorating a property of a reference or otherwise nullable type with [ObservableProperty] the two-argument partial property-changing and property-changed method prototypes are generated differently than for decorated fields, not considering that the oldValue argument may be null.
Regression
No response
Steps to reproduce
- Create a new project targeting .NET 9.0 and depending on CommunityToolkit.Mvvm
- Create a class inheriting from
ObservableObject - Add the following code to the class:
[ObservableProperty] private object _testA; [ObservableProperty] public object TestB { get; set; } partial void OnTestAChanged(object? oldValue, object newValue) { /* do nothing */ } partial void OnTestBChanged(object? oldValue, object newValue) { /* do nothing */ } - Note that
OnTestBChangedhas warning CS8826 on it, because the generated partial declaration ispartial void OnTestBChanged(global::System.Object oldValue, global::System.Object newValue);but there's no such warning forOnTestAChanged.
Expected behavior
The OnChanging(oldValue,newValue) and OnChanged(oldValue,newValue) partial method declarations for properties decorated with ObservablePropertyAttribute will be generated the same as for fields decorated with same.
Screenshots
No response
IDE and version
VS 2022
IDE version
17.14.9
Nuget packages
- CommunityToolkit.Common
- CommunityToolkit.Diagnostics
- CommunityToolkit.HighPerformance
- CommunityToolkit.Mvvm (aka MVVM Toolkit)
Nuget package version(s)
8.4.0
Additional context
The oldValue argument should always be generated as nullable for reference types as the initial call to the methods may be due to setting the property in the constructor (e.g. initial value may be based on a constructor argument, or the change methods may be used to set up and remove event handlers on the property value).
Help us help you
No, just wanted to report this
- Ngôn ngữ chính
- C#
- Star
- 3.8k
- Fork
- 402
- 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 121 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 ·
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 20/100
CommunityToolkit/dotnet#1218 ·
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
CommunityToolkit/dotnet#1217 ·
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 70/100
Maintainer thường phản hồi trong vòng 2 ngày
-
[Core] IPlatformServices.PrefersDarkTheme: the desktop's theme as the signed-in user sees itĐang mởarea: core bug help wanted ready
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
ZaidX88/sluice#265 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
rate limit at lrclib.netĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
-
area: remote bug
Độ 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
-
Install a C# EnvironmentĐang mở📅 Sprint 4 Module-Tools Setup Submit:None 🦔 Size Tiny
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
CodeYourFuture/Module-Tools#712 ·