Aspect.NET — aspect-oriented toolkit for Microsoft.NET based on Phoenix and Whidbey Dmitry Grigoriev, PhD student Vladimir O. Safonov, Senior Member, IEEE,

Slides:



Advertisements
Similar presentations
Tridion 5.3 Templates.
Advertisements

Aspect.NET – an aspect-oriented programming tool for Microsoft.NET Vladimir O. Safonov Professor of computer science, Head of laboratory St. Petersburg.
AspectWerkz 2 - and the road to AspectJ 5 Jonas Bonér Senior Software Engineer BEA Systems.
Using.NET Platform Note: Most of the material of these slides have been taken & extended from Nakov’s excellent overview for.NET framework, MSDN and wikipedia.
Aspect Oriented Programming. AOP Contents 1 Overview 2 Terminology 3 The Problem 4 The Solution 4 Join point models 5 Implementation 6 Terminology Review.
An Aspect-Oriented Approach For Web Application Access Control Presented by: Mohamed Hassan Carleton University Carleton University
ASTA Aspect Software Testing Assistant Juha Gustafsson, Juha Taina, Jukka Viljamaa University of Helsinki.
1 JAC : Aspect Oriented Programming in Java An article review by Yuval Nir and Limor Lahiani.
Overview of AspectJ Aspect Oriented Software Development Seminar Technion presented by Oren Mishali.
Component Patterns – Architecture and Applications with EJB copyright © 2001, MATHEMA AG Component Patterns Architecture and Applications with EJB JavaForum.
Aspect-Oriented Programming: An Overview Brandon Wirick Feb
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. slide 1 CS 125 Introduction to Computers and Object- Oriented Programming.
Advanced Object-Oriented Programming Features
1 FM Overview of Adaptation. 2 FM RAPIDware: Component-Based Design of Adaptive and Dependable Middleware Project Investigators: Philip McKinley, Kurt.
Creating and Running Your First C# Program Svetlin Nakov Telerik Corporation
ACM/JETT Workshop - August 4-5, 2005 UML Modeling using MagicDraw UML for Java Programmers.
1 Model Interface Implementation for Two-Way Obliviousness in Aspect-Oriented Modeling Presented by Wuliang Sun Department of Computer Science Baylor University.
©Ian Sommerville 2004Software Engineering, 7th edition. Chapter 18 Slide 1 Software Reuse.
Lecture Roger Sutton CO530 Automation Tools 5: Class Libraries and Assemblies 1.
DEV334 Creating Application Starting Points & Sharing Best Practices with Enterprise Templates Marc Gusmano Director of Emerging Technologies The Information.
.NET Framework Introduction: Metadata
Introduction to AOP.
CIS NET Applications1 Chapter 2 –.NET Component- Oriented Programming Essentials.
Creating and Running Your First C# Program Svetlin Nakov Telerik Corporation
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 12 Object-Oriented.
Lecture 8 Inheritance Richard Gesick. 2 OBJECTIVES How inheritance promotes software reusability. The concepts of base classes and derived classes. To.
Module 7: Object-Oriented Programming in Visual Basic .NET
Introduction to Aspect Oriented Programming Presented By: Kotaiah Choudary. Ravipati M.Tech IInd Year. School of Info. Tech.
Chapter 1: A First Program Using C#. Programming Computer program – A set of instructions that tells a computer what to do – Also called software Software.
Aspect Oriented Programming Razieh Asadi University of Science & Technology Mazandran Babol Aspect Component Based Software Engineering (ACBSE)
Aspect Oriented Programming Adnan Masood
1 Metamodel Access Protocols for Extensible Aspect-Oriented Modeling Naoyasu Ubayashi(Kyushu Institute of Technology, Japan) Shinji Sano(Kyushu Institute.
©Ian Sommerville 2006Software Engineering, 8th edition. Chapter 32 Slide 1 Aspect-oriented Software Development 1.
Modularizing Web Services Management with AOP María Agustina Cibrán, Bart Verheecke { Maria.Cibran, System and Software Engineering.
Aspect Oriented Programming Sumathie Sundaresan CS590 :: Summer 2007 June 30, 2007.
Knowledge.NET Ontology-based Knowledge Management Toolkit for Microsoft.NET Project Participants Anton Novikov Maxim Sigalin Alexey Smolyakov Dmitry Cherepanov.
AOSD1 Aspect-Oriented Software Design Karl Lieberherr Theo Skotiniotis.
AOP-1 Aspect Oriented Programming. AOP-2 Aspects of AOP and Related Tools Limitation of OO Separation of Concerns Aspect Oriented programming AspectJ.
CCC: An Aspect-Oriented Intermediate Language on.Net Platform Yingfei Xiong and Feng Wan University of Electronic Science and Technology of China, China.
Module 1: Getting Started. Introduction to.NET and the.NET Framework Exploring Visual Studio.NET Creating a Windows Application Project Overview Use Visual.
Introducing Allors Applications, Tools & Platform.
Inter-Type Declarations in AspectJ Awais Rashid Steffen Zschaler © Awais Rashid, Steffen Zschaler 2009.
AspectJ – AOP for Java Tom Janofsky. Instructor at Penn State Abington Consultant with Chariot Solutions JUG Member.
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University IWPSE 2003 Program.
Demeter Aspects We study techniques for the emerging area of Aspect-Oriented Software Development and focus on the following areas:  Aspectual Collaborations.
Aspect Oriented Programming Adlux Consultancy Services Pvt Ltd
Kansas City Java User’s Group Jason W. Bedell July 12, 2006
问题 Code scattering Blocks of duplicated code Blocks of complementary code, and different modules implementing complementary parts of the concern Code.
Introduction to Yan Cui Aspect Oriented Programming by
Bruno Cabral “Reflection, Code Generation and Instrumentation in the.NET platform” University of Coimbra.
R R R A Brief Introduction to Aspect-Oriented Programming.
CSC450 Software Engineering Devon M. Simmonds University of North Carolina, Wilmington 1.
AOP with AspectJ Awais Rashid, Steffen Zschaler © Awais Rashid, Steffen Zschaler 2009.
1 An AOP Implementation Framework for Extending Join Point Models Naoyasu Ubayashi(Kyushu Institute of Technology, Japan) Hidehiko Masuhara(University.
 Description of Inheritance  Base Class Object  Subclass, Subtype, and Substitutability  Forms of Inheritance  Modifiers and Inheritance  The Benefits.
.Net Reflection Taipan Tamsare. Overview Reflection core concepts Exploring metadata Detail information Attributes Building Types at runtime.
METADATA IN.NET Presented By Sukumar Manduva. INTRODUCTION  What is Metadata ? Metadata is a binary information which contains the complete description.
Enterprise Library 3.0 Memi Lavi Solution Architect Microsoft Consulting Services Guy Burstein Senior Consultant Advantech – Microsoft Division.
Phoenix Based Dynamic Slicing Debugging Tool Eric Cheng Lin Xu Matt Gruskin Ravi Ramaseshan Microsoft Phoenix Intern Team (Summer '06)
Source Code Inspection and Software Reuse
Security analysis of COM with Alloy
Software Engineering Lecture 7
Chapter 11 Object-Oriented Design
Aspect-Oriented Programming with the Eclipse AspectJ plug-in
Module 0: Introduction Chapter 2: Getting Started
Module 1: Getting Started
Creating and Using Classes
Lecture 22 Inheritance Richard Gesick.
AspectAda Aspect-Oriented Programming for Ada95
Presentation transcript:

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

Aspect.NET, Pilsen, May 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.

Aspect.NET, Pilsen, May 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?

Aspect.NET, Pilsen, May Introduction to AOP (part 3) AOP suggests: “Let’s 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)  Don’t 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

Aspect.NET, Pilsen, May 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.

Aspect.NET, Pilsen, May Aspect.NET Overview Let’s turn cross-cutting concerns into separate standalone units (classes), referred to as aspects. Aspect contain: Data (fields) Modules (aspect’s 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.

Aspect.NET, Pilsen, May 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.

Aspect.NET, Pilsen, May Aspect Library (DLL) %aspect Test//ML language public class Test { %modules private static void TestRun() { WriteLine(”test”); } %rules Aspect.ML Converter C# Compiler public class Test: Aspect//Attribute annotation { [AspectAction(“%before %call Write*")] public static void TestRunAction() { Test.TestRun(); }

Aspect.NET, Pilsen, May 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 SayScanningHelloAction() { Politeness.SayScanningHello(); } }// Politeness

Aspect.NET, Pilsen, May 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

Aspect.NET, Pilsen, May 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…

Aspect.NET, Pilsen, May 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,..)

Aspect.NET, Pilsen, May Current Aspect.NET ML expressive power (3/3) Arguments capturing AspectAction(“%after %call *Method(int) && args(arg[1])”) 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)

Aspect.NET, Pilsen, May Introducing Aspect.NET Framework Design Compiler Application Source Code Aspect Library Aspect Source Code Aspect.NET.ML Converter Application Weaver User Target Application Aspect.NET Framework

Aspect.NET, Pilsen, May 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.withdraw(); UsageLicensingAspect – checks permissions of current machine to perform these operations.

Aspect.NET, Pilsen, May

Aspect.NET, Pilsen, May Class Diagram

Aspect.NET, Pilsen, May Filtering discovered joinpoints

Aspect.NET, Pilsen, May Decompiled Results BankAccount account1 = new BankAccount(); Aspect.InternalSetArgsTypes("float"); Aspect.InternalSetMemberName("BankManagement.BankAccount.deposit"); Aspect.InternalSetTargetObject(account1); UsageLicensingAspect.DepositWrapper(20f);\\instead of \\account1.deposit(20) Aspect.InternalSetArgsTypes("float"); Aspect.InternalSetMemberName("BankManagement.BankAccount.withdraw“) Aspect.InternalSetTargetObject(account1); UsageLicensingAspect.WithdrawWrapper(20f); \\instead of \\account1. withdraw(20) Console.WriteLine("Final balance is {0}", account1.Balance);

Aspect.NET, Pilsen, May 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).

Aspect.NET, Pilsen, May 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)

Aspect.NET, Pilsen, May Q&A Where to find?