MSBuildWorkspace reports warnings as errors/failures
- Dominant language
- C#
- Stars
- 20.7k
- Forks
- 4.3k
- PR merge metrics
- PR metrics pending
Description
**Version Used**: Roslyn 4.11.0
**Steps to Reproduce**:
Run this code:
```c#
using Microsoft.CodeAnalysis.MSBuild;
var workspace = MSBuildWorkspace.Create();
var project = await workspace.OpenProjectAsync(@"..\..\..\..\project\project.csproj");
foreach (var diagnostic in workspace.Diagnostics)
{
Console.WriteLine($"{diagnostic.Kind}: {diagnostic.Message}");
}
```
Where project.csproj is:
```csproj
net8.0
enable
enable
```
**Expected Behavior**:
The workspace reports the `NU1903` warning about a vulnerability as a warning, i.e. the output should be:
```
Warning: Msbuild failed when processing the file 'C:\src\tmp\roslynworkspaceapp\project\project.csproj' with message: Package 'Newtonsoft.Json' 12.0.3 has a known high severity vulnerability, https://github.com/advisories/GHSA-5crp-9r3c-p9vr
```
**Actual Behavior**:
The warning is reported as a failure:
```
Failure: Msbuild failed when processing the file 'C:\src\tmp\roslynworkspaceapp\project\project.csproj' with message: Package 'Newtonsoft.Json' 12.0.3 has a known high severity vulnerability, https://github.com/advisories/GHSA-5crp-9r3c-p9vr
```
The problem is in `Microsoft.CodeAnalysis.MSBuild.DiagnosticReporter`, whose `Report(DiagnosticLog log)` method ignores `DiagnosticLogItem.Kind`.
Contributor guide
Assessment
This issue has not been assessed yet.