[aosd-discuss] Is there a standard .Net Aspect software package?

Corpening, Owen Owen.Corpening at amd.com
Thu Jun 15 08:58:21 EST 2006


I think this post demonstrates the problem here:

http://www.cs.virginia.edu/pipermail/eos-discuss/2005-May/000044.html

 

I added a HelloWorld logging example to the EOS examples they include in
their distribution, and it is the sort of simple example I would like to
see in every AOP tool (ApectJ has this).

The entire example (I pasted it below for easy reference) is less than
100 lines including the build script ! It is a practical example in the
sense that it uses log4net ... would be even simpler with
Console.Out.WriteLine ...

 

The "2 minute tutorial" for Aspect# is adding security to a content
management system .... Notice the post I linked to above .... I am not
the only person who would like to see a 10-second tutorial ....

 

That HelloWorld example below is part of the EOS distribution, and you
can run the "build script" (ok line) and the result runs. (The output is
not precisely what I was looking for but HEY it shows before and after
pointcuts, not so bad for <100 lines)

 

Figuring out how to use DynamicProxy to do a HelloWorld logging example
is not a 2-minute exercise. There needs to be some simple examples in
the absence of any documentation other than API docs.

 

Owen

 

HelloAspect.cs:

using System;

using log4net;

using log4net.Config;

 

public aspect HelloAspect

{

 

            private static readonly ILog log =
LogManager.GetLogger("Logger" );

 

            HelloAspect()

            {

                        BasicConfigurator.Configure();           

            }                 

 

            pointcut traceMethods():execution(any any(..))

                        || initialization( any(..))

                        && !within(HelloAspect);

                              

 

            before():traceMethods()

            {

                        string paramBuffer ="\n\t[This: ";

                        paramBuffer += thisJoinPoint.This;

                        Object[] arguments = thisJoinPoint.Args;

                        log.Debug("Number of args = " +
arguments.GetUpperBound(0));

                        paramBuffer += "]\n\t[Args: (";

                        for ( int i = arguments.GetLowerBound(0); i <=
arguments.GetUpperBound(0); i++ ) 

                        {

                            Object argument = arguments[i];

                            paramBuffer += argument;

                            if (i != arguments.GetUpperBound(0)-1) {

                                    paramBuffer += ',';

                            }

                        }

                        paramBuffer += ")]";

                        log.Debug( paramBuffer);

                        log.Debug("Entering: " + thisJoinPoint); 

            }     

 

            after():traceMethods()

            {

                        log.Debug("Exiting: " + thisJoinPoint); 

            }     

}

 

HelloWorld.cs:

/* This example demonstrate how a simple method 

   call tracing can be done using Eos.  */

 

using System;   

 

namespace HelloWorld

{

            public class Hello

            {

                        static void Main(string[] arguments)

                        {

                                    Object1 obj = new Object1("Howard");

                                    Object2 obj2 = new Object2("Social",
"Calendar");

                                    System.Console.WriteLine("Hello");

                                    String i = obj.getAString("bud");

                                    String j =
obj2.getAString("random");

                        }

            }

 

            public class Object1

            {

                        public Object1(System.String fred)

                        {

                        }

                        public string getAString(System.String dave)

                        {

                                    return "Harv";

                        }

            }

 

            public class Object2

            {

                        public Object2(System.String fred, System.String
jason)

                        {

                        }

                        public string getAString(System.String dave)

                        {

                                    return "Harv";

                        }

            }

 

}

 

Test.bat (build script)

..\..\bin\eos.exe /o:./HelloWorld.exe /r:log4net.dll
/r:..\..\bin\Eos.Runtime.dll *.cs

copy ..\..\bin\Eos.Runtime.dll .\

 

output:

C:\development\opensource\eos-0.3.3\examples\HelloWorld>HelloWorld.exe

0 [3484] DEBUG Logger  - Number of args = 0

15 [3484] DEBUG Logger  -

        [This: ]

        [Args: (System.String[],)]

31 [3484] DEBUG Logger  - Entering: execution(Static System.Void
HelloWorld.Hell

o.Main( System.String[]arguments ))

31 [3484] DEBUG Logger  - Number of args = 0

31 [3484] DEBUG Logger  -

        [This: HelloWorld.Object1]

        [Args: (Howard,)]

46 [3484] DEBUG Logger  - Entering: object_initialization(Public
HelloWorld.Obje

ct1.Object1)

62 [3484] DEBUG Logger  - Exiting: object_initialization(Public
HelloWorld.Objec

t1.Object1)

62 [3484] DEBUG Logger  - Number of args = 1

62 [3484] DEBUG Logger  -

        [This: HelloWorld.Object2]

        [Args: (SocialCalendar,)]

93 [3484] DEBUG Logger  - Entering: object_initialization(Public
HelloWorld.Obje

ct2.Object2)

109 [3484] DEBUG Logger  - Exiting: object_initialization(Public
HelloWorld.Obje

ct2.Object2)

Hello

109 [3484] DEBUG Logger  - Number of args = 0

124 [3484] DEBUG Logger  -

        [This: HelloWorld.Object1]

        [Args: (bud,)]

124 [3484] DEBUG Logger  - Entering: execution(Public System.String
HelloWorld.O

bject1.getAString( System.Stringdave ))

140 [3484] DEBUG Logger  - Exiting: execution(Public System.String
HelloWorld.Ob

ject1.getAString( System.Stringdave ))

140 [3484] DEBUG Logger  - Number of args = 0

156 [3484] DEBUG Logger  -

        [This: HelloWorld.Object2]

        [Args: (random,)]

156 [3484] DEBUG Logger  - Entering: execution(Public System.String
HelloWorld.O

bject2.getAString( System.Stringdave ))

171 [3484] DEBUG Logger  - Exiting: execution(Public System.String
HelloWorld.Ob

ject2.getAString( System.Stringdave ))

171 [3484] DEBUG Logger  - Exiting: execution(Static System.Void
HelloWorld.Hell

o.Main( System.String[]arguments ))

 

C:\development\opensource\eos-0.3.3\examples\HelloWorld>

________________________________

From: gregory young [mailto:gregoryyoung1 at gmail.com] 
Sent: Wednesday, June 14, 2006 7:29 PM
To: Corpening, Owen
Subject: Re: [aosd-discuss] Is there a standard .Net Aspect software
package?

 

I think you are getting confused between the concept of a dynamic proxy
and castle project's library dynamic proxy.

 

The concept of a dynamic proxy is a very well known method of doing
runtime weaving.

 

In castle's case Aspect# is a relatively simple bit of code using their
DynamicProxy library which does the heavy lifting. Obviously it wouldn't
make much sense to go through and update that area until the underlying
dynamic proxy is completed, the new dynamic proxy library will I would
assume create a new major release of aspect# as well. 

 

There are people working on this right now. I will refer you to the
castle-devel list for further questions as to the state of the process.

Cheers,

 

Greg

 

On 6/14/06, Corpening, Owen <Owen.Corpening at amd.com> wrote: 

So folks use DynamicProxy but not Aspect# (the CastleProject
DynamicProxy-based AOP)?

 

________________________________

From: gregory young [mailto: gregoryyoung1 at gmail.com] 
Sent: Wednesday, June 14, 2006 3:44 PM 


To: Corpening, Owen
Cc: discuss at aosd.net

Subject: Re: [aosd-discuss] Is there a standard .Net Aspect software
package?

 

If you look around a bit you will find a ton of dynamic proxy based
solutions with varying levels of completion as they are exceptionally
easy to create and make a project for an undergrad. 

 

I have literally seen about 100 proxy based AOP frameworks with varying
sized user bases.

 

I did forget to mention spring.net <http://spring.net/>  which is
another well known library. 

 

Cheers,

 

Greg
 

On 6/14/06, Corpening, Owen < Owen.Corpening at amd.com
<mailto:Owen.Corpening at amd.com> > wrote: 

This seems to be a complete summary of the .Net alternatives, only 6
months old ...

 

http://janus.cs.utwente.nl:8000/twiki/bin/view/AOSDNET/CharacterizationO
fExistingApproaches

 

Note that of the 9 for which information is available 5 are dynamic 4
are static - about %50.

 

Only one - EOS - is in a state of both technical and conceptual
completeness. I notice the head of EOS is lead of Technical Risks and
Mitigation Strategies on the site ...

________________________________

From: gregory young [mailto: gregoryyoung1 at gmail.com] 


Sent: Wednesday, June 14, 2006 1:18 PM
To: Corpening, Owen

Subject: Re: [aosd-discuss] Is there a standard .Net Aspect software
package?

 

Nearly all will work with 2.0 (the dynamic proxy based ones anyways
which is about 90% of them). They will just not necesarily support
generics in a full way. 

 

They operate on closed types so you will still be able to proxy closed
types as you used to. They will not however allow you to proxy generic
types (or to use generic arguments when defining point cuts) 

 

ex: instead of saying that you would like to attach an interceptor to

 

List<int>.Add() where it would only apply to generic instances of List
where T was an int

 

you would have to instead use

 

public class Foo : List<int> {

}

 

then apply to your closed class.
 

Other than that rather large missing but of functionality most should
work great.

 

Castle Project's Dynamic Proxy and nAspect are from what I know both
under active development. I know castle is working towards a version
2.0. I have been working on one with full generic support but there are
alot of fringe conditions to think through especially dealing with
mixins and generic proxy reuse. 

 

I have never has the courage to use EOS in a production environment so I
can't really speak on it beyond the trivial examples I have used it for.


 

Cheers,

 

Greg Young
 

On 6/14/06, Corpening, Owen < Owen.Corpening at amd.com
<mailto:Owen.Corpening at amd.com> > wrote: 

Seems to me like .Net Aspect development fell off a cliff about 2 years
ago.

 

Are any of the .Net tools still being updated, do any of them work well,
is there a consensus similar to AspectJ being a consensus of sorts in
java? 

 

I successfully used EOS over a year ago but I question whether any of
the .Net packages work of each new release of visual studio, and are in
any way supported. 

 

Open source? EOS was not ...

 

thanks,

Owen Corpening

owen.corpening at amd.com 

602-1000 x59613

 


_______________________________________________
discuss mailing list    -     discuss at aosd.net <mailto:discuss at aosd.net>


To unsubscribe and change options, go to:
http://aosd.net/mailman/listinfo/discuss_aosd.net 

Check out the AOSD.net Wiki: http://aosd.net/wiki






-- 
If knowledge can create problems, it is not through ignorance that we
can solve them. 

Isaac Asimov 




-- 
If knowledge can create problems, it is not through ignorance that we
can solve them. 

Isaac Asimov 




-- 
If knowledge can create problems, it is not through ignorance that we
can solve them. 

Isaac Asimov 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: /pipermail/discuss_aosd.net/attachments/20060615/dddf873e/attachment-0001.html 


More information about the discuss mailing list