Enable trimming/AOT analyzers so that trimming/AOT issues get flagged at build time (added the IsTrimmable/IsAotCompatible properties to relevant csproj files)
Help reflection static analysis by adding DynamicallyAccessedMembers annotations where flagged by the analyzer.
With this:
Apps that use PDFSharp no longer generate trimming warnings, since the reflection use can be statically analyzed and proved safe.
Apps can be much smaller. A .NET 8 app with PublishAot that just merges PDF files without doing anything else is 4,370,432 bytes with the current version of PDFSharp and the above workaround (and generates a warning). With the version in this PR it no longer generates warnings, doesn't need a workaround, and comes down to 2,733,056 bytes.
IsTrimmable
/IsAotCompatible
properties to relevant csproj files)DynamicallyAccessedMembers
annotations where flagged by the analyzer.With this: