Skip to content

feat: enable .NET Native trimming#825

Open
United600 wants to merge 1 commit intomainfrom
United600/trimming
Open

feat: enable .NET Native trimming#825
United600 wants to merge 1 commit intomainfrom
United600/trimming

Conversation

@United600
Copy link
Copy Markdown
Collaborator

Followed this blog post, and used this troubleshooter to enable .NET Native trimming.

Reduces the overall bundle size by approximately 10 MB.
Comparison between a bundle with trimming and one without it

And after unzipping, each package saves approximately 10 MB, with the Screenbox.dll file being the primary beneficiary of this reduction.

Without trimming With trimming
imagem imagem

@dosubot dosubot bot added size:S This PR changes 10-29 lines, ignoring generated files. enhancement New feature or request labels Mar 27, 2026
<Type Name="ProtoBuf.Serializers.ImmutableSortedDictionarySerializer`2" Activate="Required Public" />
<Type Name="ProtoBuf.Serializers.ImmutableIDictionarySerializer`2" Activate="Required Public" />
<Type Name="ProtoBuf.Serializers.ConcurrentBagSerializer`2" Activate="Required Public" />
...-->
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😩 I got tired of adding them individually. I'm not sure we'll see significant savings by continuing.

<Type Name="ProtoBuf.Internal.Level300DefaultSerializer" Dynamic="Required All" />
<Type Name="ProtoBuf.Internal.Level300FixedSerializer" Dynamic="Required All" />

<Type Name="CommunityToolkit.Mvvm.Messaging.IMessengerExtensions" Dynamic="Required All" />
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When the app launches, this method failed even though it is not marked with the RequiresDynamicCode attribute.

Maybe we could trim it more efficiently using the method troubleshooter, though I already attempted it without success.

@huynhsontung
Copy link
Copy Markdown
Owner

Do we want to enable this before moving away from protobuf?

@United600
Copy link
Copy Markdown
Collaborator Author

Do we want to enable this before moving away from protobuf?

The gains extend beyond protobuf, but we can hold off for now and use it as test bed. The earlier we start trimming, the better prepared we'll be for NAOT.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants