Avalonia controls inherit from INotifyPropertyChanged but aren't recognised by the Event Invoker
See original GitHub issueAvalonia (http://avaloniaui.net/) has controls that inherit from the base AvaloniaObject
class https://github.com/AvaloniaUI/Avalonia/blob/master/src/Avalonia.Base/AvaloniaObject.cs. This class implements INPC and has this event invoker.
protected void RaisePropertyChanged(AvaloniaProperty property, object oldValue, object newValue, BindingPriority priority = BindingPriority.LocalValue);
When using PropertyChanged I get the following error.
Could not inject EventInvoker method on type ‘Cyclops.UI.Main.MainView’. It is possible you are inheriting from a base class and have not correctly set ‘EventInvokerNames’ or you are using a explicit PropertyChanged event and the event field is not visible to this instance. Either correct ‘EventInvokerNames’ or implement your own EventInvoker on this class. If you want to suppress this place a [DoNotNotifyAttribute] on Cyclops.UI.Main.MainView.
I can work around the problem by adding DoNotNotify
to all my views, but it would be nice to not have to do that.
Update I also realised the INPC event is explicitly defined too, which is also why the EventInvoker can’t just make it’s own method.
Issue Analytics
- State:
- Created 5 years ago
- Comments:8 (8 by maintainers)
@ltrzesniewski thanks for the advice! I’ve just opened up a pull request where Fody finally plays well with the latest ReactiveUI version and Reactive Objects. We can continue the discussion there, your help and review would be highly appreciated! Thanks in advance.
BTW ReactiveUI.Fody hasn’t been receiving updates for a long period of time and I think the best and easiest option is improving this library instead of building and supporting another one.
@worldbeater that’s a different issue than what’s raised here.
~But for your case, explicitly implemented methods simply have a different name in metadata (they don’t really have a name in C#). So just add this to
FodyWeavers.xml
, I haven’t tested it but it should work:~~Don’t forget to add any of your own invoker names.~
(that won’t work since the method is private)