Does anybody know whether the following implementation of a C++ interface in C# is correct, particularly with regards to the marshaling of the GUID type.
The original C++ we are implementing:
[
object,
pointer_default(unique),
uuid(Z703B6E9-A050-4C3C-A050-6A5F4EE32767)
]
interface IThing: IUnknown
{
[propget] HRESULT Prop1([out, retval] GUID* prop1);
[propget] HRESULT Prop2([out, retval] EnumProp2* prop2);
[propget] HRESULT Prop3([out, retval] HSTRING* prop3);
};
The converted interface in our C# COM assembly:
[ComVisible(true), Guid("Z703B6E9-A050-4C3C-A050-6A5F4EE32767"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IThing
{
Guid Prop1 { get; }
EnumProp2 Prop2 { get; }
string Prop3 { get; }
}
The concrete class:
public class Thing : IThing
{
public Thing(Guid prop1, EnumProp2 prop2, string prop3)
{
Prop1 = prop1;
Prop2 = prop2;
Prop3 = prop3;
}
public Guid Prop1 { get; }
public EnumProp2 Prop2 { get; }
public string Prop3 { get; }
}
Guid.ToByteArray. reference source shows that theGuidstruct is a complex type and does not expose the raw bits.