Skip to content

Commit

Permalink
Prevent OnChanged property name to clash with partial method generation
Browse files Browse the repository at this point in the history
  • Loading branch information
paulvarache committed Apr 21, 2023
1 parent 3a94d20 commit cb23721
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -232,9 +232,6 @@ private void ProcessBindableProperty(
}
}

w._($@"partial void On{propertyName}Changed({declaringType.ToDisplayString(CommonSymbolDisplayFormat.DefaultFormat)} value);");
w._($@"partial void On{propertyName}Changing({declaringType.ToDisplayString(CommonSymbolDisplayFormat.DefaultFormat)} value);");

this.ProcessImplementationLogic(w);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public void ProcessImplementationLogic(CodeWriter w)
using (w.B(methodDefinition))
{
w._($@"var ctrl = ({this.ClassSymbol.ToDisplayString(CommonSymbolDisplayFormat.DefaultFormat)})bindable;");
this.OnChangedProperty.GetValue<string>((customMethodName) =>
if (this.OnChangedProperty.Value is string customMethodName)
{
var methods = this.GetMethodsToCall(customMethodName);
if (methods.Any())
Expand All @@ -78,9 +78,15 @@ public void ProcessImplementationLogic(CodeWriter w)
w._($@"ctrl.{customMethodName}(({this.FieldSymbol.Type})oldValue, ({this.FieldSymbol.Type})newValue);");
});
}
return default;
});
w._($@"ctrl.{methodName}(({this.FieldSymbol.Type})newValue);");
}
if (this.OnChangedProperty.Value is not string clashingCustomName || clashingCustomName != methodName)
{
w._($@"ctrl.{methodName}(({this.FieldSymbol.Type.ToDisplayString(CommonSymbolDisplayFormat.DefaultFormat)})newValue);");
}
}
if (this.OnChangedProperty.Value is not string clashingCustomCallName || clashingCustomCallName != methodName)
{
w._($@"partial void {methodName}({this.FieldSymbol.Type.ToDisplayString(CommonSymbolDisplayFormat.DefaultFormat)} value);");
}
}

Expand Down

0 comments on commit cb23721

Please sign in to comment.