IDISP006
November 25, 2021 ยท View on GitHub
Implement IDisposable
| Topic | Value |
|---|---|
| Id | IDISP006 |
| Severity | Warning |
| Enabled | True |
| Category | IDisposableAnalyzers.Correctness |
| Code | FieldAndPropertyDeclarationAnalyzer |
Description
The member is assigned with a created IDisposables within the type. Implement IDisposable and dispose it.
Motivation
The type creates IDisposable(s) and assigns it to a member. Hence it must implement IDisposable and dispose the member.
How to fix violations
Use the code fixes or manually implement IDisposable
Configure severity
Via ruleset file.
Configure the severity per project, for more info see MSDN.
Via #pragma directive.
#pragma warning disable IDISP006 // Implement IDisposable
Code violating the rule here
#pragma warning restore IDISP006 // Implement IDisposable
Or put this at the top of the file to disable all instances.
#pragma warning disable IDISP006 // Implement IDisposable
Via attribute [SuppressMessage].
[System.Diagnostics.CodeAnalysis.SuppressMessage("IDisposableAnalyzers.Correctness",
"IDISP006:Implement IDisposable",
Justification = "Reason...")]