public void Execute(bool force = false)
{
var property = _propertyData.PropertyDefinition;
if (property == null)
{
FodyEnvironment.LogWarning("Skipping an unknown property because it has no property definition");
return;
}
if (!force && !HasBackingField(property))
{
FodyEnvironment.LogDebug($"\t\tSkipping '{property.Name}' because it has no backing field");
return;
}
if (ImplementsICommand(property))
{
FodyEnvironment.LogDebug($"\t\tSkipping '{property.Name}' because it implements ICommand");
return;
}
FodyEnvironment.LogDebug("\t\t" + property.Name);
try
{
EnsureStaticConstructor(property.DeclaringType);
AddChangeNotificationHandlerField(property, _propertyData);
var fieldDefinition = AddPropertyFieldDefinition(property);
if (!AddPropertyRegistration(property, _propertyData))
{
return;
}
var fieldReference = GetFieldReference(property.DeclaringType, fieldDefinition.Name, true);
AddGetValueCall(property, fieldReference);
AddSetValueCall(property, fieldReference, _propertyData.IsReadOnly);
RemoveBackingField(property);
}
catch (Exception ex)
{
FodyEnvironment.LogError($"\t\tFailed to handle property '{property.DeclaringType.Name}.{property.Name}'\n{ex.Message}\n{ex.StackTrace}");
#if DEBUG
Debugger.Launch();
#endif
}
}