Today we’re excited to announce the release of PostSharp 4.1 Preview 4, available for download on our website and as pre-release packages on our NuGet feeds. We silently released two other previews since our last announcement. PostSharp 4.1 is all about supporting new platforms and it is now feature-complete. Let’s see what’s new in the box:
- Support for Xamarin
- Windows Phone and Windows
- Visual Studio 2015
- Conservative NuGet Versioning
- Localizable Code Contracts
- PostSharp Explorer Improvements
It made the top of our UserVoice wish list for a long time: Xamarin is now supported as a first-class member of the .NET family. All features of PostSharp, including thread safety patterns, INotifyPropertyChanged and undo/redo, are now available for Xamarin through portable class libraries (PCL).
How to use PostSharp with a Xamarin project? Just as it works with other projects. Use the smart tag or the light bulb to add a PostSharp aspect, or install the PostSharp NuGet package. It’s that simple.
More about Xamarin integration in a later post.
Windows Phone and Windows Store
You could already create your own PostSharp aspects or use the built-in INotifyPropertyChanged and undo/redo aspects with Windows Phone and WinRT. With PostSharp 4.1, you can now use PostSharp Threading Pattern Library to create truly cross-platform thread-safe apps. Additionally to .NET Framework and Xamarin, we also ported and tested thread safety library with Windows Phone and Windows Store.
Visual Studio 2015
We’ve continued to work on support for Visual Studio 2015, and PostSharp is now compatible with VS 2015 CTP 5. There are two different scenarios to be considered:
- C# and VB compilers. As you know, Visual Studio 2015 ships with a completely new generation of compilers. They break some assumptions that previous versions of PostSharp were doing. Therefore, if you build working code with VS 2015, you may cause previous versions of PostSharp to crash or invalid code to be generated. We want you to know that we take this situation extremely seriously and that we are committed to provide support for the new compilers in PostSharp 3.1, 4.0 and 4.1. Therefore, you are not forced to upgrade to new major version of PostSharp. However, you must upgrade to the newest build of your current PostSharp minor release if you want to upgrade to Visual Studio 2015.
- Visual Studio Editor. We made a significant investment to ensure the optimal user experience of PostSharp in Visual Studio 2015. Not only did we replace the smart tag with the modern light bulb, but we also added live code diagnostics and assistance.
More about Visual Studio integration in a later post.
Conservative NuGet Versioning
In the past, adding a new aspect using the smart tag or light bulb could cause the PostSharp packages to be silently upgraded to the latest version. This is how the NuGet client works by default, but this is quite annoying. PostSharp 4.1 will now always try to respect the version of PostSharp that you are already using in the solution. If a package upgrade is required because the version you are using does not support the requested feature, PostSharp will request your consent before upgrading the package.
Localizable Code Contracts
It is now possible to customize the exception messages generated by PostSharp Code Contracts, and therefore localize them. The API is based on a chain of responsibility, into which you can insert your own message provider. The implementation does not rely on managed resources so it is easier to customize. The feature is not yet documented. Start from class ContractLocalizedTextProvider for more information.
With this new release, PostSharp becomes really cross-platform. Whether you are developing desktop applications with WPF or mobile applications for Windows Phone, Windows 8, Android or iOS, you can rely on PostSharp to deliver features quicker with source code that is more concise, cleaner and more reliable.
PostSharp 4.1 is now feature-complete and there are now just a few issues (documented in the release notes) that we need to solve before we can call it a release candidate. It’s a great time to try PostSharp 4.1 if you are not on a tight go-to-production schedule.
We’re really eager for feedback from Xamarin and mobile developers, so don’t hesitate to contact us with any question, remark or frustration.