Skip to content

GUID interop: ref vs [MarshalAs(UnmanagedType.LPStruct)] is confusing #45785

Open
@s341507

Description

@s341507

Type of issue

Typo

Description

Current wording

"❌ DON'T Use [MarshalAs(UnmanagedType.LPStruct)] for anything other than ref GUID parameters."

This does not make sense, when reading the paragraph above that says "place either a ref keyword or a [MarshalAs(UnmanagedType.LPStruct)] attribute on the GUID parameter declaration"

Paragraph above current wording

"GUIDs are usable directly in signatures. Many Windows APIs take GUID& type aliases like REFIID. When the method signature contains a reference parameter, place either a ref keyword or a [MarshalAs(UnmanagedType.LPStruct)] attribute on the GUID parameter declaration."

Page URL

https://learn.microsoft.com/en-us/dotnet/standard/native-interop/best-practices#guids

Content source URL

https://github.com/dotnet/docs/blob/main/docs/standard/native-interop/best-practices.md

Document Version Independent Id

e58f3d16-8083-0efe-0057-e21dbebb262f

Platform Id

87721c9b-7c82-1598-5dfd-21d35f0beec8

Article author

@jkoritzinsky

Metadata

  • ID: 6ea501d3-d963-c5dc-342d-ee82c92d1850
  • PlatformId: 87721c9b-7c82-1598-5dfd-21d35f0beec8
  • Service: dotnet-fundamentals

Related Issues

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions