You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
NET-3876 Fix S6667 FN: Logging should pass exception not raised in IDE for Serilog #9806
When CI runs, the issue is flagged in the CI analysis, and in SonarQube for Visual Studio it is caught immediately too.
It seems to not work with SonarQube for IDE (Rider 12.2.084584) or just the NuGet package. I installed the nuget package into the project and it didn't show up in Rider or Visual Studio. Then when installing the pluging for visual studio it did show up. I don't use Visual Studio but I setup visual studio to test it out.
Product and Version
SonarCloud, SonarAnalyzer.CSharp (10.25.0.139117), SonarQube for IDE (Rider 12.2.084584) & SonarQube for Visual Studio (VS2026, 10.2.0.16704)
changed the title [-]Fix S6667 FN: Logging should pass exception not raised in IDE for Serilog[/-][+]NET-3876 Fix S6667 FN: Logging should pass exception not raised in IDE for Serilog[/+]on Jun 5, 2026
We tracked this down — the rule's compilation guard in ExceptionsShouldBeLogged.cs only subscribes when the project references one of Microsoft.Extensions.Logging.Abstractions, Castle.Core, Common.Logging.Core, log4net, or NLog — Serilog was missing from that list, even though the underlying walker already knows how to detect Serilog calls. So if a project references only Serilog (no transitive Microsoft.Extensions.Logging.Abstractions), S6667 never registers and never fires.
That's why you see the split between CI / Visual Studio (where the larger build context likely pulls in Microsoft.Extensions.Logging.Abstractions transitively) and your minimal IDE / NuGet-only repro (where it doesn't). It's not actually IDE-specific — adding a Serilog-only unit test reproduces the FN deterministically.
Fix is a one-liner adding KnownAssembly.Serilog to the guard; tracked internally as NET-3876 and going up for review now. Once merged it will roll out with the next analyzer release across all channels (NuGet, IDE plugins, server).
One related note: you might also be interested in #9798, which requests S6667 to not flag expected exceptions like OperationCanceledException. That's a separate, still-open discussion — your snippet happens to hit both, but the two are independent.
Activity
[-]Fix S6667 FN: Logging should pass exception not raised in IDE for Serilog[/-][+]NET-3876 Fix S6667 FN: Logging should pass exception not raised in IDE for Serilog[/+]github-actions commentedon Jun 5, 2026
Internal ticket NET-3876
martin-strecker-sonarsource commentedon Jun 5, 2026
Hi @MelDommer, thanks for the detailed report!
We tracked this down — the rule's compilation guard in
ExceptionsShouldBeLogged.csonly subscribes when the project references one ofMicrosoft.Extensions.Logging.Abstractions,Castle.Core,Common.Logging.Core,log4net, orNLog—Serilogwas missing from that list, even though the underlying walker already knows how to detect Serilog calls. So if a project references only Serilog (no transitiveMicrosoft.Extensions.Logging.Abstractions), S6667 never registers and never fires.That's why you see the split between CI / Visual Studio (where the larger build context likely pulls in
Microsoft.Extensions.Logging.Abstractionstransitively) and your minimal IDE / NuGet-only repro (where it doesn't). It's not actually IDE-specific — adding a Serilog-only unit test reproduces the FN deterministically.Fix is a one-liner adding
KnownAssembly.Serilogto the guard; tracked internally as NET-3876 and going up for review now. Once merged it will roll out with the next analyzer release across all channels (NuGet, IDE plugins, server).One related note: you might also be interested in #9798, which requests S6667 to not flag expected exceptions like
OperationCanceledException. That's a separate, still-open discussion — your snippet happens to hit both, but the two are independent.Thanks again!