Add the `partial` modifier to the generated property of the Relay Command
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
- Tính năng
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- csharp
- Lĩnh vực
- developer-experience, tooling
Hướng nghiên cứu
Bắt đầu bằng cách xác định điểm vào tạo mã nguồn của Relay Command và so sánh cách xử lý thuộc tính được tạo với trình tạo Observable Property. Xác minh rằng thuộc tính command được tạo hỗ trợ một khai báo partial viết thủ công tương ứng và rằng kịch bản tạo mã nguồn XAML/App Model phân giải nó tại thời điểm biên dịch mà không dùng reflection.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Overview
Add the partial modifier to the generated property of the Relay Command.
Now, app models like .NET MAUI have introduced a source generation feature that allows XAML to be translated into C#. However, the issue remains that source generators cannot interact with one another, such that only handwritten code is accessible.
Since the Observable Property is partial, it can be referenced in XAML without any issues. However, the Relay Command property is not partial, which prevents XAML source generation from inferring it. To resolve this, update the generated Relay Command property partial so that its declaration can be added in the handwritten code, while the MVVM toolkit handles the implementation.
API breakdown
Providing the source-generated code for reference. The generated property needs to be partial.
User code:
public partial IRelayCommand IncrementCommand { get; }
Generated:
private global::CommunityToolkit.Mvvm.Input.RelayCommand? incrementCommand;
// The request is make this IncrementCommand property partial
// so that the developer can add a declaration part in the source type.
public global::CommunityToolkit.Mvvm.Input.IRelayCommand IncrementCommand => incrementCommand ??= new global::CommunityToolkit.Mvvm.Input.RelayCommand(new global::System.Action(Increment));
Usage example
The IncrementCommand is now visible to the App Model source generator.
Previously, the evaluation occurred at runtime; now, to support AOT, it is resolved at compile time. To avoid reflection, the C# expression API is used, requiring at least the declaration/definition to be part of the handwritten code.
<Button Command="{Binding IncrementCommand}" />
Breaking change?
I'm not sure
Alternatives
Manually create the command property, losing all the toolkit's benefits.
Additional context
Multiple source generators at work.
Help us help you
No, just wanted to propose this
- 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
- 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 87 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 35/100
CommunityToolkit/dotnet#1217 ·
-
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 ·
Tất cả issue của CommunityToolkit/dotnet
Issue tương tự
-
[BUG]: Position intent set on a simple order is dropped when it becomes a bracket, OCO or OTO orderCó thể đã có người làm @RaphaelFakhri đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
alpacahq/alpaca-trade-api-csharp#903 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 64/100
joinrpg/joinrpg-net#5752 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug ux
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
CodeForFire/lagebuch#714 ·
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 82/100
dimitar-radenkov/Pointframe#294 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
kind/feature-request
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Altinn/altinn-correspondence#2154 ·
Maintainer thường phản hồi trong vòng 1 ngày