Skip to content

PostSharp 2027.0.5-preview

Pre-release
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. A validator that does not return bool now fails the build with XAM055 instead of failing at run time.
  • #313 Fix: Attached<T>.SetValue now sets a local value, like the indexer, so a style or a binding no longer replaces it.

Resources