|
From: Darrick W. <da...@in...> - 2004-11-07 04:18:16
|
Hi guys,
I have spent some time playing with Aspect# over the last couple of =
days, and have a few things to report to HQ. I think what you have so =
far is great stuff, and I'm really looking forward to using this in a =
project some time soon!
First, I should note that I am using the CLR 2.0 beta1 / VS 2005. That =
said, the Aspect# 1.x version seemed to work fine, and this version =
almost works, but sometimes methods that have valid pointcuts do not get =
overridden by =20
Castle.DynamicProxy.ProxyGenerator. CreateCustomClassProxy(baseClass, =
interceptor, context);=20
inside AspectSharp.Core.CustomProxyGenerator. CreateClassProxy(Type, =
object[], IInterceptor). For instance, in the example program that you =
provide, the MixinAndInterceptorExecution function works correctly, but =
the HashTableTest runs but get_Item is not intercepted, and using =
reflection I can see that the DeclaringType of get_Item is still =
HashTable. I spent a lot of time on this but I could not find an error =
in your code, and I couldn't find the source for Castle.DynamicProxy =
(the one I found at Apache.Avalon was quite different).
Secondly, I found that the cache in AspectSharp.Core.Proxy. =
DefaultProxyFactory did not work if the aspect was operating on more =
than one type. I think the problem only surfaced the second time that =
the second class was wrapped. Making the following change and adding an =
apropriate AspectInstanceKey class as below fixed this:
private Type GetProxyTypeFromCache (AspectDefinition aspect, Type =
baseClass)
{
return _aspect2ProxyType[new AspectInstanceKey(aspect, baseClass)] =
as Type;
}
private void RegisterProxyTypeInCache (AspectDefinition aspect, Type =
baseClass, Type proxyType)
{
_aspect2ProxyType[new AspectInstanceKey(aspect, baseClass)] =3D =
proxyType;
}
Third, I discovered that the parser does not treat '_' as an ID token. =
I have fixed this as well.
Fourth, I have extended the method interceptor pointcut definition so =
that we can specify the accessibility of the method we want to =
intercept. The original syntax still works, but now we can also have:
pointcut method(public * *)
pointcut method(* void *(*))
pointcut method(internal * Method.*())
etc.
Finally, just for fun I added this function to the AspectEngine. I =
think it has potential although it is nothing particularly spectacular =
right now, so I thought I'd pass it along.
public virtual TypeToWrap WrapClass<TypeToWrap>()
{
return (TypeToWrap)WrapClass(typeof(TypeToWrap));
}
called:
ISomeClass d =3D engine.WrapClass<SomeClass>();
Cheers!
Darrick Wiebe
|