Skip to content

Commit

Permalink
[GH-153] - AsyncReceivedInOrderCallbackAnalyzer using operation API
Browse files Browse the repository at this point in the history
  • Loading branch information
tpodolak committed Dec 20, 2020
1 parent 0912c72 commit 4c80162
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,16 @@ protected sealed override void InitializeAnalyzer(AnalysisContext context)

private void AnalyzeInvocation(SyntaxNodeAnalysisContext syntaxNodeContext)
{
var invocationExpression = syntaxNodeContext.Node;
var methodSymbolInfo = syntaxNodeContext.SemanticModel.GetSymbolInfo(invocationExpression);

if (methodSymbolInfo.Symbol?.Kind != SymbolKind.Method)
if (!(syntaxNodeContext.SemanticModel.GetOperation(syntaxNodeContext.Node) is IInvocationOperation invocationOperation))
{
return;
}

if (methodSymbolInfo.Symbol.IsReceivedInOrderMethod() == false)
if (invocationOperation.TargetMethod.IsReceivedInOrderMethod() == false)
{
return;
return;
}

var invocationOperation =
(IInvocationOperation)syntaxNodeContext.SemanticModel.GetOperation(invocationExpression);

foreach (var argument in invocationOperation.Arguments)
{
var asyncToken = GetCallbackArgumentSyntaxTokens(argument.Value.Syntax)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@ protected AbstractNonSubstitutableMemberAnalyzer(
{
_analyzeInvocationAction = AnalyzeInvocation;
_substitutionNodeFinder = substitutionNodeFinder;
SupportedDiagnostics = ImmutableArray.Create(DiagnosticDescriptorsProvider.NonVirtualSetupSpecification, DiagnosticDescriptorsProvider.InternalSetupSpecification);
NonVirtualSetupDescriptor = diagnosticDescriptorsProvider.NonVirtualSetupSpecification;
SupportedDiagnostics = ImmutableArray.Create(
DiagnosticDescriptorsProvider.NonVirtualSetupSpecification,
DiagnosticDescriptorsProvider.InternalSetupSpecification);
}

protected override DiagnosticDescriptor NonVirtualSetupDescriptor { get; }
Expand Down

0 comments on commit 4c80162

Please sign in to comment.