microsoft / win32metadata

Tooling to generate metadata for Win32 APIs in the Windows SDK.
Other
1.32k stars 113 forks source link

COINIT documentation is wrong #1879

Closed DragosPopse closed 4 months ago

DragosPopse commented 5 months ago

The official page the metadata points to, the definition that is shown there

typedef enum tagCOINIT {
  COINIT_APARTMENTTHREADED = 0x2,
  COINIT_MULTITHREADED,
  COINIT_DISABLE_OLE1DDE = 0x4,
  COINIT_SPEED_OVER_MEMORY = 0x8
} COINIT;

Makes you believe that MULTITHREADED is set to be 3. Looking at objasse.h, this is wrong

typedef enum tagCOINIT
{
  COINIT_APARTMENTTHREADED  = 0x2,      // Apartment model

#if  (_WIN32_WINNT >= 0x0400 ) || defined(_WIN32_DCOM) // DCOM
  // These constants are only valid on Windows NT 4.0
  COINIT_MULTITHREADED      = COINITBASE_MULTITHREADED,
  COINIT_DISABLE_OLE1DDE    = 0x4,      // Don't use DDE for Ole1 support.
  COINIT_SPEED_OVER_MEMORY  = 0x8,      // Trade memory for speed.
#endif // DCOM
} COINIT;

where COINITBASE_MULTITHREADED is defined in combaseapi.h as

typedef enum tagCOINITBASE
{
// DCOM
#if (_WIN32_WINNT >= 0x0400) || defined(_WIN32_DCOM)
  // These constants are only valid on Windows NT 4.0
  COINITBASE_MULTITHREADED      = 0x0,      // OLE calls objects on any thread.
#endif // DCOM
} COINITBASE;

This is problematic for creating bindings to the win32 API in other languages, as it misleads you to believe imaginary tales.

There are other places like this where the docs don't tell you what you need to know without jumping deep into the headers, so if this report is useful i'm happy to submit more.

riverar commented 4 months ago

Metadata currently has:

[Documentation("https://learn.microsoft.com/windows/win32/api/objbase/ne-objbase-coinit")]
[Flags]
public enum COINIT
{
    COINIT_APARTMENTTHREADED = 2,
    COINIT_MULTITHREADED = 0,
    COINIT_DISABLE_OLE1DDE = 4,
    COINIT_SPEED_OVER_MEMORY = 8
}

So doesn't seem like there's an issue here, right?

riverar commented 4 months ago

Closing for now, let us know if I missed something here. Doc bugs can be filed by clicking the pencil icon on this page https://learn.microsoft.com/windows/win32/api/objbase/ne-objbase-coinit

DragosPopse commented 4 months ago

thanks @riverar. That's the thing i was actually looking for (submitting docs bug)