<Type Name="DoNotLockOnThisOrTypesRule" FullName="Gendarme.Rules.Concurrency.DoNotLockOnThisOrTypesRule">
  <TypeSignature Language="C#" Value="public class DoNotLockOnThisOrTypesRule : Gendarme.Rules.Concurrency.LockAnalyzerRule" />
  <TypeSignature Language="ILAsm" Value=".class public auto ansi beforefieldinit DoNotLockOnThisOrTypesRule extends Gendarme.Rules.Concurrency.LockAnalyzerRule" />
  <AssemblyInfo>
    <AssemblyName>Gendarme.Rules.Concurrency</AssemblyName>
    <AssemblyVersion>2.11.0.0</AssemblyVersion>
  </AssemblyInfo>
  <Base>
    <BaseTypeName>Gendarme.Rules.Concurrency.LockAnalyzerRule</BaseTypeName>
  </Base>
  <Interfaces />
  <Attributes>
    <Attribute>
      <AttributeName>Gendarme.Framework.Problem("This method uses lock(this) or lock(typeof(X)) which makes it very difficult to ensure that the locking is done correctly.")</AttributeName>
    </Attribute>
    <Attribute>
      <AttributeName>Gendarme.Framework.Solution("Instead lock a private object so that you have better control of when the locking is done.")</AttributeName>
    </Attribute>
  </Attributes>
  <Docs>
    <summary>
            This rule checks if you're using <c>lock</c> on the current instance (<c>this</c>) or
            on a <c>Type</c>. This can cause
            problems because anyone can acquire a lock on the instance or type. And if another
            thread does acquire a lock then deadlocks become a very real possibility. The preferred way to
            handle this is to create a private <c>System.Object</c> instance field and <c>lock</c> that. This
            greatly reduces the scope of the code which may acquire the lock which makes it much easier
            to ensure that the locking is done correctly.
            </summary>
    <remarks>To be added.</remarks>
    <example>
            Bad example (this):
            <code>
            public void MethodLockingOnThis ()
            {
            	lock (this) {
            		producer++;
            }
            }
            </code></example>
    <example>
            Bad example (type):
            <code>
            public void MethodLockingOnType ()
            {
            	lock (this.GetType ()) {
            		producer++;
            	}
            }
            </code></example>
    <example>
            Good example:
            <code>
            class ClassWithALocker {
            	object locker = new object ();
            	int producer = 0;
            	public void MethodLockingLocker ()
            	{
            		lock (locker) {
            			producer++;
            		}
            	}
            }
            </code></example>
  </Docs>
  <Members>
    <Member MemberName=".ctor">
      <MemberSignature Language="C#" Value="public DoNotLockOnThisOrTypesRule ();" />
      <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="Analyze">
      <MemberSignature Language="C#" Value="public override void Analyze (Mono.Cecil.MethodDefinition method, Mono.Cecil.MethodReference enter, Mono.Cecil.Cil.Instruction ins);" />
      <MemberSignature Language="ILAsm" Value=".method public hidebysig virtual instance void Analyze(class Mono.Cecil.MethodDefinition method, class Mono.Cecil.MethodReference enter, class Mono.Cecil.Cil.Instruction ins) cil managed" />
      <MemberType>Method</MemberType>
      <AssemblyInfo>
        <AssemblyVersion>2.11.0.0</AssemblyVersion>
      </AssemblyInfo>
      <ReturnValue>
        <ReturnType>System.Void</ReturnType>
      </ReturnValue>
      <Parameters>
        <Parameter Name="method" Type="Mono.Cecil.MethodDefinition" />
        <Parameter Name="enter" Type="Mono.Cecil.MethodReference" />
        <Parameter Name="ins" Type="Mono.Cecil.Cil.Instruction" />
      </Parameters>
      <Docs>
        <param name="method">To be added.</param>
        <param name="enter">To be added.</param>
        <param name="ins">To be added.</param>
        <summary>To be added.</summary>
        <remarks>To be added.</remarks>
      </Docs>
    </Member>
  </Members>
</Type>
