Fody not weaving PropertyChanged

497 Views Asked by At

I'm having trouble getting Fody & PropertyChanged working. I've got a .NET 4.7.2 project with both Fody(6.6.4) and PropertyChanged.Fody (4.1.0) packages added through NuGet, but only "PropertyChanged" shows in the solution explorer.

My example class that implements the INotifyPropertyChanged interface and a generic test:

[AddINotifyPropertyChangedInterface]
public class NotifyingClass: INotifyPropertyChanged
{
    public event PropertyChangedEventHandler PropertyChanged;

    public string Prop1{ get; set; }
}

public class MyClass
{
    public NotifyingClass notifying {get; set; }
    private bool hasChanges = false;

    public MyForm()
    {
        InitializeComponent();
        var test = new NotifyingClass();
        test.PropertyChanged += (sender, args){
            hasChanges = true; //Never gets called
        }

        test.Prop1 = "new value";

        if(!hasChanges) throw new Exception("PropertyChanged did not fire");
    }
}

I can't to get the PropertyChange event to fire. I tried decompiling with JustDecompile and dotPeek and they just show the same above code. I also tried using the [OnChangedMethod("SomethingChanged")] attribute to no avail. It seems like Fody isn't weaving the PropertyChanged functionality. My FodyWeavers.xml is:

<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
  <PropertyChanged />
</Weavers>

My .csproj has multiple references to Fody-

    <Import Project="packages\PropertyChanged.Fody.4.1.0\build\PropertyChanged.Fody.props" Condition="Exists('packages\PropertyChanged.Fody.4.1.0\build\PropertyChanged.Fody.props')" />

    <Content Include="FodyWeavers.xml" />

    <Reference Include="PropertyChanged, Version=4.1.0.0, Culture=neutral, PublicKeyToken=ee3ee20bcf148ddd, processorArchitecture=MSIL">
      <HintPath>packages\PropertyChanged.Fody.4.1.0\lib\net40\PropertyChanged.dll</HintPath>
    </Reference>

Is there supposed to be a reference also to Fody itself and not just PropertyChanged.Fody?

0

There are 0 best solutions below