Skip to content

Commit 07fdeed

Browse files
committed
Add invocation of partial generated methods
1 parent f487d92 commit 07fdeed

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

CommunityToolkit.Mvvm.SourceGenerators/ComponentModel/ObservablePropertyGenerator.Execute.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,14 @@ public static MemberDeclarationSyntax GetPropertySyntax(PropertyInfo propertyInf
146146
{
147147
ImmutableArray<StatementSyntax>.Builder setterStatements = ImmutableArray.CreateBuilder<StatementSyntax>();
148148

149+
// Add the OnPropertyChanging() call first:
150+
//
151+
// On<PROPERTY_NAME>Changing(value);
152+
setterStatements.Add(
153+
ExpressionStatement(
154+
InvocationExpression(IdentifierName($"On{propertyInfo.PropertyName}Changing"))
155+
.AddArgumentListArguments(Argument(IdentifierName("value")))));
156+
149157
// Gather the statements to notify dependent properties
150158
foreach (string propertyName in propertyInfo.PropertyChangingNames)
151159
{
@@ -192,6 +200,14 @@ public static MemberDeclarationSyntax GetPropertySyntax(PropertyInfo propertyInf
192200
Argument(LiteralExpression(SyntaxKind.StringLiteralExpression, Literal(propertyInfo.PropertyName))))));
193201
}
194202

203+
// Add the OnPropertyChanged() call:
204+
//
205+
// On<PROPERTY_NAME>Changed(value);
206+
setterStatements.Add(
207+
ExpressionStatement(
208+
InvocationExpression(IdentifierName($"On{propertyInfo.PropertyName}Changed"))
209+
.AddArgumentListArguments(Argument(IdentifierName("value")))));
210+
195211
// Gather the statements to notify dependent properties
196212
foreach (string propertyName in propertyInfo.PropertyChangedNames)
197213
{

0 commit comments

Comments
 (0)