Skip to content

Commit a7d20a2

Browse files
committed
PropertyChangedCallback
1 parent e0941d1 commit a7d20a2

2 files changed

Lines changed: 28 additions & 1 deletion

File tree

WpfAnalyzers/Analyzers/PropertyMetadataAnalyzer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ context.Node is ObjectCreationExpressionSyntax objectCreation &&
3838
if (propertyMetadata.FindRegisteredName(context.SemanticModel, context.CancellationToken) is { Value: { } registeredName })
3939
{
4040
if (propertyMetadata.PropertyChangedArgument is { } propertyChangeArgument &&
41-
Callback.Match(propertyChangeArgument, KnownSymbols.PropertyChangedCallback, context.SemanticModel, context.CancellationToken) is { Identifier: { } onPropertyChangedNode, Target: { } onPropertyChanged })
41+
PropertyChangedCallback.Match(propertyChangeArgument, context.SemanticModel, context.CancellationToken) is { Identifier: { } onPropertyChangedNode, Target: { } onPropertyChanged })
4242
{
4343
if (TypeSymbolComparer.Equal(onPropertyChanged.ContainingType, context.ContainingSymbol.ContainingType) &&
4444
!onPropertyChanged.Name.IsParts("On", registeredName, "Changed") &&
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
namespace WpfAnalyzers;
2+
3+
using System.Threading;
4+
using Microsoft.CodeAnalysis;
5+
using Microsoft.CodeAnalysis.CSharp.Syntax;
6+
7+
internal readonly struct PropertyChangedCallback
8+
{
9+
internal readonly IdentifierNameSyntax Identifier;
10+
internal readonly IMethodSymbol Target;
11+
12+
internal PropertyChangedCallback(IdentifierNameSyntax identifier, IMethodSymbol target)
13+
{
14+
this.Identifier = identifier;
15+
this.Target = target;
16+
}
17+
18+
internal static PropertyChangedCallback? Match(ArgumentSyntax callback, SemanticModel semanticModel, CancellationToken cancellationToken)
19+
{
20+
if (Callback.Match(callback, KnownSymbols.PropertyChangedCallback, semanticModel, cancellationToken) is { } match)
21+
{
22+
return new PropertyChangedCallback(match.Identifier, match.Target);
23+
}
24+
25+
return null;
26+
}
27+
}

0 commit comments

Comments
 (0)