Skip to content

[Feature]: make the Notifications package linker-friendly #4552

@Sergio0694

Description

@Sergio0694

Describe the problem

Currently, the Microsoft.Toolkit.Uwp.Notifications package is heavily relying on reflection for the XML serialization of the various toast/tile/visual templates it can create. This fundamentally breaks trimming, and can result in incorrect behavior (ie. broken notifications) on anyone enabling it (eg. on UWP). The workaround is to explicitly add a runtime directive to preserve public members from this assembly, but that's (1) brittle and (2) cumbersome, especially for beginners. It's also just not ideal, as doing so still ends up preserving more stuff than what would actually be needed, hence increasing the package size.

Describe the solution

Since all the types being serialized are well known and internal, there is no need to actually use reflection.
As such, the code should be refactored to not use it anymore, making it linker-friendly.

Alternatives

Do nothing, and keep using reflection. Meh.

Additional info

No response

Help us help you

Yes, I'd like to be assigned to work on this item.

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions