If you’ve ever wondered how important Russian developers are to the .NET community, look no further than Resharper and DevExpress. The first comes to us from Saint Petersburg with love, the second is located in Tula, a 2-hour drive South from Moscow. At time when politicians and media feed us with fears and lies about Russia, we would like to remind how fruitful this relationship is to developers of all countries – and want to contribute to strengthen it.
Today, I’m excited to announce I’ll deliver the Patterns On The Road tour from March 11th to March 18th in Moscow and St Petersburg, the largest developer communities in Moscow. The objective of this tour is to promote the idea of pattern-oriented development: not just designing with patterns (what you’ve hopefully already done since the GoF book), but also thinking and coding with patterns. I’ll show how these ideas apply to killer problem: thread safety. For those who want to learn about PostSharp, there will be a free training day in both towns.
An evening of patterns or a full day of PostSharp? Choose what’s best for you:
Evening Lecture: Taking Design Patterns to the Next Level
Design patterns are now universally accepted and have significantly improved the way we design software. However, they had relatively little impact on how we implement it. This talk advocates for a better integration of pattern thinking in the whole development cycle. It challenges popular dogmas about design patterns and shows unexpected connections with agile methodologies. It shows how to apply pattern thinking to a top problem: thread safety.
- On March 12 (Moscow) or 16 (St Petersburg) evening. FREE event. Register now.
Training Day: Advanced PostSharp From the Horse’s Mouth
While the evening lecture remains quite general, this training day describes how we can implement pattern-driven development specifically with PostSharp.
The course opens with a quick journey through the history of programming languages and design patterns, then asks the fundamental question: why is it that we think in terms of patterns, and actually design with patterns, but actually abandon that pattern thinking as soon as we start writing code? This sets up the agenda for the whole day: thread safety, INotifyPropertyChanged, undo/redo, aspect-oriented programming and architecture validation.
- On March 13 (Moscow) or 17 (St Petersburg). FREE event but limited capacity. Register now.
I’m looking forward to visit Russia again after almost 20 years. Additionally to delivers public talks, I’ll visit Kaspersky Lab in Moscow and JetBrains in St Petersburg. It will be exciting to meet the developers there.
As we’re now in the stabilization of PostSharp 4.1, I would like to talk in a bit more detail about a few of its features. If you haven’t done it yet, you can download the last preview of PostSharp 4.1 from our web site.
Additionally to adding support for Xamarin and improving support for Windows Phone and Windows 8, we spent a lot of effort improving our Visual Studio extension.
A few highlights are:
- Support for Visual Studio 2015, including light bulb integration, live code diagnostics and coding guidance.
- Conservative NuGet versioning.
- Improvements in PostSharp Explorer.
- Support for Universal Apps (shared projects).
Visual Studio 2015
As you probably know, Visual Studio 2015 includes a brand new compiler code-named “Roslyn”. The new compiler is used directly inside the IDE and replaces various older code parsers and code object models. This new release of Visual Studio is the one that required us the most significant redesign since Visual Studio 2005, the first version we targeted with our PostSharp tooling.
Thanks to this redesign, we can now rely on powerful and well-designed APIes to understand your code, and as a result we can provide a more useful integration with the source editor.
The first thing you will notice is that PostSharp now makes use of the light bulb instead of the smart tag to provide refactoring actions. The light bulb UI is neater and more consistent than the smart tag one, and it includes the ability to display a preview.
Unlike the ones that are built in Visual Studio, PostSharp light bulb actions may open a dialog box if user interaction is required. For instance, if you choose Apply threading model, you will be asked to choose from the list of available threading models:
Live code diagnostics
Real-time code diagnostics are useful when you are implementing an advanced pattern such as a threading model or undo/redo. We implemented live analysis of the most frequent issues. Just as with other C# errors, you will see the red squiggle and the error will appear in the Error List toolbox window.
Coding guidance, or Cody Clippy
We took live code diagnostics to the next level. When you are in the process of implementing a pattern, for instance Immutable, we will show you the next more relevant issue to solve related to the task you are now completing, and will display links to the most relevant documentation articles.
PostSharp Assistant is based on analysis of your own source code in real time, so it's much more relevant than previous guidance systems.
PostSharp Assistant is a non-modal tool window that you can dock where you want. Of course you can always disable the feature once you learned how to implement a pattern.
Conservative NuGet Versioning
In the past, it was too easy to mess your versions of PostSharp in multi-project solutions. The scenario was the following:
- On Monday, you install PostSharp in ProjectA, get the latest version at this time, say 4.0.20.
- On Wednesday, we release 4.0.21.
- On Thursday, you install PostSharp in ProjectB, get the latest version at this time, that is 4.0.21.
- You have both 4.0.20 and 4.0.21 in your solution and you need to solve the mess manually.
There were even worse scenarios:
- On Monday, you install PostSharp in ProjectA and ProjectB, get the latest version at this time, say 4.0.20.
- On Wednesday, we release 4.0.21.
- On Thursday, you install PostSharp.Patterns.Model in ProjectA, get the latest version at this time, that is 4.0.21. Your PostSharp package gets upgraded to 4.0.21 in ProjectA, but not in ProjectB.
- You still have both 4.0.20 and 4.0.21.
Unfortunately, this was the default behavior of NuGet. We finally fixed this situation:
- If you install a new PostSharp Pattern Library in a project that already contains PostSharp, we will install the same version of the new package as the existing version of the PostSharp package.
- If you don’t have PostSharp installed in the current project, we will look at other projects in the solution and match the highest version already installed.
- In case we really need to upgrade the package (for instance if you want to use a 4.1 aspect in a 4.0 project), we will first warn you. Note that in this case, we don’t upgrade other projects in the solution so you will have to fix that manually.
PostSharp Explorer, the Visual Studio toolbox window that shows you which aspects are in your code, is now more useful. You can orient the panel vertically and horizontally, and it has three panels instead of two for better readability.
Universal Apps (shared projects)
We now properly support Universal Apps, the marketing name for “shared projects”. When you add an aspect to a class that is shared among several projects, PostSharp will try to install itself in all projects that use the shared project. That means that you will be only offered the aspects that are eligible for all importing projects. If you need more fine-grained control, you can skip the UI and use directly NuGet and #if blocks.
Note that Universal Apps support is not available in the currently public preview.
Visual Studio 2015 opens a new era in terms of IDE extensibility, exposing to third-party extensions all the knowledge the compiler has about your code. At PostSharp, we’re proud to be among the first commercial vendors to fully integrate with the new features and even provide unseen developing experience like with PostSharp Assistant.
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.