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