Quantcast
Channel: Tagged with gendarme - RemObjects Connect
Viewing all articles
Browse latest Browse all 2

Gendarme warning about no marshaling information for boolean parameter (P/Invoke)

$
0
0
Greetings everyone!

Consider the following code:

uses
System.Runtime.InteropServices,
System.Security;

type
[SuppressUnmanagedCodeSecurity]
UnsafeNativeMethods = static assembly class
public
[DllImport('kernel32.dll', SetLastError := true)]
class method FreeLibrary(hModule: IntPtr): [MarshalAs(UnmanagedType.Bool)] Boolean; external;
end;
If I add it to the interface section of the program.pas file in a new .NET 4 or 4.5 console application, enable Gendarme code analysis and build the solution, I get the following warning:

Program.pas(14,5): warning High/Normal: No marshaling information is supplied for boolean parameters(s) on this p/invoke declaration. Specify, even if just for clarity, the size of the unmanaged boolean representation.

As you can see from the code, I have tried to specify how the return type should be marshalled. Is there any other way I should write this?

Oxygene version 5.2.39.1091

Viewing all articles
Browse latest Browse all 2

Trending Articles