@@ -109,7 +109,6 @@ public static bool TryGetInfo(
109109 token . ThrowIfCancellationRequested ( ) ;
110110
111111 using ImmutableArrayBuilder < string > propertyChangedNames = ImmutableArrayBuilder < string > . Rent ( ) ;
112- using ImmutableArrayBuilder < string > propertyChangingNames = ImmutableArrayBuilder < string > . Rent ( ) ;
113112 using ImmutableArrayBuilder < string > notifiedCommandNames = ImmutableArrayBuilder < string > . Rent ( ) ;
114113 using ImmutableArrayBuilder < AttributeInfo > forwardedAttributes = ImmutableArrayBuilder < AttributeInfo > . Rent ( ) ;
115114
@@ -131,12 +130,6 @@ public static bool TryGetInfo(
131130
132131 token . ThrowIfCancellationRequested ( ) ;
133132
134- // Track the property changing event for the property, if the type supports it
135- if ( shouldInvokeOnPropertyChanging )
136- {
137- propertyChangingNames . Add ( propertyName ) ;
138- }
139-
140133 // The current property is always notified
141134 propertyChangedNames . Add ( propertyName ) ;
142135
@@ -296,12 +289,24 @@ public static bool TryGetInfo(
296289
297290 token . ThrowIfCancellationRequested ( ) ;
298291
292+ // Prepare the effective property changing/changed names. For the property changing names,
293+ // there are two possible cases: if the mode is disabled, then there are no names to report
294+ // at all. If the mode is enabled, then the list is just the same as for property changed.
295+ ImmutableArray < string > effectivePropertyChangedNames = propertyChangedNames . ToImmutable ( ) ;
296+ ImmutableArray < string > effectivePropertyChangingNames = shouldInvokeOnPropertyChanging switch
297+ {
298+ true => effectivePropertyChangedNames ,
299+ false => ImmutableArray < string > . Empty
300+ } ;
301+
302+ token . ThrowIfCancellationRequested ( ) ;
303+
299304 propertyInfo = new PropertyInfo (
300305 typeNameWithNullabilityAnnotations ,
301306 fieldName ,
302307 propertyName ,
303- propertyChangingNames . ToImmutable ( ) ,
304- propertyChangedNames . ToImmutable ( ) ,
308+ effectivePropertyChangingNames ,
309+ effectivePropertyChangedNames ,
305310 notifiedCommandNames . ToImmutable ( ) ,
306311 notifyRecipients ,
307312 notifyDataErrorInfo ,
0 commit comments