private void FixEncoding(ProjectInfo projectInfo, string globalSourceEncoding) { if (projectInfo.Encoding != null) { if (globalSourceEncoding != null) { logger.LogInfo(Resources.WARN_PropertyIgnored, SonarProperties.SourceEncoding); } } else { if (globalSourceEncoding == null) { if (ProjectLanguages.IsCSharpProject(projectInfo.ProjectLanguage) || ProjectLanguages.IsVbProject(projectInfo.ProjectLanguage)) { projectInfo.Encoding = Encoding.UTF8.WebName; } } else { projectInfo.Encoding = globalSourceEncoding; } } }
static void DisplayLocalHelp(string arguments, bool embedded) { if (string.IsNullOrEmpty(arguments)) { throw new ArgumentNullException("arguments"); } if (!Help3Environment.IsLocalHelp) { return; } if (!HelpLibraryAgent.IsRunning) { HelpLibraryAgent.Start(); Thread.Sleep(0x3e8); } string helpUrl = string.Format(@"{0}{1}{2}", arguments, ProjectLanguages.GetCurrentLanguageAsHttpParam(), (embedded)?"&embedded=true":string.Empty); if (Help3Service.Config.ExternalHelp) { DisplayHelpWithShellExecute(helpUrl); return; } BrowserPane browser = ActiveHelp3Browser(); if (browser != null) { LoggingService.Info(string.Format("Help 3.0: Navigating to {0}", helpUrl)); browser.Navigate(Help3Environment.GetHttpFromMsXHelp(helpUrl)); browser.WorkbenchWindow.SelectWindow(); } }
public void WriteRoslynOutputPaths(ProjectData project) { if (!project.RoslynReportFilePaths.Any()) { return; } string property = null; if (ProjectLanguages.IsCSharpProject(project.Project.ProjectLanguage)) { property = PropertiesFileGenerator.ReportFilesCsharpPropertyKey; } else if (ProjectLanguages.IsVbProject(project.Project.ProjectLanguage)) { property = PropertiesFileGenerator.ReportFilesVbnetPropertyKey; } sb.AppendLine($"{project.Guid}.{property}=\\"); sb.AppendLine(EncodeAsSonarQubeMultiValueProperty(project.RoslynReportFilePaths.Select(Escape))); }
public void WriteAnalyzerOutputPaths(ProjectData project) { if (project.AnalyzerOutPaths.Count == 0) { return; } string property = null; if (ProjectLanguages.IsCSharpProject(project.Project.ProjectLanguage)) { property = "sonar.cs.analyzer.projectOutPaths"; } else if (ProjectLanguages.IsVbProject(project.Project.ProjectLanguage)) { property = "sonar.vbnet.analyzer.projectOutPaths"; } sb.AppendLine($"{project.Guid}.{property}=\\"); sb.AppendLine(EncodeAsSonarQubeMultiValueProperty(project.AnalyzerOutPaths.Select(Escape))); }
public void WriteRoslynOutputPaths(ProjectData project) { if (!project.RoslynReportFilePaths.Any()) { return; } string property = null; if (ProjectLanguages.IsCSharpProject(project.Project.ProjectLanguage)) { property = "sonar.cs.roslyn.reportFilePaths"; } else if (ProjectLanguages.IsVbProject(project.Project.ProjectLanguage)) { property = "sonar.vbnet.roslyn.reportFilePaths"; } sb.AppendLine($"{project.Guid}.{property}=\\"); sb.AppendLine(string.Join(@",\" + Environment.NewLine, project.RoslynReportFilePaths.Select(Escape))); }
public void WriteRoslynReportPaths(ProjectData project) { if (!project.RoslynReportFilePaths.Any()) { return; } string property; if (ProjectLanguages.IsCSharpProject(project.Project.ProjectLanguage)) { property = PropertiesFileGenerator.ReportFilePathsCSharpPropertyKey; } else if (ProjectLanguages.IsVbProject(project.Project.ProjectLanguage)) { property = PropertiesFileGenerator.ReportFilePathsVbNetPropertyKey; } else { return; } AppendKeyValue(project.Guid, property, project.RoslynReportFilePaths); }
public void WriteAnalyzerOutputPaths(ProjectData project) { if (project.AnalyzerOutPaths.Count == 0) { return; } string property; if (ProjectLanguages.IsCSharpProject(project.Project.ProjectLanguage)) { property = PropertiesFileGenerator.ProjectOutPathsCsharpPropertyKey; } else if (ProjectLanguages.IsVbProject(project.Project.ProjectLanguage)) { property = PropertiesFileGenerator.ProjectOutPathsVbNetPropertyKey; } else { return; } AppendKeyValue(project.Guid, property, project.AnalyzerOutPaths); }
public void WriteSettingsForProject(ProjectInfo project, IEnumerable <string> files, string fxCopReportFilePath, string codeCoverageFilePath) { if (this.FinishedWriting) { throw new InvalidOperationException(); } if (project == null) { throw new ArgumentNullException("project"); } if (files == null) { throw new ArgumentNullException("files"); } Debug.Assert(files.Any(), "Expecting a project to have files to analyze"); Debug.Assert(files.All(f => File.Exists(f)), "Expecting all of the specified files to exist"); this.projects.Add(project); string guid = project.GetProjectGuidAsString(); AppendKeyValue(sb, guid, "sonar.projectKey", this.config.SonarProjectKey + ":" + guid); AppendKeyValue(sb, guid, "sonar.projectName", project.ProjectName); AppendKeyValue(sb, guid, "sonar.projectBaseDir", project.GetProjectDirectory()); if (fxCopReportFilePath != null) { string property = null; if (ProjectLanguages.IsCSharpProject(project.ProjectLanguage)) { property = "sonar.cs.fxcop.reportPath"; } else if (ProjectLanguages.IsVbProject(project.ProjectLanguage)) { property = "sonar.vbnet.fxcop.reportPath"; } Debug.Assert(property != null, "FxCopReportFilePath is set but the language is unrecognised. Language: " + project.ProjectLanguage); if (property != null) { AppendKeyValue(sb, guid, property, fxCopReportFilePath); } } if (codeCoverageFilePath != null) { AppendKeyValue(sb, guid, "sonar.cs.vscoveragexml.reportsPaths", codeCoverageFilePath); } if (project.ProjectType == ProjectType.Product) { sb.AppendLine(guid + @".sonar.sources=\"); } else { AppendKeyValue(sb, guid, "sonar.sources", ""); sb.AppendLine(guid + @".sonar.tests=\"); } IEnumerable <string> escapedFiles = files.Select(f => Escape(f)); sb.AppendLine(string.Join(@",\" + Environment.NewLine, escapedFiles)); sb.AppendLine(); if (project.AnalysisSettings != null && project.AnalysisSettings.Any()) { foreach (Property setting in project.AnalysisSettings) { sb.AppendFormat("{0}.{1}={2}", guid, setting.Id, Escape(setting.Value)); sb.AppendLine(); } sb.AppendLine(); } }
public ActionResult Index(string option, string search, string language) { ProjectLanguages pl = new ProjectLanguages { User = new User(), Projects = new ProjectList(), Languages = new LanguageList(), Language = new Language(), projectLanguages = new ProjectLanguageList(), Portfolios = new PortfolioList(), Users = new UserList() }; pl.Languages.Load(); //if a user choose the radio button option as Subject if (option == "Language") { // Currently searching by language only returns projects // THIS MAY CHANGE IF ADVANCED SEARCH OPTIONS ARE ADDED (IE: search portfolios by languages used [languages in all projects in a Portfolio]) ViewBag.ReturnObject = "Projects"; //Load Projects by input search string exact matches pl.projectLanguages.LoadByLanguageName(language); if (pl.projectLanguages.Count > 0) { // Found at least one match foreach (ProjectLanguage projlang in pl.projectLanguages) { Project proj = new Project(); proj.LoadById(projlang.ProjectId); pl.User.LoadById(proj.UserId); proj.CreatorUserName = pl.User.Username; pl.Projects.Add(proj); } } else { //No exact matches found //Load Projects by input search string partial matches pl.projectLanguages.LoadByPartialLanguageName(language); foreach (ProjectLanguage projlang in pl.projectLanguages) { Project proj = new Project(); proj.LoadById(projlang.ProjectId); proj.CreatorUserName = pl.User.Username; pl.Projects.Add(proj); } } if (pl.Projects.Count < 1) { //Throw Error Message for no projects loaded ViewBag.ErrorMessage = "No Projects Found"; } return(View(pl)); } else if (option == "Project") { // Currently searching by Project only returns projects // THIS MAY CHANGE IF ADVANCED SEARCH OPTIONS ARE ADDED (IE: search portfolios by languages used [languages in all projects in a Portfolio]) ViewBag.ReturnObject = "Projects"; //Load Projects by input search string exact matches pl.Projects.LoadByProjectName(search); if (pl.Projects.Count > 0) { // Found at least one match foreach (Project prj in pl.Projects) { User creator = new User(); creator.LoadById(prj.UserId); prj.CreatorUserName = creator.Username; } } else { //No exact matches found //Load Projects by input search string partial matches pl.Projects.LoadByPartialProjectName(search); foreach (Project prj in pl.Projects) { User creator = new User(); creator.LoadById(prj.UserId); prj.CreatorUserName = creator.Username; } } if (pl.Projects.Count < 1) { //Throw Error Message for no projects loaded ViewBag.ErrorMessage = "No Projects Found"; } return(View(pl)); } else if (option == "Portfolio") { // Currently searching by Portfolio only returns Portfolios // THIS MAY CHANGE IF ADVANCED SEARCH OPTIONS ARE ADDED (IE: search portfolios by languages used [languages in all projects in a Portfolio]) ViewBag.ReturnObject = "Portfolios"; //Load Portfolios by input search string exact matches pl.Portfolios.LoadByPortfolioName(search); foreach (Portfolio port in pl.Portfolios) { User creator = new User(); creator.LoadById(port.UserId); port.CreatorUsername = creator.Username; } if (pl.Portfolios.Count > 0) { // Found at least one match } else { //No exact matches found //Load Portfolios by input search string partial matches pl.Portfolios.LoadByPartialPortfolioName(search); foreach (Portfolio port in pl.Portfolios) { User creator = new User(); creator.LoadById(port.UserId); port.CreatorUsername = creator.Username; } } if (pl.Portfolios.Count < 1) { //Throw Error Message for no portfolios loaded ViewBag.ErrorMessage = "No Portfolios Found"; } else { // Portfolios returning logic } return(View(pl)); } else if (option == "Profile") { // Currently searching by UserProfiles only returns UserProfiles // THIS MAY CHANGE IF ADVANCED SEARCH OPTIONS ARE ADDED (IE: search portfolios by languages used [languages in all projects in a Portfolio]) ViewBag.ReturnObject = "Profiles"; //Load UserProfiles by input search string exact matches pl.Users.LoadByUserName(search); if (pl.Users.Count > 0) { // Found at least one match } else { //No exact matches found //Load UserProfiles by input search string partial matches pl.Users.LoadByPartialUserName(search); } if (pl.Users.Count < 1) { //Throw Error Message for no UserProfiles loaded ViewBag.ErrorMessage = "No Profiles Found"; } return(View(pl)); } else { return(View(pl)); } }