Archive

With all the good reasons mentioned by Ayende, we decided to officially switch PostSharp 2.1 to a continuous deployment process. We are abandoning the distinction between “milestone releases” and “hotfixes”. Since today, you will know always download the latest revision from the principal download page, as well as on NuGet.

Ayende’s article came at a time when we were frustrated with our release cycle. Although we released dozens of hotfixes, the front-page download was still the initial 2.1 RTM release because we constantly deferred the SP1. Clearly, the majority of people were not downloading the best-quality release, and were therefore hitting bugs that have already been solved for a long time. Not the best user experience!

Technically, the difference is quite small. PostSharp’s build and test processes have always been automated. It takes about 50 minutes to build and test all components. Uploading to our download manager is very easy too – copy the build output to a network share and execute a script that synchronizes with Amazon S3. Therefore, the time-to-market of a bug fix has always been very short – a couple of hours, typically. The fact that deployment is now integrated with the build script does not really change this fact.

Thus, the most significant difference is that we will actually publish hotfixes as front-page downloads.

Unlike “hotfixes”, “milestone releases” got additional manual testing on virtual machines, where the later got only automated testing. Installation tests are still not automated, so there’s a slight chance to get a regression in a front-page release. We bet that these defects will be infrequent and quickly detected by the community.

Bottom line: we bet that the overall quality will be higher by switching to continuous development.

Happy PostSharping, now with a fresh version!

-gael

We have just released an update for the PostSharp Diagnostics Toolkit – Log4Net and System.Diagnostics.Trace now join NLog and System.Console as the supported logging frameworks.

What does this mean for you? It means that you can now add logging to your application without any code changes – just by downloading a NuGet package:

  • For System.Diagnostics.Trace support:

  • For Log4Net support

  • For NLog support

We have changed the NuGet package name a bit to make it more readable, and made the version number match that of the PostSharp build the package depends upon.

As I mentioned in the previous blog post, the NuGet package creates a .psproj file in the project’s directory named after the project. This is an XML file, which contains the configuration that is processed by PostSharp during compilation. I will go into much greater detail about the XML configuration in the next blog post.

As always, the source code for the PostSharp Toolkits is available on Github. Your feedback is very appreciated – please tell us your suggestions and issues on our Support Forums for PostSharp Toolkits.

Happy PostSharping!

-Igal

Last week we were honored to have our friends at IdeaBlade join us for a very special webinar, dealing with real world AOP usage. Ward Bell, V.P. of Technology at IdeaBlade, did an excellent job of demonstrating how Aspect-Oriented Programming and PostSharp helps creating clutter-free data access, using their flagship product, DevForce.

DevForce uses PostSharp to infuse “Code First” entity model classes - entities like Customer and Order – with rich behaviors that go way beyond property change notification. You write entities with simple getters and setters; after PostSharp, they support property validation, entity navigation, lazy loading, dirty tracking, and UI data binding.

Here is the recorded webinar and the slides for your viewing pleasure! You can download the source code for the demo application and the slides from the IdeaBlade Documentation site.

Q&A

During the webinar you have asked us great questions, and, as promised, here are the answers to all of them:

Q: Does DevForce integrate with PostSharp?

A: Yes, DevForce Code First is built with PostSharp, so you don’t need a PostSharp to use it!

Q: Does any entity with a FirstName property get that clown verifier, or just Employee?

A: Just the Employee. As you can see, the type of the entity is passed into the custom verifier:

Q: Is it possible to step through the injected behaviors?

A: Yes, if you have the requisite symbol files (pdb files) loaded. It is rare to want to step through either the PostSharp or DevForce code itself, though. You’re usually debugging your own code, such as the “NoClownsVerifier”.

Q: Can you show some of the code in IdeaBlade.Aop?

A: Here is the definition for the two aspects provided by DevForce:

As you can see, it uses PostSharp’s abilities to introduce, or inject, behaviors at compile-time to the target classes, so it implements things like INotifyPropertyChanged for you in your entities automatically!

Please note that the specific behaviors we have injected may or may not be enabled when the entity is detached. For example, entity navigation properties require the EntityManager to locate the related entities in cache or query them from the database if necessary. Validation triggered by property setting requires an attached validation engine (our VerifierEngine) which is made available to the entity instance via its attached EntityManager. Accordingly, DevForce only enables these behaviors when the entity is attached. The capability has been injected, the code has been woven into the class, but the feature is turned off for detached entities.

Q: If you add your own properties to POCO class do you need to somehow tell PostSharp not to interfere with it?

A: The [Unmapped] attribute tells DevForce (and Entity Framework) that this property is NOT mapped to a column in the database and is not persisted. DevForce won’t activate the injected behaviors for such properties either (although we are considering an attribute that would tell DevForce to enable some of the behaviors for non-persistent properties in a future release).

Q: Can you provide you own base class for navigation property collections?

A: You can take over the behavior of any property, including navigation properties, via DevForce “property interceptors”, another feature that PostSharp weaves into your entity properties. Interceptors can be specified in the entity, in the base class, or in a separate property interceptor provider that DevForce will discover (we never require a base class in Code First).

Q: How do you mark a property to not have a specific aspect apply to it?

A: If this is a PostSharp question, the answer is “it’s up to how you implement your aspects.”

The DevForce aspects are applied at the class level but you can opt out at the property level with the [Unmapped] attribute. We only have two aspects (one for entities, one for complex objects) so I think what you’re asking is about opting out of one or more of the interfaces. DevForce lets you inject your own custom behavior into our interface implementations so you can do coarse grain or fine grained alterations of our implementations.

Q: How were the Employee.cs, Customer.cs and other table classes created?

A: I could have written them entirely by hand.  I found that boring so I used what we call our “Code Second” technique. I pointed the EF Designer at the database and asked it to generate code with our “Code First” T4 code generator. Then I threw away the EDMX and went to town, cleaning out anything I didn’t like in the generated entity classes. What you see is what I decided to keep.

Q: How do you convert an existing “Database First” to the code-first model?

A: You might try the Code Second technique that I described above.

Q: How is the raising change notification done on the FullName property in the Employee class?

A: I used DevForce property interception feature which is also woven into the properties via AOP. I added the following code at the bottom of the Employee class:

DevForce recognizes this as an Employee property interceptor for FirstName and LastName. The implementation raises PropertyChanged when either of those properties has finished setting its value.

We are considering the possibility of automating discovery of FullName’s dependence upon FirstName and LastName but that capability is not in this release.

Final words

We hope that you enjoyed this very special webinar! If you have any more questions about how to use PostSharp, please visit our Support Forums to have them answered. For more information about DevForce and IdeaBlade, please visit their website.

We thank Ward Bell and IdeaBlade for the wonderful presentation and the Q&A! See you all next time!

Until then,

Happy PostSharping!

-Igal