@@ -683,19 +683,15 @@ public static MemberDeclarationSyntax GetPropertySyntax(PropertyInfo propertyInf
683
683
string name => IdentifierName ( name )
684
684
} ;
685
685
686
- if ( propertyInfo . NotifyPropertyChangedRecipients )
687
- {
688
- // If broadcasting changes are required, also store the old value.
689
- // This code generates a statement as follows:
690
- //
691
- // <PROPERTY_TYPE> __oldValue = <FIELD_EXPRESSIONS>;
692
- setterStatements . Add (
693
- LocalDeclarationStatement (
694
- VariableDeclaration ( propertyType )
695
- . AddVariables (
696
- VariableDeclarator ( Identifier ( "__oldValue" ) )
697
- . WithInitializer ( EqualsValueClause ( fieldExpression ) ) ) ) ) ;
698
- }
686
+ // Store the old value for later. This code generates a statement as follows:
687
+ //
688
+ // <PROPERTY_TYPE> __oldValue = <FIELD_EXPRESSIONS>;
689
+ setterStatements . Add (
690
+ LocalDeclarationStatement (
691
+ VariableDeclaration ( propertyType )
692
+ . AddVariables (
693
+ VariableDeclarator ( Identifier ( "__oldValue" ) )
694
+ . WithInitializer ( EqualsValueClause ( fieldExpression ) ) ) ) ) ;
699
695
700
696
// Add the OnPropertyChanging() call first:
701
697
//
@@ -705,6 +701,14 @@ public static MemberDeclarationSyntax GetPropertySyntax(PropertyInfo propertyInf
705
701
InvocationExpression ( IdentifierName ( $ "On{ propertyInfo . PropertyName } Changing") )
706
702
. AddArgumentListArguments ( Argument ( IdentifierName ( "value" ) ) ) ) ) ;
707
703
704
+ // Also call the overload after that:
705
+ //
706
+ // On<PROPERTY_NAME>Changing(__oldValue, value);
707
+ setterStatements . Add (
708
+ ExpressionStatement (
709
+ InvocationExpression ( IdentifierName ( $ "On{ propertyInfo . PropertyName } Changing") )
710
+ . AddArgumentListArguments ( Argument ( IdentifierName ( "__oldValue" ) ) , Argument ( IdentifierName ( "value" ) ) ) ) ) ;
711
+
708
712
// Gather the statements to notify dependent properties
709
713
foreach ( string propertyName in propertyInfo . PropertyChangingNames )
710
714
{
@@ -751,6 +755,14 @@ public static MemberDeclarationSyntax GetPropertySyntax(PropertyInfo propertyInf
751
755
InvocationExpression ( IdentifierName ( $ "On{ propertyInfo . PropertyName } Changed") )
752
756
. AddArgumentListArguments ( Argument ( IdentifierName ( "value" ) ) ) ) ) ;
753
757
758
+ // Do the same for the overload, as above:
759
+ //
760
+ // On<PROPERTY_NAME>Changed(__oldValue, value);
761
+ setterStatements . Add (
762
+ ExpressionStatement (
763
+ InvocationExpression ( IdentifierName ( $ "On{ propertyInfo . PropertyName } Changed") )
764
+ . AddArgumentListArguments ( Argument ( IdentifierName ( "__oldValue" ) ) , Argument ( IdentifierName ( "value" ) ) ) ) ) ;
765
+
754
766
// Gather the statements to notify dependent properties
755
767
foreach ( string propertyName in propertyInfo . PropertyChangedNames )
756
768
{
0 commit comments