问题
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.
回答1:
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
来源:https://stackoverflow.com/questions/24202653/fody-propertychanged-and-setting-same-value