Drop WinForms so Release MSIX can trim
Merged
TO
3mo ago+1578+1578+0123456789012345678901234567890123456789-411-411-012345678901234567890123456789
Summary
- Replace WinForms folder/file dialogs and clipboard with Win32/COM interop in CmdPal and Run hosts, and swap Core's WinForms dependency for
System.Drawing.Common(icon cache only). - Re-enable Release MSIX trimming (
PublishTrimmed) with an ILLink root forQuickShellExtension, plus trim-safe source-generated JSON for form choices. - Keep workspace trust digests byte-stable via a dedicated
QuickShellDigestJsonContext(compact + nulls) and a parity test against the old anonymousSerializeshape. - Fix release-note doc links that pointed at nonexistent
main(masteris the default branch).
Test plan
-
dotnet testsecurity/digest filters (Debug):ComputeDigest_matches_legacy+WorkspaceSecurityPolicyTests+ adversarial -
dotnet build QuickShell.RunRelease x64 -
dotnet build QuickShellRelease x64 withWinGetBuild=true - Trimmed Release MSIX build via VS MSBuild (Scoop
dotnet build -c Releasehits MSB4216 ILLink task-host locally) - Smoke: folder picker, export/import JSON picker, companion exe picker, clipboard copy
- Smoke: grant trust, relaunch, confirm existing
WorkspaceReviewTokenstill matches - Compare Release MSIX size before/after if convenient
Made with Cursor
Summary by cubic
Dropped WinForms and replaced dialogs/clipboard with trim‑safe Win32/COM interop so Release MSIX can trim without changing workspace trust digest bytes. Added a shared STA dialog runner with safe exception-to-null handling and documented unmanaged call sites.
-
Refactors
- Centralized
ShellFileDialog,Win32Clipboard,StaDialogCloser,StaModalDialogRunner, andNativeForegroundWindowin Core (source‑generated COM +LibraryImport) and replaced all WinForms dialogs/clipboard in both hosts. - Hardened dialogs/clipboard: keep COMDLG filter memory alive through Show via a
usingscope; close timed‑out pickers via the STA thread’s dialog HWND; publish native thread id viaVolatile; capture owner before starting STA; bound CF_UNICODETEXT byGlobalSizeand truncate at first null; retryOpenClipboard; centralize STA exceptions to return null; added XML docstrings and inline CodeQL annotations. - Named DTOs for CmdPal choices and digest (
FormChoiceJson,TaskTypeChoiceJson,WorkspaceDigestPayload) viaQuickShellJsonContext/QuickShellDigestJsonContext; tests pin legacy digest bytes.
- Centralized
-
Dependencies
- Enabled trimming for Release MSIX (
PublishTrimmed=true), rootedQuickShellExtensionviaILLink.Descriptors.xml, and treat trim warnings as errors (suppressedIL2104). AddedSystem.Drawing.Common@9.0.8; continue usingSystem.Text.Json@9.0.8with source‑gen contexts. - Added CodeQL config and workflow wiring; exclude quality‑only
cs/call-to-unmanaged-codeandcs/unmanaged-code. Fixed release workflow links tomaster.
- Enabled trimming for Release MSIX (