Exemple #1
0
        private async void MainWindow_Loaded(object sender, RoutedEventArgs e)
        {
            MSBuildLocator.RegisterDefaults();

            this.flowGraphConverter   = new FlowToMsaglGraphConverter();
            this.csharpGraphConverter = new CSharpBuildToMsaglGraphConverter();
            this.heapGraphConverter   = new HeapToMsaglGraphConverter();

            this.aglGraphViewer = new GraphViewer()
            {
                LayoutEditingEnabled = false
            };
            this.aglGraphViewer.BindToPanel(this.graphViewerPanel);
            this.aglGraphViewer.MouseDown += this.AglGraphViewer_MouseDown;

            this.aglHeapViewer = new GraphViewer()
            {
                LayoutEditingEnabled = false
            };
            this.aglHeapViewer.BindToPanel(this.heapViewerPanel);

            // Symbolic CFGs
            this.sampleGraphProvider               = new TestFlowGraphProvider(typeof(SampleFlowGraphGenerator));
            this.graphSelectionCombo.ItemsSource   = this.sampleGraphProvider.GeneratedMethodLocations;
            this.graphSelectionCombo.SelectedIndex = 0;

            // C# CFGs built from the syntax trees of the sample methods
            var args = Environment.GetCommandLineArgs();

            if (args.Length >= 2 && File.Exists(args[1]))
            {
                string file   = args[1];
                string suffix = System.IO.Path.GetExtension(file);
                if (suffix == ".cs")
                {
                    this.csharpWorkspace = SampleCSharpWorkspaceProvider.CreateWorkspaceFromSingleFile(file);
                }
                else if (suffix == ".csproj")
                {
                    this.csharpWorkspace = MSBuildWorkspace.Create();
                    var project = await((MSBuildWorkspace)this.csharpWorkspace).OpenProjectAsync(file);
                }
            }

            if (this.csharpWorkspace == null)
            {
                this.csharpMethodTab.IsEnabled = false;
            }
            else
            {
                this.foundPathsView.ItemsSource = this.foundPaths;
                this.cliModelManager            = new TypeModelManager();
                this.csharpGraphDepth           = GraphDepth.Statement;

                this.documentSelectionCombo.ItemsSource = this.csharpWorkspace.CurrentSolution.Projects
                                                          .SelectMany(project => project.Documents)
                                                          .ToArray();
            }
        }
        public CSharpGraphBuilder(
            TypeModelManager modelManager,
            DocumentId documentId,
            SemanticModel semanticModel,
            BaseMethodDeclarationSyntax methodSyntax)
        {
            Contract.Requires <ArgumentNullException>(modelManager != null, nameof(modelManager));
            Contract.Requires <ArgumentNullException>(documentId != null, nameof(documentId));
            Contract.Requires <ArgumentNullException>(semanticModel != null, nameof(semanticModel));
            Contract.Requires <ArgumentNullException>(methodSyntax != null, nameof(methodSyntax));

            this.modelManager  = modelManager;
            this.documentId    = documentId;
            this.semanticModel = semanticModel;
            this.methodSyntax  = methodSyntax;

            this.DisplayGraph = new DisplayGraph(this.documentId);
        }
 public TypeContext(TypeModelManager modelManager)
 {
     this.modelManager = modelManager;
 }