RepoMicrosoftMicrosoftpublished Dec 1, 2020seen 1d

microsoft/CsWin32

C#

Open original ↗

Captured source

source ↗
published Dec 1, 2020seen 1dcaptured 9hhttp 200method plain

microsoft/CsWin32

Description: A source generator to add a user-defined set of Win32 P/Invoke methods and supporting types to a C# project.

Language: C#

License: MIT

Stars: 2496

Forks: 121

Open issues: 139

Created: 2020-12-01T18:59:20Z

Pushed: 2026-06-11T00:11:03Z

Default branch: main

Fork: no

Archived: no

README: C#/Win32 Interop Projection

C#/Win32 provides P/Invoke and COM Interop projection support for C#. It generates strongly-typed, source-generated bindings from CsWn32-compatible .winmd metadata files. CsWin32 supports the metadata of Microsoft.Windows.SDK.Win32Metadata as the 1st-party metadata.

  • Generates interop code quickly at compilation time.
  • Generates friendly overloads/extensions (including SafeHandle-types support).
  • Generates xml documentation based on and links back to learn.microsoft.com
  • Ships no bulky assemblies alongside your application.

Getting started

Demo

![Animation demonstrating p/invoke code generation](docfx/images/demo.gif)