<Type Name="EnsureLocalDisposalRule" FullName="Gendarme.Rules.Correctness.EnsureLocalDisposalRule">
  <TypeSignature Language="C#" Value="public sealed class EnsureLocalDisposalRule : Gendarme.Framework.Rule, Gendarme.Framework.IMethodRule" />
  <TypeSignature Language="ILAsm" Value=".class public auto ansi sealed beforefieldinit EnsureLocalDisposalRule extends Gendarme.Framework.Rule implements class Gendarme.Framework.IMethodRule, class Gendarme.Framework.IRule" />
  <AssemblyInfo>
    <AssemblyName>Gendarme.Rules.Correctness</AssemblyName>
    <AssemblyVersion>2.11.0.0</AssemblyVersion>
  </AssemblyInfo>
  <Base>
    <BaseTypeName>Gendarme.Framework.Rule</BaseTypeName>
  </Base>
  <Interfaces>
    <Interface>
      <InterfaceName>Gendarme.Framework.IMethodRule</InterfaceName>
    </Interface>
  </Interfaces>
  <Attributes>
    <Attribute>
      <AttributeName>Gendarme.Framework.EngineDependency(typeof(Gendarme.Framework.Engines.OpCodeEngine))</AttributeName>
    </Attribute>
    <Attribute>
      <AttributeName>Gendarme.Framework.FxCopCompatibility("Microsoft.Reliability", "CA2000:DisposeObjectsBeforeLosingScope")</AttributeName>
    </Attribute>
    <Attribute>
      <AttributeName>Gendarme.Framework.Problem("This disposable local is not guaranteed to be disposed of before the method returns.")</AttributeName>
    </Attribute>
    <Attribute>
      <AttributeName>Gendarme.Framework.Solution("Use a 'using' statement or surround the local's usage with a try/finally block.")</AttributeName>
    </Attribute>
  </Attributes>
  <Docs>
    <summary>
            This rule checks that disposable locals are always disposed of before the
            method returns.
            Use a 'using' statement (or a try/finally block) to guarantee local disposal
            even in the event an unhandled exception occurs.
            </summary>
    <remarks>This rule is available since Gendarme 2.4</remarks>
    <example>
            Bad example (non-guaranteed disposal):
            <code>
            void DecodeFile (string file)
            {
            	var stream = new StreamReader (file);
            	DecodeHeader (stream);
            	if (!DecodedHeader.HasContent) {
            		return;
            	}
            	DecodeContent (stream);
            	stream.Dispose ();
            }
            </code></example>
    <example>
            Good example (non-guaranteed disposal):
            <code>
            void DecodeFile (string file)
            {
            	using (var stream = new StreamReader (file)) {
            		DecodeHeader (stream);
            		if (!DecodedHeader.HasContent) {
            			return;
            		}
            		DecodeContent (stream);
            	}
            }
            </code></example>
    <example>
            Bad example (not disposed of / not locally disposed of):
            <code>
            void DecodeFile (string file)
            {
            	var stream = new StreamReader (file);
            	Decode (stream);
            }
            void Decode (Stream stream)
            {
            	/*code to decode the stream*/
            	stream.Dispose ();
            }
            </code></example>
    <example>
            Good example (not disposed of / not locally disposed of):
            <code>
            void DecodeFile (string file)
            {
            	using (var stream = new StreamReader (file)) {
            		Decode (stream);
            	}
            }
            void Decode (Stream stream)
            {
            	/*code to decode the stream*/
            }
            </code></example>
  </Docs>
  <Members>
    <Member MemberName=".ctor">
      <MemberSignature Language="C#" Value="public EnsureLocalDisposalRule ();" />
      <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="CheckMethod">
      <MemberSignature Language="C#" Value="public Gendarme.Framework.RuleResult CheckMethod (Mono.Cecil.MethodDefinition method);" />
      <MemberSignature Language="ILAsm" Value=".method public hidebysig newslot virtual instance valuetype Gendarme.Framework.RuleResult CheckMethod(class Mono.Cecil.MethodDefinition method) cil managed" />
      <MemberType>Method</MemberType>
      <AssemblyInfo>
        <AssemblyVersion>2.11.0.0</AssemblyVersion>
      </AssemblyInfo>
      <ReturnValue>
        <ReturnType>Gendarme.Framework.RuleResult</ReturnType>
      </ReturnValue>
      <Parameters>
        <Parameter Name="method" Type="Mono.Cecil.MethodDefinition" />
      </Parameters>
      <Docs>
        <param name="method">To be added.</param>
        <summary>To be added.</summary>
        <returns>To be added.</returns>
        <remarks>To be added.</remarks>
      </Docs>
    </Member>
  </Members>
</Type>
