Repository navigation
PostSharp 2027.0.4-preview
Pre-release
Pre-release
PostSharp 2027.0.4-preview is based on v2027.0.3-preview and v2026.0.19, plus the following changes.
This release forward-ports v2026.0.19: 3 enhancements and 5 bug fixes.
New
- #255 Applications that use PostSharp can now be published with ReadyToRun, trimmed, or compiled ahead of time (NativeAOT).
- #89 The aspect framework: a woven application no longer fails when its aspects are initialized after trimming or NativeAOT compilation. The serializers that the weaver generates are now created without reflection, and
PostSharp.dllis annotated for the trimmer. - #252 The pattern libraries (Common, Aggregation, Model, Threading, Diagnostics and Caching) now work in trimmed and NativeAOT applications.
- #254 The new advice
InstantiateTypeAdviceInstancelets an aspect request the native code of a closed generic type that it creates by reflection at run time.[Cache]and[Log]use it.
- #89 The aspect framework: a woven application no longer fails when its aspects are initialized after trimming or NativeAOT compilation. The serializers that the weaver generates are now created without reflection, and
Enhancements
- #40 The new MSBuild property
PostSharpDependencyRestorePropertiessets MSBuild properties, such asNuGetAudit=false, in the projects that PostSharp generates to restore its compiler dependencies. It does not affect the build of your project. - #158 What the licensing, configuration and telemetry services log is now written to the build-time trace (
PostSharpTrace), in the trace category of the same name. Before, it went to a separate log configured bydiagnostics.json. - #190 An unattended build is now licensed for PostSharp Logging in production mode.
- #242 The
MethodBaseof a generic method, or of a method of a generic type, is now looked up once per generic instance instead of on each call. - #266 The
FileLocktrace category now records the retries of file operations that fail because the file is locked, and thePOSTSHARP_FILE_LOCK_TIMEOUTandPOSTSHARP_FILE_LOCK_WARNINGenvironment variables now set the timeout and the warning threshold of these retries. 2027.0.3-preview introduced them, but they had no effect until this version. - #239 The XML documentation of
MethodPointcut,MatchPointcutand the instance lifecycle advices now describes which targets they accept.
Fixes
Aspect framework
- #189 With runtime async, an exception thrown by an
OnYieldorOnResumeadvice no longer runs thefinallyblocks of the user code around theawait, so runtime async now behaves as a compiler state machine. With the new MSBuild propertyPostSharpCompatibilityLevelset to2027.0or higher, the exception instead goes through thecatchandfinallyblocks of the user code, then throughOnExceptionandOnExit, with both implementations.⚠️ Breaking change. - #244 An advice that joins a group implicitly and sets
SemanticallyAdvisedMethodKinds,UnsupportedTargetActionorApplyToStateMachine, which only the master advice can set, is now reported as error LA0135. Before, the value was ignored without any message. - #263 A method interception advice applied to an abstract method is now reported as warning LA0254. The behavior is unchanged: neither the abstract method nor its overrides are intercepted.
- #258, #259
MatchPointcuton a method-level or an assembly-level aspect is now reported as error LA0251, instead of failing the build with anInvalidCastException. - #249 An
InvalidAnnotationExceptionthrown byCompileTimeValidateis now reported as error LA0252 at the target, with the message of the exception, instead of as the unexpected exception PS0125. - #250 An aspect applied to a C# 14 extension property is now applied to its accessors. Before, it was ignored without any message.
- #251 The PS0112 message of a positioned
RequireorConflictdependency now states the order correctly, and the documentation ofAspectDependencyActionnow describes the position of the current aspect. Which builds fail is unchanged. - #264
[WaiveAspectEffect]is now taken into account on aspects that use advice methods. - #256 A generic
[ReturnValue] out Tparameter of an invoke advice applied to avoidmethod no longer causes aBadImageFormatException: the advice receives no return value. A non-generic[ReturnValue] out objectparameter in the same situation now builds too; setIsRequired = trueto keep an error. - #257 A by-value
[LocationValue] objectparameter of a set advice on a property of a value type is now boxed, instead of producing invalid IL. - #260 An
OnMethodInvokeAdvicewith bound parameters applied to an instance method of a struct no longer fails the build with aNullReferenceException.
Compiler and packaging
- #265 On Linux and macOS, warning PS0134 for a Windows-format PDB now says that this format can be read on Windows only, instead of giving a meaningless reason.
- #268 On Linux, the weaver of a pattern library is now found when the package version has capital letters, such as
2027.0.3-Beta1. Before, the build failed with PS0052. - #270 The unzipper of the
PostSharppackage now uses SharpCompress 0.49.0, which security scanners no longer report as vulnerable (GHSA-6c8g-7p36-r338). The vulnerability was not exploitable through PostSharp.
Licensing
- #271 On Windows, a build with
VcsCheckEnabledno longer waits two minutes and then requires a license although no source file is modified. Thegitcommand that checks the source files blocked on the standard input that it inherited from the compiler.
Pattern libraries
- #112 A relationship attribute (
[Child],[Parent],[Reference]) or[ExplicitlySynchronized]applied with thefield:target to an automatic property is now reported, with the new warnings COM015 to COM018 and THR042, instead of being ignored without any message. The new MSBuild propertyPostSharpUnifiedAutomaticPropertyAnnotationsmakes the attributes of a property and of its backing field be read as one set. - #267 The new warning THR043 reports an
appliesToMethodOnlyargument of[ExplicitlySynchronized]that has no effect because the attribute is applied to a property. The behavior is unchanged. - #247 A property that depends on an
[AggregateAllChanges]collection now raisesPropertyChangedonce, not twice, when an item is added. - #248 Closing a logging activity twice is now reported to
ILoggingExceptionHandler.OnInvalidUserCode, with a message that says that the activity is already closed. Before, it was reported as an internal exception, and the default handler disabled the backend.
Resources
- Milestone
- Milestone 2024.0.28 (upstream, through v2026.0.19)
- PostSharp 2024.0.29 milestone