Skip to content

VisibaCare/IDisposableAnalyzers

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

Roslyn analyzers for IDisposable

Resources

License

Stars

Watchers

Forks

Languages

  • C# 99.9%
  • PowerShell 0.1%