@@ -105,23 +105,30 @@ protected override void AutobuildFailureDiagnostic()
105105 // otherwise, we just report that the one script we found didn't work
106106 if ( this . autoBuildRule . BuildCommandAutoRule . CandidatePaths . Count ( ) > 1 )
107107 {
108- message = MakeDiagnostic ( "multiple-build-scripts" , "There are multiple potential build scripts" ) ;
109- message . MarkdownMessage =
110- "CodeQL found multiple potential build scripts for your project and " +
111- $ "attempted to run `{ relScriptPath } `, which failed. " +
112- "This may not be the right build script for your project. " +
113- $ "Set up a [manual build command]({ buildCommandDocsUrl } ).";
108+ message = new (
109+ this . Options . Language ,
110+ "multiple-build-scripts" ,
111+ "There are multiple potential build scripts" ,
112+ markdownMessage :
113+ "CodeQL found multiple potential build scripts for your project and " +
114+ $ "attempted to run `{ relScriptPath } `, which failed. " +
115+ "This may not be the right build script for your project. " +
116+ $ "Set up a [manual build command]({ buildCommandDocsUrl } )."
117+ ) ;
114118 }
115119 else
116120 {
117- message = MakeDiagnostic ( "script-failure" , "Unable to build project using build script" ) ;
118- message . MarkdownMessage =
119- "CodeQL attempted to build your project using a script located at " +
120- $ "`{ relScriptPath } `, which failed. " +
121- $ "Set up a [manual build command]({ buildCommandDocsUrl } ).";
121+ message = new (
122+ this . Options . Language ,
123+ "script-failure" ,
124+ "Unable to build project using build script" ,
125+ markdownMessage :
126+ "CodeQL attempted to build your project using a script located at " +
127+ $ "`{ relScriptPath } `, which failed. " +
128+ $ "Set up a [manual build command]({ buildCommandDocsUrl } )."
129+ ) ;
122130 }
123131
124- message . Severity = DiagnosticMessage . TspSeverity . Error ;
125132 AddDiagnostic ( message ) ;
126133 }
127134
@@ -135,50 +142,63 @@ protected override void AutobuildFailureDiagnostic()
135142 // then neither of those rules would've worked
136143 if ( this . ProjectsOrSolutionsToBuild . Count == 0 )
137144 {
138- var message = MakeDiagnostic ( "no-projects-or-solutions" , "No project or solutions files found" ) ;
139- message . PlaintextMessage =
140- "CodeQL could not find any project or solution files in your repository. " +
141- $ "Set up a [manual build command]({ buildCommandDocsUrl } ).";
142- message . Severity = DiagnosticMessage . TspSeverity . Error ;
143-
144- AddDiagnostic ( message ) ;
145+ this . AddDiagnostic ( new (
146+ this . Options . Language ,
147+ "no-projects-or-solutions" ,
148+ "No project or solutions files found" ,
149+ markdownMessage :
150+ "CodeQL could not find any project or solution files in your repository. " +
151+ $ "Set up a [manual build command]({ buildCommandDocsUrl } )."
152+ ) ) ;
145153 }
146154 // show a warning if there are projects which are not compatible with .NET Core, in case that is unintentional
147155 else if ( foundNotDotNetProjects . Any ( ) )
148156 {
149- var message = MakeDiagnostic ( "dotnet-incompatible-projects" , "Some projects are incompatible with .NET Core" ) ;
150- message . MarkdownMessage =
151- "CodeQL found some projects which cannot be built with .NET Core:\n " +
152- autoBuildRule . DotNetRule . NotDotNetProjects . Select ( p => this . MakeRelative ( p . FullPath ) ) . ToMarkdownList ( MarkdownUtil . CodeFormatter , 5 ) ;
153- message . Severity = DiagnosticMessage . TspSeverity . Warning ;
154-
155- AddDiagnostic ( message ) ;
157+ this . AddDiagnostic ( new (
158+ this . Options . Language ,
159+ "dotnet-incompatible-projects" ,
160+ "Some projects are incompatible with .NET Core" ,
161+ severity : DiagnosticMessage . TspSeverity . Warning ,
162+ markdownMessage : $ """
163+ CodeQL found some projects which cannot be built with .NET Core:
164+
165+ { autoBuildRule . DotNetRule . NotDotNetProjects . Select ( p => this . MakeRelative ( p . FullPath ) ) . ToMarkdownList ( MarkdownUtil . CodeFormatter , 5 ) }
166+ """
167+ ) ) ;
156168 }
157169
158170 // report any projects that failed to build with .NET Core
159171 if ( autoBuildRule . DotNetRule . FailedProjectsOrSolutions . Any ( ) )
160172 {
161- var message = MakeDiagnostic ( "dotnet-build-failure" , "Some projects or solutions failed to build using .NET Core" ) ;
162- message . MarkdownMessage =
163- "CodeQL was unable to build the following projects using .NET Core:\n " +
164- autoBuildRule . DotNetRule . FailedProjectsOrSolutions . Select ( p => this . MakeRelative ( p . FullPath ) ) . ToMarkdownList ( MarkdownUtil . CodeFormatter , 10 ) +
165- $ "\n Set up a [manual build command]({ buildCommandDocsUrl } ).";
166- message . Severity = DiagnosticMessage . TspSeverity . Error ;
167-
168- AddDiagnostic ( message ) ;
173+ this . AddDiagnostic ( new (
174+ this . Options . Language ,
175+ "dotnet-build-failure" ,
176+ "Some projects or solutions failed to build using .NET Core" ,
177+ markdownMessage : $ """
178+ CodeQL was unable to build the following projects using .NET Core:
179+
180+ { autoBuildRule . DotNetRule . FailedProjectsOrSolutions . Select ( p => this . MakeRelative ( p . FullPath ) ) . ToMarkdownList ( MarkdownUtil . CodeFormatter , 10 ) }
181+
182+ Set up a [manual build command]({ buildCommandDocsUrl } ).
183+ """
184+ ) ) ;
169185 }
170186
171187 // report any projects that failed to build with MSBuild
172188 if ( autoBuildRule . MsBuildRule . FailedProjectsOrSolutions . Any ( ) )
173189 {
174- var message = MakeDiagnostic ( "msbuild-build-failure" , "Some projects or solutions failed to build using MSBuild" ) ;
175- message . MarkdownMessage =
176- "CodeQL was unable to build the following projects using MSBuild:\n " +
177- autoBuildRule . MsBuildRule . FailedProjectsOrSolutions . Select ( p => this . MakeRelative ( p . FullPath ) ) . ToMarkdownList ( MarkdownUtil . CodeFormatter , 10 ) +
178- $ "\n Set up a [manual build command]({ buildCommandDocsUrl } ).";
179- message . Severity = DiagnosticMessage . TspSeverity . Error ;
180-
181- AddDiagnostic ( message ) ;
190+ this . AddDiagnostic ( new (
191+ this . Options . Language ,
192+ "msbuild-build-failure" ,
193+ "Some projects or solutions failed to build using MSBuild" ,
194+ markdownMessage : $ """
195+ CodeQL was unable to build the following projects using MSBuild:
196+
197+ { autoBuildRule . MsBuildRule . FailedProjectsOrSolutions . Select ( p => this . MakeRelative ( p . FullPath ) ) . ToMarkdownList ( MarkdownUtil . CodeFormatter , 10 ) }
198+
199+ Set up a [manual build command]({ buildCommandDocsUrl } ).
200+ """
201+ ) ) ;
182202 }
183203 }
184204
0 commit comments