Tetractic.CodeAnalysis.ExceptionAnalyzers
1.1.0
Prefix Reserved
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
<PackageReference Include="Tetractic.CodeAnalysis.ExceptionAnalyzers" Version="1.1.0"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
paket add Tetractic.CodeAnalysis.ExceptionAnalyzers --version 1.1.0
#r "nuget: Tetractic.CodeAnalysis.ExceptionAnalyzers, 1.1.0"
// 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
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.6 | 4,214 | 10/28/2024 |
1.4.5 | 1,768 | 5/11/2024 |
1.4.4 | 1,084 | 3/7/2024 |
1.4.3 | 331 | 3/1/2024 |
1.4.2 | 961 | 12/1/2023 |
1.4.1 | 2,497 | 11/22/2022 |
1.4.0 | 539 | 10/8/2022 |
1.3.2 | 451 | 9/6/2022 |
1.3.1 | 2,013 | 5/28/2022 |
1.3.0 | 585 | 12/23/2021 |
1.2.2 | 347 | 10/22/2021 |
1.2.1 | 322 | 10/21/2021 |
1.2.0 | 358 | 10/19/2021 |
1.1.2 | 426 | 10/15/2021 |
1.1.1 | 388 | 10/13/2021 |
1.1.0 | 386 | 10/11/2021 |
1.0.1 | 512 | 10/9/2021 |