Archive

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.

Light bulb

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:

  1. On Monday, you install PostSharp in ProjectA, get the latest version at this time, say 4.0.20.
  2. On Wednesday, we release 4.0.21.
  3. On Thursday, you install PostSharp in ProjectB, get the latest version at this time, that is 4.0.21.
  4. 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:

  1. On Monday, you install PostSharp in ProjectA and ProjectB, get the latest version at this time, say 4.0.20.
  2. On Wednesday, we release 4.0.21.
  3. 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.
  4. 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

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.

Summary

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.

Happy PostSharping!

-gael

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

Xamarin

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.

Summary

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.

Happy PostSharping!

-gael

Just one month after we published PostSharp 4.0 RTM and one week after Visual Studio 2015 Preview went out, we’re excited to release PostSharp 4.1 Preview 1 today, introducing support for Xamarin and Visual Studio 2015. PostSharp 4.1 is all about adding support for new platforms. We want to make PostSharp the number-one extension for pattern-driven programming – not only for desktop and server applications, but also for mobile devices.

PostSharp 4.1 Preview 1 is available for download from our web site and from NuGet as a pre-release package. Note that this is still an early preview, and needless to say PostSharp Tools for Visual Studio 2015 are particularly experimental.

Support for Xamarin

A few years ago, PostSharp had an ambiguous relationship with Mono. Technically, it was possible to run PostSharp on Mono, and there were even a few classes written specifically for this use case. However, we didn’t have any significant testing with Mono. So  even if we said we “supported” it, the idea was really just: use PostSharp with Mono at your own risks.

Starting with PostSharp 3, we decided to take the term support more seriously. If we said PostSharp would support a platform, it means that we had automated tests for it, that we would have a development and testing lab, and that we would answer support requests. To support a platform is much more than merely hoping for eventual compatibility. So, we decided to remove Mono support in PostSharp 3. This was not a bad decision; we could not afford another anyway.

But since last week, things are different. Microsoft announced an enhanced partnership with Xamarin to make .NET the most productive development platform for all devices, from wearable to cloud . Through its potential to reduce the size and complexity of .NET code by 20%, PostSharp is a natural fit in this effort to increase developer productivity. Today, we’re announcing that PostSharp 4.1 embraces the cross-platform vision.

Limitations in PostSharp 4.1 Preview 1

This early release is an important milestone but there’s still much work to do:

  • We only added support for Xamarin into the PostSharp package, but not to the pattern libraries. That is, you can create your own aspects for Xamarin, but you cannot use the pre-built ones yet. Pattern libraries will be ported in a later release.
  • We only support a few Xamarin profiles. More will be supported later.
  • You can build only from Visual Studio. The Mac compilation server is supported but your main build machine must be Windows. Mac as a main developer workstation will not be supported in PostSharp 4.1.

Support for Visual Studio 2015

From our point of view, Visual Studio 2015 is the most significant release since Visual Studio 2005, when PostSharp started to integrate with the IDE. We had to rewrite significant portions of our software to take advantage of the new version. The new code is not only simpler, it is also faster and allows for more features and better integration.

When using PostSharp 4.1 with Visual Studio 2015, you will see the following differences:

  • Integrate with the light bulb instead of the smart tag. It’s a small difference but it will provide a more consistent experience. Smart tags didn’t scale well with multiple vendors (Microsoft, PostSharp and CodeRush for instance), but the light bulb has been designed for this.
  • Real-time detection of some errors. For instance, when making a class recordable or thread-safe, you know in real time that a field must be annotated with [Child] or [Reference].
  • Advanced code fixes. When making a class recordable or thread-safe, collection child fields have to be changed from List to AdvisableCollection. There’s now a code fix to do this change automatically, and it even updates field assignments where possible.

What’s Next in PostSharp 4.1?

In the next weeks, we’ll be working on the following improvements:

  • PostSharp Threading Pattern Library: support for Windows Phone, Windows Store and Xamarin.
  • PostSharp Model Pattern Library: support for Xamarin (Windows Phone and Windows Store are already implemented in 4.0).
  • Xamarin: support for all profiles.
  • Visual Studio 2015: tuning of the user experience.

You should now see a new release every 3rd week.

Happy PostSharping!

-gael