예제 #1
0
            private void NoteRegisterActionInvocation(IMethodSymbol method, TInvocationExpressionSyntax invocation, SemanticModel model, CancellationToken cancellationToken)
            {
                if (method.ContainingType.Equals(_analysisContext))
                {
                    // Not a nested action.
                    return;
                }

                SyntaxNode receiver = GetInvocationReceiver(invocation);

                if (receiver == null)
                {
                    return;
                }

                // Get the context parameter on which we are registering an action.
                var contextParameter = model.GetSymbolInfo(receiver, cancellationToken).Symbol as IParameterSymbol;

                if (contextParameter == null)
                {
                    return;
                }

                // Check if we are bailing out on this context parameter.
                if (_startAnalysisContextParamsToSkip != null && _startAnalysisContextParamsToSkip.Contains(contextParameter))
                {
                    return;
                }

                _nestedActionsMap = _nestedActionsMap ?? new Dictionary <IParameterSymbol, List <NodeAndSymbol> >();
                List <NodeAndSymbol> registerInvocations;

                if (!_nestedActionsMap.TryGetValue(contextParameter, out registerInvocations))
                {
                    registerInvocations = new List <NodeAndSymbol>();
                }

                registerInvocations.Add(new NodeAndSymbol {
                    Invocation = invocation, Method = method
                });
                _nestedActionsMap[contextParameter] = registerInvocations;
            }
 protected abstract SyntaxNode GetInvocationReceiver(TInvocationExpressionSyntax invocation);
 protected abstract IEnumerable <SyntaxNode> GetArgumentExpressions(TInvocationExpressionSyntax invocation);