@@ -105,23 +105,30 @@ protected override void AutobuildFailureDiagnostic()
105
105
// otherwise, we just report that the one script we found didn't work
106
106
if ( this . autoBuildRule . BuildCommandAutoRule . CandidatePaths . Count ( ) > 1 )
107
107
{
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
+ ) ;
114
118
}
115
119
else
116
120
{
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
+ ) ;
122
130
}
123
131
124
- message . Severity = DiagnosticMessage . TspSeverity . Error ;
125
132
AddDiagnostic ( message ) ;
126
133
}
127
134
@@ -135,50 +142,63 @@ protected override void AutobuildFailureDiagnostic()
135
142
// then neither of those rules would've worked
136
143
if ( this . ProjectsOrSolutionsToBuild . Count == 0 )
137
144
{
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
+ ) ) ;
145
153
}
146
154
// show a warning if there are projects which are not compatible with .NET Core, in case that is unintentional
147
155
else if ( foundNotDotNetProjects . Any ( ) )
148
156
{
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
+ ) ) ;
156
168
}
157
169
158
170
// report any projects that failed to build with .NET Core
159
171
if ( autoBuildRule . DotNetRule . FailedProjectsOrSolutions . Any ( ) )
160
172
{
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
+ ) ) ;
169
185
}
170
186
171
187
// report any projects that failed to build with MSBuild
172
188
if ( autoBuildRule . MsBuildRule . FailedProjectsOrSolutions . Any ( ) )
173
189
{
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
+ ) ) ;
182
202
}
183
203
}
184
204
0 commit comments