internal CodeExecutionPathGenerator WithLazyLoadingDatabaseAccessingMethodCall()
        {
            GetDatabaseAccessingMethodCall();

            var entityDeclarationsLoadedByDbCall = new List <DatabaseEntityDeclaration <FakeORMToolType> >()
            {
                customerEntityDeclaration
            };

            dbAccessingMethodCall.SetLoadedEntityDeclarations(entityDeclarationsLoadedByDbCall);

            _codeExecutionPath.AddModel(dbAccessingMethodCall);
            return(this);
        }
Esempio n. 2
0
        private async Task GetInitialCodeExecutionPaths(Solution solution, IProgress <ExtractionProgress> progressIndicator)
        {
            Dictionary <MethodDeclarationSyntax, HashSet <ISymbol> > methodDecAndTheirSymbolsContainingDbAccessingMethodCalls = GetMethodDeclarationsAndTheirSymbolsForDbAccessingMethodCalls();

            //int totalForProgress = GetTotalAmountForProgress(solution, methodDecAndTheirSymbolsContainingDbAccessingMethodCalls);
            //int counter = 0;

            foreach (var project in solution.Projects)
            {
                foreach (var document in project.Documents)
                {
                    // counter++;
                    //progressIndicator.Report(new ExtractionProgress(counter * 100 / totalForProgress));

                    SyntaxNode root = await document.GetSyntaxRootAsync();

                    SemanticModel semanticModel = await document.GetSemanticModelAsync();

                    var invocations = root.DescendantNodes().OfType <InvocationExpressionSyntax>();
                    foreach (var methodDeclarationAndSymbol in methodDecAndTheirSymbolsContainingDbAccessingMethodCalls)
                    {
                        if (invocations != null && invocations.Count() > 0)
                        {
                            foreach (var symbolToMethodDeclarationOnClassOrInterface in methodDeclarationAndSymbol.Value)
                            {
                                var methodInvocations = invocations.Where(i => semanticModel.GetSymbolInfo(i).Symbol == symbolToMethodDeclarationOnClassOrInterface);
                                foreach (var invocation in methodInvocations)
                                {
                                    var methodCall = new MethodCall(methodDeclarationAndSymbol.Key, invocation.GetCompilationInfo(semanticModel));

                                    CodeExecutionPath codeExecutionPath = new CodeExecutionPath();
                                    codeExecutionPath.AddModel(methodCall);

                                    CodeExecutionPaths.Add(codeExecutionPath);
                                }
                            }
                        }
                    }
                }
            }
        }