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;
         }
     }
 }
        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)));
        }
Beispiel #5
0
        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);
        }
Beispiel #6
0
        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);
        }
Beispiel #7
0
        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();
            }
        }