Skip to content

Commit ca0dc71

Browse files
committed
CoerceValueCallback
1 parent 0454bbf commit ca0dc71

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
@@ -84,7 +84,7 @@ context.Node is ObjectCreationExpressionSyntax objectCreation &&
8484
}
8585

8686
if (propertyMetadata.CoerceValueArgument is { } coerceValueArgument &&
87-
Callback.Match(coerceValueArgument, KnownSymbols.CoerceValueCallback, context.SemanticModel, context.CancellationToken) is { Identifier: { } coerceNode, Target: { } coerce })
87+
CoerceValueCallback.Match(coerceValueArgument, context.SemanticModel, context.CancellationToken) is { Identifier: { } coerceNode, Target: { } coerce })
8888
{
8989
if (TypeSymbolComparer.Equal(coerce.ContainingType, context.ContainingSymbol.ContainingType) &&
9090
!coerce.Name.IsParts("Coerce", registeredName))
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 CoerceValueCallback
8+
{
9+
internal readonly IdentifierNameSyntax Identifier;
10+
internal readonly IMethodSymbol Target;
11+
12+
internal CoerceValueCallback(IdentifierNameSyntax identifier, IMethodSymbol target)
13+
{
14+
this.Identifier = identifier;
15+
this.Target = target;
16+
}
17+
18+
internal static CoerceValueCallback? Match(ArgumentSyntax callback, SemanticModel semanticModel, CancellationToken cancellationToken)
19+
{
20+
if (Callback.Match(callback, KnownSymbols.CoerceValueCallback, semanticModel, cancellationToken) is { } match)
21+
{
22+
return new CoerceValueCallback(match.Identifier, match.Target);
23+
}
24+
25+
return null;
26+
}
27+
}

0 commit comments

Comments
 (0)