ExceptionalStatistics 1.0.0

dotnet tool install --global ExceptionalStatistics --version 1.0.0                
This package contains a .NET tool you can call from the shell/command line.
dotnet new tool-manifest # if you are setting up this repo
dotnet tool install --local ExceptionalStatistics --version 1.0.0                
This package contains a .NET tool you can call from the shell/command line.
#tool dotnet:?package=ExceptionalStatistics&version=1.0.0                
nuke :add-package ExceptionalStatistics --version 1.0.0                

ExceptionalStatistics

Using Roslyn to gather statistics on bad exception handling - i.e. empty "catch-all" blocks.

Getting Started

Install the ExceptionalStatistics tool from NuGet - that's it.

Prerequisites

The ExceptionalStatistics tool targets .NET 7.

Usage

You can look for bad exceptional handlers by either providing the location of a solution file:

ExceptionalStatistics --sln "C:\MyDirectory\MySolutionFile.sln"

Or, you give a directory as the starting point - ExceptionalStatistics will enumerate all files within that directory and subdirectories for C# files:

ExceptionalStatistics --dir "C:\MyDirectory"

In either case, you should see output something like this:

Total number of files: 12704
Number of statements: 903409
Number of expressions: 3900845
Number of bad catch blocks: 43
Number of empty catch blocks with filters: 64

Bad Catch Clauses

        File: M:\repos\roslyn2\src\VisualStudio\Core\Def\EditAndContinue\EditAndContinueFeedbackDiagnosticFileProvider.cs
                Microsoft.VisualStudio.LanguageServices.EditAndContinue.EditAndContinueFeedbackDiagnosticFileProvider.OnFeedbackSemaphoreDeleted()
                Start line location: 134
                End line location: 134
        File: M:\repos\roslyn2\src\Workspaces\Remote\Core\BrokeredServiceConnection.cs
                Microsoft.CodeAnalysis.Remote.BrokeredServiceConnection.OnUnexpectedException()
                Start line location: 410
                End line location: 410

Feedback

If you run into any issues, please add them here.

Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

Version Downloads Last updated
1.0.0 247 9/15/2023