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
using System.Diagnostics.CodeAnalysis;namespaceConsoleApp1{internalstaticclassProgram{internalstaticvoidMain(){
Example.MyMethod();}}internalstaticclassExample{[SuppressMessage("Design","CA1031:Do not catch general exception types", Justification ="I want to catch every possibly exception.")]publicstaticvoidMyMethod(){try{stringtext= File.ReadAllText("example.txt");
Console.WriteLine(text);}catch(Exceptionex){
Console.WriteLine($"An error occurred: {ex}");}}}}
Exceptions (if any)
The following warning is reported incorrectly.
Severity Code Description Project File Line Suppression State Details
Message (active) IDE0079 Remove unnecessary suppression ConsoleApp1 C:\Users\Fots\source\ConsoleApp1\Program.cs 15
If you remove the "unnecessary" suppression, CA1031 is reported for the block.
Severity Code Description Project File Line Suppression State Details
Warning (active) CA1031 A general exception such as System.Exception or System.SystemException or a disallowed exception type is caught in a catch statement, or a general catch clause is used. General and disallowed exceptions should not be caught. ConsoleApp1 C:\Users\Fots\source\ConsoleApp1\Program.cs 22
Further technical details
Include the output of dotnet --info
.NET SDK:
Version: 9.0.100
Commit: 59db016f11
Workload version: 9.0.100-manifests.c6f19616
MSBuild version: 17.12.7+5b8665660
Runtime Environment:
OS Name: Windows
OS Version: 10.0.22631
OS Platform: Windows
RID: win-x64
Base Path: C:\Program Files\dotnet\sdk\9.0.100\
.NET workloads installed:
There are no installed workloads to display.
Configured to use loose manifests when installing new manifests.
Host:
Version: 9.0.0
Architecture: x64
Commit: 9d5a6a9aa4
.NET SDKs installed:
9.0.100 [C:\Program Files\dotnet\sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 8.0.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 9.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 8.0.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 9.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 8.0.11 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 9.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Other architectures found:
x86 [C:\Program Files (x86)\dotnet]
registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]
Environment variables:
Not set
global.json file:
Not found
Learn more:
https://aka.ms/dotnet/info
Download .NET:
https://aka.ms/dotnet/download
The IDE (VS / VS Code/ VS4Mac) you're running on, and its version
Microsoft Visual Studio Version 17.12.1
The text was updated successfully, but these errors were encountered:
Describe the bug
IDE0079 Remove unnecessary suppression is reported incorrectly when
<AnalysisLevel>latest-all</AnalysisLevel>
is used to enable all analysers.Edit: This also occurs with an .editorconfig and no AnalysisLevel set. Here's the .editorconfig I used to test it.
To Reproduce
ConsoleApp1.csproj
Program.cs
Exceptions (if any)
The following warning is reported incorrectly.
If you remove the "unnecessary" suppression, CA1031 is reported for the block.
Further technical details
dotnet --info
Microsoft Visual Studio Version 17.12.1
The text was updated successfully, but these errors were encountered: