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.
Fody, propertychanged and setting same value?
Asked Answered
Same problem... ended up with the INotifyPropertyChanged interface implementation. –
Pappano
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
There is also attribute DoNotCheckEquality that can be set per property –
Neuroma
© 2022 - 2024 — McMap. All rights reserved.