Repository navigation
Labels
Area-PlatformsTarget frameworks, SDKs, reference packs, languagesTarget frameworks, SDKs, reference packs, languages
Milestone
Description
PostSharp 2027.0 supports applications that are published with ReadyToRun, trimmed, or compiled ahead of time (NativeAOT). This issue groups the three issues that implement this support.
| Issue | Scope |
|---|---|
| #89 | The aspect framework: PostSharp.dll and the code that the weaver generates. ReadyToRun is tested. |
| #252 | The pattern libraries: Common, Aggregation, Model, Threading, Diagnostics and Caching. |
| #254 | A new advice, InstantiateTypeAdviceInstance, with which an aspect requests the native code of a closed generic type. [Cache] and [Log] use it. |
What is supported
- ReadyToRun. A woven assembly is precompiled, and it behaves as without ReadyToRun. It needed no change.
- Trimming and NativeAOT of a woven assembly. The serializers of the aspects are created by code that the weaver generates, not by reflection. The
net10.0build of PostSharp.dll is annotated (IsAotCompatible), and a publication reports no trimming or AOT warning. - Trimming and NativeAOT of the pattern libraries. The
net10.0builds of Common, Aggregation, Model, Threading, Diagnostics and Caching are annotated. The code that only the compiler runs is behind the feature switchPostSharp.Patterns.IsCompileTimeCodeSupported, so the trimmer removes it. - Generic types over value types under NativeAOT. An aspect returns
InstantiateTypeAdviceInstancefromIAdviceProviderfor each closed generic type that it creates by reflection at run time. The weaver then makes the ahead-of-time compiler produce the native code of the type. The advice has no effect unless the MSBuild propertyPostSharpAotCompatibleWeavingistrue. Its default istruewhen the project setsPublishAot,IsAotCompatibleorEnableAotAnalyzer.
What the user does
- An application sets
PublishAotorPublishTrimmed, as for any .NET application. The packages set the feature switches. - A library that is published in a native application sets
IsAotCompatible, so that its woven assembly requests the native code that its aspects need.
Limits
- An adapter or a formatter over a value type that the application registers at run time has no native code under NativeAOT.
MemoryCachingBackenddoes not support trimming, becauseSystem.Runtime.Cachingreads the configuration throughSystem.Configuration.MemoryCacheBackenddoes.- The backends of the logging and caching libraries,
PostSharp.Patterns.Diagnostics.Configuration,PostSharp.Patterns.Xamland the Windows-specific parts ofPostSharp.Patterns.Threadingare not annotated. - NativeAOT was measured on
win-x64only.
The details, the measurements and the tests are in each issue. The implementation is in a single pull request of the source repository.
— Claude for Gael
Metadata
Metadata
Assignees
Labels
Area-PlatformsTarget frameworks, SDKs, reference packs, languagesTarget frameworks, SDKs, reference packs, languages
Type
Projects
- StatusShow more project fieldsDone
Activity
gfraiteur commentedon Oct 14, 2026
Released in PostSharp 2027.0.4-preview.
-- Claude for Gael