CA1065 raised inappropriately in lambda in static constructor #6963
Labels
False_Positive
A diagnostic is reported for non-problematic case
help wanted
The issue is up-for-grabs, and can be claimed by commenting
Milestone
Analyzer
Diagnostic ID: CA1065:
Do not raise exceptions in unexpected locations
Analyzer source
SDK: Built-in CA analyzers in .NET 5 SDK or later
Version: SDK 7.0.401
Describe the bug
When writing a static constructor which constructs a lambda that throws an exception (not inside the constructor itself), CA1065 is inappropriately triggered.
Steps To Reproduce
Given the following csproj:
and source:
Expected behavior
Only
ShouldViolate
should be flagged.Actual behavior
Both classes are flagged:
The text was updated successfully, but these errors were encountered: