For example, this is from .NET Framework source file UnsafeNativeMethods.cs:
[DllImport(ExternDll.User32, ExactSpelling=true, CharSet=CharSet.Auto)]
public static extern bool GetWindowRect(HandleRef hWnd,
[In, Out] ref NativeMethods.RECT rect);
and this is from PInvoke.Net:
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool GetWindowRect(HandleRef hwnd, out RECT lpRect);
Which is the correct/best signature for this function? (only one of them has
[return: MarshalAs(UnmanagedType.Bool)]
, or[In, Out] ref
, etc.)I've noticed that in .NET Framework source files many/most signatures have
ExactSpelling=true, CharSet=CharSet.Auto
, but on PInvoke they don't. Is this required?