Skip to content

[Package Size] Reduce size of new Controls.Primitives Package #3683

@michael-hawker

Description

@michael-hawker

Describe the problem this feature would solve

I noticed from the report in #3676 that the Primitives package is still fairly large if you just want the panels and nothing else from the toolkit:

Microsoft.Toolkit.Uwp.UI.Controls.Primitives Additional Footprint: 486,329 bytes
  App Diff: (.exe) = 3,072
  App Diff: (.xml) = 657
  App Diff: (.appxsym) = 90,372
  Size Diff: AppxBundleManifest.xml = 34
  Size Diff: AppxBlockMap.xml = 961
  Size Diff: AppxManifest.xml = 33
  Size Diff: resources.pri = 544
  Size Diff: System.Runtime.CompilerServices.Unsafe.dll = 1,536
  Additional: Microsoft.Toolkit.dll = 96,768
  Additional: Microsoft.Toolkit.Uwp.dll = 104,448
  Lib (self): Microsoft.Toolkit.Uwp.UI.Controls.Primitives.dll = 42,496
  Additional: Microsoft.Toolkit.Uwp.UI.dll = 145,408
-----------------------------------------

I did a quick investigation, and I think the only place an element from a lower package is used is in the DockPanel for FindParent here:

https://github.com/windows-toolkit/WindowsCommunityToolkit/blob/542498998d218efe942c566529d4da5631b1994b/Microsoft.Toolkit.Uwp.UI.Controls/DockPanel/DockPanel.cs#L18-L24

If we were able to remove this reference we could say the Primitives package has no other dependencies and effectively shrink the package:

Microsoft.Toolkit.Uwp.UI.Controls.Primitives Additional Footprint: ~>139,705 bytes
  App Diff: (.exe) = 3,072
  App Diff: (.xml) = 657
  App Diff: (.appxsym) = 90,372
  Size Diff: AppxBundleManifest.xml = 34
  Size Diff: AppxBlockMap.xml = 961
  Size Diff: AppxManifest.xml = 33
  Size Diff: resources.pri = 544
  Size Diff: System.Runtime.CompilerServices.Unsafe.dll = 1,536
  Lib (self): Microsoft.Toolkit.Uwp.UI.Controls.Primitives.dll = 42,496
-----------------------------------------

There's also a small reference to the guard API in the UniformGrid internal helper which we could remove?

This would help support #3145 of course too.

Describe the solution

Evaluate removing the extra dependency to make the the Primitives package super light-weight in case no other elements of the Toolkit wish to be used by the end developer.

@vgromfeld @Sergio0694 @skendrot @RosarioPulella thoughts?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions