CA1901: P/Invoke declarations should be portable
Breaking - If the P/Invoke is visible outside the assembly. Non Breaking - If the P/Invoke is not visible outside the assembly.
This rule evaluates the size of each parameter and the return value of a P/Invoke and verifies that their size, when marshaled to unmanaged code on 32-bit and 64-bit platforms, is correct. The most common violation of this rule is to pass a fixed-sized integer where a platform-dependent, pointer-sized variable is required.
Either of the following scenarios violates this rule occurs:
The return value or parameter is typed as a fixed-size integer when it should be typed as an IntPtr.
The return value or parameter is typed as an IntPtr when it should be typed as a fixed-size integer.
You can fix this violation by using IntPtr or UIntPtr to represent handles instead of Int32 or UInt32.
You should not suppress this warning.
The following example demonstrates a violation of this rule.
To fix the violation, change the declaration to the following: