<Type Name="AvoidLocalDataStoreSlotRule" FullName="Gendarme.Rules.Performance.AvoidLocalDataStoreSlotRule">
  <TypeSignature Language="C#" Value="public class AvoidLocalDataStoreSlotRule : Gendarme.Framework.Rule, Gendarme.Framework.IMethodRule" />
  <TypeSignature Language="ILAsm" Value=".class public auto ansi beforefieldinit AvoidLocalDataStoreSlotRule extends Gendarme.Framework.Rule implements class Gendarme.Framework.IMethodRule, class Gendarme.Framework.IRule" />
  <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.IMethodRule</InterfaceName>
    </Interface>
  </Interfaces>
  <Attributes>
    <Attribute>
      <AttributeName>Gendarme.Framework.EngineDependency(typeof(Gendarme.Framework.Engines.OpCodeEngine))</AttributeName>
    </Attribute>
    <Attribute>
      <AttributeName>Gendarme.Framework.Problem("LocalDataStoreSlot is slower than the [ThreadStatic] or [ContextStatic] alternatives.")</AttributeName>
    </Attribute>
    <Attribute>
      <AttributeName>Gendarme.Framework.Solution("Change your code to use [ThreadStatic] or [ContextStatic] attributes.")</AttributeName>
    </Attribute>
  </Attributes>
  <Docs>
    <summary>
            This rule warns if a method use <c>LocalDataStoreSlot</c> to store or
            retrieve data from Thread or Context Local Storage. The faster alternative
            is to use <c>[ThreadStatic]</c> or <c>[ContextStatic]</c> attributes to avoid
            extra calls and typecasts.
            Also <c>[ThreadStatic]</c> is available on Silverlight while the
            <c>LocalDataStoreSlot</c> API are not.
            </summary>
    <remarks>This rule is available since Gendarme 2.8</remarks>
    <example>
            Bad example (Thread Local Storage):
            <code>
            static void SetSharedKey (byte[] key)
            {
            	LocalDataStoreSlot lds = Thread.AllocateNamedDataSlot ("shared-key");
            	lds.SetData (key.Clone ());
            }
            public byte[] SignData (byte[] data)
            {
            	LocalDataStoreSlot lds = Thread.GetNamedDataSlot ("shared-key");
            	using (HMACSHA1 hmac = new HMACSHA1 (Thread.GetData (lds) as byte[])) {
            		return hmac.ComputeHash (data);
            	}
            }
            </code></example>
    <example>
            Good example (Thread Local Storage):
            <code>
            [ThreadStatic]
            static byte[] shared_key;
            static void SetSharedKey (byte[] key)
            {
            	shared_key = (byte[]) key.Clone ();
            }
            public byte[] SignData (byte[] data)
            {
            	using (HMACSHA1 hmac = new HMACSHA1 (shared_key)) {
            		return hmac.ComputeHash (data);
            	}
            }
            </code></example>
  </Docs>
  <Members>
    <Member MemberName=".ctor">
      <MemberSignature Language="C#" Value="public AvoidLocalDataStoreSlotRule ();" />
      <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>
    <Member MemberName="Initialize">
      <MemberSignature Language="C#" Value="public override void Initialize (Gendarme.Framework.IRunner runner);" />
      <MemberSignature Language="ILAsm" Value=".method public hidebysig virtual instance void Initialize(class Gendarme.Framework.IRunner runner) cil managed" />
      <MemberType>Method</MemberType>
      <AssemblyInfo>
        <AssemblyVersion>2.11.0.0</AssemblyVersion>
      </AssemblyInfo>
      <ReturnValue>
        <ReturnType>System.Void</ReturnType>
      </ReturnValue>
      <Parameters>
        <Parameter Name="runner" Type="Gendarme.Framework.IRunner" />
      </Parameters>
      <Docs>
        <param name="runner">To be added.</param>
        <summary>To be added.</summary>
        <remarks>To be added.</remarks>
      </Docs>
    </Member>
  </Members>
</Type>
