Open
Description
Hi
Is it possible to customize the genertation of the DllImport
lines? For example, rather than:
[SuppressUnmanagedCodeSecurity]
[DllImport("Generated", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, EntryPoint="<entry point>")]
internal static extern int GetValueForExternalName(global::System.IntPtr name);
I wish to have
[SuppressUnmanagedCodeSecurity]
[DllImport("Generated", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, EntryPoint="<entry point>")]
internal static extern int GetValueForExternalName([MarshalAs(UnmanagedType.LPStr)] string name);
Notice that the desired parameter is [MarshalAs(UnmanagedType.LPStr)] string name
rather than global::System.IntPtr name
.
Similarly I wish to modify the declared return type. For example rather than:
[SuppressUnmanagedCodeSecurity]
[DllImport("Generated", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
EntryPoint="entry point")]
internal static extern void GetCode(global::System.IntPtr __instance, global::System.IntPtr @return);
I wish to have:
[SuppressUnmanagedCodeSecurity]
[DllImport("Generated", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, EntryPoint="entry point")]
[return: MarshalAs(UnmanagedType.BStr)]
internal static extern string GetCode(global::System.IntPtr __instance);
Again instead of an out IntPtr, the return is marshaled as System.String.
Thanks