I've done quite a bit of PInvoke stuff recently, wanting to stay close to the Windows API header files.
When creating the enum below, you get this compiler error:
Error 1 Type byte, sbyte, short, ushort, int, uint, long, or ulong expected
Why is it that the C# compiler does not understand any other underlying types?
The C# compiler can go from uint to System.UInt32, why not the other way around?
using System;
using System.Runtime.InteropServices;
using DWORD = System.UInt32;
namespace BeSharp.Win32
{
[StructLayout(LayoutKind.Sequential)]
internal class MOUSEINPUT
{
// ...
MouseData mouseData; // DWORD
// ...
[Flags]
internal enum MouseData : System.UInt32; // needs to be uint; you cannot do DWORD or System.UInt32 here
{
Nothing = 0x0000,
XBUTTON1 = 0x0001,
XBUTTON2 = 0x0002,
}
// ...
}
}