![]() Remove EventSource related code or logic. For more information, see UTF-7 code paths are obsolete. For more information, see BinaryFormatter serialization methods are obsolete. Remove BinaryFormatter serialization support. Remove code that enables better debugging experiences. Remove code that creates autorelease pools on supported platforms. Several feature areas of the framework libraries come with trimmer directives that make it possible to remove the code for disabled features. When debugger support is disabled, trimming will remove symbols automatically ( TrimmerRemoveSymbols will default to true). The SDK also makes it possible to disable debugger support using the property DebuggerSupport. This applies to both the application code and any dependencies that come with symbols. Remove symbols from the trimmed application, including embedded PDBs and separate PDB files. Symbols are usually trimmed to match the trimmed assemblies. Show all detailed warnings, instead of collapsing them to a single warning per assembly. You can also show individual warnings for all assemblies: NET 6+, trim analysis produces at most one warning for each assembly that comes from a PackageReference, indicating that the assembly's internals are not compatible with trimming. This may be useful to avoid turning trim analysis warnings into errors when treating compiler warnings as errors globally. There is an additional option that controls the ILLink warn-as-error behavior independently:ĭon't treat ILLink warnings as errors. You can suppress individual warning codes using the usual MSBuild properties respected by the toolchain, including NoWarn, WarningsAsErrors, WarningsNotAsErrors, and TreatWarningsAsErrors. You can also enable or disable the analyzer independently of PublishTrimmed.Įnable a Roslyn analyzer for a subset of trim analysis warnings. NET 6+ also enables a Roslyn analyzer that shows a limited set of analysis warnings. This will include warnings about the entire app, including your own code, library code, and framework code. To warn about such patterns, set to false. Apps that use reflection or other patterns that create dynamic dependencies may be broken by trimming. Trimming removes IL that is not statically reachable. įor example, MyRoots.xml might root a specific method that is dynamically accessed by the application: This lets you root specific members instead of a whole assembly. ![]() dll extension): Īnother way to specify roots for analysis is using an XML file that uses the trimmer descriptor format. Additional assemblies may be "rooted" by name (without the. If an assembly is not trimmed it is considered "rooted", which means that it and all of its statically understood dependencies will be kept. Setting TrimMode on an assembly implies true.Ĭontrol whether to show single warnings for this assembly. This takes precedence over the global TrimMode. The supported metadata is:Ĭontrol whether the given assembly is trimmed.Ĭontrol the trimming granularity of this assembly. You can also use this to override the trimming behavior specified by the library author, by setting false for an assembly with ).ĭo not add or remove items to/from ManagedAssemblyToLink, because the SDK computes this set during publish and expects it not to change. The following example shows how to enable trimming of MyAssembly. To set this metadata, create a target that runs before the built-in PrepareForILLink target. ManagedAssemblyToLink may have metadata that controls the trimming behavior per assembly. When publishing a trimmed app, the SDK computes an ItemGroup called ManagedAssemblyToLink that represents the set of files to be processed for trimming. Trimming settings for individual assemblies NET 6+, you can also opt in to trimming for a library without this attribute, specifying the assembly by name (without the. The framework libraries have this attribute. NET 6+, PublishTrimmed trims assemblies with the following assembly-level attribute: ![]() NET 6+, and copyused in previous versions. NET 6+.Įnable assembly-level trimming, which keeps an entire assembly if any part of it is used (in a statically understood way).Īssemblies with true metadata but no explicit TrimMode will use the global TrimMode. This can be set as a property affecting all trimmer input assemblies, or as metadata on an individual assembly, which overrides the property setting.Įnable member-level trimming, which removes unused members from types. The following granularity settings control how aggressively unused IL is discarded.
0 Comments
Leave a Reply. |