<Type Name="DoNotAssumeIntPtrSizeRule" FullName="Gendarme.Rules.Interoperability.DoNotAssumeIntPtrSizeRule">
  <TypeSignature Language="C#" Value="public class DoNotAssumeIntPtrSizeRule : Gendarme.Framework.Rule, Gendarme.Framework.IMethodRule" />
  <TypeSignature Language="ILAsm" Value=".class public auto ansi beforefieldinit DoNotAssumeIntPtrSizeRule extends Gendarme.Framework.Rule implements class Gendarme.Framework.IMethodRule, class Gendarme.Framework.IRule" />
  <AssemblyInfo>
    <AssemblyName>Gendarme.Rules.Interoperability</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 casts a [U]IntPtr to a 32-bit value which won't work on 64-bit architectures.")</AttributeName>
    </Attribute>
    <Attribute>
      <AttributeName>Gendarme.Framework.Solution("You should always use 64 bits integers, signed or unsigned, when doing pointer math.")</AttributeName>
    </Attribute>
  </Attributes>
  <Docs>
    <summary>
            This rule checks for code which casts an <code>IntPtr</code> or <code>UIntPtr</code> into a
            32-bit (or smaller) value. It will also check if memory read with the <c>Marshal.ReadInt32</c>
            and <c>Marshal.ReadInt64</c> methods is being cast into an <code>IntPtr</code> or
            <code>UIntPtr</code>. <code>IntPtr</code> is generally used to reference a memory
            location and downcasting them to 32-bits will make the code fail on 64-bit CPUs.
            </summary>
    <remarks>This rule is available since Gendarme 2.0 but was named DoNotCastIntPtrToInt32Rule before 2.2</remarks>
    <example>
            Bad example (cast):
            <code>
            int ptr = dest.ToInt32 ();
            for (int i = 0; i &lt; 16; i++) {
            	Marshal.StructureToPtr (this, (IntPtr)ptr, false);
            	ptr += 4;
            }
            </code></example>
    <example>
            Bad example (Marshal.Read*):
            <code>
            // that won't work on 64 bits platforms
            IntPtr p = (IntPtr) Marshal.ReadInt32 (p);
            </code></example>
    <example>
            Good example (cast):
            <code>
            long ptr = dest.ToInt64 ();
            for (int i = 0; i &lt; 16; i++) {
            	Marshal.StructureToPtr (this, (IntPtr) ptr, false);
            	ptr += IntPtr.Size;
            }
            </code></example>
    <example>
            Good example (Marshal.Read*):
            <code>
            IntPtr p = (IntPtr) Marshal.ReadIntPtr (p);
            </code></example>
  </Docs>
  <Members>
    <Member MemberName=".ctor">
      <MemberSignature Language="C#" Value="public DoNotAssumeIntPtrSizeRule ();" />
      <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>
