Skip to content

Support full trim publishing#5053

Merged
Gabriel Dufresne (GabrielDuf) merged 1 commit into
mainfrom
analyze-package-size
Jul 7, 2026
Merged

Support full trim publishing#5053
Gabriel Dufresne (GabrielDuf) merged 1 commit into
mainfrom
analyze-package-size

Conversation

@mamoreau-devolutions

Copy link
Copy Markdown
Contributor

Summary

  • Switch the Avalonia app default publish mode from TrimMode=partial to TrimMode=full while keeping self-contained ReadyToRun publishing.
  • Replace Octokit usage with a narrow, trim-safe GitHubApiClient using HttpClient and source-generated System.Text.Json DTOs for OAuth, device flow, current user, and gist backup APIs.
  • Statically root the conditional Windows Mica styles as a typed ResourceDictionary; the first full-trim launch exposed this because the dynamically loaded Styles.WindowsMica.axaml resource was trimmed.
  • Add targeted handling for app-owned trim warnings: AUMID shortcut COM activation suppression, expected Avalonia constructor warning suppression, and non-blocking CI visibility for full-trim publish warnings.

Size impact

Measured against same-code x64 Release self-contained ReadyToRun publishes:

Build Raw publish Zipped publish
Partial trim 135.01 MiB 59.21 MiB
Full trim 115.62 MiB 50.31 MiB
Savings 19.39 MiB / 14.4% 8.90 MiB / 15.0%

Earlier installer measurement showed a similar gain: 44.56 MiB -> 36.66 MiB, about 7.9 MiB smaller.

Full-trim warning audit

Full-trim publish succeeds and now leaves 45 trim warnings, all from external dependencies:

Category Count Notes
Avalonia DataGrid/Controls 10 Reflection/converter paths in Avalonia DataGrid. UniGetUI uses explicit template columns with AutoGenerateColumns="False", but grids still need careful manual validation.
WinRT ABI generated code 35 CsWinRT/WinRT ABI generic annotation warnings from Windows package manager interop. Review WinGet/native package-manager paths carefully.
Octokit/AppShortcut/Mica/AVLN3001 0 App-owned warning categories cleared.

I intentionally did not blanket-suppress the remaining external warnings so future app-owned trim regressions stay visible.

Needs careful review

  • Package list DataGrid behavior: installed packages, updates, search/discover, sorting, selection, context menus, details dialogs.
  • Desktop shortcut manager DataGrid behavior.
  • WinGet / Windows Package Manager COM interop paths, including manager initialization and package queries.
  • GitHub auth and backup flows using the new API client: loopback OAuth, device flow IPC auth, avatar/current-user loading, gist create/list/get/update, backup upload/download/restore.
  • Windows-specific shell paths: AUMID shortcut stamping, toast notifications, tray restore/quit behavior, and Mica/acrylic styling.

Validation

  • dotnet restore src/UniGetUI.Windows.slnx
  • dotnet build src/UniGetUI.Windows.slnx --no-restore --verbosity q --nologo /p:Platform=x64 /p:UseSharedCompilation=false /m:1
  • dotnet test src/UniGetUI.Windows.slnx --no-restore --verbosity q --nologo /p:Platform=x64 /p:UseSharedCompilation=false /m:1
  • dotnet format whitespace src --folder --verify-no-changes --verbosity minimal
  • dotnet format style src/UniGetUI.Windows.slnx --no-restore --verify-no-changes --verbosity minimal
  • Full-trim x64 Release publish with TrimmerSingleWarn=false
  • Launched the full-trim published UniGetUI.exe successfully and inspected the backup settings UI path

Switch the Avalonia app to TrimMode=full by default, replace Octokit with a trim-safe source-generated GitHub API client, and statically root the conditional Windows Mica resource so full-trim publish launches successfully.

Add CI visibility for full-trim publish warnings and targeted trim warning handling for app-owned COM activation and expected Avalonia constructor diagnostics.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@GabrielDuf Gabriel Dufresne (GabrielDuf) merged commit 0dddfab into main Jul 7, 2026
3 checks passed
@GabrielDuf Gabriel Dufresne (GabrielDuf) deleted the analyze-package-size branch July 7, 2026 17:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants