dotnet / roslyn

The Roslyn .NET compiler provides C# and Visual Basic languages with rich code analysis APIs.
https://docs.microsoft.com/dotnet/csharp/roslyn-sdk/
MIT License
18.96k stars 4.03k forks source link

Can't raise errors from source generators via WarningsAsErrors #49219

Open matkoch opened 3 years ago

matkoch commented 3 years ago

<WarningsAsErrors>CS8785</WarningsAsErrors> doesn't have any effect for exceptions occurring in source generators. Instead, I have to use MSBuildWarningsAsErrors.

Discussed with @rainersigwald:

image
chsienki commented 3 years ago

This is related to #46939

Tatenshi commented 2 years ago

This seems to be working now. With both WarningsAsErrors and MSBuildWarningsAsErrors, the warning CS8785 is replaced by an error.

However, despite error in the output, the build runs successfully and is not aborted. This problem occurs with both WarningsAsErrors and MSBuildWarningsAsErrors. Normal warnings cause the build to fail as intended.