Aspect'NET aspectoriented toolkit for Microsoft'NET based on Phoenix and Whidbey - PowerPoint PPT Presentation

Loading...

PPT – Aspect'NET aspectoriented toolkit for Microsoft'NET based on Phoenix and Whidbey PowerPoint presentation | free to download - id: 1e0126-ZTI5N



Loading


The Adobe Flash plugin is needed to view this content

Get the plugin now

View by Category
About This Presentation
Title:

Aspect'NET aspectoriented toolkit for Microsoft'NET based on Phoenix and Whidbey

Description:

Current Aspect.NET ML expressive power (1/3) ... UsageLicensingAspect checks permissions of current machine to perform these operations. ... – PowerPoint PPT presentation

Number of Views:65
Avg rating:3.0/5.0
Slides: 23
Provided by: Dimit9
Learn more at: http://wscg.zcu.cz
Category:

less

Write a Comment
User Comments (0)
Transcript and Presenter's Notes

Title: Aspect'NET aspectoriented toolkit for Microsoft'NET based on Phoenix and Whidbey


1
Aspect.NET aspect-oriented toolkit for
Microsoft.NET based on Phoenix and Whidbey
Dmitry Grigoriev, PhD student Vladimir O.
Safonov, Senior Member, IEEE, professor Mikhail
Gratchev, PhD student Alexander Maslennikov, PhD
student Saint-Petersburg State University
2
Introduction to AOP (part 1)
  • Aspect-oriented programming (AOP) is an attempt
    to solve the problems of development complex
    software.
  • Each of software modules (classes, methods,
    procedures, etc.) solves some definite logically
    independent task (event logging,
    authentification, security, assertions,..). To
    use new modules in our product, we need to inject
    their calls into the sources.

3
Introduction to AOP (part 2)
  • As a result we have a lot of tangled code in our
    sources.
  • What shall we do when we decide to remove or
    modify such a cross-cutting concern or add
    another one?

4
Introduction to AOP (part 3)
  • AOP suggests Lets remove them from sources and
    weave directly to binaries instead, according to
    our rules described in special language
  • Approaches
  • Extend an existing language (AspectJ, Aspect)
  • ? Need special compiler for every language
    version.
  • Dynamic execution (hooks at definite points of
    execution) (Loom.NET, RAIL)
  • ? Dont know what kind of code is currently
    executing.
  • ? Low performance
  • Static weaving into assemblies (Aspect.NET)
  • ? High performance
  • ? Resulting code could be examined explicitly
    (Reflector)
  • ? A lot of existing .NET tools can work with
    resulting assemblies

5
Aspect.NET goals
  • Aspect.NET is an aspect-oriented tool that allows
    you to define some functionality by specific
    aspect units and weave them into your assemblies.
  • So, the cross-cutting concerns appear to be
    structured into aspects which makes the code
    clearer.
  • Aspect.NET is implemented as Visual Studio.NET
    2005 (Whidbey) add-in, to use AOP technology in
    a comfortable manner, alongside with using
    ubiquitous VS.NET software development features.

6
Aspect.NET Overview
  • Lets turn cross-cutting concerns into separate
    standalone units (classes), referred to as
    aspects.
  • Aspect contain
  • Data (fields)
  • Modules (aspects methods )
  • Actions (public methods to be called at specially
    defined join points of target code)
  • Weaving rules (Determine the set of join points)
  • Generally, aspect is a class whose methods are
    annotated by specific AOP weaving attributes.

7
Aspect.NET ML
  • Aspect definition is specified in a simple
    meta-language Aspect.NET.ML.
  • Meta-language allows you to describe a set of
    desired join-points and reuse such declarations
    for other aspects (ruleset).
  • Then special converter turns it into .NET class
    source code, with meta-language annotations
    represented as custom attributes.
  • This aspect class is compiled into an assembly by
    a common use .NET Framework compiler.

8
(No Transcript)
9
Aspect.NET ML Example
  • aspect Politeness
  • public class Politeness
  • modules
  • private static void SayScanningHello()
  • Console.WriteLine("Welcome to Aspect.NET
    scanning system!")
  • rules
  • before call SomeMethod
  • action public static void SayScanningHelloActi
    on()
  • Politeness.SayScanningHello()
  • // Politeness

10
Custom attributes (example)
  • public class Politeness Aspect
  • private static void SayScanningHello()
  • Console.WriteLine("Welcome to Aspect.NET
    scanning system!")
  • AspectAction(before call SomeMethod)
  • public static void SayScanningHelloAction()
  • Politeness.SayScanningHello()
  • // Politeness

11
Current Aspect.NET ML expressive power (1/3)
  • Can inject actions before, after or instead call
    instructions
  • Actions have full access to the woven context
    through the properties of base Aspect class
  • Object This \\this keyword
  • Object TargetObject \\p.TargetMethod(..)
  • MemberInfo TargetMemberInfo \\TargetMethod as
    MethodInfo
  • Type WithinType \\this.GetType()
  • MethodBase WithinMethod \\this.CurrentMethod()
  • string SourceFilePath \\.cs filepath
  • string SourceFileLine. \\source line number
  • And more

12
Current Aspect.NET ML expressive power (2/3)
  • Weaving rules are specified by a mask and a
    regular expression.
  • before call Namespace.Class.MethodName
  • or
  • before call MethodName
  • Signature filtering.
  • instead call static public void Method(float,
    string, ..)

13
Current Aspect.NET ML expressive power (3/3)
  • Arguments capturing
  • AspectAction(after call Method(int)
    args(arg1))
  • static public void MethodAction(int i)
  • Console.WriteLine(0, i)
  • Additional restrictions on join points placement
  • within(SomeType)
  • withincode(SomeMethod)
  • instead call Method within(MyType)
    !withincode(.ctor)

14
Introducing Aspect.NET Framework Design
15
Examples of Weaving
  • Target application BankManagement system
  • static void Main(string args)
  • BankAccount acc1 new BankAccount()
  • acc1.deposit(20)//apply aspects here
  • acc1.withdraw(20)//apply aspects
    here
  • BankAccountContractAspect Design by Contract
    Invariant, Pre Post checks of
    BankManagement.Deposit() and BankManagement.withdr
    aw()
  • UsageLicensingAspect checks permissions of
    current machine to perform these operations.

16
(No Transcript)
17
Class Diagram
18
Filtering discovered joinpoints
19
Decompiled Results
  • BankAccount account1 new BankAccount()
  • Aspect.InternalSetArgsTypes("float")
  • Aspect.InternalSetMemberName("BankManagement.BankA
    ccount.deposit")
  • Aspect.InternalSetTargetObject(account1)
  • UsageLicensingAspect.DepositWrapper(20f)\\instead
    of \\account1.deposit(20)
  • Aspect.InternalSetArgsTypes("float")
  • Aspect.InternalSetMemberName("BankManagement.BankA
    ccount.withdraw)
  • Aspect.InternalSetTargetObject(account1)
  • UsageLicensingAspect.WithdrawWrapper(20f)
    \\instead of \\account1. withdraw(20)
  • Console.WriteLine("Final balance is 0",
    account1.Balance)

20
Microsoft Phoenix
  • Reflection is very poor for instrumenting MSIL
    assemblies (even in .NET 2.0).
  • Microsoft Phoenix is a framework for building
    compilers and a wide range of tools for program
    analysis, optimization, and testing.
  • Phoenix provides high level instructions for MSIL
    code.
  • Phoenix tools can be implemented as compiler
    phases.
  • Phoenix lets work with debug information instead
    of addressing unmanaged COM interfaces DIA.
  • So we use it.
  • We are collaborating with Phoenix developers at
    Microsoft Research (the project supported by
    MSR).

21
AOP problems and our approach
  • Comprehension
  • Must be able to predict behavior (Aspect.NET
    View join points in source)
  • Must be easy to understand (Aspect.NET Easy
    meta-language)
  • Integration into existing tools and software
    processes (Aspect.NET Nice add-in to Visual
    Studio)
  • Debuggability
  • Source-level debugging is critical (Aspect.NET
    we are planning this feature)
  • Testing
  • AOP introduces new fault models (Aspect.NET Unit
    testing within VS)
  • Evolution ?
  • Performance (Aspect.NET Static weaving gives
    minimal overhead)

22
  • QA
  • Where to find?
  • http//www.msdnaa.net/curriculum/?id6334
About PowerShow.com