Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Differentiate NativeTypedef structs that exist in the headers vs. only in metadata #1538

Merged
merged 10 commits into from
Apr 17, 2023
2 changes: 1 addition & 1 deletion docs/projections.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ DISCLAIMER: This list is a work in progress and is not yet comprehensive.
* NOTE: Examples of `"<FIELDNAME>"` include `"cbSize"` for a field on the struct or `"StartupInfo.cb"` for a nested field like `StartupInfo.cb` on the `STARTUPINFOEXW` struct
* Native unions are represented as CLR structs whose names follow the pattern `_<NAME>_e__Union` and are decorated with `[StructLayout(LayoutKind.Explicit)]` where all fields are decorated with `[FieldOffset(0)]`. Anonymous unions will use `AnonymousN` in place of `<NAME>` where `N` is an optional number added to differentiate multiple anonymous unions within the same scope. Named unions will preserve the name in place of `<NAME>`. Struct fields that refer to these unions use `<NAME>` for the field names. ([#99](https://github.com/microsoft/win32metadata/issues/99))
* Scoped enums are decorated with the `[ScopedEnum]` attribute
* typedefs (e.g. `BCRYPT_KEY_HANDLE`) are represented as CLR structs with a single field where the `NativeTypedef` attribute is applied to the struct. The type being defined is given by the name of the struct, and the type it is being defined as is the type of the struct field. typedefs can include the attributes `AlsoUsableFor`, `RAIIFree` and `InvalidHandleValue`:
* typedefs (e.g. `BCRYPT_KEY_HANDLE`) are represented as CLR structs with a single field where either the `NativeTypedef` or `MetadataTypedef` attribute is applied to the struct. `NativeTypedef` represents typedefs that exist in the Win32 headers while `MetadataTypedef` represents metadata-only typedefs added to improve API usability. Projections can choose to unwrap `MetadataTypedef` structs in order to align with the original header definitions. The type being defined is given by the name of the struct, and the type it is being defined as is the type of the struct field. typedefs can include the attributes `AlsoUsableFor`, `RAIIFree` and `InvalidHandleValue`:
* `AlsoUsableFor` indicates that the type is implicitly convertible to another type (e.g. `BCRYPT_HANDLE`)
* `RAIIFree` indicates what function should be used to close the handle (e.g. `BCryptDestroyKey`)
* `InvalidHandleValue` attributes indicate invalid handle values (e.g. `0L`)
Expand Down
Loading