Tetractic.CodeAnalysis.ExceptionAnalyzers 1.1.0

The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org. Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package Tetractic.CodeAnalysis.ExceptionAnalyzers --version 1.1.0
NuGet\Install-Package Tetractic.CodeAnalysis.ExceptionAnalyzers -Version 1.1.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Tetractic.CodeAnalysis.ExceptionAnalyzers" Version="1.1.0">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Tetractic.CodeAnalysis.ExceptionAnalyzers --version 1.1.0
#r "nuget: Tetractic.CodeAnalysis.ExceptionAnalyzers, 1.1.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Tetractic.CodeAnalysis.ExceptionAnalyzers as a Cake Addin
#addin nuget:?package=Tetractic.CodeAnalysis.ExceptionAnalyzers&version=1.1.0

// Install Tetractic.CodeAnalysis.ExceptionAnalyzers as a Cake Tool
#tool nuget:?package=Tetractic.CodeAnalysis.ExceptionAnalyzers&version=1.1.0

Exception Analyzers helps you check that exceptions are caught or documented in C#.

How It Works

An analyzer examines throw statements, try/catch blocks, and the <exception> elements in documentation comment XML for symbols referenced by your code to determine what exception types could escape your code. Diagnostics are reported for any of those exception types that do not appear in the <exception> elements in the documentation comment XML for your code.

Example

void Demo1() => throw new NotSupportedException();
//              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//              Ex0100: 'Demo1()' may throw undocumented exception: NotSupportedException

/// <exception cref="NotSupportedException"/>
void Demo2() => throw new NotSupportedException();  // No diagnostic; exception is documented.

void Demo3() => Demo2();
//              ~~~~~
//              Ex0100: 'Demo3()' may throw undocumented exception: NotSupportedException

void Demo4(bool b)
{
    try
    {
        if (b)
            throw new NotSupportedException();  // No diagnostic; Exception is caught.
        else
            throw new Exception();
        //  ~~~~~~~~~~~~~~~~~~~~~~
        //  Ex0100: 'Demo4(bool)' may throw undocumented exception: Exception
    }
    catch (NotSupportedException)
    {
        throw;
    //  ~~~~~~
    //  Ex0100: 'Demo4(bool)' may throw undocumented exception: NotSupportedException
    }
}

Configuration

.editorconfig

dotnet_ignored_exceptions

Provides a list of exception types that will be ignored by exception analysis.

Setting name: dotnet_ignored_exceptions
Value: A comma-separated list of fully-qualified type names.
Default value: System.NullReferenceException, System.UnreachableException

dotnet_intransitive_exceptions

Provides a list of exception types that will be ignored by exception analysis when not thrown directly. This is useful for exception types that generally indicate incorrect code when thrown. The conditions under which these exception types are thrown should be documented, but those conditions should be avoidable and avoided in correctly-written code.

For example, it should be possible to avoid providing unacceptable arguments that would cause an ArgumentException to be thrown. ArgumentException and its subtypes, in particular, are so pervasive that reporting a diagnostic for every method invocation that might throw one of them would be unhelpful.

Setting name: dotnet_intransitive_exceptions
Value: A comma-separated list of fully-qualified type names.
Default value: System.ArgumentException, System.IndexOutOfRangeException, System.InvalidOperationException, System.Collections.Generic.KeyNotFoundException

Exception Adjustments

TODO

There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.4.5 376 5/11/2024
1.4.4 847 3/7/2024
1.4.3 278 3/1/2024
1.4.2 889 12/1/2023
1.4.1 2,258 11/22/2022
1.4.0 494 10/8/2022
1.3.2 412 9/6/2022
1.3.1 1,468 5/28/2022
1.3.0 547 12/23/2021
1.2.2 313 10/22/2021
1.2.1 282 10/21/2021
1.2.0 325 10/19/2021
1.1.2 388 10/15/2021
1.1.1 354 10/13/2021
1.1.0 337 10/11/2021
1.0.1 479 10/9/2021