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

[Bug] `ToPropertyUnsafe` (and Possibly Other Unsafe Methods) Always Fails

Đã đóng Phù hợp với người mới
#176 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

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

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
66/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
csharp
Lĩnh vực
backend

Hướng nghiên cứu

Bắt đầu tại src/ReactiveUI.Binding.Shared/Fallback/RuntimePropertyRaiser.cs, đặc biệt là các dòng được tham chiếu 152–157 và nhánh xử lý ngoại lệ tại 108–114. Kiểm tra cách runtime phân giải IReactiveObject và IReactiveObjectExtensions giữa các assembly của chúng, sau đó tái hiện bằng ví dụ MVVM Avalonia sử dụng ReactiveUI 26.0.1. Công việc được xem là hoàn tất khi ToPropertyUnsafe chạy mà không ném ngoại lệ trong lần tái hiện đó.

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

Mô tả

bug
Prerequisites
  • I have searched this repository's open and closed issues for duplicates.
  • I am using the latest stable release.
What happens

ToPropertyUnsafe always fails, because this code is wrong:

https://github.com/reactiveui/ReactiveUI.Binding.SourceGenerators/blob/c79c70ccff42edbd97fe7e1dcac6edabc563dd52/src/ReactiveUI.Binding.Shared/Fallback/RuntimePropertyRaiser.cs#L152-L157

IReactiveObject is defined in the ReactiveUI.Core assembly, while IReactiveObjectExtensions is defined the ReactiveUI assembly, so the code above always fails, and ToPropertyUnsafe ends up throwing this exception:

https://github.com/reactiveui/ReactiveUI.Binding.SourceGenerators/blob/c79c70ccff42edbd97fe7e1dcac6edabc563dd52/src/ReactiveUI.Binding.Shared/Fallback/RuntimePropertyRaiser.cs#L108-L114

What you expected instead

No exception thrown.

Minimal reproduction

In a fresh Avalonia MVVM app with ReactiveUI, add the following lines to the MainViewModel:

    private readonly ObservableAsPropertyHelper<string> _valueOaph;
    public MainViewModel()
    {
        _valueOaph = Observable.Return("").ToPropertyUnsafe(this, x => x.Value)
    }
    public string Value => _valueOaph.Value;
Steps to reproduce
  1. Create an Avalonia MVVM app with Reactive UI: dotnet new avalonia.mvvm -m ReactiveUI
  2. Add the lines mentioned in Minimal Reproduction
  3. dotnet run
Exception and stack trace

Package and version

ReactiveUI 26.0.1

UI framework

Avalonia

Operating system

Windows

Target framework

net10.0

Device and OS version

No response

IDE

No response

Did this work in an earlier version?

No response

Workaround

No response

Additional information

No response

Ngôn ngữ chính
C#
Star
9
Fork
2
Merge trung bình
7 giờ 7 phút
Pull request đã merge (30 ngày)
75

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

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

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 reactiveui/ReactiveUI.Binding.SourceGenerators

Tất cả issue của reactiveui/ReactiveUI.Binding.SourceGenerators

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.