Skip to content

Commit 134058d

Browse files
committed
Renamed [AlsoNotifyFor] attribute to [AlsoNotifyChangeFor]
1 parent c5b9050 commit 134058d

File tree

5 files changed

+14
-14
lines changed

5 files changed

+14
-14
lines changed

Microsoft.Toolkit.Mvvm.SourceGenerators/ComponentModel/ObservablePropertyGenerator.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ private static PropertyDeclarationSyntax CreatePropertyDeclaration(
178178
typeName = fieldSymbol.Type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat),
179179
propertyName = GetGeneratedPropertyName(fieldSymbol);
180180

181-
INamedTypeSymbol alsoNotifyForAttributeSymbol = context.Compilation.GetTypeByMetadataName(typeof(AlsoNotifyForAttribute).FullName)!;
181+
INamedTypeSymbol alsoNotifyChangeForAttributeSymbol = context.Compilation.GetTypeByMetadataName(typeof(AlsoNotifyChangeForAttribute).FullName)!;
182182
INamedTypeSymbol? validationAttributeSymbol = context.Compilation.GetTypeByMetadataName("System.ComponentModel.DataAnnotations.ValidationAttribute");
183183

184184
List<StatementSyntax> dependentPropertyNotificationStatements = new();
@@ -187,7 +187,7 @@ private static PropertyDeclarationSyntax CreatePropertyDeclaration(
187187
foreach (AttributeData attributeData in fieldSymbol.GetAttributes())
188188
{
189189
// Add dependent property notifications, if needed
190-
if (SymbolEqualityComparer.Default.Equals(attributeData.AttributeClass, alsoNotifyForAttributeSymbol))
190+
if (SymbolEqualityComparer.Default.Equals(attributeData.AttributeClass, alsoNotifyChangeForAttributeSymbol))
191191
{
192192
foreach (TypedConstant attributeArgument in attributeData.ConstructorArguments)
193193
{

Microsoft.Toolkit.Mvvm.SourceGenerators/Input/ICommandGenerator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ private static (string FieldName, string PropertyName) GetGeneratedFieldAndPrope
226226
{
227227
string propertyName = methodSymbol.Name;
228228

229-
if (SymbolEqualityComparer.Default.Equals(methodSymbol.ReturnType, context.Compilation.GetTypeByMetadataName("System.Threading.Tasks.Task")!) &&
229+
if (SymbolEqualityComparer.Default.Equals(methodSymbol.ReturnType, context.Compilation.GetTypeByMetadataName("System.Threading.Tasks.Task")) &&
230230
methodSymbol.Name.EndsWith("Async"))
231231
{
232232
propertyName = propertyName.Substring(0, propertyName.Length - "Async".Length);

Microsoft.Toolkit.Mvvm.SourceGenerators/Microsoft.Toolkit.Mvvm.SourceGenerators.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
</ItemGroup>
1515

1616
<ItemGroup>
17-
<Compile Include="..\Microsoft.Toolkit.Mvvm\ComponentModel\Attributes\AlsoNotifyForAttribute.cs" Link="Microsoft.Toolkit.Mvvm\ComponentModel\Attributes\AlsoNotifyForAttribute.cs" />
17+
<Compile Include="..\Microsoft.Toolkit.Mvvm\ComponentModel\Attributes\AlsoNotifyChangeForAttribute.cs" Link="Microsoft.Toolkit.Mvvm\ComponentModel\Attributes\AlsoNotifyChangeForAttribute.cs" />
1818
<Compile Include="..\Microsoft.Toolkit.Mvvm\ComponentModel\Attributes\INotifyPropertyChangedAttribute.cs" Link="Microsoft.Toolkit.Mvvm\ComponentModel\Attributes\INotifyPropertyChangedAttribute.cs" />
1919
<Compile Include="..\Microsoft.Toolkit.Mvvm\ComponentModel\Attributes\ObservableObjectAttribute.cs" Link="Microsoft.Toolkit.Mvvm\ComponentModel\Attributes\ObservableObjectAttribute.cs" />
2020
<Compile Include="..\Microsoft.Toolkit.Mvvm\ComponentModel\Attributes\ObservablePropertyAttribute.cs" Link="Microsoft.Toolkit.Mvvm\ComponentModel\Attributes\ObservablePropertyAttribute.cs" />

Microsoft.Toolkit.Mvvm/ComponentModel/Attributes/AlsoNotifyForAttribute.cs renamed to Microsoft.Toolkit.Mvvm/ComponentModel/Attributes/AlsoNotifyChangeForAttribute.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ namespace Microsoft.Toolkit.Mvvm.ComponentModel
2828
/// partial class MyViewModel : ObservableObject
2929
/// {
3030
/// [ObservableProperty]
31-
/// [AlsoNotifyFor(nameof(FullName))]
31+
/// [AlsoNotifyChangeFor(nameof(FullName))]
3232
/// private string name;
3333
///
3434
/// [ObservableProperty]
35-
/// [AlsoNotifyFor(nameof(FullName))]
35+
/// [AlsoNotifyChangeFor(nameof(FullName))]
3636
/// private string surname;
3737
///
3838
/// public string FullName => $"{Name} {Surname}";
@@ -64,26 +64,26 @@ namespace Microsoft.Toolkit.Mvvm.ComponentModel
6464
/// </code>
6565
/// </summary>
6666
[AttributeUsage(AttributeTargets.Field, AllowMultiple = false, Inherited = false)]
67-
public sealed class AlsoNotifyForAttribute : Attribute
67+
public sealed class AlsoNotifyChangeForAttribute : Attribute
6868
{
6969
/// <summary>
70-
/// Initializes a new instance of the <see cref="AlsoNotifyForAttribute"/> class.
70+
/// Initializes a new instance of the <see cref="AlsoNotifyChangeForAttribute"/> class.
7171
/// </summary>
7272
/// <param name="propertyName">The name of the property to also notify when the annotated property changes.</param>
73-
public AlsoNotifyForAttribute(string propertyName)
73+
public AlsoNotifyChangeForAttribute(string propertyName)
7474
{
7575
PropertyNames = new[] { propertyName };
7676
}
7777

7878
/// <summary>
79-
/// Initializes a new instance of the <see cref="AlsoNotifyForAttribute"/> class.
79+
/// Initializes a new instance of the <see cref="AlsoNotifyChangeForAttribute"/> class.
8080
/// </summary>
8181
/// <param name="propertyName">The name of the property to also notify when the annotated property changes.</param>
8282
/// <param name="otherPropertyNames">
8383
/// The other property names to also notify when the annotated property changes. This parameter can optionally
8484
/// be used to indicate a series of dependent properties from the same attribute, to keep the code more compact.
8585
/// </param>
86-
public AlsoNotifyForAttribute(string propertyName, string[] otherPropertyNames)
86+
public AlsoNotifyChangeForAttribute(string propertyName, string[] otherPropertyNames)
8787
{
8888
PropertyNames = new[] { propertyName }.Concat(otherPropertyNames).ToArray();
8989
}

UnitTests/UnitTests.NetCore/Mvvm/Test_ObservablePropertyAttribute.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public void Test_ObservablePropertyAttribute_Events()
5858

5959
[TestCategory("Mvvm")]
6060
[TestMethod]
61-
public void Test_AlsoNotifyForAttribute_Events()
61+
public void Test_AlsoNotifyChangeForAttribute_Events()
6262
{
6363
var model = new DependentPropertyModel();
6464

@@ -129,11 +129,11 @@ public partial class SampleModel : ObservableObject
129129
public sealed partial class DependentPropertyModel
130130
{
131131
[ObservableProperty]
132-
[AlsoNotifyFor(nameof(FullName))]
132+
[AlsoNotifyChangeFor(nameof(FullName))]
133133
private string? name;
134134

135135
[ObservableProperty]
136-
[AlsoNotifyFor(nameof(FullName))]
136+
[AlsoNotifyChangeFor(nameof(FullName))]
137137
private string? surname;
138138

139139
public string FullName => $"{Name} {Surname}";

0 commit comments

Comments
 (0)