microsoft/CsWin32
A source generator to add a user-defined set of Win32 P/Invoke methods and supporting types to a C# project. observed · 2026-08-28
Health v2 · maintenance only
96/100
- Activity 99
- Release rhythm 89
- Longevity 100
How is this computed?
round(0.45*activity + 0.35*rhythm + 0.20*longevity); archived -> min(score, 10) — computed 2026-09-03. Adoption (stars, forks) is never an input.
- gap_med: 5
- age_days: 2101
- days_rel: 72
- days_push: 7
- n_releases_24m: 22
Adoption not part of the score
2518 stars · 123 forks observed · 2026-08-28
What it is AI-extracted, prompt v1, taxonomy v1, 2026-08-30, confidence not recorded
A C# source generator that emits strongly-typed P/Invoke and COM interop bindings for Win32 APIs from .winmd metadata. It generates friendly overloads, SafeHandle support, and XML docs at compile time without shipping extra assemblies.
Use cases
- call Win32 APIs from C# without hand-writing P/Invoke signatures
- generate type-safe interop bindings for Windows SDK functions
- use COM interfaces from .NET with proper marshaling
- avoid manual DllImport declarations and unsafe code
- get SafeHandle-based resource management for native handles
When to choose
- you need to call Win32 or COM APIs from a C# project
- you want compile-time generated, strongly-typed interop code
- you prefer no runtime interop assembly dependency
When to avoid
- you target non-Windows platforms exclusively
- you need cross-platform native interop beyond Win32 metadata
- your project does not use Roslyn source generators
Facets
library · maturity active
developer-tools developer-tools windows apis windows dotnet cross-platform source-generator p-invoke win32 com-interop csharp roslyn code-generation interop
2 sources
- readme: https://github.com/microsoft/CsWin32 · fetched 2026-08-28 · 3acca83def4b
- homepage: https://microsoft.github.io/CsWin32/ · fetched 2026-08-29 · 32a809a611ad
Member repositories
| Repository | Role | Health v2 |
|---|---|---|
| microsoft/CsWin32 | main | 96 |
For agents
markdown · JSON · MCP: product_card(name="microsoft/CsWin32")
Data as of 2026-08-30T08:39:29.467469+00:00 · Report a problem