<Type Name="DoNotUseGetInterfaceToCheckAssignabilityRule" FullName="Gendarme.Rules.BadPractice.DoNotUseGetInterfaceToCheckAssignabilityRule">
  <TypeSignature Language="C#" Value="public class DoNotUseGetInterfaceToCheckAssignabilityRule : Gendarme.Framework.Rule, Gendarme.Framework.IMethodRule" />
  <TypeSignature Language="ILAsm" Value=".class public auto ansi beforefieldinit DoNotUseGetInterfaceToCheckAssignabilityRule extends Gendarme.Framework.Rule implements class Gendarme.Framework.IMethodRule, class Gendarme.Framework.IRule" />
  <AssemblyInfo>
    <AssemblyName>Gendarme.Rules.BadPractice</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("This method calls Type.GetInterface(string) to query if an interface is supported by the type, but the result may be incorrect if the type is not qualified with a namespace (and not even that is guaranteed to work).")</AttributeName>
    </Attribute>
    <Attribute>
      <AttributeName>Gendarme.Framework.Solution("Instead use Type.IsAssignableFrom(Type) method to query for types known at compile time.")</AttributeName>
    </Attribute>
  </Attributes>
  <Docs>
    <summary>
            This rule checks for calls to <c>Type.GetInterface</c> that look like they query if
            a type is supported, i.e. the result is only used to compare against <c>null</c>.
            The problem is that only assembly qualified names uniquely identify a type so if
            you just use the interface name or even just the name and namespace you may
            get unexpected results.
            </summary>
    <remarks>This rule is available since Gendarme 2.2</remarks>
    <example>
            Bad example:
            <code>
            if (type.GetInterface ("IConvertible") != null)  {
            	// then the type can be assigned to IConvertible
            	// but what if there is another IConvertible in there ?!?
            }
            </code></example>
    <example>
            Good example:
            <code>
            if (typeof (IConvertible).IsAssignableFrom (type))  {
            	// then the type can be assigned to IConvertible
            	// without a doubt!
            }
            </code></example>
  </Docs>
  <Members>
    <Member MemberName=".ctor">
      <MemberSignature Language="C#" Value="public DoNotUseGetInterfaceToCheckAssignabilityRule ();" />
      <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>
