== How to fix it === Code examples ==== Noncompliant code example include::{language}/noncompliant-code.adoc[] ==== Compliant solution include::{language}/compliant-code.adoc[] === Going the extra mile In general object finalization can be a complex and error-prone operation and should not be implemented except within the https://learn.microsoft.com/en-us/dotnet/standard/garbage-collection/implementing-dispose[dispose pattern]. When https://learn.microsoft.com/en-us/dotnet/standard/garbage-collection/unmanaged[cleaning up unmanaged resources], it is recommended to implement the dispose pattern or, to cover uncalled https://learn.microsoft.com/en-us/dotnet/api/system.idisposable.dispose[`Dispose`] method by the consumer, implement https://learn.microsoft.com/en-us/dotnet/api/system.runtime.interopservices.safehandle[`SafeHandle`].