question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Avalonia controls inherit from INotifyPropertyChanged but aren't recognised by the Event Invoker

See original GitHub issue

Avalonia (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:closed
  • Created 5 years ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
worldbeatercommented, Apr 28, 2018

@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.

1reaction
ltrzesniewskicommented, Apr 28, 2018

@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:~

<Weavers>
  <PropertyChanged EventInvokerNames="ReactiveUI.IReactiveObject.RaisePropertyChanged, RaisePropertyChanged" />
</Weavers>

~Don’t forget to add any of your own invoker names.~

(that won’t work since the method is private)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Avalonia controls inherit from INotifyPropertyChanged but ...
Avalonia controls inherit from INotifyPropertyChanged but aren't recognised by the Event Invoker.
Read more >
Change Notifications
The easiest way to do this is to use ReactiveUI and make your view model class inherit from ReactiveObject . You then add...
Read more >
Newest 'propertychanged' Questions
I am currently building a control library for WPF, WinUI3 and UWP. I use custom ContentControls for my controls with DependencyProperties.
Read more >
Multiplatform Avalonia .NET Framework Programming ...
This article covers important concepts of Avalonia/WPF needed for programming and software design.
Read more >
Multiplatform Avalonia .NET Framework Programming ...
In Avalonia, the primitives usually inherit from Control class, while the more complex controls inherit from TemplatedControl class, while in ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found