<Type Name="DoNotUseMethodImplOptionsSynchronizedRule" FullName="Gendarme.Rules.Concurrency.DoNotUseMethodImplOptionsSynchronizedRule">
  <TypeSignature Language="C#" Value="public class DoNotUseMethodImplOptionsSynchronizedRule : Gendarme.Framework.Rule, Gendarme.Framework.IMethodRule" />
  <TypeSignature Language="ILAsm" Value=".class public auto ansi beforefieldinit DoNotUseMethodImplOptionsSynchronizedRule extends Gendarme.Framework.Rule implements class Gendarme.Framework.IMethodRule, class Gendarme.Framework.IRule" />
  <AssemblyInfo>
    <AssemblyName>Gendarme.Rules.Concurrency</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.Problem("This method is decorated with [MethodImpl(MethodImplOptions.Synchronized)].")</AttributeName>
    </Attribute>
    <Attribute>
      <AttributeName>Gendarme.Framework.Solution("Remove the attribute and provide your own private lock object.")</AttributeName>
    </Attribute>
  </Attributes>
  <Docs>
    <summary>
            This rule fires if a method is decorated with <c>[MethodImpl(MethodImplOptions.Synchronized)]</c>.
            The runtime synchronizes those methods automatically using a <c>lock(this)</c> for
            instance methods or a <c>lock(typeof(X))</c> for static methods. 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:
            <code>
            [MethodImpl (MethodImplOptions.Synchronized)]
            public void SychronizedMethod ()
            {
            	producer++;
            }
            </code></example>
    <example>
            Good example:
            <code>
            public 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 DoNotUseMethodImplOptionsSynchronizedRule ();" />
      <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>
