@@ -109,7 +109,6 @@ public static bool TryGetInfo(
109
109
token . ThrowIfCancellationRequested ( ) ;
110
110
111
111
using ImmutableArrayBuilder < string > propertyChangedNames = ImmutableArrayBuilder < string > . Rent ( ) ;
112
- using ImmutableArrayBuilder < string > propertyChangingNames = ImmutableArrayBuilder < string > . Rent ( ) ;
113
112
using ImmutableArrayBuilder < string > notifiedCommandNames = ImmutableArrayBuilder < string > . Rent ( ) ;
114
113
using ImmutableArrayBuilder < AttributeInfo > forwardedAttributes = ImmutableArrayBuilder < AttributeInfo > . Rent ( ) ;
115
114
@@ -131,12 +130,6 @@ public static bool TryGetInfo(
131
130
132
131
token . ThrowIfCancellationRequested ( ) ;
133
132
134
- // Track the property changing event for the property, if the type supports it
135
- if ( shouldInvokeOnPropertyChanging )
136
- {
137
- propertyChangingNames . Add ( propertyName ) ;
138
- }
139
-
140
133
// The current property is always notified
141
134
propertyChangedNames . Add ( propertyName ) ;
142
135
@@ -296,12 +289,24 @@ public static bool TryGetInfo(
296
289
297
290
token . ThrowIfCancellationRequested ( ) ;
298
291
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
+
299
304
propertyInfo = new PropertyInfo (
300
305
typeNameWithNullabilityAnnotations ,
301
306
fieldName ,
302
307
propertyName ,
303
- propertyChangingNames . ToImmutable ( ) ,
304
- propertyChangedNames . ToImmutable ( ) ,
308
+ effectivePropertyChangingNames ,
309
+ effectivePropertyChangedNames ,
305
310
notifiedCommandNames . ToImmutable ( ) ,
306
311
notifyRecipients ,
307
312
notifyDataErrorInfo ,
0 commit comments