IDisposableAnalyzers.Reloaded 5.0.0

dotnet add package IDisposableAnalyzers.Reloaded --version 5.0.0
                    
NuGet\Install-Package IDisposableAnalyzers.Reloaded -Version 5.0.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="IDisposableAnalyzers.Reloaded" Version="5.0.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.
<PackageVersion Include="IDisposableAnalyzers.Reloaded" Version="5.0.0" />
                    
Directory.Packages.props
<PackageReference Include="IDisposableAnalyzers.Reloaded">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add IDisposableAnalyzers.Reloaded --version 5.0.0
                    
#r "nuget: IDisposableAnalyzers.Reloaded, 5.0.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.
#:package IDisposableAnalyzers.Reloaded@5.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=IDisposableAnalyzers.Reloaded&version=5.0.0
                    
Install as a Cake Addin
#tool nuget:?package=IDisposableAnalyzers.Reloaded&version=5.0.0
                    
Install as a Cake Tool

IDisposableAnalyzers.Reloaded

Roslyn analyzers for IDisposable - a maintained fork ("Reloaded") of the abandoned DotNetAnalyzers/IDisposableAnalyzers, originally created by Johan Larsson and milleniumbug.

License NuGet Build

animation

Drop-in replacement: same analyzer assembly (IDisposableAnalyzers.dll) and the same diagnostic ids (IDISPxxx). Swap the IDisposableAnalyzers package for IDisposableAnalyzers.Reloaded and your existing .editorconfig severities keep working. Targets Visual Studio 2022+ (Roslyn 4.x), the same baseline as upstream 4.x.

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.Reloaded

Add the IDisposableAnalyzers.Reloaded NuGet package to your project(s). The analyzer then lights up in Visual Studio, Rider and dotnet build / CI.

The severity of individual rules is configured via .editorconfig, for example:

dotnet_diagnostic.IDISP001.severity = warning
dotnet_diagnostic.IDISP004.severity = error

Installation

dotnet add package IDisposableAnalyzers.Reloaded

or

Install-Package IDisposableAnalyzers.Reloaded

Acknowledgements

Originally created by Johan Larsson and milleniumbug as IDisposableAnalyzers under the MIT license. This fork revives and maintains that work after the upstream went dormant in 2024. All original diagnostic ids and behavior are preserved.

Current status

The analyzer tackles a genuinely hard problem and will never be perfect, but it finds real bugs and improves one test case at a time. Please file issues where it should warn but does not, or where it warns and 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
5.0.0 21,733 7/8/2026

5.0.0
     Maintained fork "Reloaded" of IDisposableAnalyzers (based on 4.0.8).
     CHANGE: Rebranded package as IDisposableAnalyzers.Reloaded; drop-in replacement (same IDISP ids, same analyzer assembly name).
     CHANGE: Dropped the Visual Studio VSIX; NuGet-only delivery.
     CHANGE: Test/sample projects target net10.0.
     4.0.8
     BUGFIX: Handle moq setup
     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.