Skip to content

Make PdfSharpCore trimmable #293

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Aug 31, 2022
Merged

Make PdfSharpCore trimmable #293

merged 5 commits into from
Aug 31, 2022

Conversation

Marv51
Copy link
Contributor

@Marv51 Marv51 commented Aug 25, 2022

Trimming enables the compiler to strip out parts of the library and the framework that are unused. It does this by analyzing the code at compile time. Some patterns (esp. heavy reflection usage) can make it hard for the compiler to automatically analyze the code. By using DynamicallyAccessedMembers attributes we can help the compiler.

I fixed all the trim-warnings the compiler produced for me. I was quite surprised how little was needed to make this work.

A SampleApp that just puts text in a PDF (probably the ideal case for trimming) was 70.5MB (self-contained) before and with trimming is only 21.5MB (-70%).

This is also a mayor focus area of .NET 7.

The most difficult part was the constructor of DictionaryMeta DictionaryMeta(Type type), here the older .net framework code works better with trimming on .NET 5 and 6.

@ststeiger ststeiger merged commit 655ae9b into ststeiger:master Aug 31, 2022
@Marv51
Copy link
Contributor Author

Marv51 commented Aug 31, 2022

thanks for merging and thank you for your continued work on this project @ststeiger

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants