public static async Task Main(string[] args)
        {
            var cfgCtx = new ConfigContext(InterfaceResolverType.ProjectLevel);

            try
            {
                var options = new ProgramOptions(args);

                if (!string.IsNullOrEmpty(options.DemoCase))
                {
                    options.CreateDemoCase();
                }

                IDoLog logger      = new ConsoleLogger(verbose: options.VerboseLogging, debug: options.DebugLogging);
                var    msBuildPath = options.PathToMSBuild;
                if (string.IsNullOrEmpty(msBuildPath))
                {
                    msBuildPath = @"C:\Program Files\dotnet\sdk\2.2.103";
                    logger.Warning("No Path to MSBuild given falling back to " + msBuildPath);
                }
                using (var solutionAnalyzer = new SolutionAnalyzer(options.PathToSolution, msBuildPath, logger))
                {
                    await solutionAnalyzer.LoadSolution(options.ExcludingAssemblies);

                    var projectAnalyzer = new ProjectAnalyzer(solutionAnalyzer.ParsedSolution, solutionAnalyzer.OutputFiles, logger);
                    await projectAnalyzer.LoadProject(options.ProjectName);

                    var interfaceResolver = InterfaceResolverFactory.GetInterfaceResolver(solutionAnalyzer, projectAnalyzer, logger, cfgCtx);

                    var    sequenceDiagram = new SequenceDiagramGenerator(projectAnalyzer.AnalyzedClasses, interfaceResolver, logger);
                    string diagramText     = await sequenceDiagram.GetSequenceDiagramForMethod(options.ClassName, options.MethodName);

                    await WriteDiagramToFile(diagramText, options.OutputFile);

                    Console.WriteLine("Wrote to " + options.OutputFile);
                }
            }
            catch (InvalidOperationException ex)
            {
                Console.WriteLine(ex.Message);
            }

            Console.WriteLine("Finished...");
        }
示例#2
0
        public async Task <string> CreateDiagram(string msBuildPath, string className, string methodName, string excludingAssemblies)
        {
            var solutionDir = Path.Combine(GetTestDataPath(), _testDir, _solutionName);

            var    cfgCtx = new ConfigContext(InterfaceResolverType.ProjectLevel);
            IDoLog logger = new NullLogger();

            using (var solutionAnalyzer = new SolutionAnalyzer(solutionDir, msBuildPath, logger))
            {
                await solutionAnalyzer.LoadSolution(excludingAssemblies);

                var projectAnalyzer = new ProjectAnalyzer(solutionAnalyzer.ParsedSolution, solutionAnalyzer.OutputFiles, logger);
                await projectAnalyzer.LoadProject(_projectName);

                var interfaceResolver = InterfaceResolverFactory.GetInterfaceResolver(solutionAnalyzer, projectAnalyzer, logger, cfgCtx);

                var sequenceDiagram = new SequenceDiagramGenerator(projectAnalyzer.AnalyzedClasses, interfaceResolver, logger);
                return(await sequenceDiagram.GetSequenceDiagramForMethod(className, methodName));
            }
        }