Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

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

未关闭 适合新手
#176 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
66/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
csharp
领域
backend

调研方向

从src/ReactiveUI.Binding.Shared/Fallback/RuntimePropertyRaiser.cs开始,重点查看引用的第152–157行以及第108–114行的异常路径。检查runtime如何跨各自的assembly解析IReactiveObject和IReactiveObjectExtensions,然后使用ReactiveUI 26.0.1通过Avalonia MVVM示例复现问题。在该复现中ToPropertyUnsafe运行时不抛出异常,即视为完成。

由索引模型根据 Issue 内容生成。

描述

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

主要语言
C#
星标
9
派生
2
平均合并
6 小时 48 分钟
30 天内合并 PR
71

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

reactiveui/ReactiveUI.Binding.SourceGenerators 的其他 Issue

查看 reactiveui/ReactiveUI.Binding.SourceGenerators 的全部 Issue

相似的 Issue

更多 C# Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。