presentation aspect.net - vladimir safonov
TRANSCRIPT
8/3/2019 Presentation Aspect.net - Vladimir Safonov
http://slidepdf.com/reader/full/presentation-aspectnet-vladimir-safonov 1/34
Aspect.NET – an aspect-orientedprogramming tool for
Microsoft.NET
Vladimir O. Safonov
Professor of computer science,Head of laboratory
St. Petersburg University
8/3/2019 Presentation Aspect.net - Vladimir Safonov
http://slidepdf.com/reader/full/presentation-aspectnet-vladimir-safonov 2/34
Vladimir Safonov, SSCLI CapstoneWorkshop, Redmond 2005 2
Aspect.NET project(granted by MSR in 2002 and 2004)
Goals:
Develop a state-of-the-art aspect-oriented programming
(AOP) tool for Microsoft.NET, on top of Microsoft
Phoenix, integrated with the latest Visual Studio (Whidbey)
and working also in SSCLI/Rotor environment
Make AOP ubiquitous for Microsoft.NET software
developers
Develop most adequate ways of representing aspects for
Microsoft.NET
Lay the foundation for future research and development
work on spreading AOP among Microsoft.NET users
8/3/2019 Presentation Aspect.net - Vladimir Safonov
http://slidepdf.com/reader/full/presentation-aspectnet-vladimir-safonov 3/34
Vladimir Safonov, SSCLI Capstone
Workshop, Redmond 2005
3
AOP origin and status
• Aspect-oriented programming (AOP) – a prospectivesoftware engineering paradigm based on a concept of cross-cutting concern whose implementation contains not only arelated set of modules (“generalized procedure”), but also a
set of tangled code fragments to be woven (inserted) into atarget application
• Predecessor: Professor A. L. Fouxman (Rostov University,Russia), “Technological Aspects of Software SystemsDevelopment”, 1979
• Modern classicist of AOP: Professor Gregor Kiczales,University of British Columbia, Canada (AspectJ tool ~ AOPextension for Java)
8/3/2019 Presentation Aspect.net - Vladimir Safonov
http://slidepdf.com/reader/full/presentation-aspectnet-vladimir-safonov 4/34
Vladimir Safonov, SSCLI Capstone
Workshop, Redmond 2005
4
AOP basics
• Cross-cutting concern ~ a concern whose implementation cannot bemade by a generalized procedure
• Examples ~ logging; security; MT-safety; implementation of a new
source language construct in a compiler
• Aspect ~ implementation of a cross-cutting concern
• Weaving ~ applying an aspect to a target application (inserting newmodules and definitions; inserting, replacing or deleting tangled pieces
of code)
• Pointcut ~ a set of weaving rules for an aspect
• Join points ~ a set of concrete points in a target application subject to
aspect weaving
• Benefits of AOP: make software development and maintenance easier,
due to performing it in terms of aspects
8/3/2019 Presentation Aspect.net - Vladimir Safonov
http://slidepdf.com/reader/full/presentation-aspectnet-vladimir-safonov 5/34
Vladimir Safonov, SSCLI Capstone
Workshop, Redmond 2005
5
Our approach to AOP
• Make aspects multi-language (language agnostic), in accordance to .NETprogramming paradigm, as opposed to extending any concrete
programming language by AOP constructs (as in AspectJ)
• Use a simple AOP meta-language Aspect.NET.ML to provide user-level
AOP annotations to source code of compilation units
• Represent meta-information on aspects by custom attributes (AspectDef,AspectRef), to safely tie them to assemblies, to make them easily available
to AOP tools, and to avoid updating any general .NET tools for the
purpose of their “AOP-awareness”
• Use Phoenix to handle assemblies and to support weaving
• Develop Aspect.NET as a Whidbey add-in to closely integrate it to
Microsoft.NET development tools, technologies and environments
8/3/2019 Presentation Aspect.net - Vladimir Safonov
http://slidepdf.com/reader/full/presentation-aspectnet-vladimir-safonov 6/34
Vladimir Safonov, SSCLI Capstone
Workshop, Redmond 2005
6
Compare to other approaches to AOP
• Language extensions of a specific (usually – Java)language for AOP (AspectJ)
• Multi-dimensional separations of concerns (IBM HyperJ)
• Interceptors
• XML files with AspectJ-like specifications (Weave.NET)
• Dynamic aspects (similar to debugger breakpoints)
• Our approach is easy-to-use, language-agnostic, andintegrated with the latest Microsoft technologies and tools(Whidbey and Phoenix)
•As far as we can judge, right now there is no other AOPtool so closely integrated to Microsoft development toolsas our Aspect.NET
8/3/2019 Presentation Aspect.net - Vladimir Safonov
http://slidepdf.com/reader/full/presentation-aspectnet-vladimir-safonov 7/34
Vladimir Safonov, SSCLI Capstone
Workshop, Redmond 2005
7
Aspect.NET architecture
• Aspect.NET.ML converters (currently for C#) to
definitions of AspectDef AOP attribute
• Aspect weaver :
Target assembly + Aspect assemblies -> Target assembly*
• Aspect editor + aspect GUI : locating aspects, coloring
aspects, editing aspects, deleting aspects; integrated to
Whidbey as add-in
• Aspect.NET .msi-based installer (checks where the
Phoenix RDK is located on your machine)
• AspectRotor – a separate console version of Aspect.NET
for Rotor environment
8/3/2019 Presentation Aspect.net - Vladimir Safonov
http://slidepdf.com/reader/full/presentation-aspectnet-vladimir-safonov 8/34
Vladimir Safonov, SSCLI Capstone
Workshop, Redmond 2005
8
Example: the Politeness aspect%aspect Politeness
public class Politeness
{
%modules
public static SayHello ()
{
System.Console.WriteLine(“Hello”);
} public static SayBye ()
{
System.Console.WriteLine(“Bye”);
}
%rules
%before %call *
%action public static void SayHelloAction
{ Politeness.SayHello()}
%after %call *
%action public static void SayByeAction { Politeness.SayBye()}
8/3/2019 Presentation Aspect.net - Vladimir Safonov
http://slidepdf.com/reader/full/presentation-aspectnet-vladimir-safonov 9/34
Vladimir Safonov, SSCLI Capstone
Workshop, Redmond 2005
9
Example: Weaving Politeness
%to MyApplication %apply Politeness
(the same can be done by means of Aspect editor)
8/3/2019 Presentation Aspect.net - Vladimir Safonov
http://slidepdf.com/reader/full/presentation-aspectnet-vladimir-safonov 10/34
Vladimir Safonov, SSCLI Capstone
Workshop, Redmond 2005
10
Aspect.NET working screenshot
8/3/2019 Presentation Aspect.net - Vladimir Safonov
http://slidepdf.com/reader/full/presentation-aspectnet-vladimir-safonov 11/34
Vladimir Safonov, SSCLI Capstone
Workshop, Redmond 2005
11
Aspect coloring screenshot
8/3/2019 Presentation Aspect.net - Vladimir Safonov
http://slidepdf.com/reader/full/presentation-aspectnet-vladimir-safonov 12/34
Vladimir Safonov, SSCLI Capstone
Workshop, Redmond 2005
12
Aspect.NET status and perspectives• Aspect.NET implementation team (SPBU PhD and graduate
students: Dmitry Grigoryev, Mikhail Gratchev, Alexander Maslennikov, Oleg Romashin.)
• A working prototype of Aspect.NET on top of latest Phoenix(02/28/05) and Whidbey beta2 developed
• Aspect.NET installer/distribution developed
• Working console version of Aspect.NET for Rotor environment(AspectRotor) developed
• Aspect.NET uploaded to MSDNAA Curriculum Repository Website
• Perspectives: library of examples; further research on aspect-
oriented knowledge management and on aspectizing (aspectmining)
• Our desire is to get funding from Microsoft to continue ourproject, to make Aspect.NET a product to be shipped with thefuture versions of Visual Studio.NET
8/3/2019 Presentation Aspect.net - Vladimir Safonov
http://slidepdf.com/reader/full/presentation-aspectnet-vladimir-safonov 13/34
Vladimir Safonov, SSCLI Capstone
Workshop, Redmond 2005
13
Conferences and seminars where
Aspect.NET project presented
• First MSR Rotor Workshop, Cambridge, July 2002• Rotor Workshop, University of Pisa, Italy, April 2003
• Fault-tolerant Software and Hardware Systems Workshop,Hasso-Plattner Institute, Potsdam, February 2004
• Microsoft Academic Days, Moscow, April 2005
• IEEE Regional Conference, St. Petersburg, May 2005
• MSR Faculty Summit, Redmond, July 2005 (as part of thePhoenix panel)
• Now MSR Rotor Capstone Workshop, Redmond,September 2005
• Current plans (Sep 2005): submit a paper and talk onAspect.NET to the Fifth International AOSD Conference,Bonn, Germany, March 2006 (the “classical” AOPconference)
8/3/2019 Presentation Aspect.net - Vladimir Safonov
http://slidepdf.com/reader/full/presentation-aspectnet-vladimir-safonov 14/34
Vladimir Safonov, SSCLI Capstone
Workshop, Redmond 2005
14
Aspect.NET users, evaluators and those
who sent feedback (Sep 2005)
• Microsoft Phoenix team –
John Lefor, Shahrokh Mortazavi, Jim Hogg et al.
• Mercury Interactive (www.mercury.com),
contact person: Yaniv Bronstein• University in Brazil, contact person: Andrea Furtado
• Highly appreciated the project (email feedback):
Andreas Mauer, TRIA IT-consulting GmbH
(www.tria.de)
John Fahring [email protected]
8/3/2019 Presentation Aspect.net - Vladimir Safonov
http://slidepdf.com/reader/full/presentation-aspectnet-vladimir-safonov 15/34
Vladimir Safonov, SSCLI Capstone
Workshop, Redmond 2005
15
Aspect.NET team’s creative contacts
to other AOP R&D teams
• Gregor Kiczales, University of British Columbia
• Andreas Polze, Hasso-Plattner Institute, Potsdam, Germany
• Mark Eaddy, Professor A. Aho’s AOP intern in Phoenix
team• Donal Lafferty, Trinity College, Dublin, Ireland
(Weave.NET project)
• Tihamer Levendovsky, Budapest Technical University,
Hungary• Andrea Furtado, University in Brazil
8/3/2019 Presentation Aspect.net - Vladimir Safonov
http://slidepdf.com/reader/full/presentation-aspectnet-vladimir-safonov 16/34
Vladimir Safonov, SSCLI Capstone
Workshop, Redmond 2005
16
Aspect.NET references
1) http://aosd.net - The starting Web site on AOP
2) http://www.msdnaa.net/curriculum/?6219 – Aspect.NET&doc
3) Safonov V. O. Aspect.NET: a new approach to aspect-oriented
programming. - .NET Developer’s Journal, 2003, #4.
4) Safonov V.O. Aspect.NET: concepts and architecture. - .NET
Developer’s Journal, 2004, #10.
5) Safonov V.O., Grigoryev D.A. Aspect.NET: aspect-oriented
programming for Microsoft.NET in practice. - .NET
Developer’s Journal, 2005, # 7.
6) Safonov V.O., Grigoryev D.A. Aspect.NET – an aspect-
oriented programming tool for Microsoft.NET. – Proceedings
of St. Petersburg Regional IEEE conference, St. Petersburg,
May 2005.
8/3/2019 Presentation Aspect.net - Vladimir Safonov
http://slidepdf.com/reader/full/presentation-aspectnet-vladimir-safonov 17/34
Using Aspect.NET
Vladimir O. Safonov
ProfessorSt. Petersburg University
8/3/2019 Presentation Aspect.net - Vladimir Safonov
http://slidepdf.com/reader/full/presentation-aspectnet-vladimir-safonov 18/34
Vladimir Safonov, SSCLI Capstone
Workshop, Redmond 2005
18
Installing Aspect.NET
Pre-requisites:• 1) Microsoft Visual Studio 2005 beta 2 installed.
• 2) Microsoft Phoenix RDK 02/28/05 Release installed
Notes:
• Aspect.NET Framework has been tested under MicrosoftVisual Studio 2005 beta 2 and with assemblies written inC# only.
• To install Aspect.NET, run AspectNETFramework.msi
and follow tips of the wizard.• The installer copies core assemblies, deployment files aswell as Phoenix binaries into the folder specified by theuser.
8/3/2019 Presentation Aspect.net - Vladimir Safonov
http://slidepdf.com/reader/full/presentation-aspectnet-vladimir-safonov 19/34
Vladimir Safonov, SSCLI Capstone
Workshop, Redmond 2005
19
Starting Aspect.NET Framework
• The Aspect.NET Framework add-in window appears every
time Visual Studio is started.
8/3/2019 Presentation Aspect.net - Vladimir Safonov
http://slidepdf.com/reader/full/presentation-aspectnet-vladimir-safonov 20/34
Vladimir Safonov, SSCLI Capstone
Workshop, Redmond 2005
20
How to create an aspect in Aspect.NET ML?• Aspect is a special VS C# project template.
• So, please create a new project (say MAddNopCounter) specified with aspect template.
8/3/2019 Presentation Aspect.net - Vladimir Safonov
http://slidepdf.com/reader/full/presentation-aspectnet-vladimir-safonov 21/34
Vladimir Safonov, SSCLI Capstone
Workshop, Redmond 2005
21
How to create an aspect?• The wizard generates the simple aspect skeleton in aspect.an file, which is container for
aspect description written in Aspect.NET ML.
• Сode the body of the aspect in the .an file, based on the skeleton generated by thewizard.
8/3/2019 Presentation Aspect.net - Vladimir Safonov
http://slidepdf.com/reader/full/presentation-aspectnet-vladimir-safonov 22/34
Vladimir Safonov, SSCLI Capstone
Workshop, Redmond 2005
22
How to create an aspect?
• Click “Build Solution” button or execute“Rebuild All”. At this phase, the aspect.an.cs fileis created to contain correct C# source code withML annotations converted into the customattribute AspectDef. Then, the standard C#compiler compiles it to the aspect assembly andplaces it into the debug folder (sayMAddNopCounter.dll).
• One can weave this assembly as an aspect tohis/her projects.
8/3/2019 Presentation Aspect.net - Vladimir Safonov
http://slidepdf.com/reader/full/presentation-aspectnet-vladimir-safonov 23/34
Vladimir Safonov, SSCLI Capstone
Workshop, Redmond 2005
23
Weaving aspects
• Open or Create new C# project in Visual Studio.
• In Aspect.NET Framework click "Add ExistingAspect Module" button on "Modules" tab to addAspect assemblies. You can add multiple
assemblies.• Press "Find Joinpoints" button to find the join
points in the currently active project.
• If join points have been found, Aspect.NET
Framework switches to the "Aspects" tab. Hereyou can filter the joinpoints and browse them.
8/3/2019 Presentation Aspect.net - Vladimir Safonov
http://slidepdf.com/reader/full/presentation-aspectnet-vladimir-safonov 24/34
Vladimir Safonov, SSCLI Capstone
Workshop, Redmond 2005
24
Weaving aspects
• Use the checkboxes in the join points tree to enable or
disable a join point. You can enable or disable groups of
join points by checking or unchecking parent methods,
classes and namespaces.
• You can click the join point to see its location in a source
code.
• Pressing "Weave Aspects" button results in aspects
weaving into the debug assembly of the current project.
• When weaving is finished , Aspect.NET Framework
informs you where the target assembly is located.
8/3/2019 Presentation Aspect.net - Vladimir Safonov
http://slidepdf.com/reader/full/presentation-aspectnet-vladimir-safonov 25/34
Vladimir Safonov, SSCLI Capstone
Workshop, Redmond 2005
25
Weaving aspects
• Visualization Tab represents program modules, with aspect actionswoven, as colored chart.
8/3/2019 Presentation Aspect.net - Vladimir Safonov
http://slidepdf.com/reader/full/presentation-aspectnet-vladimir-safonov 26/34
8/3/2019 Presentation Aspect.net - Vladimir Safonov
http://slidepdf.com/reader/full/presentation-aspectnet-vladimir-safonov 27/34
Vladimir Safonov, SSCLI Capstone
Workshop, Redmond 2005
27
Step by Step playing with
Aspect.NET
• Turn the MAddNop.cs file from
\PhoenixRDK\src\Samples\maddnop into
VS project named MAddNop.
• Lets weave our aspect to MAddNop project
and check the results.
8/3/2019 Presentation Aspect.net - Vladimir Safonov
http://slidepdf.com/reader/full/presentation-aspectnet-vladimir-safonov 28/34
Vladimir Safonov, SSCLI Capstone
Workshop, Redmond 2005
28
Step by Step playing with Aspect.NET
• First of all load the source project into VS IDE.
8/3/2019 Presentation Aspect.net - Vladimir Safonov
http://slidepdf.com/reader/full/presentation-aspectnet-vladimir-safonov 29/34
Vladimir Safonov, SSCLI Capstone
Workshop, Redmond 2005
29
Step by Step playing with Aspect.NET
• Load the MAddNopCounter assembly to the Aspects list.
8/3/2019 Presentation Aspect.net - Vladimir Safonov
http://slidepdf.com/reader/full/presentation-aspectnet-vladimir-safonov 30/34
Vladimir Safonov, SSCLI Capstone
Workshop, Redmond 2005
30
Step by Step playing with Aspect.NET
• Click “Find Joinpoints” button and wait until the obtained points will
not be printed at Aspects tab.
8/3/2019 Presentation Aspect.net - Vladimir Safonov
http://slidepdf.com/reader/full/presentation-aspectnet-vladimir-safonov 31/34
Vladimir Safonov, SSCLI Capstone
Workshop, Redmond 2005
31
Step by Step playing with Aspect.NET• To weave the actions to the join points, click “Weave Aspects” button and
check the resulting assembly ~MAddNop.exe in the debug folder of yourproject.
• Lets try how it works on the testapp.exe shipped with PhoenixRDK. Copytestapp.exe and testapp.pdb from \PhoenixRDK\Applications\Tests into debugfolder of MAddNop project.
• Run “~MAddNop.exe testapp.exe newapp.exe”
and “MAddNop.exe testapp.exe newapp.exe”
in the console to compare the behavior of the assembly with the aspect woven
to that of the original assembly.
8/3/2019 Presentation Aspect.net - Vladimir Safonov
http://slidepdf.com/reader/full/presentation-aspectnet-vladimir-safonov 32/34
Vladimir Safonov, SSCLI Capstone
Workshop, Redmond 2005
32
Step by Step playing with Aspect.NET
• The result of executing two assemblies is presented below.
• As we can see, output of our new assembly is much more
informative, as compared to the original assembly. NoPhoenix source code touched to achieve this goal
8/3/2019 Presentation Aspect.net - Vladimir Safonov
http://slidepdf.com/reader/full/presentation-aspectnet-vladimir-safonov 33/34
Vladimir Safonov, SSCLI Capstone
Workshop, Redmond 2005
33
AspectRotor
• The first Aspect.NET console version working in the Rotorenvironment. Included into the Aspect.NET archiveuploaded to the MSDNAA Web site
• A set of Perl scripts (please use ActivePearl 5.8.7) toinitialize, to build and remember target applications and
aspects, to select join points, to visualize the sources, toweave aspects, to run the original and the updatedassemblies
• Uses Phoenix as well-as the add-in version, and the Rotorbinaries shipped with the Phoenix RDK
• A simple comfortable menus in console mode provided foreach step; it’s possible to undo and return back
• DEMO (IF TIME PERMITS…)
8/3/2019 Presentation Aspect.net - Vladimir Safonov
http://slidepdf.com/reader/full/presentation-aspectnet-vladimir-safonov 34/34
Vladimir Safonov, SSCLI Capstone
Workshop Redmond 2005
34
Q & A