What's New in PostSharp 5.0
As a new major version, PostSharp 5.0 was the opportunity to introduce a few breaking changes. First, we dropped support for Microsoft's failed platforms Windows Phone and WinRT in favor of .NET Core, .NET Standard and Visual Studio 2017. Then, we completely revisited PostSharp Logging. Additionally, we added a caching aspect and three MVVM aspects.
As a major version, PostSharp 5.0 contains some breaking changes. See Breaking Changes in PostSharp 5.0 for details.
PostSharp 5.0 includes the following improvements:
- Logging: complete revamping
- Caching: a brand new feature
- Filled gaps in support for async methods
- XAML: Command, Dependency Property and Attached Property
- Code Contracts: support for out parameters and return values
- Architecture Framework: new constraints
- Support for Visual Studio 2017
- Support for .NET Core and .NET Standard
- Support for NuGet 3
- End of support for Windows Phone, WinRT and Silverlight
- Suspended support for Xamarin
That's a complete rewrite! The new PostSharp Logging is fully customizable and faster than ever. See Logging for details.
We've added a brand new ready-made caching framework, which includes not only a caching aspect but also a cache invalidation aspect. PostSharp Caching 5.0 comes with support for MemoryCache and Redis. See Caching for details.
We've put a lot of efforts to put async methods on par with normal methods in PostSharp:
The MethodInterceptionAspect and OnMethodBoundaryAspect aspects now advise async methods and iterators semantically by default (i.e. the state machine itself is advised), while previous versions advised the kick-off methods by default. The new property SemanticallyAdvisedMethodKinds controls whether the advice is applied semantically or not. The UnsupportedTargetAction property determines what should be done when semantic advising of the current method is not supported.
If you're writing XAML applications, you probably wrote a lot of boilerplate code for commands and dependency properties. We've created new aspects to automate that. See XAML for details.
It is now possible to add code contracts to return values and out or ref parameters. The values are validated when the method succeeds.
PostSharp 5.0 adds three constraints:
The NamingConventionAttribute constraint is a simple way to force derived class to respect some naming convention.
The ParameterValueConstraint abstract constraint lets you validate, at build-time, the value passed to method parameters.
The ReferenceConstraint abstract constraint allows you to validate which code uses (i.e. references) your type or method.
PostSharp 5.0 supports Visual Studio 2017 including the new project format (package references) and the new features of C# 7.0.
PostSharp 5.0 supports .NET Core 1.0 and .NET Standard 1.3 in Visual Studio 2017 and .NET Core CLI. See Requirements and Compatibility for details.
PostSharp 5.0 supports NuGet 3 and it no longer needs install.ps1 to introduce itself into the build chain.
Let's face it, these platforms were a failure. We no longer want to pay a price for that and we're dropping support in PostSharp 5.0.
Usage data show that only a few customers are using PostSharp with Xamarin, so we demoted the priority of this platform. It is not supported in PostSharp 5.0. Affected customers should contact our support team. We're considering to support Xamarin through .NET Standard if there is significant demand for it.