Spring.Net, Feb 2008, PostSharp:  A Technical Introduction
Upcoming SlideShare
Loading in...5

Like this? Share it with your network

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads


Total Views
On Slideshare
From Embeds
Number of Embeds



Embeds 1

http://www.slideshare.net 1

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

    No notes for slide


  • 1. PostSharp & Spring.NET 2. PostSharp Architecture
  • 2. you are now supposed to be woken up!
  • 3. however, you should already know that!
  • 4. The Big Picture Plug-Ins PostSharp Core PostSharp Laos Hosts MSBuild Host Command-Line Host Runtime Host
  • 5. A finer picture PostSharp Core Code Object Model represents a .NET module Module Reader reads a .NET binary assembly into the Code Object Model Module Writer writes the Code Object Model into a binary assembly (using ILASM) Code Weaver provides the infrastructure for MSIL injection Platform Infrastructure executes projects, loads plug-ins, loads and schedules tasks Plug-in performs specific analysis or transformation Host bootstraps PostSharp and invoke project executions Independent Program uses PostSharp without the Platform Infrastructure PostSharp Laos PostSharp4EntLib PostSharp.Samples.Trace custom plug-ins command-line utility MSBuild task PostSharp.Samples.Host custom application servers PostSharp.Samples.Explorer
  • 6. Core vs. Laos PostSharp Core PostSharp Laos Objective Absolutely free editing of .NET assemblies Aspect-Oriented Programming Easily Primitives Low-Level (MSIL) High-Level Audience ISV, MSIL/PostSharp specialist Everyone Learning Curve Steep High Complexity / Error Proneness High Low Runtime performance Fast Slower Licensing of extensions GPL/Commercial Any
  • 7. Compared Example: Logging
    • Boring but instructive
    Hello, World
  • 8. have you done your homework?
  • 9. The Laos Solution
    • Derive a custom attribute.
    • Implement “event handlers”.
    • Apply/multicast the custom attribute.
    • Compile-time instantiation.
    • Deserialization.
    • Reflector.
  • 10. The Core Solution
    • Define the Public Interface.
      • Custom Attribute in the example, but anything else is allowed (XML, DSL).
    • Implement the weaver.
      • Advice.
      • Advice Provider (pointcut evaluation).
    • Plug-In Manifest.
    • Discovery.
    • Reflector.
  • 11. Compound Aspects
    • Implement INotifyPropertyChanged .
  • 12. Translating the implementation pattern to AOP Aspected Class Property 1 Property 2 Property 3 NotifyPropertyChangedImpl internal OnPropertyChanged event PropertyChanged Property Setter Aspect OnSuccess handler Composition Aspect
  • 13. Putting it together: Compound Aspect
    • True meta-programming at compile-time.
    • No limitation to custom attributes.
    • The base of PostSharp bridges to Microsoft Enterprise Library or Microsoft Entity Framework.
  • 14. Summary
    • With PostSharp Core, you are completely free but you have to pay the price.
    • PostSharp Laos allows to do pretty much things, but:
      • It is slower: it generates suboptimal instructions .
      • No division of compile-time and run-time logic.
      • Attention to abuses!
  • 15.