I was analyzing the execution flow of my PasteRich daemon when I realized I needed hardcore enterprise open-source experience. What better place to integrate this functionality than Microsoft PowerToys—the flagship open-source productivity suite for Windows? Building a standalone tool is one thing; architecting that logic directly into a 4-million-line monolithic beast is a completely different engineering discipline.
Part 2 of the PasteRich Chronicles: Architectural Feature PR on Microsoft PowerToys (PR #49460 / Issue #40202).
The Native C# Implementation in Advanced Paste
Rather than running an external wrapper, I engineered a native "Paste as Rich Text" action directly inside PowerToys Advanced Paste (RichTextHelper.cs). The engine ingests raw Markdown source text, converts it via Markdig.Signed, and packages the rendered markup into native Windows CF_HTML clipboard fragments. This guarantees rich formatted pasting directly into Microsoft Word, WordPad, and Outlook without losing formatting or relying on third-party web converters.
The real complexity lay across the Cross-Process IPC and WinRT boundary. PowerToys separates low-level Windows keyboard hooks in its C++ Runner from the C# WinUI 3 desktop host. To route the shortcut without breaking backwards compatibility:
- Extended the C++/WinRT interop layer (
Constants.idl,Constants.h,Constants.cpp, andshared_constants.h) to dispatch the newAdvancedPasteRichTextMessageIPC signal. - Registered the global hotkey in
dllmain.cppand routed the message directly toExecutePasteFormatAsyncinside the WinUI 3 runner (App.xaml.cs). - Preserved strict ABI stability by assigning an explicit stored integer ID (
RichText = 11) and declaring an explicit display sequence inOptionsViewModel.csto prevent enum shift regressions across existing user settings.
Code Review, Telemetry & Upstream Drift
When core maintainer @MuyuanMS reviewed the branch, we identified that WinAppDriver UI automation was inherently flaky in CI. I took immediate ownership: deleted the brittle UI automation entirely and replaced it with fast, deterministic MSTest unit tests in RichTextHelperTests.cs validating HTML fragment generation and empty clipboard edge cases. After securing sign-off from Microsoft telemetry maintainer @chatasweetie, I maintained the branch through a 448-commit upstream drift, cleanly resolving rebase conflicts against upstream's Phi Silica AI additions.
Architecting an enterprise feature PR isn't about writing isolated code in a vacuum. It's about respecting cross-process IPC boundaries, preserving binary ABI stability, and ruthlessly refactoring tests to satisfy core enterprise maintainers.
You can inspect the full implementation and review history directly on GitHub: microsoft/PowerToys PR #49460.