NativeAOT and Trimming - Implications or best practices for organizing dependencies? #102534
-
Let's say we have a library that for illustrative purposes we'll call 'LibABC'. We are considering breaking up the library into 3 distinct libs/NuGet packages since not all use cases will require all of the functionality provided by LibABC at once. Hypothetical Breakdown If LibABC is broken out into separate assemblies/packages as roughly outlined above, will there be an impact to NativeAOT/trimming capability or effectiveness if a user were to reference LibA, LibB, and LibC individually at the same time (say from a metapackage)? In other words, is the compiler/linker's ability to trim impacted by breaking up an assembly into smaller assemblies for organizational purposes (E.g. for non-trimming scenarios where you only want to reference what you need)? Is it a matter of preference? Would there be any caveats or gotchas either way? For the sake of simplicity in the example, let's say all code in LibABC is trimming compatible by default. Thanks in advance for any advice or suggestions! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Trimming are done for individual types and methods. I'm not aware that assembly boundary can affect anything. |
Beta Was this translation helpful? Give feedback.
Assembly boundaries could matter with
<TrimMode>partial</TrimMode>
. In this mode, that is not preferred, but some workloads like Blazor WASM/MAUI default to it for historical reasons, any assembly that wasn't marked<IsTrimmable>true</IsTrimmable>
in the library project file would be kept unconditionally. There could be differences in TrimMode=partial if some of the new assemblies get marked IsTrimmable, but not others. Otherwise it's all the same.