Exemplo n.º 1
0
 private void StepIntoExtensionMethod(InvocationExpressionSyntax node, InvokedMethod method)
 {
     if (context.Collector.IsExtensionMethodAlreadyCollected(method.Method, method.ArgumentTypes.First()?.Type))
     {
         StepOverExtensionMethod(node, method.Method, method.ArgumentTypes.First()?.Type);
     }
     else
     {
         context.Collector.StepIntoExtensionMethod(method.Method, method.ArgumentTypes.First()?.Type);
         var visitor = new InvocationTreeAnalyzer(context, method.DeclaringSyntaxReference.SyntaxTree.GetSemanticModel(context),
                                                  new InvokedMethod(method.Method, method.TargetType, method.ArgumentTypes, method.DeclaringSyntaxReference));
         visitor.Visit(method.DeclaringSyntaxReference.GetSyntax());
         context.Collector.StepOut();
     }
 }
 private SyntaxNode StepInto(InvocationExpressionSyntax node, InvokedMethod method)
 {
     if (context.Collector.IsAlreadyCollected(method.Method))
     {
         return(StepOver(node, method.Method));
     }
     else
     {
         context.Collector.StepInto(method.Method);
         var visitor = new InvocationTreeAnalyzer(context, method.DeclaringSyntaxReference.SyntaxTree.GetSemanticModel(context),
                                                  new InvokedMethod(method.Method, method.TargetType, method.ArgumentTypes, method.DeclaringSyntaxReference));
         visitor.Visit(method.DeclaringSyntaxReference.GetSyntax());
         context.Collector.StepOut();
         return(node);
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="InvocationTreeAnalyzer"/> class.
 /// </summary>
 /// <param name="context">The <see cref="AnalyzeContext"/> tracking information regarding the analysis.</param>
 /// <param name="model">A <see cref="SemanticModel"/> for the code being analyzed.</param>
 /// <param name="invokedMethod">An <see cref="InvokedMethod"/> instance that represents the method currently being analyzed.</param>
 public InvocationTreeAnalyzer(AnalyzeContext context, SemanticModel model, InvokedMethod?invokedMethod)
 {
     this.context       = context;
     this.model         = model;
     this.invokedMethod = invokedMethod.GetValueOrDefault();
 }