Fody, propertychanged and setting same value?
Asked Answered
N

1

3

Is there any way to configure fody to not check the value which is set to property - I have situations when value is the same and I want property to be set because I have additional logic in property setter that is not invoked.

Neuroma answered 13/6, 2014 at 9:59 Comment(1)
Same problem... ended up with the INotifyPropertyChanged interface implementation.Pappano
S
4

This is clearly literally years after the original question but for future reference:

This is indeed possible by modifying the options in the FodyWeavers.xml file.

As is shown on the PropertyChanged.Fody wiki, one of the options is called CheckForEquality and can be set to false (it defaults to true). This will prevent Fody from injecting equality checking code. The FodyWeavers.xml file could now look as follows:

<?xml version="1.0" encoding="utf-8" ?>
<Weavers>
  <PropertyChanged CheckForEquality='false'/>
</Weavers>

As noted in the comments there is also the possibility to do this per property via the DoNotCheckEquality attribute e.g.

[ImplementPropertyChanged]
public class Person 
{
    [DoNotCheckEquality]
    public string Name { get; set; }
}

See wiki/Attributes

Smegma answered 3/10, 2016 at 18:8 Comment(1)
There is also attribute DoNotCheckEquality that can be set per propertyNeuroma

© 2022 - 2024 — McMap. All rights reserved.