Cysharp / R3

The new future of dotnet/reactive and UniRx.
MIT License
2.27k stars 99 forks source link

Able to write value to `IReadOnlyBindableReactiveProperty<T>` #245

Closed hsytkm closed 3 months ago

hsytkm commented 3 months ago

Issue

It is possible to write value to IReadOnlyBindableReactiveProperty<T>, which should be read-only.

Details

While the Value property does not have a setter in C# code, preventing direct modification. But binding from XAML (e.g., to ListView.SelectedItem) will also set the value.

Additional Information

When using IReadOnlyReactiveProperty<T> from runceel/ReactiveProperty, a System.Windows.Markup.XamlParseException occurs immediately after execution.

Environment

Repository

R3Wpf.ROBindableRpDemo - GitHub

neuecc commented 3 months ago

In the #234, I had said that I would not fix this problem, but I have decided to fix it by wrapping it in a ReadOnly type and correctly propagating events. v1.2.6 is now correctly ReadOnly. cc: @runceel

hsytkm commented 3 months ago

I appreciate your quick fix and for introducing the discussion #234. I mistakenly set up a TwoWay binding in XAML for a property that was defined as read-only in ViewModel, so this kind of security enhancement is very helpful for me.