windows-rs
Copilot instructions13k starsChanged 58 days agoApache-2.0View on GitHub
Read this file at the start of every session. It contains the essential commands, conventions, and architecture knowledge needed to work on this repository. Do not create git commits automatically. The maintainer reviews all changes first and handles commits manually. Make changes locally, run fmt/clippy/tests to verify, and report back. Cargo workspace (resolver = "3"). Members are globbed from: - crates/libs/* - the published/library crates (windows, windows-sys, windows-core, plus windows-bindgen, metadata, rdl, and the newer reactor/canvas/webview/window crates). See docs/readme.md for…
Trending
Quiet since July.about the whole repository
Who's talking about microsoft/windows-rs
- A Hacker News story“Rust for Windows”Hacker News · Jan 21, 2021 · 785 points
- rust-lang/rust“Tracking issue for RFC 2627: #[link(kind="raw-dylib")]”GitHub · Feb 24, 2019 · 86 reactions
- rust-lang/cargo“Need a reliable way to get the target dir from the build script”GitHub · Jul 7, 2021 · 75 reactions
- golang/go“x/sys/windows: use win32metadata?”GitHub · Jan 22, 2021 · 26 reactions
- A Hacker News story“Rust for Windows”Hacker News · Jan 21, 2021 · 18 points
The biggest 5 of 41 mentions linking to the repository that our crawl found. Each line is their own headline.
See all 41
Talked about on Bluesky, GitHub and Hacker News (41 times).
On Bluesky · 18
- May 26, 2026oh neat nearly the entire win32 api is exposed via these rust crates github.com/microsoft/wi... — @threddyrex.org9 likes and reposts
- Dec 28, 2024microsoft / windows-rs: Rust for Windows ★10842 https://github.com/microsoft/windows-rs — @rusttrending.bsky.social4 likes and reposts
- Dec 15, 2024📦 microsoft / windows-rs ⭐ 10,551 (+6) 🗒 Rust Rust for Windows — @github-trending.bsky.social4 likes and reposts
- May 25, 2025microsoft / windows-rs: Rust for Windows ★11330 https://github.com/microsoft/windows-rs — @rusttrending.bsky.social3 likes and reposts
- Feb 28, 2025microsoft / windows-rs: Rust for Windows ★11022 https://github.com/microsoft/windows-rs — @rusttrending.bsky.social3 likes and reposts
13 more on Bluesky
- Dec 19, 2024microsoft / windows-rs: Rust for Windows ★10804 https://github.com/microsoft/windows-rs — @rusttrending.bsky.social3 likes and reposts
- Nov 23, 2024microsoft / windows-rs: Rust for Windows ★10480 https://github.com/microsoft/windows-rs — @rusttrending.bsky.social3 likes and reposts
- May 2, 2026RustってMicrosoftが公式にwindows SDK的なのを提供してるのか。 知らなかったよ・・・もうRust入門してWin32アプリを作るしかなくなっちゃったよ。 github.com/microsoft/wi... — @lacunas.lacunas.net2 likes and reposts
- Feb 1, 2025microsoft / windows-rs: Rust for Windows ★10974 https://github.com/microsoft/windows-rs — @rusttrending.bsky.social2 likes and reposts
- Jan 8, 2025microsoft / windows-rs: Rust for Windows ★10873 https://github.com/microsoft/windows-rs — @rusttrending.bsky.social2 likes and reposts
- Dec 13, 2024microsoft / windows-rs: Rust for Windows ★10534 https://github.com/microsoft/windows-rs — @rusttrending.bsky.social2 likes and reposts
- Apr 7, 2024microsoft / windows-rs: Rust for Windows ★9717 https://github.com/microsoft/windows-rs — @rusttrending.bsky.social2 likes and reposts
- Jul 7, 2026microsoft / windows-rs: Rust for Windows ★12518 https://github.com/microsoft/windows-rs — @rusttrending.bsky.social1 likes and repost
- Feb 4, 2026microsoft / windows-rs: Rust for Windows ★11910 https://github.com/microsoft/windows-rs — @rusttrending.bsky.social1 likes and repost
- Dec 16, 2024microsoft / windows-rs: Rust for Windows ★10718 https://github.com/microsoft/windows-rs — @rusttrending.bsky.social1 likes and repost
- Dec 16, 2024microsoft / windows-rs: Rust for Windows ★10714 https://github.com/microsoft/windows-rs — @rusttrending.bsky.social1 likes and repost
- Apr 8, 2024microsoft / windows-rs: Rust for Windows ★9743 https://github.com/microsoft/windows-rs — @rusttrending.bsky.social1 likes and repost
- Jun 18, 2026Windows-rs is open-source at github.com/microsoft/wi.... — @rustaceans.bsky.social0 likes and reposts · 1 reply
On GitHub · 17
- Feb 24, 2019Tracking issue for RFC 2627: #[link(kind="raw-dylib")] — rust-lang/rust86 reactions · 138 comments
- Jul 7, 2021Need a reliable way to get the target dir from the build script — rust-lang/cargo75 reactions · 74 comments
- Jan 22, 2021x/sys/windows: use win32metadata? — golang/go26 reactions · 31 comments
- Jul 17, 2025stabilize c-style varargs for sysv64, win64, efiapi, aapcs — rust-lang/rust7 reactions · 51 comments
- Mar 17, 2024[features] Support `WinUI` Styles Menu in windows 11 — tauri-apps/muda7 reactions
12 more on GitHub
- Mar 21, 2023Replace `windows-sys` with manual bindings — notify-rs/notify6 reactions · 21 comments
- Nov 14, 2022Migrate to Windows-rs from winapi — gfx-rs/wgpu6 reactions · 32 comments
- Oct 1, 2025WASAPI: Use `ActivateAudioInterfaceAsync` with virtual device IDs for default devices — RustAudio/cpal5 reactions · 2 comments
- May 7, 2024Change `unexpected_cfg` to `allow` by default — rust-lang/rust5 reactions · 8 comments
- Mar 20, 2023Remove `windows-sys` dependency — Amanieu/parking_lot5 reactions · 1 comment
- Jan 9, 2023migrate compiler, bootstrap and compiletest to windows-rs — rust-lang/rust5 reactions · 74 comments
- Dec 22, 2022I've forked this repository as semantic-release-cargo — kettleby/semantic-release-rust5 reactions · 1 comment
- Aug 16, 2024Improve tests for GUID/UUID — tigerbeetle/tigerbeetle4 reactions
- Jan 30, 2023use windows crate directly — strawlab/iana-time-zone4 reactions · 9 comments
- Oct 20, 2022Update windows-sys to 0.42 — steffengy/schannel-rs4 reactions · 4 comments
- Jun 27, 2022[feat] Support Badging API — tauri-apps/tauri4 reactions · 6 comments
- Jan 6, 2022Add FAQ entry on whether to use winapi-rs or windows-rs — retep998/winapi-rs4 reactions · 1 comment
On Hacker News · 6
- Jan 21, 2021Rust for Windows785 points · 293 comments
- Jan 21, 2021Rust for Windows18 points · 3 comments
- Jun 1, 2026Microsoft ships a Rust WinUI3 library, React-like4 points · 1 comment
- Mar 12, 2025Rust for Windows4 points
- May 29, 2026Windows Reactor: UI library for Rust developers targeting WinUI 32 points
1 more on Hacker News
- Aug 15, 2022Strings RFC2 points
The file
We split this copilot-instructions.md into the rules it gives an agent
10 rules. About 0 are common, 1 is distinctive, and 9 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
9
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 3
Read this file at the start of every session.
- Very specific: line 8
Do not create git commits automatically.
- Very specific: line 130
After regenerating, always verify: cargo check -p <affected-crate> --quiet
- Very specific: line 163
Panics: Use panic! only for invariant violations.
- Very specific: line 166
No
thread_local!in app code: - keep state in components and pass shared values through typed contexts. - Very specific: line 184
When making changes to a crate, update its docs/crates/<crate>.md page and its readme.md as needed.
- Very specific: line 194
ASCII punctuation only: Use - for dashes (never em/en-dashes), ...
- Very specific: line 200
No LLM tells: Avoid the vocabulary and tics that mark agent-written text: faithful, corpus, ledger, crucially, notably, essentially, …
- Very specific: line 206
No decorative formatting: No box-drawing banner comments (// -- Title ------), no duplicated doc paragraphs (a real copy-paste tell), no …
- Very specific: line 210
Describe the code as it is,: not its history. Avoid churn narration (used to, previously, an earlier version, no longer) unless it …
≈ “Common” is an estimate: at least 1 in 5 of the 1,644 Copilot instructions files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Copilot Instructions for windows-rs
Read this file at the start of every session. It contains the essential commands, conventions, and architecture knowledge needed to work on this repository.
Workflow
Do not create git commits automatically. The maintainer reviews all changes first and handles commits manually. Make changes locally, run fmt/clippy/tests to verify, and report back.
Repository Layout
Cargo workspace (resolver = "3"). Members are globbed from:
crates/libs/*- the published/library crates (windows,windows-sys,windows-core, pluswindows-bindgen,metadata,rdl, and the newerreactor/canvas/webview/windowcrates). Seedocs/readme.mdfor the full categorized crate index, anddocs/crates/<crate>.mdper crate.crates/tools/*- code generators and CI helpers, run viacargo run -p tool-*.crates/tests/*/*- test crates;crates/tests/libs/<crate>mirrors each library crate (e.g.test_reactor,test-webview). Crate names aretest_<dir>.crates/samples/*/*- runnable examples.
The crates fall into rough groups (see docs/readme.md for the authoritative list): core & errors
(windows-core, windows-result, windows-strings); values & collections (numerics,
collections, reference, time); async & threading (future, threading); system services
(registry, services, version); COM macros & linking (implement, interface, link); UI &
graphics (reactor, canvas, webview, window, animation, reactor-setup); codegen &
metadata tooling (bindgen, metadata, rdl, cppwinrt); and the full API projection (windows,
windows-sys).
Before Finalizing Changes
cargo fmt --allCI enforces rustfmt. Always format before finalizing changes. On Windows, the workspace-wide
command may exceed the process command-line limit; use cargo fmt -p <crate> for each affected
crate instead.
Build & Test Commands
Core crates
cargo check -p windows-core --quiet
cargo check -p windows --quiet
cargo clippy -p <crate> --all-targets
cargo test -p <crate>
# Run a single test by name filter
cargo test -p <crate> <test_name_substring>CI sets RUSTFLAGS: -D warnings, so any warning fails the build. Workspace-wide lints are
configured in the root Cargo.toml ([workspace.lints]) - clippy lints like
uninlined_format_args, redundant_clone, and semicolon_if_nothing_returned are promoted to
warnings and therefore enforced.
Reactor
# Refresh WinUI metadata after changing Windows App SDK or WebView2 pins
cargo run -p tool-reactor-metadata --quiet
# Regenerate Reactor code after editing schema.toml or tool-reactor source
cargo run -p tool-reactor --quiet
# Regenerate bindings (after editing filter .txt files)
cargo run -p tool-bindings --quiet
# Verify reactor compiles
cargo check -p windows-reactor --quiet
# Unit tests (headless, fast)
cargo test -p windows-reactor --all-features --quiet
# Integration tests (launches WinUI window)
cargo run -p test-reactor-selftest
cargo run -p test-reactor-selftest -- --headless # CI mode
cargo run -p test-reactor-selftest --bin application_menu
cargo run -p test-reactor-selftest --bin canvas_integration
cargo run -p test-reactor-selftest --bin webview_integration
cargo run -p test-reactor-selftest --bin window_state
# Clippy
cargo clippy -p windows-reactor --all-targetsCanvas
cargo check -p windows-canvas --quiet
cargo test -p windows-canvas --quiet
cargo clippy -p windows-canvas --all-targetsFull workspace
cargo run -p tool-clippy-all # runs clippy across all cratesCode Generation Pipeline
Never hand-edit generated files. Generated outputs are committed, and CI fails if regenerating
produces a diff (the gen workflow runs each cargo run -p tool-* and rejects any change; the
test workflow likewise fails if tests modify tracked files). After editing generators or filters,
re-run the tool and commit the result.
The core windows / windows-sys crates are generated from Windows metadata (.winmd) via
windows-bindgen (driven by tool-package). windows-metadata and windows-rdl support
reading/authoring that metadata. The reactor / canvas / webview pipelines layer on top:
tool-reactor-metadata- refreshes committed WinUI / Windows App SDK / WebView2.winmdmetadata and generatesextras.winmd.tool-reactor- readscrates/tools/reactor/src/schema.tomlplus the shared WinUI metadata -> generates Reactor declarations, native projection code, the Reactor native bindings, and the canvas Reactor bridge bindings.tool-bindings- reads filter.txtfiles fromcrates/tools/bindings/src/-> runswindows-bindgen-> generatesbindings.rsin each crate:crates/libs/canvas/src/bindings.rs(fromcanvas.txt)crates/libs/time/src/bindings.rs,numerics,reference, etc.
tool-package- generates the publishedwindowsandwindows-syspackage crates using--packagemode (per-namespace files + Cargo.toml features).- After regenerating, always verify:
cargo check -p <affected-crate> --quiet
Key Architecture Facts
Crate relationships
windows-coreis the foundation - almost everything depends on it.windowsis the umbrella crate that re-exports fromwindows-core,windows-numerics,windows-time,windows-collections,windows-reference, etc.windows-reactordepends onwindows-core(notwindows) and uses minimal bindings generated with--minimal --flatmode.windows-canvassimilarly uses minimal bindings for D2D/DXGI/DWrite/WIC.windows-animationwraps Win32 UIAnimation Manager COM APIs.
Reactor architecture
- WinUI backend ownership is split across
crates/libs/reactor/src/native/winui.rsandcrates/libs/reactor/src/native/winui/. - The TOML config (
crates/tools/reactor/src/schema.toml) declares 79 WinUI controls. Keys are WinUI metadata names; the tool infers types, setter patterns, and event handlers from.winmdfiles. - COM casts: classes Deref to their default interface (zero-cost). Only cast to non-default parent
interfaces. The
Paramtrait handles parent-class conversions automatically.
Canvas architecture
- Canvas wraps D2D/DXGI behind safe Rust types (
GpuDevice,SwapChain,DrawingSession,PathBuilder). animated_canvas()(reactor feature) renders on UI thread viaCompositionTarget::Rendering.- Device-lost recovery is automatic.
Conventions
- Panics: Use
panic!only for invariant violations. Usediag::helpers for missing features (warn in debug, no-op in release). .unwrap()over.expect("...")- the panic hook provides full context.- No
thread_local!in app code - keep state in components and pass shared values through typed contexts.thread_local!is reserved for framework plumbing. - Test naming: Reactor unit tests live in
windows-reactor; live WinUI coverage lives intest-reactor-selftest. Canvas tests use WARP software rendering.
Documentation
The docs/ folder has one page per crate:
docs/crates/<crate>.md- a single page per crate covering both usage and internals (how the crate is built and maintained: codegen pipeline, generated files, conventions). It links to the crate's ownreadme.mdfor the user-facing intro and quick example.crates/libs/<crate>/readme.md- the user-facing introduction with a quick example (also the crates.io / docs.rs landing).docs/readme.md- the documentation hub and crate index.
docs/ also holds contributing.md, code_of_conduct.md, and security.md.
When making changes to a crate, update its docs/crates/<crate>.md page and its readme.md as
needed. For example, windows-reactor changes touch docs/crates/windows-reactor.md (codegen,
TOML, threading, COM pitfalls, plus the conceptual overview) and crates/libs/reactor/readme.md
(getting started and the quick example).
Writing Style for Docs and Comments
These rules were established while cleaning up the docs and code comments and apply to all Markdown
(.md) and Rust comments/doc-comments across the repo. Keep new writing consistent with them.
- ASCII punctuation only. Use
-for dashes (never em/en-dashes),...for ellipsis,->for arrows,<=/>=/!=for comparisons, and straight quotes. Drop the section sign from standard references (writeECMA-335 II.22,C11 6.4.4.1, not\u00a7...). The only non-ASCII that stays is genuine test data (e.g. a Greek-letter string literal exercising UTF-8 handling). - 100-column wrap. Hard-wrap Markdown prose and long comment blocks at 100 columns. Keep the wrap consistent within a file - do not mix wrapped and unwrapped paragraphs.
- No LLM tells. Avoid the vocabulary and tics that mark agent-written text:
faithful,corpus,ledger,crucially,notably,essentially,robust,seamless,comprehensive,deliberately,simply,under the hood,that said,importantly,conceptually,effectively,single source of truth,industry-standard,first-class,leverage,utilize,Note that .... Say the concrete thing instead.ergonomicand rustdoc**bold**are fine. - No decorative formatting. No box-drawing banner comments (
// -- Title ------), no duplicated doc paragraphs (a real copy-paste tell), no filler that restates the code. - Prefer tables over wordy paragraphs where the content is a set of parallel cases (rules, mappings, options).
- Describe the code as it is, not its history. Avoid churn narration (
used to,previously,an earlier version,no longer) unless it describes real runtime behavior, not codebase edits. - Do not edit generated files to satisfy these rules; only hand-written sources.
Open Investigations / TODO
Enduring record of known issues so they are not lost between sessions. Add findings here; remove or mark done as they are addressed. Cite code by file + symbol name, not line number - line numbers go stale fast.
Repo-wide dead-code / quality audit (2026-07)
Open items across the hand-written crates (reactor, bindgen, rdl, clang, canvas, metadata, webview,
core) that need a design decision or a larger change. Any bindgen source change must be proven
output-neutral by running the tool-* generators and confirming git diff shows no generated-file
changes (the gen workflow enforces this).
Duplication / refactor candidates
| Location | Issue |
metadata merge/mod.rs write_type vs merge/remap.rs write_type | Two ~60-line structurally identical functions; the remap copy's comment says it mirrors merge::write_type. Any new ECMA table must be added to both, with no compiler guard. |
canvas session.rs gradient-stop + bitmap-properties builders | Duplicated ABI-stop and bitmap-properties construction across the brush paths. |
bindgen types/interface.rs + cpp_interface.rs local fn combine | Duplicate local helper. |
canvas color.rs DARK_SLATE_BLUE | rgb(0.05, 0.05, 0.1) does not match the CSS color of that name (public API used by samples). |
Coverage gaps
| Area | Gap |
metadata Remapper (merge/remap.rs) | No tests anywhere; routing/split_apis logic is exercised only in the live build, so a regression yields a malformed namespaced winmd with no failing test. |
| webview | process-failed, download, and deferral paths untested. |
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

