Repository navigation
Releases: postsharp/PostSharp.Public
Release list
PostSharp 2027.0.7-preview
PostSharp 2027.0.7-preview is based on v2027.0.6-preview, plus the following changes.
The packages of 2027.0.6-preview were never published to nuget.org, so 2027.0.7-preview is the first build that ships the changes listed in v2027.0.6-preview.
Highlights
postsharp introspect. Thepostsharpcommand line tool now answers questions about how PostSharp applied aspects to a project or a solution, from the files of its last build: which aspects apply to a declaration and why, in what order the transformations run, and how many lines of code the aspects saved. The output is JSON for AI agents and text for a person (#332).
PostSharp.Testing.AspectTesting
- #333 New: the
@CompareWeavingSymbolsdirective compares the weaving symbol file (.pssym) of a test with a.t.pssymsnapshot next to the test, as@CompareTransformedCodedoes with a.t.csfile. The snapshot holds the content, not the encoding: the PostSharp version and the line counts are placeholders, and the identifiers of the aspect instances are numbered by first appearance. A.t.<tfm>.pssymfile replaces the snapshot for one target framework, and a snapshot is accepted like the other expected files.
Resources
PostSharp 2027.0.6-preview
PostSharp 2027.0.6-preview is based on v2027.0.5-preview, plus the following changes.
Highlights
- Dependency injection in aspects. An aspect can now receive a service from dependency injection: the target class gets the service as a constructor parameter, and the advices read it (#318).
[Cache]and[InvalidateCache]are the first aspects to use it: they can take theirICachingServicefrom the container instead of a process-wide static (#323). - Background compilation server for .NET. Until now, only .NET Framework projects were compiled in a background pipe server. With
dotnet build, .NET projects are now compiled in one too, on Windows, Linux and macOS, instead of in a newdotnet execprocess for each project (#322).
Aspect framework
- #316 New:
[ImportMember]can be applied to the parameters of an advice method, so that a statically scoped aspect can read and write the members of its target class without an instance-scoped aspect. The type of the parameter selects what the advice receives: the value or the address of a field (T,in T,ref T,out T), the value of a property, anILocationBinding<T>, an open delegate or anIMethodBindingfor a method, or aProperty<T>orEvent<T>in an instance-scoped aspect. Without a name, a field or property is matched by its type. - #317 New:
IntroduceFieldAdviceInstance, returned byIAdviceProvider.ProvideAdvices, introduces a field into the target class, so that a statically scoped aspect can keep per-object state in the target object. The request can reuse an existing field, which is how two aspects share a field, and the advices read the field with[ImportMember]. - #318 New:
ImportDependencyAdviceInstancelets an aspect receive a service from dependency injection. The target class gets a field and a constructor parameter of the service type, also pulled into its derived classes in the project, and the advices read the service with[ImportMember]. The original constructors are kept as non-public forwarders that resolve the service from the newRunTimeServiceLocator, sonewin the project still works. Applying such an aspect to a public class changes its public constructors. - #324 Enhancement: the advices of an aspect are grouped by the new
GroupingAdvice.Groupproperty, which names the group of an advice, whatever the class that declares it. WhenGroupis not set, an advice without a pointcut joins the group of its class that has no advice of its kind yet.Masterand[SelfPointcut]are obsolete (CS0618). A redundantGroupis reported as LA0255, two groups of one family that both apply to the target of the aspect as LA0257,GroupandMasteron one advice as LA0258, and two pointcuts in one group as LA0259.⚠️ Breaking change: several[SelfPointcut]advices of different kinds withoutMaster, such as an entry and an exit advice, now form one group instead of one group each, so they share theirMethodExecutionArgsandMethodExecutionTag. Builds that useTreatWarningsAsErrorsfail on the new warnings until the aspect is updated. - #325 Enhancement:
[OnMethodInvokeAsyncAdvice]now accepts the[Declaration],[DeclarationName],[DeclarationIdentifier],[Arguments],[Argument]and[Binding](asIAsyncMethodBinding) parameters, also in a generic advice method. The advice can return aTask<T>whose result becomes the result of the target; any other result type is reported as LA0287. - #328 Enhancement: set
MatchPointcut.IsRequiredtotrueto report LA0285 when the advice applies to no method, because no method has the name or no overload matches the advice. - #315 New:
ProjectLocal<T>stores build-time state per project, for state that an aspect or a build-time service kept in a static field and that therefore leaked from one project to another processed by the same process.
Compiler
- #322 New: with
dotnet build, PostSharp compiles a .NET project in a long-running pipe server of the current user, instead of starting adotnet execprocess for each project. The server runs several compilations at a time, each in its own assembly load context, on Windows, Linux and macOS. On a small solution, a warm server compiled a project in 0.2 to 0.3 s instead of about 1 s. SetPostSharpUsePipeServertoFalseto compile withdotnet execas before. Projects that target x86, and the MSBuild of Visual Studio, keepdotnet exec.postsharp shutdownalso stops these servers.⚠️ Breaking change: on by default. - #321 Fix: the compiler no longer shares its third-party dependencies, such as Newtonsoft.Json, System.Text.Json, System.Collections.Immutable or Microsoft.Extensions.DependencyInjection, with the project it compiles. On .NET Framework, a project that references a higher version of one of them no longer fails with PS0264, and the build-time code of a project runs against the versions that the project references.
⚠️ Breaking change: an add-in loaded with<Using>inPostSharp.configthat relied on the compiler to supply one of these assemblies must ship it beside the add-in.
PostSharp.Patterns.Caching
- #323 New: with
[CacheConfiguration( UseDependencyInjection = true )],[Cache]and[InvalidateCache]use anICachingServicethat the class receives from dependency injection, instead of the process-wideCachingServices.DefaultBackend, so each container has its own cache. Register the service with, for instance,services.AddSingleton<ICachingService>( new CachingService( backend ) ). Static methods and methods of structs fall back toCachingServices.DefaultServiceand are reported as CAC011, whose severityStaticMethodFallbackSeveritysets. Invalidating a method that uses the other service is CAC012.⚠️ Breaking change:CacheAttributeandInvalidateCacheAttributeare now sealed and derive fromMethodLevelAspectinstead ofMethodInterceptionAspect.CachingServices.DefaultBackend,DefaultKeyBuilder, someCachingServices.Invalidationoverloads and the nestedCachingServices.CachingProfileRegistryare obsolete; useCachingServices.DefaultService. An async iterator with[Cache]is now reported as CAC013 instead of LA0197.
PostSharp.Testing.AspectTesting
- #326 New: the
@CompareTransformedCodedirective decompiles the woven assembly to C# and compares the declarations marked with// <target>, or all the top-level types of the file, with a.t.cssnapshot next to the test, which is accepted like the other expected files.
Resources
PostSharp 2027.0.5-preview
PostSharp 2027.0.5-preview is based on v2027.0.4-preview, plus the following changes.
PostSharp.Testing.AspectTesting
- #272 New: the
PostSharp.Testing.AspectTestingpackage lets you test your aspects the way PostSharp tests its own. Each source file of an xunit.v3 test project is a test: the framework compiles it, weaves it, verifies the woven assembly and runs itsMainmethod. Directives in comments, such as// @ExpectedMessage(MY001), set the expected messages. Tests run on .NET and .NET Framework and, on .NET, can also run as ReadyToRun, trimmed or NativeAOT programs.
Documentation
- #314 New: the documentation has an Errors and Warnings reference, with one article for each message that PostSharp and the pattern libraries report: its cause, how to resolve it and, in most articles, an example. The texts of 237 messages were corrected while these articles were written.
Aspect framework
- #281 Fix: an aspect provided to a property, an event or a parameter of a referenced assembly is now reported as error LA0031, LA0032 or LA0103. Before, the aspect had no effect, or the build failed with PS0099 (
ModuleMismatchException). - #282 Fix: a call to
AspectUtilities.InitializeCurrentAspects()no longer prevents the initialization of the instance-scoped aspects of the class. - #283 Fix:
[CopyCustomAttributes]on an aspect class now copies the attributes, and can report LA0073. - #284 Fix: a deserialization constructor that calls the constructor of a base class from another assembly no longer fails the build with PS0209.
- #285 Fix:
[MulticastAttributeUsage]now applies itsTargetParameterAttributesandTargetExternalTypeAttributesfilters. Aspects whose usage restricts parameters or external types can therefore apply to fewer declarations, and a usage that setsTargetTypeAttributesnow restricts external types too. - #287 Fix: an invalid aspect serializer type is reported as LA0021 or LA0022 only, without a crash or a spurious LA0001.
- #288 Fix: an advice whose pointcut fails with LA0048, LA0101 or LA0102 is no longer applied to the aspect target or followed by a spurious LA0049.
- #311 Fix: the overloads of
Message.Writethat take a format string no longer throwNullReferenceExceptionoutside of PostSharp. - #312 Fix: the XML documentation of
MulticastAttributeUsageAttribute.AllowMultipleandAllowExternalAssembliesnow states that the getter returnsfalsewhen the value is not set on the instance.
Compiler and messages
- #279 Fix: concurrent compilations in one process no longer fail with
NullReferenceExceptioninFrameworkFileBuilder. - #280 Fix: a message located on a method that has a
ref,outorinparameter now has a file and line. - #289 Fix: invalid project or plug-in configuration is now reported with messages, such as PS0017 or PS0136, instead of exceptions.
- #290 Fix: PS0049 is no longer reported a second time as PS0014, and PS0016 is reported once and stops the build at the 500th error.
- #291 Fix: LA0106 now names the type of the object that the pointcut returned, and SR0011 gives its arguments in the right order.
- #293 Fix: AR0106 is no longer reported on the assembly that declares the experimental API, and AR0110 now accepts generic types.
- #295 Fix: a message on a local function or an anonymous method is now located on the containing method, and a message on an annotation on its target. A warning on an annotation can now be suppressed.
- #296 Fix: unreachable report sites of messages were removed, PS0123 is reported once per hole, and LA0187 no longer applies to enumerable methods.
PostSharp.Patterns.Common
- #309 Fix: the exception for a formatting string with too many parameters now gives the expected number of parameters.
PostSharp.Patterns.Caching
- #297 Fix:
CachedParameterInfo.Parameteris now the parameter at its own position, instead of the first parameter of the method. - #298 Fix: a cached method that returned a null
IEnumerator<T>no longer throwsNullReferenceExceptionon the next call. - #299 Fix: when an async method throws before its first
await,[Cache]and[InvalidateCache]now throw its exception. Before, the exception was lost or wrapped in anAggregateException, and[InvalidateCache]invalidated the cached methods anyway. - #300 Fix: a change to a
CachingProfileproperty is no longer ignored by a cached method that runs at the same time. - #303 Fix: a value adapter that implements only the non-generic
IValueAdapter, or anIValueAdapter<Base>registered for a derived type, now works instead of throwingNullReferenceException.
PostSharp.Patterns.Caching.Backends.Redis
- #301 Fix:
RedisCachingBackend.CreateAsyncnow uses the same key prefix asCreatewhenIsLocallyCachedis true. WithCreateAsyncandIsLocallyCached, the distributed cache therefore starts empty after the upgrade. - #302 Fix:
RedisCachingBackendConfiguration.KeyCompressingThreshold, which had no effect, is now obsolete. Use the threshold ofCacheKeyBuilder.
PostSharp.Patterns.Diagnostics
- #306 Fix: the default
RootSyntheticIdnow has 64 random bits instead of 39. - #310 Fix:
new MultiplexerBackend(null)now creates a multiplexer without children instead of throwingNullReferenceException.
PostSharp.Patterns.Diagnostics.Backends.Tracing
- #304 Fix: the EventSource logging backend no longer writes the exit of a custom activity as a failure event.
PostSharpEventSource.EventIds.CustomActivityExitis now 20 instead of 16, the value ofCustomActivityFailure, and a custom activity exit below theWarninglevel is written with its ownVerboseevent. An exit of levelWarningor higher is still written asCustomActivityFailure.⚠️ Breaking change.
PostSharp.Patterns.Diagnostics.Backends.Microsoft
- #305 Fix:
MicrosoftLoggingBackendnow uses the loggers of its ownILoggerFactory, instead of those of another backend instance.
PostSharp.Patterns.Diagnostics.Backends.Serilog
- #307 Fix: the Serilog logging backend now adds the
IndentLevelproperty according toSerilogSpecialProperties.IndentLevel. Before,SerilogSpecialProperties.Indentadded both properties andIndentLevelhad no effect. The default value ofIncludedSpecialPropertiesis nowIndent | IndentLevel, so the default output is unchanged. If you setIncludedSpecialPropertiestoIndentexplicitly, addIndentLevelto keep the property.⚠️ Breaking change.
PostSharp.Patterns.Model
- #294 Fix:
Depends.Onin a method that a property getter calls is now reported as DOM012.
PostSharp.Patterns.Threading
- #292 Fix: THR017 now names the threading model of the class, and is reported once.
- #308 Fix: a
[ThreadAffine]object is now checked as thread-affine, not as thread-unsafe, when it becomes the child of another object. It is therefore rejected as a child of a[ThreadUnsafe],[Actor],[Synchronized]or[ReaderWriterSynchronized]object, as the compatibility rules of threading models declare. At build time, a[Child]field of such a class whose type is a[ThreadAffine]class is reported, unless the field hasDisableBehaviorPropagationorDisableBuildTimeValidation. At run time, assigning a thread-affine child to such a parent throwsInvalidOperationException, including for an item of an advisable collection and for a field withDisableBehaviorPropagation.⚠️ Breaking change.
PostSharp.Patterns.Xaml
- #286 Fix: the XAML aspects now report XAM051, XAM052, XAM055 and XAM077 to XAM079 instead of failing with an exception...
PostSharp 2027.0.4-preview
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
PostSharp 2026.0.19
PostSharp 2026.0.19 is based on v2026.0.18 and v2024.0.28.
This release forward-ports v2024.0.28: 3 enhancements and 5 bug fixes.
Resources
- Milestone 2024.0.28 (upstream)
- Full Changelog: v2026.0.18...v2026.0.19
PostSharp 2024.0.28
PostSharp 2024.0.28 is based on v2024.0.27, plus the following changes.
Enhancements
- #177 When an assembly fails to load because of an earlier request made before the project was loaded,
PS0265now shows the complete stack trace of the code that made that request, and the assembly resolution logs the requesting assembly. - #176 The new
FileLocktrace category (PostSharpTrace=FileLock) records the retries of file operations that fail because the file is locked: when they start, when the error changes, and how they end. Before, a lock shorter than the 5 seconds of theFileLockwarning left no trace in the build log. - #178 The
POSTSHARP_FILE_LOCK_TIMEOUTandPOSTSHARP_FILE_LOCK_WARNINGenvironment variables set the timeout and the warning threshold of the retries on locked files, in milliseconds. The defaults are unchanged: 10 seconds and 5 seconds.
Fixes
- #113 With
VcsCheckEnabled, a project that applies no aspect, such as an aspect library, no longer fails withPS0242when its source files are unmodified. The source control check now runs whether or not an aspect is woven. - #123 Fixed a
RemotingException("Object '…' has been disconnected or does not exist at the server") that failed the build when a weave did not communicate with the build for several minutes. The endpoint of the pipe server now stays reachable for as long as the weave runs. - #150 An assembly lookup through the host assembly store before build-time logging is initialized no longer makes every later lookup in the AppDomain fail.
- #253 Fixed
BindingException: Ambiguous assembly binding policieson .NET Framework when the project redirects an assembly that PostSharp ships to a newer version. The redirect of the project now replaces the redirect of PostSharp instead of being added next to it. - #245 The ARM64 native compiler host now queries the global assembly cache for the ARM64 variant of an assembly, instead of the x86 variant.
Resources
- Milestone
- Full Changelog: v2024.0.27...v2024.0.28
PostSharp 2027.0.3-preview
PostSharp 2027.0.3-preview is based on v2027.0.2-preview, plus the following changes.
New
- PostSharp.AI.Skills: a PostSharp plugin for Claude Code and OpenAI Codex. It gives coding agents the PostSharp documentation and API reference, so that they write PostSharp code from the real API instead of guessing.
Advice Parameter Binding
This preview continues the work on advice parameter binding, which became a public feature in 2027.0.2-preview (#168).
- #164 The new
[Exception]binding gives the exception to an[OnMethodExceptionAdvice]with bound parameters. Areforoutparameter can replace the exception, andFlowBehavior.ThrowExceptionnow throws it. Before, a bound advice rethrew the original exception. - #165
[ReturnValue]is now accepted in method boundary advices. Success and exit advices can read the return value and replace it. Entry and exception advices can set the value thatFlowBehavior.Returnreturns. In an async method, the value is the result of the task. - #166 The new
[Declaration]binding gives the reflection object of the target: theMethodBaseof a method (the method declared in source code for an async method or an iterator), theLocationInfoof a field or property, or theTypeof a constructed instance. - #163 The compiler now checks each binding against the advice kinds, parameter modes and counts it accepts. Combinations that crashed the compiler or produced invalid IL are now errors, and those that had no effect are now warnings.
- #169 The type arguments of generic advice methods are now inferred correctly, including for by-reference parameters, constraints between type parameters and generic aspect classes. LA0220 now gives the reason, and the new warning LA0245 reports an unused type parameter.
- #238
[CurrentTask]is nownulluntil the async method has yielded; on .NET, the task read earlier never completed. After the first yield, it is the task of the caller.ValueTaskandValueTask<T>are now supported.⚠️ Breaking change. - #243 Fixed an internal compiler exception when an advice under
MatchPointcutbinds an argument by name ([Argument("x")]) or by type ([Argument]).
Enhancements
- #92 The MSBuild integration now works in the MSBuild server, which the .NET 11 SDK enables by default. The cache of installed .NET runtimes is refreshed when the installation changes, and the memory throttling no longer shuts down the MSBuild server that runs the build.
- #240
PostSharpValidateLanguageVersionno longer loads the Roslyn assemblies of the SDK into the MSBuild process, where they stayed loaded and locked.
⚠️ Breaking Changes
- #201
TreatWarningsAsErrorsnow applies to the warnings of PostSharp and of aspects, through the newPostSharpTreatWarningsAsErrorsproperty, which honorsWarningsNotAsErrors. Set it toFalsefor the previous behavior. The PostSharp codes inWarningsAsErrorsare escalated too. - #205 Implementing an
[InternalImplement]interface ofPostSharp.dll, such asIArgumentsWriter, is now reported as warning AR0101. - #206 Applying an
[Internal]custom attribute of another assembly is now reported as warning AR0105. - #237
[Internal]read[InternalsVisibleTo]in the wrong direction. A friend assembly of the declaring assembly no longer gets AR0105. An assembly that only grants the declaring assembly access to its own internals now gets AR0105. - #225
PostSharp.Patterns.Diagnostics.Serilognow depends on Serilog 4.4.0 instead of 2.3.0. An application that uses Serilog 2.x or 3.x is upgraded, and sinks built for Serilog 2 may need a newer version. - #221 The Serilog backend no longer passes string values with PostSharp's quotes, for example
guestinstead of"guest". Sinks that read the properties receive the new value. Serilog adds its own quotes in the rendered message.
Fixes
MSBuild integration and packaging
- #156 Fixed a build failure when the .NET 11 CLI cannot connect to the MSBuild server during the restore of the compiler dependencies. The restore is now judged by its exit code, not by its standard error.
- #241
PostSharpExtractToolscould extract the compiler of another package with the same main version. The archive is now taken from the imported package, and a warning is reported when the task assembly that runs is not the one the project imports. - #193 Mismatched versions of
PostSharpandPostSharp.Redistare now diagnosed. A higherPostSharp.Redistis an error that gives thedotnet nuget whycommand, which shows the package that requires it. A lower one is a warning.PostSharpRedistVersionCheckDisabledskips the check. - #197 Fixed a build failure when the project targets a Windows SDK version that is newer than the Windows version of the build machine.
- #198 The reference packs of the target frameworks of referenced assemblies, such as
NETStandard.Library.Ref, are now restored when the SDK does not include them.
Compiler output
- #194 PostSharp no longer removes the public signing flag (
<PublicSign>true</PublicSign>) of the assembly. - #195 The debug directory of an assembly with a Windows PDB no longer says that the PDB is a Portable PDB. This broke tools such as dotCover.
- #196 The local variables of a method enhanced by an aspect are now visible in the debugger on the closing brace.
- #199 Fixed a
BindingExceptionwhen PostSharp builds a facade assembly forMicrosoft.VisualStudio.Debugger.Engine.dll.
Aspect ordering
- #203
AspectDependencyAction.Commuteis now taken into account when only one of the two aspects declares it. - #204 PS0114 no longer reports an aspect as conflicting with itself on async methods and iterators.
Threading models
- #207 An abstract event in a
[ReaderWriterSynchronized]class no longer fails with LA0146. - #208 The thread-safety policy now recognizes the thread-safe types of referenced assemblies.
- #211 The
LockRecursionExceptionthrown when a[Writer]method is called from a[Yielder]method now explains the cause, and recommends[UpgradeableReader]on the method that raises the event. - #212 Fixed a lock that was acquired on each access to a thread-safe object after its parent had changed.
- #213 The enumerators of advisable collections no longer throw after an
awaitthat resumes on another thread. The threading model decides:[ThreadAffine]throwsThreadMismatchException, and[Synchronized]and[ReaderWriterSynchronized]take the lock.
NotifyPropertyChanged
- #214
[NotifyPropertyChanged]no longer keeps the parent alive through its subscription to a child that implementsINotifyPropertyChangedby hand. - #215
[NotifyPropertyChanged]no longer throwsNullReferenceExceptionfor an explicitly implemented auto-property. - #226, #229, #230, #234 Fixed
[NotifyPropertyChanged]defects that caused missing, duplicate or early notifications, and stale subscriptions. Dependencies declared withDepends.Onon another property are now tracked. - #227
NotifyPropertyChangedServices.ResumeEventswithout a matchingSuspendEventsnow throwsInvalidOperationExceptioninstead of silently disabling the next suspension. - #228
NotifyPropertyChangedOverflowExceptionis now thrown for an infinite loop of notifications, and no longer for a flush that ends normally after 64 passes. - [#232](https://github.com/postsharp/PostShar...
PostSharp 2027.0.2-preview
PostSharp 2027.0.2-preview is based on v2027.0.1-preview, plus the following changes.
New
- #168 Advice parameter binding is now a publicly supported feature, after years of internal use by the Pattern Libraries. An advice method can receive only the values it needs, as typed parameters bound by attributes such as
[Argument],[This]and[State], instead of anAdviceArgsobject allocated on every call. This release reports invalid bindings as errors (#161, #162) and makes simple declarative aspects less verbose (#192). - #187 Added support for runtime-generated async methods (
<Features>runtime-async=on</Features>on .NET 11), whose state machine is generated by the runtime instead of the C# compiler. Aspects applied to these methods previously failed at run time withInvalidProgramException. Aspects see the same advices, in the same order and with the same arguments, as with a compiler-generated state machine. - #188 A repository can opt out of telemetry for every build and every machine by setting the
TelemetryEnabledproperty toFalsein thepostsharp.configfile at its root. - SharpCrafters.Backstage#24 Added the reading of a configuration file at the root of the repository. PostSharp reads
postsharp.config, where a repository can opt out of telemetry with theTelemetryEnabledproperty (postsharp/PostSharp.Public#188). A file that cannot be read is reported as a build warning.
Enhancements
- #192 In a declarative aspect,
[SelfPointcut]andMastercan now be omitted when there is only one way to group the advices.
Fixes
- #161 Fixed an internal compiler exception, or an advice silently disabled, when an advice method has an invalid parameter binding, for example two binding attributes on one parameter or a parameter type that is not compatible with the bound value. An error located at the parameter is now reported.
- #162 Fixed invalid IL, or an internal compiler exception, when an advice with bound parameters does not match its target, for example
[Argument(n)]with an index out of range or[This]on a static target. An error that names the advice, the parameter and the target is now reported. - #171 The
PostSharp.Toolpackage, which was missing from 2027.0.1-preview, is now published, sodotnet tool install -g PostSharp.Toolinstalls thepostsharpcommand line tool. - #182 Warnings about the repository configuration, for example a
postsharp.configfile that cannot be read, are now reported as PS0284 build warnings located at the file. They were previously ignored. - SharpCrafters.Backstage#26 Fixed usage telemetry slowing down the parallel build of a large solution. Each project now records its usage session separately, so build processes no longer wait for each other on a single lock (metalama/Metalama#2092).
- SharpCrafters.Backstage#25 Fixed a crash with
COMExceptionwhen Windows refuses to display a toast notification. The notification is now skipped when the machine cannot display it (metalama/Metalama#2047).
Resources
PostSharp 2027.0.1-preview
PostSharp 2027.0.1-preview is the first preview of PostSharp 2027.0. It is based on v2026.0.18, plus the following changes.
PostSharp 2027.0 moves the supported platforms to .NET 10 and .NET 11, and replaces the licensing, configuration, telemetry and user interface services of the compiler with the infrastructure stack that Metalama also uses. The PostSharp Options application is replaced by a web-based user interface and by the new postsharp command line tool. Several of these changes are breaking: read the section below before upgrading.
Warning
The PostSharp.Tool package, which provides the postsharp command line tool, was not uploaded to nuget.org with this release by mistake, so dotnet tool install -g PostSharp.Tool fails for now. It will be published with the next release (#171). Until then, supply a licence key through the PostSharpLicense MSBuild property or postsharp.config.
⚠️ Breaking Changes
- #87
net6.0,net8.0andnet9.0are no longer supported target frameworks, and the packages no longer ship assets for them.net10.0andnet11.0are supported, and the minimum SDK at build time is the .NET 10 SDK. - #114 Removed the PostSharp Options application (
PostSharp.Settings.UI.exeandPostSharp.Settings.exe). It is replaced by a web-based user interface, which is shared with Metalama: the build shows toast notifications, and they open pages served locally in the browser, for example to register a licence key. SetPostSharpDisableUserInterfacetoTrueto silence them. - #117 Interactive builds on Linux and macOS now require a licence, as they always have on Windows. Builds under a CI agent, a service or a container remain unattended.
- #118 Usage telemetry is switched on at the first build unless the user opts out, with a notification that says how to turn it off. Crash reporting is unchanged and is never sent without consent.
- #142 Add-ins compile against the reference assemblies of the new
PostSharp.Sdkpackage.PostSharp.Compiler.CommonandPostSharp.Compiler.Enginenow only depend on it. - #145 Builds on Windows build agents now use the pipe server, which keeps running after the build. Set
PostSharpUsePipeServer=Falseto restore the former behaviour.PostSharpAllowPipeServerWhenUnattendedis obsolete.
New
- #119 Added the
postsharpcommand line tool (dotnet tool install -g PostSharp.Tool), which registers licence keys, edits settings and reports the telemetry state, on Windows, Linux and macOS. - #124 Added
postsharp shutdown, which stops the PostSharp processes that keep running after a build, such as the pipe server. - SharpCrafters.Backstage#15
postsharp shutdownalso stops the .NET build servers (dotnet build-server shutdown, theVBCSCompilerserver and the MSBuild nodes) and the background worker and notifier. Without--force, a process that does not exit is reported as still running.postsharp killis another name of the same command. - #170 Added support for licence keys signed with Elliptic Curve DSA (P-256 and SHA-256). Keys signed with DSA, which include every key issued so far, remain valid. Finite field DSA is not available on macOS in .NET 11, so a signed licence key can now be verified on every supported platform.
Fixes
- #115 Fixed an intermittent build failure with
ObjectDisposedException: Safe handle has been closedwhile assembly identities are read concurrently, for example in a solution build through the pipe server. - #116 Fixed a build failure with PS0242 in a linked git worktree when the licence key is limited to a namespace.
- #154 Fixed, on Linux and macOS, a package whose version contains an upper-case letter (for example
1.0.0-RC1) being left out of the dependencies of the compiler, with a "Couldn't locate restored package" warning. - #159 Fixed a hang of the Redis caching backend in
Clear,InvalidateDependencyorCleanUpAsync, which kept a CPU core busy and ignored the cancellation token. - #160 Fixed a
NullReferenceExceptioninMultiplexerBackendwhen a child logging backend creates no transaction.
Resources
PostSharp 2026.0.18
PostSharp 2026.0.18 is based on v2026.0.17 and v2024.0.27.
This release forward-ports the upstream v2024.0.27 changes to the 2026.0 line: the build now retries transient file system errors during assembly resolution instead of failing with LA0014 or PS0264 or silently binding another build of an assembly, and binding failures are reported with a PS0265 binding record. It contains no other change.
Resources
- Milestone 2024.0.27 (upstream)