-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Description
The Roslyn trim analyzer doesn't have a whole program view and doesn't know about trim/AOT unsafety of dependencies if they're not annotated. One can easily get into a situation where an unannotated dependency is not detected as problematic and an IsTrimmable
assembly that can't actually be used with trimming is produced by the build.
It happened to us in #102341 where we have an IsTrimmable assembly that depends on another assembly that we didn't annotate yet.
Our guidance is to have a test app exercising everything in the library that gets PublishTrimmed/PublishAot with WarnAsError true to catch whatever the analyzer missed.
We might want to consider emitting a warning from the analyzer when a reference doesn't have the IsTrimmable attribute. This warning would only be generated by the analyzer, not by illink/ilc. It would detect cases where the dependency isn't contractually trimmable. The contractual aspect (the author of the library guarantees trimability) is interesting - the test app approach doesn't ensure that - a dependency that isn't contractually trimmable, just happens to be fine for the test app doesn't guarantee it won't be broken in next version.
Cc @dotnet/illink @eerhardt
Metadata
Metadata
Assignees
Labels
Type
Projects
Status