Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fody, propertychanged and setting same value?

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.

like image 854
dnf Avatar asked Apr 18 '26 04:04

dnf


1 Answers

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

like image 107
Seb Andraos Avatar answered Apr 24 '26 02:04

Seb Andraos



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!