@@ -91,12 +91,19 @@ internal static class Execute
91
91
{
92
92
// Gather dependent property and command names
93
93
if ( TryGatherDependentPropertyChangedNames ( fieldSymbol , attributeData , propertyChangedNames , builder ) ||
94
- TryGatherDependentCommandNames ( fieldSymbol , attributeData , notifiedCommandNames , builder ) ||
95
- TryGetIsBroadcastingChanges ( fieldSymbol , attributeData , builder , out alsoBroadcastChange ) )
94
+ TryGatherDependentCommandNames ( fieldSymbol , attributeData , notifiedCommandNames , builder ) )
96
95
{
97
96
continue ;
98
97
}
99
98
99
+ // Check whether the property should also broadcast changes
100
+ if ( TryGetIsBroadcastingChanges ( fieldSymbol , attributeData , builder , out bool isBroadcastTargetValid ) )
101
+ {
102
+ alsoBroadcastChange = isBroadcastTargetValid ;
103
+
104
+ continue ;
105
+ }
106
+
100
107
// Track the current validation attribute, if applicable
101
108
if ( attributeData . AttributeClass ? . InheritsFromFullyQualifiedName ( "global::System.ComponentModel.DataAnnotations.ValidationAttribute" ) == true )
102
109
{
@@ -332,21 +339,21 @@ bool IsCommandNameValidWithGeneratedMembers(string commandName)
332
339
/// <param name="fieldSymbol">The input <see cref="IFieldSymbol"/> instance to process.</param>
333
340
/// <param name="attributeData">The <see cref="AttributeData"/> instance for <paramref name="fieldSymbol"/>.</param>
334
341
/// <param name="diagnostics">The current collection of gathered diagnostics.</param>
335
- /// <param name="alsoBroadcastChange ">Whether or not the resulting property should also broadcast changes.</param>
342
+ /// <param name="isBroadcastTargetValid ">Whether or not the the property is in a valid target that can broadcast changes.</param>
336
343
/// <returns>Whether or not the generated property for <paramref name="fieldSymbol"/> used <c>[AlsoBroadcastChange]</c>.</returns>
337
344
private static bool TryGetIsBroadcastingChanges (
338
345
IFieldSymbol fieldSymbol ,
339
346
AttributeData attributeData ,
340
347
ImmutableArray < Diagnostic > . Builder diagnostics ,
341
- out bool alsoBroadcastChange )
348
+ out bool isBroadcastTargetValid )
342
349
{
343
350
if ( attributeData . AttributeClass ? . HasFullyQualifiedName ( "global::CommunityToolkit.Mvvm.ComponentModel.AlsoBroadcastChangeAttribute" ) == true )
344
351
{
345
352
// If the containing type is valid, track it
346
353
if ( fieldSymbol . ContainingType . InheritsFromFullyQualifiedName ( "global::CommunityToolkit.Mvvm.ComponentModel.ObservableRecipient" ) ||
347
354
fieldSymbol . ContainingType . HasOrInheritsAttributeWithFullyQualifiedName ( "global::CommunityToolkit.Mvvm.ComponentModel.ObservableRecipientAttribute" ) )
348
355
{
349
- alsoBroadcastChange = true ;
356
+ isBroadcastTargetValid = true ;
350
357
351
358
return true ;
352
359
}
@@ -358,12 +365,12 @@ private static bool TryGetIsBroadcastingChanges(
358
365
fieldSymbol . ContainingType ,
359
366
fieldSymbol . Name ) ;
360
367
361
- alsoBroadcastChange = false ;
368
+ isBroadcastTargetValid = false ;
362
369
363
370
return true ;
364
371
}
365
372
366
- alsoBroadcastChange = false ;
373
+ isBroadcastTargetValid = false ;
367
374
368
375
return false ;
369
376
}
0 commit comments