Can Spring.Net function as PostSharp?
Posted
by Alex K
on Stack Overflow
See other posts from Stack Overflow
or by Alex K
Published on 2010-03-19T22:20:41Z
Indexed on
2010/03/20
2:51 UTC
Read the original article
Hit count: 740
A few months back I've discovered PostSharp, and for a time, it was good.
But then legal came back with an answer saying that they don't like the licence of the old versions. Then the department told me that 2.0's price was unacceptably high (for the number of seats we need)... I was extremely disapponted, but not disheartened. Can't be the only such framework, I thought.
I kept looking for a replacement, but most of it was either dead, ill maintained (especially in documentation department), for academic use, or all of the above (I'm looking at you Aspect.Net)
Then I've discovered Spring.Net, and for a time, it was good.
I've been reading the documentation and it went on to paint what seemed to be a supperior picture of an AOP nirvana. No longer was I locked to attributes to mark where I wanted code interception to take place, but it could be configured in XML and changes to it didn't require re-compile. Great.
Then I looked at the samples and saw the following, in every single usage scenario:
// Create AOP proxy using Spring.NET IoC container.
IApplicationContext ctx = ContextRegistry.GetContext();
ICommand command = (ICommand)ctx["myServiceCommand"];
command.Execute();
if (command.IsUndoCapable)
{
command.UnExecute();
}
Why must the first two lines of code exist? It ruins everything. This means I cannot simply provide a user with a set of aspects and attributes or XML configs that they can use by sticking appropriate attributes on the appropriate methods/classes/etc or editing the match pattern in XML. They have to modify their program logic to make this work!
Is there a way to make Spring.Net behave as PostSharp in this case? (i.e. user only needs to add attributes/XML config, not edit content of any methods.
Alternatively, is there a worthy and functioning alternative to PostSharp? I've seen a few question titled like this on SO, but none of them were actually looking to replace PostSharp, they only wanted to supplement its functionality. I need full replacement.
© Stack Overflow or respective owner