예제 #1
0
        public AnalyzerViewModel(AnalyzerModel modelModel, NodeView nodeView)
        {
            _analyzerModelModel = modelModel;

            modelModel.PropertyChanged += model_PropertyChanged;
            InitializeDelegateCommands();
        }
예제 #2
0
        private void RunMappingTest(string resourceFileName, Platform platform)
        {
            var analyzerResult = RoslynCompiler.Run(resourceFileName, platform);

            AnalyzerModel analyzerModel = new AnalyzerModel()
            {
                CallGraph = analyzerResult.CallGraph
            };
            CodeModel codeModel = new CodeModel()
            {
                AnalyzerModel = analyzerModel
            };
            var cache = new Cache()
            {
                SemanticModel = analyzerResult.SemanticModel, SyntaxRoot = analyzerResult.SemanticModel.SyntaxTree.GetRoot()
            };

            foreach (SyntaxNode node in analyzerResult.SemanticModel.SyntaxTree.GetRoot().DescendantNodes())
            {
                var symbol = cache.SemanticModel.GetSymbolInfo(node).Symbol;
                if (symbol == null || (symbol.Kind != SymbolKind.Method && symbol.Kind != SymbolKind.Property && symbol.Kind != SymbolKind.NamedType))
                {
                    continue;
                }

                if ((symbol as IMethodSymbol)?.MethodKind == MethodKind.BuiltinOperator)
                {
                    continue;
                }

                if (symbol.Kind == SymbolKind.NamedType && node.FirstAncestorOrSelf <ObjectCreationExpressionSyntax>() == null || node.FirstAncestorOrSelf <TypeArgumentListSyntax>() != null)
                {
                    continue;
                }

                var method = codeModel.GetMethodCall(cache, node.Span);
                if (method == null)
                {
                    Console.WriteLine("Platform " + platform);
                    Console.WriteLine("No mapped Method found for " + node.ToString());
                    Console.WriteLine("Events:\r\n");
                    foreach (var e in analyzerResult.CallGraph.EventDetails)
                    {
                        Console.WriteLine(e.ToString());
                    }

                    Assert.Fail("No mapped Method found for " + node.ToString());
                }
            }
        }
예제 #3
0
 public AnalyzerView(AnalyzerModel Model, NodeView nodeView)
 {
     InitializeComponent();
 }