<Type Name="UseSuppressFinalizeOnIDisposableTypeWithFinalizerRule" FullName="Gendarme.Rules.Performance.UseSuppressFinalizeOnIDisposableTypeWithFinalizerRule">
  <TypeSignature Language="C#" Value="public class UseSuppressFinalizeOnIDisposableTypeWithFinalizerRule : Gendarme.Framework.Rule, Gendarme.Framework.ITypeRule" />
  <TypeSignature Language="ILAsm" Value=".class public auto ansi beforefieldinit UseSuppressFinalizeOnIDisposableTypeWithFinalizerRule extends Gendarme.Framework.Rule implements class Gendarme.Framework.IRule, class Gendarme.Framework.ITypeRule" />
  <AssemblyInfo>
    <AssemblyName>Gendarme.Rules.Performance</AssemblyName>
    <AssemblyVersion>2.11.0.0</AssemblyVersion>
  </AssemblyInfo>
  <Base>
    <BaseTypeName>Gendarme.Framework.Rule</BaseTypeName>
  </Base>
  <Interfaces>
    <Interface>
      <InterfaceName>Gendarme.Framework.ITypeRule</InterfaceName>
    </Interface>
  </Interfaces>
  <Attributes>
    <Attribute>
      <AttributeName>Gendarme.Framework.EngineDependency(typeof(Gendarme.Framework.Engines.OpCodeEngine))</AttributeName>
    </Attribute>
    <Attribute>
      <AttributeName>Gendarme.Framework.Problem("The type has a finalizer and implements IDisposable, but Dispose does not call System.GC.SuppressFinalize.")</AttributeName>
    </Attribute>
    <Attribute>
      <AttributeName>Gendarme.Framework.Solution("Add a call to GC.SuppressFinalize inside your Dispose method.")</AttributeName>
    </Attribute>
  </Attributes>
  <Docs>
    <summary>
            This rule will fire if a type implements <c>System.IDisposable</c> and has a finalizer
            (called a destructor in C#), but the Dispose method does not call <c>System.GC.SuppressFinalize</c>.
            Failing to do this should not cause properly written code to fail, but it does place a non-trivial
            amount of extra pressure on the garbage collector and on the finalizer thread.
            </summary>
    <remarks>Prior to Gendarme 2.2 this rule was named IDisposableWithDestructorWithoutSuppressFinalizeRule</remarks>
    <example>
            Bad example:
            <code>
            class BadClass : IDisposable {
            	~BadClass ()
            	{
            		Dispose (false);
            	}
            	public void Dispose ()
            	{
            		// GC.SuppressFinalize is missing so the finalizer will be called
            		// which puts needless extra pressure on the garbage collector.
            		Dispose (true);
            	}
            	private void Dispose (bool disposing)
            	{
            		if (ptr != IntPtr.Zero) {
            			Free (ptr);
            			ptr = IntPtr.Zero;
            		}
            	}
            	[DllImport ("somelib")]
            	private static extern void Free (IntPtr ptr);
            	private IntPtr ptr;
            }
            </code></example>
    <example>
            Good example:
            <code>
            class GoodClass : IDisposable {
            	~GoodClass ()
            	{
            		Dispose (false);
            	}
            	public void Dispose ()
            	{
            		Dispose (true);
            		GC.SuppressFinalize (this);
            	}
            	private void Dispose (bool disposing)
            	{
            		if (ptr != IntPtr.Zero) {
            			Free (ptr);
            			ptr = IntPtr.Zero;
            		}
            	}
            	[DllImport ("somelib")]
            	private static extern void Free (IntPtr ptr);
            	private IntPtr ptr;
            }
            </code></example>
  </Docs>
  <Members>
    <Member MemberName=".ctor">
      <MemberSignature Language="C#" Value="public UseSuppressFinalizeOnIDisposableTypeWithFinalizerRule ();" />
      <MemberSignature Language="ILAsm" Value=".method public hidebysig specialname rtspecialname instance void .ctor() cil managed" />
      <MemberType>Constructor</MemberType>
      <AssemblyInfo>
        <AssemblyVersion>2.11.0.0</AssemblyVersion>
      </AssemblyInfo>
      <Parameters />
      <Docs>
        <summary>To be added.</summary>
        <remarks>To be added.</remarks>
      </Docs>
    </Member>
    <Member MemberName="CheckType">
      <MemberSignature Language="C#" Value="public Gendarme.Framework.RuleResult CheckType (Mono.Cecil.TypeDefinition type);" />
      <MemberSignature Language="ILAsm" Value=".method public hidebysig newslot virtual instance valuetype Gendarme.Framework.RuleResult CheckType(class Mono.Cecil.TypeDefinition type) cil managed" />
      <MemberType>Method</MemberType>
      <AssemblyInfo>
        <AssemblyVersion>2.11.0.0</AssemblyVersion>
      </AssemblyInfo>
      <ReturnValue>
        <ReturnType>Gendarme.Framework.RuleResult</ReturnType>
      </ReturnValue>
      <Parameters>
        <Parameter Name="type" Type="Mono.Cecil.TypeDefinition" />
      </Parameters>
      <Docs>
        <param name="type">To be added.</param>
        <summary>To be added.</summary>
        <returns>To be added.</returns>
        <remarks>To be added.</remarks>
      </Docs>
    </Member>
  </Members>
</Type>
