Fody/PropertyChanged

System.MethodAccessException when using ReactiveU.ReactiveObject

distantcam opened this issue · 6 comments

PropetyChanged v3.2.3
ReactiveUI v11.1.6

System.MethodAccessException
  HResult=0x80131510
  Message=Attempt by method 'App.MainViewModel.set_Property(System.String)' to access method 'ReactiveUI.ReactiveObject.ReactiveUI.IReactiveObject.RaisePropertyChanged(System.ComponentModel.PropertyChangedEventArgs)' failed.

It looks like the IL for the RaisePropertyChanged callvirt is wrong.

Fody:

callvirt instance void [ReactiveUI]ReactiveUI.ReactiveObject::ReactiveUI.IReactiveObject.RaisePropertyChanged(class [System.ObjectModel]System.ComponentModel.PropertyChangedEventArgs)

Manual:

callvirt instance void [ReactiveUI]ReactiveUI.IReactiveObject::RaisePropertyChanged(class [System.ObjectModel]System.ComponentModel.PropertyChangedEventArgs)

If someones wondering, the difference lies in the I before ReactiveObject:

[ReactiveUI]ReactiveUI.ReactiveObject
[ReactiveUI]ReactiveUI.IReactiveObject

anyone want to submit a PR that fixes this?

Yep might give this a go this weekend.

ReactiveUI's Fody using [Reactive] uses this.RaiseAndSetIfChanged.
If I use the [Reactive] attribute, the PropertyChanged.Fody also weaves it and I have double calls.

You probably shouldn't use both weavers simultaneously, they're trying to do the same thing in a different manner.

Yeah, I noticed that and suppressing the PropertyChanged.Fody weaving on every ReactiveObject with [DoNotNotify] on class till this issue get solved.