1. Home
  2. Computing & Technology
  3. C / C++ / C#
photo of David Bolton
David's C / C++ / C# Blog

By David Bolton, About.com Guide to C / C++ / C#

Reduce Your .NET Line Count- PostSharp

Friday September 12, 2008
Czech Republic developer Gael Fraiteur has spent four years of years building PostSharp and it just reached version 1.0 yesterday. PostSharp transforms assemblies after compilation; it's an AOP - Aspect Oriented Programming framework. You can enhance your application through custom methods introduced as attributes. AOP is a methodology that lets you write code that works across many classes. For example logging is a classic aspect; you might want to log the inputs and outputs of many methods regardless of which class they are in. I'm sure you can think of lots of other uses.

PostSharp uses custom attributes. You define attributes in code, for example

[Log("MyFuncton")]
bool ALogMethod() {
  // body
}

When you implement this as a class, add references to it using PostSharp and implement new functionality that is called at runtime. This is medium to advanced stuff, not for the beginner but certainly worth the time investment. PostSharp is GPL licensed and you'll also find it linked on the page below. Summarizing it here is a bit short so I'll come back to using PostSharp in a longer article.

Comments

No comments yet. Leave a Comment

Leave a Comment

Line and paragraph breaks are automatic. Some HTML allowed: <a href="" title="">, <b>, <i>, <strike>

Explore C / C++ / C#
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. C / C++ / C#

©2009 About.com, a part of The New York Times Company.

All rights reserved.