AdaskoTheBeAsT.IDisposableAnalyzers 4.0.7.4

dotnet add package AdaskoTheBeAsT.IDisposableAnalyzers --version 4.0.7.4
NuGet\Install-Package AdaskoTheBeAsT.IDisposableAnalyzers -Version 4.0.7.4
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="AdaskoTheBeAsT.IDisposableAnalyzers" Version="4.0.7.4">
  <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 AdaskoTheBeAsT.IDisposableAnalyzers --version 4.0.7.4
#r "nuget: AdaskoTheBeAsT.IDisposableAnalyzers, 4.0.7.4"
#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 AdaskoTheBeAsT.IDisposableAnalyzers as a Cake Addin
#addin nuget:?package=AdaskoTheBeAsT.IDisposableAnalyzers&version=4.0.7.4

// Install AdaskoTheBeAsT.IDisposableAnalyzers as a Cake Tool
#tool nuget:?package=AdaskoTheBeAsT.IDisposableAnalyzers&version=4.0.7.4

IDisposableAnalyzers

Roslyn analyzers for IDisposable

License Gitter Build status Build Status NuGet

animation

  • 3.x versions are for Visual Studio 2019.
  • 2.x versions are for Visual Studio 2017.
  • 1.x versions are for Visual Studio 2015.
Id Title
IDISP001 Dispose created
IDISP002 Dispose member
IDISP003 Dispose previous before re-assigning
IDISP004 Don't ignore created IDisposable
IDISP005 Return type should indicate that the value should be disposed
IDISP006 Implement IDisposable
IDISP007 Don't dispose injected
IDISP008 Don't assign member with injected and created disposables
IDISP009 Add IDisposable interface
IDISP010 Call base.Dispose(disposing)
IDISP011 Don't return disposed instance
IDISP012 Property should not return created disposable
IDISP013 Await in using
IDISP014 Use a single instance of HttpClient
IDISP015 Member should not return created and cached instance
IDISP016 Don't use disposed instance
IDISP017 Prefer using
IDISP018 Call SuppressFinalize
IDISP019 Call SuppressFinalize
IDISP020 Call SuppressFinalize(this)
IDISP021 Call this.Dispose(true)
IDISP022 Call this.Dispose(false)
IDISP023 Don't use reference types in finalizer context
IDISP024 Don't call GC.SuppressFinalize(this) when the type is sealed and has no finalizer
IDISP025 Class with no virtual dispose method should be sealed
IDISP026 Class with no virtual DisposeAsyncCore method should be sealed
SyntaxTreeCacheAnalyzer Controls caching of for example semantic models for syntax trees

Using IDisposableAnalyzers

The preferable way to use the analyzers is to add the nuget package IDisposableAnalyzers to the project(s).

The severity of individual rules may be configured using rule set files in Visual Studio 2015.

Installation

IDisposableAnalyzers can be installed using:

  • Paket
  • NuGet command line
  • NuGet Package Manager in Visual Studio.

Install using the command line:

paket add IDisposableAnalyzers --project <project>

or if you prefer NuGet

Install-Package IDisposableAnalyzers

Updating

The ruleset editor does not handle changed IDs well, if things get out of sync you can try:

  1. Close visual studio.
  2. Edit the ProjectName.rulset file and remove the IDisposableAnalyzers element.
  3. Start visual studio and add back the desired configuration.

Above is not ideal, sorry about this. Not sure if this is our bug.

Current status

Early alpha, finds bugs in the code but there are also bugs in the analyzer. The analyzer will probably never be perfect as it is a pretty hard problem to solve but we can improve it one test case at the time. Write issues for places where it should warn but does not or where it warns where there is no bug.

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
4.0.7.4 424 5/27/2024
4.0.7.3 2,380 3/5/2024
4.0.7.2 412 2/26/2024
4.0.7.1 638 2/11/2024

4.0.7
     BUGFIX: Handle target typed new
     4.0.6
     BUGFIX: Handle ref struct
     BUGFIX: Handle target typed new
     4.0.5
     BUGFIX: Handle ValueTask
     BUGFIX: awaited in expression
     4.0.3
     BUGFIX: Handle recursive builder
     4.0.2
     BUGFIX: IDISP007 when disposing static member in static context
     4.0.1
     BUGFIX: IDISP007 false warning when using Rx
     BUGFIX: IDISP016 false warning when foreach
     BUGFIX: Handle leaveOpen when AsyncDisposable
     BUGIX: Handle top level statements.
     4.0.0
     BREAKING: For VS2022+ now.
     BUGFIX: AD0001 -> Could not load file or assembly
     3.4.15
     BUGFIX: IDISP005 with ServiceDescriptor
     BUGFIX: IDISP004 when DisposeWith
     3.4.14
     BUGFIX: IDISP005 should not warn in Assert.Throws.
     BUGFIX: Handle function pointer.
     3.4.13
     BUGFIX: Specialcase Gu.Reactive extension methods.
     3.4.12
     BUGFIX: Handle more cases when chained extension methods.
     BUGFIX: When leaveOpen has default value
     3.4.11
     BUGFIX IDISP023 handle trivial and.
     BUGFIX IDISP023 when chained constructors
     BUGFIX IDISP001 when if statement.
     BUGFIX IDISP004 when chained leave open.
     3.4.10
     BUGFIX: Handle using in loop
     3.4.9
     BUGFIX: IDISP023 Allow touching static reference types.
     BUGFIX: AD0001: Analyzer 'IDisposableAnalyzers.LocalDeclarationAnalyzer
     3.4.8
     BUGFIX: Don't use Roslyn's SymbolEqualityComparer
     3.4.7
     Can't repro issues, thinking maybe the 3.4.6 release used wrong binaries.
     3.4.6
     BUGFIX: IDSP007 when using declaration.
     BUGFIX: Figure out chained calls.
     3.4.5
     FEATURE: Handle switch expression.
     BUGFIX: Figure out await in more places.
     BUGFIX: Tweak assumptions about binary symbols.
     BUGFIX: Handle Interlocked.Exchange
     3.4.4
     FEATURE: Handle some common uses of reflection.
     3.4.3
     Special case ConnectionFactory.CreateConnection
     BUGFIX: Handle chained calls
     BUGFIX: Cast and dispose correctly.
     3.4.2
     Handle some regressions in Roslyn 3.7
     3.4.1
     Publish with binaries.
     3.4.0
     FEATURE: Handle DisposableMixins.DisposeWith
     BUGFIX: IDISP025 when abstract dispose method.
     BUGFIX: IDISP006 when explicit implementation.
     3.3.9
     BUGFIX: Special case IHostedService more
     3.3.8
     BUGFIX: Handle nullable
     3.3.7
     BUGFIX: Handle conditional access (regression)
     3.3.6
     Handle ValueTask
     Handle HostingAbstractionsHostExtensions
     BUGFIX: IDISP010 when public override void Dispose()
     3.3.5
     Handle IHostedService
     3.3.4
     BUGFIX: IDISP004 when yield return.
     BUGFIX: IDISP004 handle System.Net.Mail.Attachment
     BUGFIX: IDISP003 handle null forgiving operator.
     3.3.3
     BUGFIX: Infinite recursion killing VS.
     3.3.2
     BUGFIX: IDISP023 don't warn on attribute.
     3.3.1
     BUGFIX: IDISP017: when DisposeAsync()
     BUGFIX: IDISP004 when pooled
     3.3.0
     FEAUTURE: Initial support for AsyncDisposable
     3.2.0
     BUGFIX: Handle extension methods in binary references better.