Skip to content

Commit 0267515

Browse files
committed
Rename [NotifyRecipients] to [NotifyPropertyChangedRecipients]
1 parent 32285a1 commit 0267515

File tree

7 files changed

+86
-86
lines changed

7 files changed

+86
-86
lines changed

CommunityToolkit.Mvvm.SourceGenerators/ComponentModel/Models/PropertyInfo.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ namespace CommunityToolkit.Mvvm.SourceGenerators.ComponentModel.Models;
2020
/// <param name="PropertyChangingNames">The sequence of property changing properties to notify.</param>
2121
/// <param name="PropertyChangedNames">The sequence of property changed properties to notify.</param>
2222
/// <param name="NotifiedCommandNames">The sequence of commands to notify.</param>
23-
/// <param name="NotifyRecipients">Whether or not the generated property also broadcasts changes.</param>
23+
/// <param name="NotifyPropertyChangedRecipients">Whether or not the generated property also broadcasts changes.</param>
2424
/// <param name="NotifyDataErrorInfo">Whether or not the generated property also validates its value.</param>
2525
/// <param name="ForwardedAttributes">The sequence of forwarded attributes for the generated property.</param>
2626
internal sealed record PropertyInfo(
@@ -30,7 +30,7 @@ internal sealed record PropertyInfo(
3030
ImmutableArray<string> PropertyChangingNames,
3131
ImmutableArray<string> PropertyChangedNames,
3232
ImmutableArray<string> NotifiedCommandNames,
33-
bool NotifyRecipients,
33+
bool NotifyPropertyChangedRecipients,
3434
bool NotifyDataErrorInfo,
3535
ImmutableArray<AttributeInfo> ForwardedAttributes)
3636
{
@@ -48,7 +48,7 @@ protected override void AddToHashCode(ref HashCode hashCode, PropertyInfo obj)
4848
hashCode.AddRange(obj.PropertyChangingNames);
4949
hashCode.AddRange(obj.PropertyChangedNames);
5050
hashCode.AddRange(obj.NotifiedCommandNames);
51-
hashCode.Add(obj.NotifyRecipients);
51+
hashCode.Add(obj.NotifyPropertyChangedRecipients);
5252
hashCode.Add(obj.NotifyDataErrorInfo);
5353
hashCode.AddRange(obj.ForwardedAttributes, AttributeInfo.Comparer.Default);
5454
}
@@ -63,7 +63,7 @@ protected override bool AreEqual(PropertyInfo x, PropertyInfo y)
6363
x.PropertyChangingNames.SequenceEqual(y.PropertyChangingNames) &&
6464
x.PropertyChangedNames.SequenceEqual(y.PropertyChangedNames) &&
6565
x.NotifiedCommandNames.SequenceEqual(y.NotifiedCommandNames) &&
66-
x.NotifyRecipients == y.NotifyRecipients &&
66+
x.NotifyPropertyChangedRecipients == y.NotifyPropertyChangedRecipients &&
6767
x.NotifyDataErrorInfo == y.NotifyDataErrorInfo &&
6868
x.ForwardedAttributes.SequenceEqual(y.ForwardedAttributes, AttributeInfo.Comparer.Default);
6969
}

CommunityToolkit.Mvvm.SourceGenerators/ComponentModel/ObservablePropertyGenerator.Execute.cs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ internal static class Execute
9191
ImmutableArray<AttributeInfo>.Builder forwardedAttributes = ImmutableArray.CreateBuilder<AttributeInfo>();
9292
bool notifyRecipients = false;
9393
bool notifyDataErrorInfo = false;
94-
bool hasOrInheritsClassLevelNotifyRecipients = false;
94+
bool hasOrInheritsClassLevelNotifyPropertyChangedRecipients = false;
9595
bool hasOrInheritsClassLevelNotifyDataErrorInfo = false;
9696
bool hasAnyValidationAttributes = false;
9797

@@ -104,11 +104,11 @@ internal static class Execute
104104
// The current property is always notified
105105
propertyChangedNames.Add(propertyName);
106106

107-
// Get the class-level [NotifyRecipients] setting, if any
107+
// Get the class-level [NotifyPropertyChangedRecipients] setting, if any
108108
if (TryGetIsNotifyingRecipients(fieldSymbol, out bool isBroadcastTargetValid))
109109
{
110110
notifyRecipients = isBroadcastTargetValid;
111-
hasOrInheritsClassLevelNotifyRecipients = true;
111+
hasOrInheritsClassLevelNotifyPropertyChangedRecipients = true;
112112
}
113113

114114
// Get the class-level [NotifyDataErrorInfo] setting, if any
@@ -129,7 +129,7 @@ internal static class Execute
129129
}
130130

131131
// Check whether the property should also notify recipients
132-
if (TryGetIsNotifyingRecipients(fieldSymbol, attributeData, builder, hasOrInheritsClassLevelNotifyRecipients, out isBroadcastTargetValid))
132+
if (TryGetIsNotifyingRecipients(fieldSymbol, attributeData, builder, hasOrInheritsClassLevelNotifyPropertyChangedRecipients, out isBroadcastTargetValid))
133133
{
134134
notifyRecipients = isBroadcastTargetValid;
135135

@@ -424,10 +424,10 @@ bool IsCommandNameValidWithGeneratedMembers(string commandName)
424424
/// </summary>
425425
/// <param name="fieldSymbol">The input <see cref="IFieldSymbol"/> instance to process.</param>
426426
/// <param name="isBroadcastTargetValid">Whether or not the the property is in a valid target that can notify recipients.</param>
427-
/// <returns>Whether or not the generated property for <paramref name="fieldSymbol"/> is in a type annotated with <c>[NotifyRecipients]</c>.</returns>
427+
/// <returns>Whether or not the generated property for <paramref name="fieldSymbol"/> is in a type annotated with <c>[NotifyPropertyChangedRecipients]</c>.</returns>
428428
private static bool TryGetIsNotifyingRecipients(IFieldSymbol fieldSymbol, out bool isBroadcastTargetValid)
429429
{
430-
if (fieldSymbol.ContainingType?.HasOrInheritsAttributeWithFullyQualifiedName("global::CommunityToolkit.Mvvm.ComponentModel.NotifyRecipientsAttribute") == true)
430+
if (fieldSymbol.ContainingType?.HasOrInheritsAttributeWithFullyQualifiedName("global::CommunityToolkit.Mvvm.ComponentModel.NotifyPropertyChangedRecipientsAttribute") == true)
431431
{
432432
// If the containing type is valid, track it
433433
if (fieldSymbol.ContainingType.InheritsFromFullyQualifiedName("global::CommunityToolkit.Mvvm.ComponentModel.ObservableRecipient") ||
@@ -456,23 +456,23 @@ private static bool TryGetIsNotifyingRecipients(IFieldSymbol fieldSymbol, out bo
456456
/// <param name="fieldSymbol">The input <see cref="IFieldSymbol"/> instance to process.</param>
457457
/// <param name="attributeData">The <see cref="AttributeData"/> instance for <paramref name="fieldSymbol"/>.</param>
458458
/// <param name="diagnostics">The current collection of gathered diagnostics.</param>
459-
/// <param name="hasOrInheritsClassLevelNotifyRecipients">Indicates wether the containing type of <paramref name="fieldSymbol"/> has or inherits <c>[NotifyRecipients]</c>.</param>
459+
/// <param name="hasOrInheritsClassLevelNotifyPropertyChangedRecipients">Indicates wether the containing type of <paramref name="fieldSymbol"/> has or inherits <c>[NotifyPropertyChangedRecipients]</c>.</param>
460460
/// <param name="isBroadcastTargetValid">Whether or not the the property is in a valid target that can notify recipients.</param>
461-
/// <returns>Whether or not the generated property for <paramref name="fieldSymbol"/> used <c>[NotifyRecipients]</c>.</returns>
461+
/// <returns>Whether or not the generated property for <paramref name="fieldSymbol"/> used <c>[NotifyPropertyChangedRecipients]</c>.</returns>
462462
private static bool TryGetIsNotifyingRecipients(
463463
IFieldSymbol fieldSymbol,
464464
AttributeData attributeData,
465465
ImmutableArray<Diagnostic>.Builder diagnostics,
466-
bool hasOrInheritsClassLevelNotifyRecipients,
466+
bool hasOrInheritsClassLevelNotifyPropertyChangedRecipients,
467467
out bool isBroadcastTargetValid)
468468
{
469-
if (attributeData.AttributeClass?.HasFullyQualifiedName("global::CommunityToolkit.Mvvm.ComponentModel.NotifyRecipientsAttribute") == true)
469+
if (attributeData.AttributeClass?.HasFullyQualifiedName("global::CommunityToolkit.Mvvm.ComponentModel.NotifyPropertyChangedRecipientsAttribute") == true)
470470
{
471471
// Emit a diagnostic if the attribute is unnecessary
472-
if (hasOrInheritsClassLevelNotifyRecipients)
472+
if (hasOrInheritsClassLevelNotifyPropertyChangedRecipients)
473473
{
474474
diagnostics.Add(
475-
UnnecessaryNotifyRecipientsAttributeOnFieldWarning,
475+
UnnecessaryNotifyPropertyChangedRecipientsAttributeOnFieldWarning,
476476
fieldSymbol,
477477
fieldSymbol.ContainingType,
478478
fieldSymbol.Name);
@@ -489,7 +489,7 @@ private static bool TryGetIsNotifyingRecipients(
489489

490490
// Otherwise just emit the diagnostic and then ignore the attribute
491491
diagnostics.Add(
492-
InvalidContainingTypeForNotifyRecipientsFieldError,
492+
InvalidContainingTypeForNotifyPropertyChangedRecipientsFieldError,
493493
fieldSymbol,
494494
fieldSymbol.ContainingType,
495495
fieldSymbol.Name);
@@ -505,7 +505,7 @@ private static bool TryGetIsNotifyingRecipients(
505505
}
506506

507507
/// <summary>
508-
/// Checks whether a given type using <c>[NotifyRecipients]</c> is valid and creates a <see cref="Diagnostic"/> if not.
508+
/// Checks whether a given type using <c>[NotifyPropertyChangedRecipients]</c> is valid and creates a <see cref="Diagnostic"/> if not.
509509
/// </summary>
510510
/// <param name="typeSymbol">The input <see cref="INamedTypeSymbol"/> instance to process.</param>
511511
/// <returns>The <see cref="Diagnostic"/> for <paramref name="typeSymbol"/>, if not a valid type.</returns>
@@ -516,7 +516,7 @@ private static bool TryGetIsNotifyingRecipients(
516516
!typeSymbol.HasOrInheritsAttributeWithFullyQualifiedName("global::CommunityToolkit.Mvvm.ComponentModel.ObservableRecipientAttribute"))
517517
{
518518
return Diagnostic.Create(
519-
InvalidTypeForNotifyRecipientsError,
519+
InvalidTypeForNotifyPropertyChangedRecipientsError,
520520
typeSymbol.Locations.FirstOrDefault(),
521521
typeSymbol);
522522
}
@@ -671,7 +671,7 @@ public static MemberDeclarationSyntax GetPropertySyntax(PropertyInfo propertyInf
671671
string name => IdentifierName(name)
672672
};
673673

674-
if (propertyInfo.NotifyRecipients)
674+
if (propertyInfo.NotifyPropertyChangedRecipients)
675675
{
676676
// If broadcasting changes are required, also store the old value.
677677
// This code generates a statement as follows:
@@ -769,7 +769,7 @@ public static MemberDeclarationSyntax GetPropertySyntax(PropertyInfo propertyInf
769769
}
770770

771771
// Also broadcast the change, if requested
772-
if (propertyInfo.NotifyRecipients)
772+
if (propertyInfo.NotifyPropertyChangedRecipients)
773773
{
774774
// This code generates a statement as follows:
775775
//

CommunityToolkit.Mvvm.SourceGenerators/ComponentModel/ObservablePropertyGenerator.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,13 @@ public void Initialize(IncrementalGeneratorInitializationContext context)
3838
fieldSymbols
3939
.Where(static item => item.HasAttributeWithFullyQualifiedName("global::CommunityToolkit.Mvvm.ComponentModel.ObservablePropertyAttribute"));
4040

41-
// Get diagnostics for fields using [NotifyPropertyChangedFor], [NotifyCanExecuteChangedFor], [NotifyRecipients] and [NotifyDataErrorInfo], but not [ObservableProperty]
41+
// Get diagnostics for fields using [NotifyPropertyChangedFor], [NotifyCanExecuteChangedFor], [NotifyPropertyChangedRecipients] and [NotifyDataErrorInfo], but not [ObservableProperty]
4242
IncrementalValuesProvider<Diagnostic> fieldSymbolsWithOrphanedDependentAttributeWithErrors =
4343
fieldSymbols
4444
.Where(static item =>
4545
(item.HasAttributeWithFullyQualifiedName("global::CommunityToolkit.Mvvm.ComponentModel.NotifyPropertyChangedForAttribute") ||
4646
item.HasAttributeWithFullyQualifiedName("global::CommunityToolkit.Mvvm.ComponentModel.NotifyCanExecuteChangedForAttribute") ||
47-
item.HasAttributeWithFullyQualifiedName("global::CommunityToolkit.Mvvm.ComponentModel.NotifyRecipientsAttribute") ||
47+
item.HasAttributeWithFullyQualifiedName("global::CommunityToolkit.Mvvm.ComponentModel.NotifyPropertyChangedRecipientsAttribute") ||
4848
item.HasAttributeWithFullyQualifiedName("global::CommunityToolkit.Mvvm.ComponentModel.NotifyDataErrorInfoAttribute")) &&
4949
!item.HasAttributeWithFullyQualifiedName("global::CommunityToolkit.Mvvm.ComponentModel.ObservablePropertyAttribute"))
5050
.Select(static (item, _) => Execute.GetDiagnosticForFieldWithOrphanedDependentAttributes(item));
@@ -143,14 +143,14 @@ public void Initialize(IncrementalGeneratorInitializationContext context)
143143
static (node, _) => node is ClassDeclarationSyntax { AttributeLists.Count: > 0 },
144144
static (context, _) => (INamedTypeSymbol)context.SemanticModel.GetDeclaredSymbol(context.Node)!);
145145

146-
// Filter only the type symbols with [NotifyRecipients] and create diagnostics for them
146+
// Filter only the type symbols with [NotifyPropertyChangedRecipients] and create diagnostics for them
147147
IncrementalValuesProvider<Diagnostic> notifyRecipientsErrors =
148148
classSymbols
149-
.Where(static item => item.HasAttributeWithFullyQualifiedName("global::CommunityToolkit.Mvvm.ComponentModel.NotifyRecipientsAttribute"))
149+
.Where(static item => item.HasAttributeWithFullyQualifiedName("global::CommunityToolkit.Mvvm.ComponentModel.NotifyPropertyChangedRecipientsAttribute"))
150150
.Select(static (item, _) => Execute.GetIsNotifyingRecipientsDiagnosticForType(item))
151151
.Where(static item => item is not null)!;
152152

153-
// Output the diagnostics for [NotifyRecipients]
153+
// Output the diagnostics for [NotifyPropertyChangedRecipients]
154154
context.ReportDiagnostics(notifyRecipientsErrors);
155155

156156
// Filter only the type symbols with [NotifyDataErrorInfo] and create diagnostics for them

0 commit comments

Comments
 (0)