I am quite new to PostSharp, so please guide me to the correct direction.
Let's say I have LoggingAspect:
public class LoggingAspect : OnMethodBoundaryAspect
{
private ILog _log;
private string _targetFullName;
}
First question if I declare _log as static member, would it be share across all LoggingAspect instances? does it common to use static variables inside the aspects?
Now I use compile time initialization by overriding CompileTimeInitialize:
public override void CompileTimeInitialize(MethodBase method, AspectInfo aspectInfo)
{
_log = LogManager.GetLogger(method.DeclaringType);
_targetFullName = string.Format("{0}.{1}", method.DeclaringType.Name, method.Name);
}
Here I am a bit confused, how does PostSharp keeps reference to logger instance when it serialize my aspect to managed resource?
Beside, I can assign logger to my _log variable during run-time:
public override void RuntimeInitialize(MethodBase method)
{
_log = LogManager.GetLogger(method.DeclaringType);
}
What approach should I use? Compile-time or run-time? does it make some difference at all?