2020-12-03 05:05:06 +03:00
# Projections
Language projections built on top of Win32 metadata are what developers should use to call Win32 APIs from various languages.
## Principles
Below are some principles that all language projections should follow:
* Language projections should provide maximum API coverage
* Language projections should provide friendly adaptations of APIs and types where appropriate
* Language projections should provide Intellisense sourced from official documentation
2020-12-03 05:09:33 +03:00
* Language projections should support filtering available APIs based on the SDK version that a project targets
2020-12-03 05:05:06 +03:00
* Language projections should enable developers to target a specific set of APIs and link or include only the artifacts necessary to provide support for those APIs
2021-06-11 07:30:00 +03:00
## Consuming language projections
To call Win32 APIs from the language of your choice based off of this metadata, use the following language projections:
2021-02-16 21:59:02 +03:00
* C# - https://github.com/microsoft/cswin32 (Microsoft)
* C++ - https://github.com/microsoft/cppwin32 (Microsoft)
* Rust - https://github.com/microsoft/windows-rs (Microsoft)
* D - https://github.com/rumbu13/windows-d (Community)
2021-03-18 05:15:40 +03:00
* Dart - https://github.com/timsneath/win32 (Community)
2021-04-28 21:02:59 +03:00
* Zig - https://github.com/marlersoft/zigwin32 (Community)
2021-02-16 21:59:02 +03:00
2021-06-11 07:30:00 +03:00
Note: Community projects are listed here to help with discovery but are not officially validated by Microsoft.
## Implementing language projections
### Parsing the metadata
The winmd file produced by this project can be parsed with any ECMA-335 compliant parser like .NET [System.Reflection ](https://docs.microsoft.com/dotnet/api/system.reflection?view=net-5.0 ) and [System.Reflection.Metadata ](https://docs.microsoft.com/dotnet/api/system.reflection.metadata?view=net-5.0 ) APIs.
2023-02-01 22:06:34 +03:00
Alternatively, a JSON translation of the winmd file can be found at https://github.com/marlersoft/win32json.
### Scenarios
2023-02-01 22:30:58 +03:00
Below are scenarios that are represented in the metadata and that language projections should handle for the best possible developer experience.
* Namespaces allow users to import only the APIs they require and/or to control any code generation that is producing language bindings
* CanReturnAlternateSuccessCodes / CanReturnErrorsAsSuccess ([#1315](https://github.com/microsoft/win32metadata/issues/1315))
2023-02-01 22:06:34 +03:00
* Struct initializers ([#1337](https://github.com/microsoft/win32metadata/issues/1337))