Because of Roslyn
-
It should now be possible (though it's not implemented) to use lambda expressions in static initializers that get the compiler to do work. Basically, you should be able to declare delegates as fields on classes like System.Attribute. Then you could do something like
[CrossCut(Before:(callContext)=> { Debug.WriteLine("Member "+callContext.Name+" calling on employee"); }), After:(callContext)=>{Debug.WriteLine("Member "+callContext.Name+" called on employee");})]
class EmployeeEntity {
public string Name {get; set; }
public string Title {get; set; }
public string Address {get; set; }
}To add method logging to all your calls. Just as an example. There is no reason, that with Roslyn this can't be done. The only reason I can think of why it *shouldn't* be done is it could potentially allow DoS attacks against Roslyn's compiler service by hanging the compiler running one of the lambdas in an infinite loop, but Roslyn also *should* be able to handle that. Edit: I know you can use the .NET COM+ wrapper to do this with "context objects" or whatever they're called, but that's COM+ and it's ugly
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.