Skip to content

Provide a static interface for the Guid on COM structs #752

@JeremyKuhne

Description

@JeremyKuhne

We don't want to use reflection to get Guid information and also want to constrain generic helpers so in WinForms we implement INativeGuid on every generated COM struct:

internal interface INativeGuid
{
    public static abstract unsafe Guid* NativeGuid { get; }
}

internal unsafe partial struct IStream : IPopulateVTable<IStream.Vtbl>, INativeGuid
{
    static Guid* INativeGuid.NativeGuid => (Guid*)Unsafe.AsPointer(ref Unsafe.AsRef(in Guid));
}

Here is an example of how we use it: #751 (comment)

Here is another:

picture.Value->QueryInterface(IPersistStream.NativeGuid, persist);

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions