All rules
CA2015Reliability Enabled by default: As warning
Do not define finalizers for types derived from MemoryManager<T>
Do not define finalizers for types derived from MemoryManager<T>
Microsoft docsDescription
Adding a finalizer to a type derived from System.Buffers.MemoryManager1 is likely an indication of a bug, as it suggests a native resource that could have been handed out in a System.Span1 is getting cleaned up and potentially while it is still in use by the System.Span1. The System.Buffers.MemoryManager1 class is intended for advanced scenarios. Most developers do not need to use it.
Cause
Defining finalizers for types derived from System.Buffers.MemoryManager`1
How to fix violations
To fix the violation, remove the finalizer definition.
Example
class DerivedClass <T> : MemoryManager<T>
{
public override bool Dispose(bool disposing)
{
if (disposing)
{
_handle.Dispose();
}
}
...
// Violation occurs, remove the finalizer to fix the warning.
~DerivedClass() => Dispose(false);
}When to suppress
It is safe to suppress a violation of this rule if the intent is to create a finalizer for debugging or validation purposes.
Your vote
Group results
0 yes 0 no
ConsensusNone (disabled)
Severity preference (yes voters)
Suggestion0
Warning0
Error0