示例#1
0
        public void FindDirectoryFileConfig()
        {
            const String        someRepoPath                 = "C:\\SomeRepo";
            const String        someRepoConfigDirPath        = "C:\\Configs\\SomeRepoConfig";
            const String        someRepoConfigFilePath       = "C:\\Configs\\SomeRepoConfig\\porter.config";
            const String        someProjectPath              = "C:\\SomeRepo\\SomeProject";
            const String        someSubprojectPath           = "C:\\SomeRepo\\SomeProject\\SomeSubproject";
            const String        someSubprojectConfigDirPath  = "C:\\Configs\\SomeRepoConfig\\SomeSubprojectConfig";
            const String        someSubprojectConfigFilePath = "C:\\Configs\\SomeRepoConfig\\SomeSubprojectConfig\\porter.config";
            IList <SourceEntry> entries = new List <SourceEntry>
            {
                new SourceEntry(someRepoPath, someRepoConfigDirPath),
                new SourceEntry(someRepoPath, someRepoConfigFilePath),
                new SourceEntry(someProjectPath, ""),
                new SourceEntry(someSubprojectPath, someSubprojectConfigFilePath),
                new SourceEntry(someSubprojectPath, someSubprojectConfigDirPath),
                new SourceEntry("C:\\OtherRepo", "C:\\Configs\\OtherRepoConfig"),
                new SourceEntry("C:\\OtherRepo", "C:\\Configs\\OtherRepoConfig\\porter.config")
            };
            IConfigDataProvider configDataProvider = new ReadOnlyConfigDataProvider("C:\\AppSomeLocation", OutputLevel.Error, entries);

            Assert.AreEqual(someRepoConfigDirPath, ConfigFinder.FindConfig(configDataProvider, someRepoPath));
            Assert.AreEqual("", ConfigFinder.FindConfig(configDataProvider, someProjectPath));
            Assert.AreEqual(someSubprojectConfigFilePath, ConfigFinder.FindConfig(configDataProvider, someSubprojectPath));
            Assert.AreEqual(someRepoConfigDirPath, ConfigFinder.FindConfig(configDataProvider, someRepoPath + "\\OtherProject"));
            Assert.AreEqual("", ConfigFinder.FindConfig(configDataProvider, someProjectPath + "\\OtherSubproject"));
            Assert.AreEqual(someSubprojectConfigFilePath, ConfigFinder.FindConfig(configDataProvider, someSubprojectPath + "\\SomeInnerSubproject"));
            Assert.AreEqual("", ConfigFinder.FindConfig(configDataProvider, "C:\\AnotherRepo"));
        }
        private async Task ExecuteProjectsAnalysisImplAsync(IList <ProjectData> projects, ProjectsAnalysisStat statistics, String appPath, IConfigDataProvider configDataProvider)
        {
            await OutputHelper.OutputMessageAsync(ServiceProvider, $"Source code analysis for {statistics.TargetType} named \"{statistics.ProjectNames}\" is started");

            foreach (ProjectData project in projects)
            {
                String target = project.FileName;
                if (String.Equals(project.LanguageId, LanguageCSharpId))
                {
                    String          configPath  = ConfigFinder.FindConfig(configDataProvider, target);
                    OutputLevel     outputLevel = configDataProvider.GetOutputLevel();
                    ExecutionResult result      = await ExecutionHelper.ExecuteSourceCodeAnalysisAsync(appPath, target, configPath, outputLevel);

                    if (result.ExitCode == 0)
                    {
                        ++statistics.SuccessCount;
                    }
                    else
                    {
                        ++statistics.FailedCount;
                    }
                    await OutputHelper.OutputTargetAnalysisResultAsync(ServiceProvider, result, target, "project");
                }
                else
                {
                    ++statistics.SkippedCount;
                    await OutputHelper.OutputMessageAsync(ServiceProvider, $"Project \"{target}\" can't be processed due to unsupported language");
                }
            }
            await OutputHelper.OutputMessageAsync(ServiceProvider, $"Source code analysis for {statistics.TargetType} named \"{statistics.ProjectNames}\" is finished");

            await UIHelper.ShowProjectsSummaryAsync(_package, statistics);
        }
示例#3
0
        private async Task ExecuteSolutionAnalysisImplAsync(String target, String appPath, IConfigDataProvider configDataProvider)
        {
            await OutputHelper.OutputMessageAsync(ServiceProvider, $"Source code analysis for solution named \"{target}\" is started");

            String          configPath  = ConfigFinder.FindConfig(configDataProvider, target);
            OutputLevel     outputLevel = configDataProvider.GetOutputLevel();
            ExecutionResult result      = await ExecutionHelper.ExecuteSourceCodeAnalysisAsync(appPath, target, configPath, outputLevel);

            await OutputHelper.OutputTargetAnalysisResultAsync(ServiceProvider, result, target, "solution");

            await OutputHelper.OutputMessageAsync(ServiceProvider, $"Source code analysis for solution named \"{target}\" is finished");

            await UIHelper.ShowSolutionSummaryAsync(_package, result, target);
        }