Skip to content

Releases: postsharp/PostSharp.Public

PostSharp 2027.0.7-preview

Pre-release

Choose a tag to compare

@gfraiteur gfraiteur released this 27 Oct 16:07

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. The postsharp command 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 @CompareWeavingSymbols directive compares the weaving symbol file (.pssym) of a test with a .t.pssym snapshot next to the test, as @CompareTransformedCode does with a .t.cs file. 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>.pssym file replaces the snapshot for one target framework, and a snapshot is accepted like the other expected files.

Resources

PostSharp 2027.0.6-preview

Pre-release

Choose a tag to compare

@gfraiteur gfraiteur released this 22 Oct 19:17

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 their ICachingService from 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 new dotnet exec process 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, an ILocationBinding<T>, an open delegate or an IMethodBinding for a method, or a Property<T> or Event<T> in an instance-scoped aspect. Without a name, a field or property is matched by its type.
  • #317 New: IntroduceFieldAdviceInstance, returned by IAdviceProvider.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: ImportDependencyAdviceInstance lets 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 new RunTimeServiceLocator, so new in 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.Group property, which names the group of an advice, whatever the class that declares it. When Group is not set, an advice without a pointcut joins the group of its class that has no advice of its kind yet. Master and [SelfPointcut] are obsolete (CS0618). A redundant Group is reported as LA0255, two groups of one family that both apply to the target of the aspect as LA0257, Group and Master on one advice as LA0258, and two pointcuts in one group as LA0259. ⚠️ Breaking change: several [SelfPointcut] advices of different kinds without Master, such as an entry and an exit advice, now form one group instead of one group each, so they share their MethodExecutionArgs and MethodExecutionTag. Builds that use TreatWarningsAsErrors fail on the new warnings until the aspect is updated.
  • #325 Enhancement: [OnMethodInvokeAsyncAdvice] now accepts the [Declaration], [DeclarationName], [DeclarationIdentifier], [Arguments], [Argument] and [Binding] (as IAsyncMethodBinding) parameters, also in a generic advice method. The advice can return a Task<T> whose result becomes the result of the target; any other result type is reported as LA0287.
  • #328 Enhancement: set MatchPointcut.IsRequired to true to 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 a dotnet exec process 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. Set PostSharpUsePipeServer to False to compile with dotnet exec as before. Projects that target x86, and the MSBuild of Visual Studio, keep dotnet exec. postsharp shutdown also 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> in PostSharp.config that 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 an ICachingService that the class receives from dependency injection, instead of the process-wide CachingServices.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 to CachingServices.DefaultService and are reported as CAC011, whose severity StaticMethodFallbackSeverity sets. Invalidating a method that uses the other service is CAC012. ⚠️ Breaking change: CacheAttribute and InvalidateCacheAttribute are now sealed and derive from MethodLevelAspect instead of MethodInterceptionAspect. CachingServices.DefaultBackend, DefaultKeyBuilder, some CachingServices.Invalidation overloads and the nested CachingServices.CachingProfileRegistry are obsolete; use CachingServices.DefaultService. An async iterator with [Cache] is now reported as CAC013 instead of LA0197.

PostSharp.Testing.AspectTesting

  • #326 New: the @CompareTransformedCode directive 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.cs snapshot next to the test, which is accepted like the other expected files.

Resources

PostSharp 2027.0.5-preview

Pre-release

Choose a tag to compare

@gfraiteur gfraiteur released this 16 Oct 23:00

PostSharp 2027.0.5-preview is based on v2027.0.4-preview, plus the following changes.

PostSharp.Testing.AspectTesting

  • #272 New: the PostSharp.Testing.AspectTesting package 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 its Main method. 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 its TargetParameterAttributes and TargetExternalTypeAttributes filters. Aspects whose usage restricts parameters or external types can therefore apply to fewer declarations, and a usage that sets TargetTypeAttributes now 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.Write that take a format string no longer throw NullReferenceException outside of PostSharp.
  • #312 Fix: the XML documentation of MulticastAttributeUsageAttribute.AllowMultiple and AllowExternalAssemblies now states that the getter returns false when the value is not set on the instance.

Compiler and messages

  • #279 Fix: concurrent compilations in one process no longer fail with NullReferenceException in FrameworkFileBuilder.
  • #280 Fix: a message located on a method that has a ref, out or in parameter 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.Parameter is 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 throws NullReferenceException on 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 an AggregateException, and [InvalidateCache] invalidated the cached methods anyway.
  • #300 Fix: a change to a CachingProfile property 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 an IValueAdapter<Base> registered for a derived type, now works instead of throwing NullReferenceException.

PostSharp.Patterns.Caching.Backends.Redis

  • #301 Fix: RedisCachingBackend.CreateAsync now uses the same key prefix as Create when IsLocallyCached is true. With CreateAsync and IsLocallyCached, the distributed cache therefore starts empty after the upgrade.
  • #302 Fix: RedisCachingBackendConfiguration.KeyCompressingThreshold, which had no effect, is now obsolete. Use the threshold of CacheKeyBuilder.

PostSharp.Patterns.Diagnostics

  • #306 Fix: the default RootSyntheticId now has 64 random bits instead of 39.
  • #310 Fix: new MultiplexerBackend(null) now creates a multiplexer without children instead of throwing NullReferenceException.

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.CustomActivityExit is now 20 instead of 16, the value of CustomActivityFailure, and a custom activity exit below the Warning level is written with its own Verbose event. An exit of level Warning or higher is still written as CustomActivityFailure. ⚠️ Breaking change.

PostSharp.Patterns.Diagnostics.Backends.Microsoft

  • #305 Fix: MicrosoftLoggingBackend now uses the loggers of its own ILoggerFactory, instead of those of another backend instance.

PostSharp.Patterns.Diagnostics.Backends.Serilog

  • #307 Fix: the Serilog logging backend now adds the IndentLevel property according to SerilogSpecialProperties.IndentLevel. Before, SerilogSpecialProperties.Indent added both properties and IndentLevel had no effect. The default value of IncludedSpecialProperties is now Indent | IndentLevel, so the default output is unchanged. If you set IncludedSpecialProperties to Indent explicitly, add IndentLevel to keep the property. ⚠️ Breaking change.

PostSharp.Patterns.Model

  • #294 Fix: Depends.On in 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 has DisableBehaviorPropagation or DisableBuildTimeValidation. At run time, assigning a thread-affine child to such a parent throws InvalidOperationException, including for an item of an advisable collection and for a field with DisableBehaviorPropagation. ⚠️ 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...
Read more

PostSharp 2027.0.4-preview

Pre-release

Choose a tag to compare

@gfraiteur gfraiteur released this 14 Oct 16:30

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.dll is 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 InstantiateTypeAdviceInstance lets an aspect request the native code of a closed generic type that it creates by reflection at run time. [Cache] and [Log] use it.

Enhancements

  • #40 The new MSBuild property PostSharpDependencyRestoreProperties sets MSBuild properties, such as NuGetAudit=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 by diagnostics.json.
  • #190 An unattended build is now licensed for PostSharp Logging in production mode.
  • #242 The MethodBase of 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 FileLock trace category now records the retries of file operations that fail because the file is locked, and the POSTSHARP_FILE_LOCK_TIMEOUT and POSTSHARP_FILE_LOCK_WARNING environment 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, MatchPointcut and the instance lifecycle advices now describes which targets they accept.

Fixes

Aspect framework

  • #189 With runtime async, an exception thrown by an OnYield or OnResume advice no longer runs the finally blocks of the user code around the await, so runtime async now behaves as a compiler state machine. With the new MSBuild property PostSharpCompatibilityLevel set to 2027.0 or higher, the exception instead goes through the catch and finally blocks of the user code, then through OnException and OnExit, with both implementations. ⚠️ Breaking change.
  • #244 An advice that joins a group implicitly and sets SemanticallyAdvisedMethodKinds, UnsupportedTargetAction or ApplyToStateMachine, 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 MatchPointcut on a method-level or an assembly-level aspect is now reported as error LA0251, instead of failing the build with an InvalidCastException.
  • #249 An InvalidAnnotationException thrown by CompileTimeValidate is 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 Require or Conflict dependency now states the order correctly, and the documentation of AspectDependencyAction now 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 T parameter of an invoke advice applied to a void method no longer causes a BadImageFormatException: the advice receives no return value. A non-generic [ReturnValue] out object parameter in the same situation now builds too; set IsRequired = true to keep an error.
  • #257 A by-value [LocationValue] object parameter of a set advice on a property of a value type is now boxed, instead of producing invalid IL.
  • #260 An OnMethodInvokeAdvice with bound parameters applied to an instance method of a struct no longer fails the build with a NullReferenceException.

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 PostSharp package 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 VcsCheckEnabled no longer waits two minutes and then requires a license although no source file is modified. The git command 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 the field: 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 property PostSharpUnifiedAutomaticPropertyAnnotations makes the attributes of a property and of its backing field be read as one set.
  • #267 The new warning THR043 reports an appliesToMethodOnly argument 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 raises PropertyChanged once, 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

PostSharp 2026.0.19

Choose a tag to compare

@gfraiteur gfraiteur released this 14 Oct 16:51

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

PostSharp 2024.0.28

Choose a tag to compare

@gfraiteur gfraiteur released this 14 Oct 16:51

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, PS0265 now shows the complete stack trace of the code that made that request, and the assembly resolution logs the requesting assembly.
  • #176 The new FileLock trace 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 the FileLock warning left no trace in the build log.
  • #178 The POSTSHARP_FILE_LOCK_TIMEOUT and POSTSHARP_FILE_LOCK_WARNING environment 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 with PS0242 when 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 policies on .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

PostSharp 2027.0.3-preview

Pre-release

Choose a tag to compare

@gfraiteur gfraiteur released this 08 Oct 04:19

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. A ref or out parameter can replace the exception, and FlowBehavior.ThrowException now 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 that FlowBehavior.Return returns. In an async method, the value is the result of the task.
  • #166 The new [Declaration] binding gives the reflection object of the target: the MethodBase of a method (the method declared in source code for an async method or an iterator), the LocationInfo of a field or property, or the Type of 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 now null until the async method has yielded; on .NET, the task read earlier never completed. After the first yield, it is the task of the caller. ValueTask and ValueTask<T> are now supported. ⚠️ Breaking change.
  • #243 Fixed an internal compiler exception when an advice under MatchPointcut binds 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 PostSharpValidateLanguageVersion no longer loads the Roslyn assemblies of the SDK into the MSBuild process, where they stayed loaded and locked.

⚠️ Breaking Changes

  • #201 TreatWarningsAsErrors now applies to the warnings of PostSharp and of aspects, through the new PostSharpTreatWarningsAsErrors property, which honors WarningsNotAsErrors. Set it to False for the previous behavior. The PostSharp codes in WarningsAsErrors are escalated too.
  • #205 Implementing an [InternalImplement] interface of PostSharp.dll, such as IArgumentsWriter, 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.Serilog now 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 guest instead 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 PostSharpExtractTools could 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 PostSharp and PostSharp.Redist are now diagnosed. A higher PostSharp.Redist is an error that gives the dotnet nuget why command, which shows the package that requires it. A lower one is a warning. PostSharpRedistVersionCheckDisabled skips 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 BindingException when PostSharp builds a facade assembly for Microsoft.VisualStudio.Debugger.Engine.dll.

Aspect ordering

  • #203 AspectDependencyAction.Commute is 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 LockRecursionException thrown 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 await that resumes on another thread. The threading model decides: [ThreadAffine] throws ThreadMismatchException, and [Synchronized] and [ReaderWriterSynchronized] take the lock.

NotifyPropertyChanged

  • #214 [NotifyPropertyChanged] no longer keeps the parent alive through its subscription to a child that implements INotifyPropertyChanged by hand.
  • #215 [NotifyPropertyChanged] no longer throws NullReferenceException for an explicitly implemented auto-property.
  • #226, #229, #230, #234 Fixed [NotifyPropertyChanged] defects that caused missing, duplicate or early notifications, and stale subscriptions. Dependencies declared with Depends.On on another property are now tracked.
  • #227 NotifyPropertyChangedServices.ResumeEvents without a matching SuspendEvents now throws InvalidOperationException instead of silently disabling the next suspension.
  • #228 NotifyPropertyChangedOverflowException is 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...
Read more

PostSharp 2027.0.2-preview

Pre-release

Choose a tag to compare

@gfraiteur gfraiteur released this 03 Oct 08:56

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 an AdviceArgs object 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 with InvalidProgramException. 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 TelemetryEnabled property to False in the postsharp.config file 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 the TelemetryEnabled property (postsharp/PostSharp.Public#188). A file that cannot be read is reported as a build warning.

Enhancements

  • #192 In a declarative aspect, [SelfPointcut] and Master can 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.Tool package, which was missing from 2027.0.1-preview, is now published, so dotnet tool install -g PostSharp.Tool installs the postsharp command line tool.
  • #182 Warnings about the repository configuration, for example a postsharp.config file 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 COMException when 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

Pre-release

Choose a tag to compare

@gfraiteur gfraiteur released this 29 Sep 17:16

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.0 and net9.0 are no longer supported target frameworks, and the packages no longer ship assets for them. net10.0 and net11.0 are supported, and the minimum SDK at build time is the .NET 10 SDK.
  • #114 Removed the PostSharp Options application (PostSharp.Settings.UI.exe and PostSharp.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. Set PostSharpDisableUserInterface to True to 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.Sdk package. PostSharp.Compiler.Common and PostSharp.Compiler.Engine now only depend on it.
  • #145 Builds on Windows build agents now use the pipe server, which keeps running after the build. Set PostSharpUsePipeServer=False to restore the former behaviour. PostSharpAllowPipeServerWhenUnattended is obsolete.

New

  • #119 Added the postsharp command 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 shutdown also stops the .NET build servers (dotnet build-server shutdown, the VBCSCompiler server and the MSBuild nodes) and the background worker and notifier. Without --force, a process that does not exit is reported as still running. postsharp kill is 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 closed while 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, InvalidateDependency or CleanUpAsync, which kept a CPU core busy and ignored the cancellation token.
  • #160 Fixed a NullReferenceException in MultiplexerBackend when a child logging backend creates no transaction.

Resources

PostSharp 2026.0.18

Choose a tag to compare

@gfraiteur gfraiteur released this 26 Sep 11:03

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