@@ -91,12 +91,19 @@ internal static class Execute
9191 {
9292 // Gather dependent property and command names
9393 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 ) )
9695 {
9796 continue ;
9897 }
9998
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+
100107 // Track the current validation attribute, if applicable
101108 if ( attributeData . AttributeClass ? . InheritsFromFullyQualifiedName ( "global::System.ComponentModel.DataAnnotations.ValidationAttribute" ) == true )
102109 {
@@ -332,21 +339,21 @@ bool IsCommandNameValidWithGeneratedMembers(string commandName)
332339 /// <param name="fieldSymbol">The input <see cref="IFieldSymbol"/> instance to process.</param>
333340 /// <param name="attributeData">The <see cref="AttributeData"/> instance for <paramref name="fieldSymbol"/>.</param>
334341 /// <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>
336343 /// <returns>Whether or not the generated property for <paramref name="fieldSymbol"/> used <c>[AlsoBroadcastChange]</c>.</returns>
337344 private static bool TryGetIsBroadcastingChanges (
338345 IFieldSymbol fieldSymbol ,
339346 AttributeData attributeData ,
340347 ImmutableArray < Diagnostic > . Builder diagnostics ,
341- out bool alsoBroadcastChange )
348+ out bool isBroadcastTargetValid )
342349 {
343350 if ( attributeData . AttributeClass ? . HasFullyQualifiedName ( "global::CommunityToolkit.Mvvm.ComponentModel.AlsoBroadcastChangeAttribute" ) == true )
344351 {
345352 // If the containing type is valid, track it
346353 if ( fieldSymbol . ContainingType . InheritsFromFullyQualifiedName ( "global::CommunityToolkit.Mvvm.ComponentModel.ObservableRecipient" ) ||
347354 fieldSymbol . ContainingType . HasOrInheritsAttributeWithFullyQualifiedName ( "global::CommunityToolkit.Mvvm.ComponentModel.ObservableRecipientAttribute" ) )
348355 {
349- alsoBroadcastChange = true ;
356+ isBroadcastTargetValid = true ;
350357
351358 return true ;
352359 }
@@ -358,12 +365,12 @@ private static bool TryGetIsBroadcastingChanges(
358365 fieldSymbol . ContainingType ,
359366 fieldSymbol . Name ) ;
360367
361- alsoBroadcastChange = false ;
368+ isBroadcastTargetValid = false ;
362369
363370 return true ;
364371 }
365372
366- alsoBroadcastChange = false ;
373+ isBroadcastTargetValid = false ;
367374
368375 return false ;
369376 }
0 commit comments