Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

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

Open Beginner friendly
#176 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
66/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
csharp
Domain
backend

Research direction

Start in src/ReactiveUI.Binding.Shared/Fallback/RuntimePropertyRaiser.cs, especially the referenced lines 152–157 and the exception path at 108–114. Check how the runtime resolves IReactiveObject and IReactiveObjectExtensions across their assemblies, then reproduce with the Avalonia MVVM example using ReactiveUI 26.0.1. Done means ToPropertyUnsafe runs without throwing in that reproduction.

Written by the indexing model from the issue text.

Description

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

Dominant language
C#
Stars
9
Forks
2
Avg merge
6h 48m
Merged PRs (30d)
71

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from reactiveui/ReactiveUI.Binding.SourceGenerators

All issues in reactiveui/ReactiveUI.Binding.SourceGenerators

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.