/// <summary> /// Creates a folder containing a ProjectInfo.xml and compiled file list as /// specified in the supplied descriptor /// </summary> private static void CreateFilesFromDescriptor(ProjectDescriptor descriptor, string compileFiles, string visualStudioCodeCoverageReportFileName) { if (!Directory.Exists(descriptor.FullDirectoryPath)) { Directory.CreateDirectory(descriptor.FullDirectoryPath); } var projectInfo = descriptor.CreateProjectInfo(); // Create the analysis file list if any input files have been specified if (descriptor.FilesToAnalyse.Any()) { var fullAnalysisFileListPath = Path.Combine(descriptor.FullDirectoryPath, compileFiles); File.WriteAllLines(fullAnalysisFileListPath, descriptor.FilesToAnalyse); // Add the compile list as an analysis result projectInfo.AnalysisResults.Add(new AnalysisResult() { Id = AnalysisType.FilesToAnalyze.ToString(), Location = fullAnalysisFileListPath }); } // Create the Visual Studio Code Coverage report file if (visualStudioCodeCoverageReportFileName != null) { var fullVisualStudioCodeCoverageName = Path.Combine(descriptor.FullDirectoryPath, visualStudioCodeCoverageReportFileName); File.Create(fullVisualStudioCodeCoverageName); // Add the Visual Studio Code Coverage report as an analysis result var analysisResult = new AnalysisResult() { Id = AnalysisType.VisualStudioCodeCoverage.ToString(), Location = fullVisualStudioCodeCoverageName }; descriptor.AnalysisResults.Add(analysisResult); projectInfo.AnalysisResults.Add(analysisResult); } // Save a project info file in the target directory projectInfo.Save(Path.Combine(descriptor.FullDirectoryPath, FileConstants.ProjectInfoFileName)); }
private void CheckAnalysisFileList(ProjectDescriptor expected, string projectOutputFolder) { string[] expectedFiles = GetExpectedAnalysisFiles(expected).ToArray(); if (!expectedFiles.Any()) { AssertFileDoesNotExist(projectOutputFolder, ExpectedAnalysisFilesListFileName); } else { string fullName = AssertFileExists(projectOutputFolder, ExpectedAnalysisFilesListFileName); string[] actualFiles = File.ReadAllLines(fullName); // The actual files might contain extra compiler generated files, so check the expected files // we expected is a subset of the actual CollectionAssert.IsSubsetOf(expectedFiles, actualFiles, "Analysis file does not contain the expected entries"); // Check that any files that should not be analysed are not included if (expected.FilesNotToAnalyse != null && expected.FilesNotToAnalyse.Any()) { foreach (string unanalysedFile in expected.FilesNotToAnalyse) { string filePathToCheck = unanalysedFile; if (!Path.IsPathRooted(filePathToCheck)) { // Assume paths are relative to the project directory filePathToCheck = Path.Combine(expected.FullDirectoryPath, filePathToCheck); } CollectionAssert.DoesNotContain(actualFiles, filePathToCheck, "Not expecting file to be included for analysis: {0}", filePathToCheck); } } } }
private void ExecuteAddSingleRequirementToSpecIF() { object selectedItem; EAAPI.ObjectType objectType = _repository.GetTreeSelectedItem(out selectedItem); EAAPI.Element element = selectedItem as EAAPI.Element; ProjectDescriptor project = ExecuteSelectProject(); if (project != null) { logger.Info("Integrating requirement " + element.Name + "..."); Resource repositoryResource = _projectIntegrator.AddRequirementToSpecIF(_requirementMasterDataWriter, element, project.ID); if (repositoryResource == null) { logger.Error("Error integrating requirement."); } else { logger.Info("Finished."); } } }
public void BuildProject(ProjectDescriptor project) { #pragma warning disable IDE0062 // Make local function 'static' void WriteProcessError(object sender, DataReceivedEventArgs e) { if (!string.IsNullOrWhiteSpace(e.Data)) { UnityEngine.Debug.LogError(e.Data); } } void WriteProcessOutput(object sender, DataReceivedEventArgs e) { if (!string.IsNullOrWhiteSpace(e.Data)) { UnityEngine.Debug.Log(e.Data); } } #pragma warning restore IDE0062 // Make local function 'static' var csprojPath = NamesPaths.CreateCsprojPathFromAsmDefPath(project.AsmdefPath); if (!File.Exists(csprojPath)) { UnityEngine.Debug.LogWarning($"Skipping project file, because it does not exists: {csprojPath}"); return; } var process = new Process { StartInfo = new ProcessStartInfo { FileName = "dotnet", Arguments = $"build \"{csprojPath}\"", UseShellExecute = false, RedirectStandardOutput = true, RedirectStandardError = true, CreateNoWindow = true } }; var outputHandler = new DataReceivedEventHandler(WriteProcessOutput); var errorHandler = new DataReceivedEventHandler(WriteProcessError); UnityEngine.Debug.Log($"Starting {project.AsmdefPath} build"); process.OutputDataReceived += outputHandler; process.ErrorDataReceived += errorHandler; process.Start(); process.BeginOutputReadLine(); process.BeginErrorReadLine(); process.WaitForExit(); process.OutputDataReceived -= outputHandler; process.ErrorDataReceived -= errorHandler; UnityEngine.Debug.Log($"Finished {project.AsmdefPath} build"); }
public void InitializeProject(ProjectDescriptor project) { var baseDirectory = new FileInfo(project.AsmdefPath).DirectoryName; CreateFolderStructure(baseDirectory, project.OverWrite); CreateDefaultFiles(baseDirectory, project.AsmdefPath, project.OverWrite); }
private void CheckProjectOutputFolder(ProjectDescriptor expected, string projectOutputFolder) { Assert.IsFalse(string.IsNullOrEmpty(projectOutputFolder), "Test error: projectOutputFolder should not be null/empty"); Assert.IsTrue(Directory.Exists(projectOutputFolder), "Expected project folder does not exist: {0}", projectOutputFolder); // Check folder naming string folderName = Path.GetFileName(projectOutputFolder); Assert.IsTrue(folderName.StartsWith(expected.ProjectName), "Project output folder does not start with the project name. Expected: {0}, actual: {1}", expected.ProjectFolderName, folderName); // Check specific files ProjectInfo expectedProjectInfo = CreateExpectedProjectInfo(expected, projectOutputFolder); CheckProjectInfo(expectedProjectInfo, projectOutputFolder); CheckAnalysisFileList(expected, projectOutputFolder); // Check there are no other files List <string> allowedFiles = new List <string>(expectedProjectInfo.AnalysisResults.Select(ar => ar.Location)) { Path.Combine(projectOutputFolder, FileConstants.ProjectInfoFileName) }; AssertNoAdditionalFilesInFolder(projectOutputFolder, allowedFiles.ToArray()); }
public void WriteProjectInfo_AnalysisFileList_FilesTypes_SpecifiedPlusDefaults() { // Arrange string rootInputFolder = TestUtils.CreateTestSpecificFolder(this.TestContext, "Inputs"); string rootOutputFolder = TestUtils.CreateTestSpecificFolder(this.TestContext, "Outputs"); ProjectDescriptor descriptor = BuildUtilities.CreateValidProjectDescriptor(rootInputFolder, "fileTypes.proj.txt"); ProjectRootElement projectRoot = CreateInitializedProject(descriptor, new WellKnownProjectProperties(), rootOutputFolder); // Files we don't expect to be included by default string fooType1 = AddFileToProject(projectRoot, "fooType", sonarQubeExclude: null); string xxxType1 = AddFileToProject(projectRoot, "xxxType", sonarQubeExclude: null); AddFileToProject(projectRoot, "barType", sonarQubeExclude: null); // Files we'd normally expect to be included by default string managed1 = AddFileToProject(projectRoot, TargetProperties.ItemType_Compile, sonarQubeExclude: null); string content1 = AddFileToProject(projectRoot, TargetProperties.ItemType_Content, sonarQubeExclude: null); // Update the "item types" property to add some extra item type // NB this has to be done *after* the integration targets have been imported ProjectPropertyGroupElement group = projectRoot.CreatePropertyGroupElement(); projectRoot.AppendChild(group); group.AddProperty("SQAnalysisFileItemTypes", "fooType;$(SQAnalysisFileItemTypes);xxxType"); projectRoot.Save(); // Act ProjectInfo projectInfo = ExecuteWriteProjectInfo(projectRoot, rootOutputFolder); // Assert AssertResultFileExists(projectInfo, AnalysisType.FilesToAnalyze, fooType1, xxxType1, content1, managed1); }
/// <summary> /// Creates and builds a new Sonar-enabled project using the supplied descriptor. /// The method will check the build succeeded and that a single project output file was created. /// </summary> /// <returns>The full path of the project-specific directory that was created during the build</returns> private string CreateAndBuildSonarProject(ProjectDescriptor descriptor, string rootOutputFolder, WellKnownProjectProperties preImportProperties) { var projectRoot = BuildUtilities.CreateInitializedProjectRoot(TestContext, descriptor, preImportProperties); // Act var result = BuildRunner.BuildTargets(TestContext, descriptor.FullFilePath); TestContext.AddResultFile(result.FilePath); // Assert result.AssertTargetSucceeded(TargetConstants.DefaultBuildTarget); // We expect the compiler to warn if there are no compiler inputs var expectedWarnings = (descriptor.ManagedSourceFiles.Any()) ? 0 : 1; result.AssertExpectedErrorCount(0); result.AssertExpectedWarningCount(expectedWarnings); result.AssertExpectedTargetOrdering( TargetConstants.CategoriseProjectTarget, TargetConstants.DefaultBuildTarget, TargetConstants.CalculateFilesToAnalyzeTarget, TargetConstants.WriteProjectDataTarget); // Check expected folder structure exists CheckRootOutputFolder(rootOutputFolder); // Check expected project outputs Assert.AreEqual(1, Directory.EnumerateDirectories(rootOutputFolder).Count(), "Only expecting one child directory to exist under the root analysis output folder"); ProjectInfoAssertions.AssertProjectInfoExists(rootOutputFolder, descriptor.FullFilePath); return(Directory.EnumerateDirectories(rootOutputFolder).Single()); }
/// <summary> /// Creates and builds a new Sonar-enabled project using the supplied descriptor. /// The method will check the build succeeded and that a single project output file was created. /// </summary> /// <returns>The full path of the project-specsific directory that was created during the build</returns> private string CreateAndBuildSonarProject(ProjectDescriptor descriptor, string rootOutputFolder, WellKnownProjectProperties preImportProperties) { ProjectRootElement projectRoot = BuildUtilities.CreateInitializedProjectRoot(this.TestContext, descriptor, preImportProperties); BuildLogger logger = new BuildLogger(); // Act BuildResult result = BuildUtilities.BuildTargets(projectRoot, logger); // Assert BuildAssertions.AssertTargetSucceeded(result, TargetConstants.DefaultBuildTarget); // We expect the compiler to warn if there are no compiler inputs int expectedWarnings = (descriptor.ManagedSourceFiles == null || !descriptor.ManagedSourceFiles.Any()) ? 1 : 0; logger.AssertExpectedErrorCount(0); logger.AssertExpectedWarningCount(expectedWarnings); logger.AssertExpectedTargetOrdering(TargetConstants.CoreCompileTarget, TargetConstants.CalculateSonarQubeFileListsTarget, TargetConstants.DefaultBuildTarget, TargetConstants.WriteProjectDataTarget); // Check expected folder structure exists CheckRootOutputFolder(rootOutputFolder); // Check expected project outputs Assert.AreEqual(1, Directory.EnumerateDirectories(rootOutputFolder).Count(), "Only expecting one child directory to exist under the root analysis output folder"); ProjectInfoAssertions.AssertProjectInfoExists(rootOutputFolder, projectRoot.FullPath); return(Directory.EnumerateDirectories(rootOutputFolder).Single()); }
private void OutputProjectInfoRecords(IOutputTransaction trx, ProjectDescriptor project) { var flat = new SortedDictionary <String, Object>(); AddPrimaryKeyElements(project, flat); flat.Add("LastCrawlDate", DateTime.Now); flat.Add(PropertyKeys.KEY_PRESET, project.PresetName); flat.Add("Policies", project.Policies); foreach (var lastScanProduct in project.LatestScanDateByProduct.Keys) { flat.Add($"{lastScanProduct}_LastScanDate", project.LatestScanDateByProduct[lastScanProduct]); } foreach (var scanCountProduct in project.ScanCountByProduct.Keys) { flat.Add($"{scanCountProduct}_Scans", project.ScanCountByProduct[scanCountProduct]); } if (project.CustomFields != null && project.CustomFields.Count > 0) { flat.Add(PropertyKeys.KEY_CUSTOMFIELDS, project.CustomFields); } trx.write(ProjectInfoOut, flat); }
public void WriteProjectInfo_FakesProjects_ExplicitSonarTestPropertyIsIgnored() { // Checks that fakes projects are recognised and marked as test // projects, irrespective of whether the SonarQubeTestProject is // already set. // Arrange string rootInputFolder = TestUtils.CreateTestSpecificFolder(this.TestContext, "Inputs"); string rootOutputFolder = TestUtils.CreateTestSpecificFolder(this.TestContext, "Outputs"); EnsureAnalysisConfig(rootInputFolder, "pattern that won't match anything"); WellKnownProjectProperties preImportProperties = CreateDefaultAnalysisProperties(rootInputFolder, rootOutputFolder); preImportProperties.SonarTestProject = "false"; preImportProperties.AssemblyName = "MyFakeProject.fakes"; ProjectDescriptor descriptor = BuildUtilities.CreateValidProjectDescriptor(rootInputFolder, "f.proj"); // Act ProjectInfo projectInfo = ExecuteWriteProjectInfo(descriptor, preImportProperties, rootOutputFolder); // Assert AssertIsTestProject(projectInfo); AssertProjectIsExcluded(projectInfo); }
public void WriteProjectInfo_AnalysisFileList_HasFiles() { // The analysis file list should be created with the expected files // Arrange string rootInputFolder = TestUtils.CreateTestSpecificFolder(this.TestContext, "Inputs"); string rootOutputFolder = TestUtils.CreateTestSpecificFolder(this.TestContext, "Outputs"); ProjectDescriptor descriptor = BuildUtilities.CreateValidProjectDescriptor(rootInputFolder, "content.X.proj.txt"); ProjectRootElement projectRoot = CreateInitializedProject(descriptor, new WellKnownProjectProperties(), rootOutputFolder); // Files we expect to be included string file1 = AddFileToProject(projectRoot, TargetProperties.ItemType_Content, "false"); string file2 = AddFileToProject(projectRoot, TargetProperties.ItemType_Compile, "FALSE"); string file3 = AddFileToProject(projectRoot, TargetProperties.ItemType_Content, null); // no metadata // Files we don't expect to be included AddFileToProject(projectRoot, TargetProperties.ItemType_Content, "true"); AddFileToProject(projectRoot, TargetProperties.ItemType_Content, "TRUE"); AddFileToProject(projectRoot, TargetProperties.ItemType_Compile, "true"); AddFileToProject(projectRoot, TargetProperties.ItemType_Compile, "TRUE"); // Act ProjectInfo projectInfo = ExecuteWriteProjectInfo(projectRoot, rootOutputFolder); // Assert AssertResultFileExists(projectInfo, AnalysisType.FilesToAnalyze, file1, file2, file3); }
public void ProjectLoader_NonRecursive() { // 0. Setup string rootTestDir = Path.Combine(this.TestContext.DeploymentDirectory, "ProjectLoader_NonRecursive"); string childDir = Path.Combine(rootTestDir, "Child1"); // Create a valid project in the child directory ProjectDescriptor validNonTestProject = new ProjectDescriptor() { ParentDirectoryPath = childDir, ProjectFolderName = "validNonTestProjectDir", ProjectFileName = "validNonTestproject.proj", ProjectGuid = Guid.NewGuid(), IsTestProject = false }; validNonTestProject.AddCompileInputFile("ASourceFile.vb", true); validNonTestProject.AddCompileInputFile("AnotherSourceFile.vb", true); CreateFilesFromDescriptor(validNonTestProject, "CompileList.txt", null); // 1. Run against the root dir -> not expecting the project to be found IEnumerable <ProjectInfo> projects = SonarScanner.Shim.ProjectLoader.LoadFrom(rootTestDir); Assert.AreEqual(0, projects.Count()); // 2. Run against the child dir -> project should be found projects = SonarScanner.Shim.ProjectLoader.LoadFrom(childDir); Assert.AreEqual(1, projects.Count()); }
public void ProjectLoader_NonRecursive() { // 0. Setup var rootTestDir = TestUtils.CreateTestSpecificFolder(TestContext); var childDir = Path.Combine(rootTestDir, "Child1"); // Create a valid project in the child directory var validNonTestProject = new ProjectDescriptor() { ParentDirectoryPath = childDir, ProjectFolderName = "validNonTestProjectDir", ProjectFileName = "validNonTestproject.proj", ProjectGuid = Guid.NewGuid(), IsTestProject = false }; validNonTestProject.AddCompileInputFile("ASourceFile.vb", true); validNonTestProject.AddCompileInputFile("AnotherSourceFile.vb", true); CreateFilesFromDescriptor(validNonTestProject, "CompileList.txt", null); // 1. Run against the root dir -> not expecting the project to be found IEnumerable <ProjectInfo> projects = SonarScanner.MSBuild.Shim.ProjectLoader.LoadFrom(rootTestDir); projects.Should().BeEmpty(); // 2. Run against the child dir -> project should be found projects = SonarScanner.MSBuild.Shim.ProjectLoader.LoadFrom(childDir); projects.Should().ContainSingle(); }
/// <summary> /// Creates and returns a valid, initialized MSBuild ProjectRootElement for a new project in the /// specified parent folder /// </summary> /// <param name="projectDirectory">The folder in which the project should be created</param> /// <param name="preImportProperties">Any MSBuild properties that should be set before any targets are imported</param> public static ProjectRootElement CreateValidProjectRoot(TestContext testContext, string projectDirectory, IDictionary <string, string> preImportProperties, bool isVBProject = false) { ProjectDescriptor descriptor = CreateValidProjectDescriptor(projectDirectory, isVBProject: isVBProject); ProjectRootElement projectRoot = CreateInitializedProjectRoot(testContext, descriptor, preImportProperties); return(projectRoot); }
/// <inheritdoc /> protected override ProjectTemplateResult CreateProjectCore(IFileService fileService, FilePath filePath) { var project = (NetProject)ProjectDescriptor.GetDescriptorByExtension(filePath.Extension).CreateProject(filePath.FileName); project.ApplicationType = ApplicationType; project.FilePath = filePath; var results = new List <TemplateResult>(); foreach (var file in Files) { var result = file.CreateFile( fileService, project, new FilePath(project.ProjectDirectory, file.Name + Language.StandardFileExtension)); foreach (var createdFile in result.CreatedFiles) { project.ProjectFiles.Add(new ProjectFileEntry(createdFile.File as OpenedFile)); } results.Add(result); } foreach (var reference in References) { project.References.Add(reference); } return(new ProjectTemplateResult(project, results.ToArray())); }
private static ProjectInfo CreateExpectedProjectInfo(ProjectDescriptor expected, string projectOutputFolder) { ProjectInfo expectedProjectInfo = expected.CreateProjectInfo(); // Work out what the expected analysis results are if (expected.ManagedSourceFiles != null && expected.ManagedSourceFiles.Any()) { expectedProjectInfo.AnalysisResults.Add( new AnalysisResult() { Id = AnalysisType.ManagedCompilerInputs.ToString(), Location = Path.Combine(projectOutputFolder, ExpectedManagedInputsListFileName) }); } if (expected.ContentFiles != null && expected.ContentFiles.Any()) { expectedProjectInfo.AnalysisResults.Add( new AnalysisResult() { Id = AnalysisType.ContentFiles.ToString(), Location = Path.Combine(projectOutputFolder, ExpectedContentsListFileName) }); } return(expectedProjectInfo); }
public void WriteProjectInfo_AnalysisFileList_FilesTypes_OnlySpecified() { // Arrange string rootInputFolder = TestUtils.CreateTestSpecificFolder(this.TestContext, "Inputs"); string rootOutputFolder = TestUtils.CreateTestSpecificFolder(this.TestContext, "Outputs"); ProjectDescriptor descriptor = BuildUtilities.CreateValidProjectDescriptor(rootInputFolder, "fileTypes.proj.txt"); ProjectRootElement projectRoot = CreateInitializedProject(descriptor, new WellKnownProjectProperties(), rootOutputFolder); // Files we don't expect to be included by default string fooType1 = AddFileToProject(projectRoot, "fooType", sonarQubeExclude: null); string xxxType1 = AddFileToProject(projectRoot, "xxxType", sonarQubeExclude: null); AddFileToProject(projectRoot, "barType", sonarQubeExclude: null); // Files we'd normally expect to be included by default AddFileToProject(projectRoot, TargetProperties.ItemType_Compile, sonarQubeExclude: null); AddFileToProject(projectRoot, TargetProperties.ItemType_Content, sonarQubeExclude: null); projectRoot.AddProperty("SQAnalysisFileItemTypes", "fooType;xxxType"); // Act ProjectInfo projectInfo = ExecuteWriteProjectInfo(projectRoot, rootOutputFolder); // Assert AssertResultFileExists(projectInfo, AnalysisType.FilesToAnalyze, fooType1, xxxType1); }
private string AddEmptyAnalysedCodeFile(ProjectDescriptor descriptor, string projectFolder, string extension = "cs") { string filePath = CreateEmptyFile(projectFolder, extension); descriptor.AddCompileInputFile(filePath, true); return(filePath); }
public void WriteProjectInfo_AnalysisSettings() { // Check analysis settings are correctly passed from the targets to the task // Arrange string rootInputFolder = TestUtils.CreateTestSpecificFolder(this.TestContext, "Inputs"); string rootOutputFolder = TestUtils.CreateTestSpecificFolder(this.TestContext, "Outputs"); ProjectDescriptor descriptor = BuildUtilities.CreateValidProjectDescriptor(rootInputFolder, "content.proj.txt"); ProjectRootElement projectRoot = CreateInitializedProject(descriptor, new WellKnownProjectProperties(), rootOutputFolder); // Invalid items AddItem(projectRoot, "UnrelatedItemType", "irrelevantItem"); // should be ignored AddItem(projectRoot, TargetProperties.ItemType_Compile, "IrrelevantFile.cs"); // should be ignored AddItem(projectRoot, BuildTaskConstants.SettingItemName, "invalid.settings.no.value.metadata"); // invalid -> ignored // Module-level settings AddItem(projectRoot, BuildTaskConstants.SettingItemName, "valid.setting1", BuildTaskConstants.SettingValueMetadataName, "value1"); AddItem(projectRoot, BuildTaskConstants.SettingItemName, "valid.setting2...", BuildTaskConstants.SettingValueMetadataName, "value 2 with spaces"); AddItem(projectRoot, BuildTaskConstants.SettingItemName, "valid.path", BuildTaskConstants.SettingValueMetadataName, @"d:\aaa\bbb.txt"); AddItem(projectRoot, BuildTaskConstants.SettingItemName, "common.setting.name", BuildTaskConstants.SettingValueMetadataName, @"local value"); // Act ProjectInfo projectInfo = ExecuteWriteProjectInfo(projectRoot, rootOutputFolder, noWarningOrErrors: false /* expecting warnings */); // Assert AssertSettingExists(projectInfo, "valid.setting1", "value1"); AssertSettingExists(projectInfo, "valid.setting2...", "value 2 with spaces"); AssertSettingExists(projectInfo, "valid.path", @"d:\aaa\bbb.txt"); AssertSettingExists(projectInfo, "common.setting.name", "local value"); // Additional settings might be added by other targets so we won't check the total number of settings }
[TestCategory("E2E"), TestCategory("Targets")] // SONARMSBRU-12: Analysis build fails if the build definition name contains brackets public void E2E_UsingTaskHandlesBracketsInName() { // Arrange string rootInputFolder = TestUtils.CreateTestSpecificFolder(this.TestContext, "folder with brackets in name (SONARMSBRU-12)"); string rootOutputFolder = TestUtils.CreateTestSpecificFolder(this.TestContext, "Outputs"); ProjectDescriptor descriptor = BuildUtilities.CreateValidProjectDescriptor(rootInputFolder); AddEmptyAnalysedCodeFile(descriptor, rootInputFolder); // Copy the task assembly to a folder with brackets in the name string taskAssemblyFilePath = typeof(WriteProjectInfoFile).Assembly.Location; string asmName = Path.GetFileName(taskAssemblyFilePath); string copiedTaskAssemblyFilePath = Path.Combine(rootInputFolder, Path.GetFileName(asmName)); File.Copy(taskAssemblyFilePath, copiedTaskAssemblyFilePath); // Set the project property to use that file. To reproduce the bug, we need to have MSBuild search for // the assembly using "GetDirectoryNameOfFileAbove". string val = @"$([MSBuild]::GetDirectoryNameOfFileAbove('{0}', '{1}'))\{1}"; val = string.Format(System.Globalization.CultureInfo.InvariantCulture, val, rootInputFolder, asmName); WellKnownProjectProperties preImportProperties = CreateDefaultAnalysisProperties(rootInputFolder, rootOutputFolder); preImportProperties.Add(TargetProperties.SonarBuildTasksAssemblyFile, val); // Act string projectDir = CreateAndBuildSonarProject(descriptor, rootOutputFolder, preImportProperties); AssertFileExists(projectDir, ExpectedAnalysisFilesListFileName); CheckProjectOutputFolder(descriptor, projectDir); }
public void E2E_HasManagedAndContentFiles_VB() { // Arrange string rootInputFolder = TestUtils.CreateTestSpecificFolder(this.TestContext, "Inputs"); string rootOutputFolder = TestUtils.CreateTestSpecificFolder(this.TestContext, "Outputs"); ProjectDescriptor descriptor = BuildUtilities.CreateValidProjectDescriptor(rootInputFolder); descriptor.ProjectLanguage = ProjectLanguages.VisualBasic; AddEmptyAnalysedCodeFile(descriptor, rootInputFolder, ".vb"); AddEmptyAnalysedCodeFile(descriptor, rootInputFolder, ".vb"); AddEmptyContentFile(descriptor, rootInputFolder); AddEmptyContentFile(descriptor, rootInputFolder); WellKnownProjectProperties preImportProperties = CreateDefaultAnalysisProperties(rootInputFolder, rootOutputFolder); // Act string projectDir = CreateAndBuildSonarProject(descriptor, rootOutputFolder, preImportProperties); AssertFileExists(projectDir, ExpectedAnalysisFilesListFileName); CheckProjectOutputFolder(descriptor, projectDir); }
public override List <ProjectDescriptor> GetProjectDescriptions() { List <ProjectDescriptor> result = new List <ProjectDescriptor>(); Task <ProjectSearchResponse> task = _jiraClient.GetJiraProjectsAsync(); task.Wait(); ProjectSearchResponse projectSearchResponse = task.Result; if (projectSearchResponse != null) { foreach (Project jiraProject in projectSearchResponse.Values) { string projectID = JiraGuidConverter.ConvertToSpecIfGuid(jiraProject.Self, jiraProject.ID); ProjectDescriptor projectDescriptor = new ProjectDescriptor { ID = projectID, Title = new List <MultilanguageText> { new MultilanguageText(jiraProject.Name) }, Generator = _url, GeneratorVersion = "Jira REST API 2", }; result.Add(projectDescriptor); } } return(result); }
public void WriteProjectInfo_AnalysisFileList_AutoGenFilesIgnored() { // The content file list should not include items with <AutoGen>true</AutoGen> metadata // Arrange string rootInputFolder = TestUtils.CreateTestSpecificFolder(this.TestContext, "Inputs"); string rootOutputFolder = TestUtils.CreateTestSpecificFolder(this.TestContext, "Outputs"); ProjectDescriptor descriptor = BuildUtilities.CreateValidProjectDescriptor(rootInputFolder, "agC.proj.txt"); ProjectRootElement projectRoot = CreateInitializedProject(descriptor, new WellKnownProjectProperties(), rootOutputFolder); // Files we don't expect to be included AddFileToProject(projectRoot, TargetProperties.ItemType_Content, null, "TRUE"); // only AutoGen, set to true AddFileToProject(projectRoot, TargetProperties.ItemType_Content, "false", "truE"); // exclude=false, autogen=true AddFileToProject(projectRoot, TargetProperties.ItemType_Content, "true", "false"); // exclude=true, autogen=false // Files we expect to be included string content1 = AddFileToProject(projectRoot, TargetProperties.ItemType_Content, null, null); // no metadata string compile1 = AddFileToProject(projectRoot, TargetProperties.ItemType_Compile, null, null); // no metadata string autogenContentFalseAndIncluded = AddFileToProject(projectRoot, TargetProperties.ItemType_Content, "false", "FALSe"); // exclude=false, autogen=false string autogenCompileFalseAndIncluded = AddFileToProject(projectRoot, TargetProperties.ItemType_Compile, "false", "faLSE"); // exclude=false, autogen=false // Act ProjectInfo projectInfo = ExecuteWriteProjectInfo(projectRoot, rootOutputFolder); // Assert AssertResultFileExists(projectInfo, AnalysisType.FilesToAnalyze, compile1, content1, autogenContentFalseAndIncluded, autogenCompileFalseAndIncluded); }
public void Init() { list.ClearList(true); this.project = AppManager.Instance.GetCurrentProject(); this.projectItems = project.items; foreach(ProjectItemDescriptor projectItem in this.projectItems) { ProjectItem itemObj = Instantiate(item) as ProjectItem; itemObj.Title = projectItem.name; itemObj.SubTitle = projectItem.subtitle; itemObj.Description = projectItem.description; itemObj.onPressDelegate = OnSelectProduct; itemObj.project = projectItem; list.AddItem(itemObj); } list.transform.localPosition = UpdatePositionList(); list.UpdateCamera(); Show(); if(GlobalParams.Instance.HasInternetConnection) StartCoroutine(DownloadImages()); else GetImagesFromCache(); }
public void WriteProjectInfo_AnalysisFileList_FilesTypes_Defaults() { // Check that all default item types are included for analysis // Arrange string rootInputFolder = TestUtils.CreateTestSpecificFolder(this.TestContext, "Inputs"); string rootOutputFolder = TestUtils.CreateTestSpecificFolder(this.TestContext, "Outputs"); ProjectDescriptor descriptor = BuildUtilities.CreateValidProjectDescriptor(rootInputFolder, "fileTypes.proj.txt"); ProjectRootElement projectRoot = CreateInitializedProject(descriptor, new WellKnownProjectProperties(), rootOutputFolder); // Files we don't expect to be included by default AddFileToProject(projectRoot, "fooType"); AddFileToProject(projectRoot, "barType"); // Files we expect to be included by default string managed1 = AddFileToProject(projectRoot, TargetProperties.ItemType_Compile, sonarQubeExclude: null); string content1 = AddFileToProject(projectRoot, TargetProperties.ItemType_Content, sonarQubeExclude: null); string embedded1 = AddFileToProject(projectRoot, "EmbeddedResource", sonarQubeExclude: null); string none1 = AddFileToProject(projectRoot, "None", sonarQubeExclude: null); string nativeCompile1 = AddFileToProject(projectRoot, "ClCompile", sonarQubeExclude: null); string page1 = AddFileToProject(projectRoot, "Page", sonarQubeExclude: null); string typeScript1 = AddFileToProject(projectRoot, "TypeScriptCompile", sonarQubeExclude: null); // Act ProjectInfo projectInfo = ExecuteWriteProjectInfo(projectRoot, rootOutputFolder); // Assert AssertResultFileExists(projectInfo, AnalysisType.FilesToAnalyze, managed1, content1, embedded1, none1, nativeCompile1, page1, typeScript1); projectRoot.AddProperty("SQAnalysisFileItemTypes", "$(SQAnalysisFileItemTypes);fooType;barType;"); }
/// <summary> /// Creates and returns a valid, initialized MSBuild ProjectRootElement for a new project in the /// specified parent folder with the specified project file name /// </summary> /// <param name="projectDirectory">The folder in which the project should be created</param> /// <param name="projectFileName">The name of the project file</param> /// <param name="preImportProperties">Any MSBuild properties that should be set before any targets are imported</param> /// <returns></returns> public static ProjectRootElement CreateValidNamedProjectRoot(TestContext testContext, string projectFileName, string projectDirectory, IDictionary <string, string> preImportProperties) { ProjectDescriptor descriptor = CreateValidNamedProjectDescriptor(projectDirectory, projectFileName); ProjectRootElement projectRoot = CreateInitializedProjectRoot(testContext, descriptor, preImportProperties); return(projectRoot); }
public void ProjectLoader() { // Arrange string testSourcePath = TestUtils.CreateTestSpecificFolder(this.TestContext); // Create sub-directories, some with project info XML files and some without TestUtils.EnsureTestSpecificFolder(this.TestContext, "EmptyDir1"); ProjectDescriptor validTestProject = new ProjectDescriptor() { ParentDirectoryPath = testSourcePath, ProjectFolderName = "validTestProjectDir", ProjectFileName = "validTestProject.csproj", ProjectGuid = Guid.NewGuid(), IsTestProject = true, ManagedSourceFiles = new string[] { "TestFile1.cs", "TestFile2.cs" }, ContentFiles = new string[] { "contentFile1.js" }, }; CreateFilesFromDescriptor(validTestProject, "testCompileListFile", "testContentList", "testFxCopReport", "testVisualStudioCodeCoverageReport"); TestUtils.EnsureTestSpecificFolder(this.TestContext, "EmptyDir2"); ProjectDescriptor validNonTestProject = new ProjectDescriptor() { ParentDirectoryPath = testSourcePath, ProjectFolderName = "validNonTestProjectDir", ProjectFileName = "validNonTestproject.proj", ProjectGuid = Guid.NewGuid(), IsTestProject = false, ManagedSourceFiles = new string[] { "ASourceFile.vb", "AnotherSourceFile.vb" }, }; CreateFilesFromDescriptor(validNonTestProject, "list.txt", null, "fxcop.xml", "visualstudio-codecoverage.xml"); ProjectDescriptor validNonTestNoReportsProject = new ProjectDescriptor() { ParentDirectoryPath = testSourcePath, ProjectFolderName = "validNonTestNoReportsProjectDir", ProjectFileName = "validNonTestNoReportsProject.proj", ProjectGuid = Guid.NewGuid(), IsTestProject = false, ManagedSourceFiles = new string[] { "SomeFile.cs" } }; CreateFilesFromDescriptor(validNonTestNoReportsProject, "SomeList.txt", null, null, null); // Act IEnumerable <ProjectInfo> projects = SonarRunner.Shim.ProjectLoader.LoadFrom(testSourcePath); // Assert Assert.AreEqual(3, projects.Count()); AssertProjectResultExists(validTestProject.ProjectName, projects); AssertProjectResultExists(validNonTestProject.ProjectName, projects); AssertProjectResultExists(validNonTestNoReportsProject.ProjectName, projects); }
private void ExecuteNewRequirementCreationRequested() { ProjectDescriptor project = ExecuteSelectProject(); if (project != null) { } }
public void ProjectLoader() { // Arrange var testSourcePath = TestUtils.CreateTestSpecificFolder(TestContext); // Create sub-directories, some with project info XML files and some without TestUtils.EnsureTestSpecificFolder(TestContext, "EmptyDir1"); var validTestProject = new ProjectDescriptor() { ParentDirectoryPath = testSourcePath, ProjectFolderName = "validTestProjectDir", ProjectFileName = "validTestProject.csproj", ProjectGuid = Guid.NewGuid(), IsTestProject = true }; validTestProject.AddCompileInputFile("TestFile1.cs", true); validTestProject.AddCompileInputFile("TestFile1.cs", true); validTestProject.AddContentFile("contentFile1.js", true); CreateFilesFromDescriptor(validTestProject, "testCompileListFile", "testVisualStudioCodeCoverageReport"); TestUtils.EnsureTestSpecificFolder(TestContext, "EmptyDir2"); var validNonTestProject = new ProjectDescriptor() { ParentDirectoryPath = testSourcePath, ProjectFolderName = "validNonTestProjectDir", ProjectFileName = "validNonTestproject.proj", ProjectGuid = Guid.NewGuid(), IsTestProject = false }; validNonTestProject.AddContentFile("ASourceFile.vb", true); validNonTestProject.AddContentFile("AnotherSourceFile.vb", true); CreateFilesFromDescriptor(validNonTestProject, "list.txt", "visualstudio-codecoverage.xml"); var validNonTestNoReportsProject = new ProjectDescriptor() { ParentDirectoryPath = testSourcePath, ProjectFolderName = "validNonTestNoReportsProjectDir", ProjectFileName = "validNonTestNoReportsProject.proj", ProjectGuid = Guid.NewGuid(), IsTestProject = false }; validNonTestNoReportsProject.AddContentFile("SomeFile.cs", true); CreateFilesFromDescriptor(validNonTestNoReportsProject, "SomeList.txt", null); // Act IEnumerable<ProjectInfo> projects = SonarScanner.MSBuild.Shim.ProjectLoader.LoadFrom(testSourcePath); // Assert Assert.AreEqual(3, projects.Count()); AssertProjectResultExists(validTestProject.ProjectName, projects); AssertProjectResultExists(validNonTestProject.ProjectName, projects); AssertProjectResultExists(validNonTestNoReportsProject.ProjectName, projects); }
public void ShallowPath_HasNoSubsegments() { var sut = new ProjectDescriptor(ShallowPath); sut.Subsegments.Should().BeEquivalentTo(new[] { "main file.ext" }); }
private void SetInfo() { appProject = AppManager.Instance.GetCurrentProject(); if(GlobalParams.Instance.HasInternetConnection) StartCoroutine(DownloadThumbnail(appProject.smallLogoURL)); else GetThumbnailFromCache(); if(project.sortDescription.Length <= 0) return; logo.Hide(true); subtitle.Text = project.name + " / " + project.sortDescription; }
public void ParseInfoToProjectDescriptor( string result ) { ArrayList projectsResult = MiniJSON.jsonDecode(result) as ArrayList; this.projects = new List<ProjectDescriptor>(); foreach(Hashtable project in projectsResult) { ProjectDescriptor projectDescriptor = new ProjectDescriptor(); projectDescriptor.id = int.Parse(project["id"].ToString()); projectDescriptor.name = project["name"].ToString(); projectDescriptor.portraitURL = project["portrait_url"].ToString(); projectDescriptor.smallLogoURL = project["small_logo_url"].ToString(); projectDescriptor.items = GetProjectsItems( project["projects"] as ArrayList ); projectDescriptor.imagesBundle = GetImagesCacheAsset(project["images"] as Hashtable); this.projects.Add(projectDescriptor); } }
/// <summary> /// Creates a new .NET MSBuild project with the default values. /// </summary> public NetProject(string name, ProjectDescriptor projectDescriptor) : base(MSBuildProjectFactory.CreateNetProject(projectDescriptor.MSBuildTargetsFile)) { Name = RootNamespace = name; }
private void OnProductSelect(ProjectDescriptor product) { AppManager.Instance.CurrentProjectID = product.id; projectItems.Init(); }