PostSharp OnMethodBoundaryAspect with Abstract Methods

时间:2012-03-06 23:11:25

标签: methods abstract postsharp

我是PostSharp的新手,正在研究它对我们项目的用途。我正在尝试在抽象方法上应用OnMethodBoundaryAspect并收到以下错误:http://screencast.com/t/1LyzIz2M

能够使用常规方法和虚拟方法执行方面,我是否遗漏了任何内容,或者是否可能是抽象成员?

这是我的简单方面:

[Serializable]
public sealed class TraceAttribute : OnMethodBoundaryAspect
{
    protected string _strMethodName;
    protected static readonly Stopwatch _sw = new Stopwatch();

    public TraceAttribute(string pMethodName)
    {
        _strMethodName = pMethodName;
    }

    public override void OnEntry(MethodExecutionArgs args)
    {
        _sw.Start();
        string strMsg = string.Format(">> Entering {0}.{1}", args.Method.DeclaringType.Name, args.Method);
        Debug.Print(strMsg);
    }

    public override void OnExit(MethodExecutionArgs args)
    {
        _sw.Stop();
        string strMsg = string.Format("<< Leaving {0}.{1} - EXECTIME: {2} ms", args.Method.DeclaringType.Name,
                                      args.Method, _sw.ElapsedMilliseconds);
        Debug.Print(strMsg);

        _sw.Reset();
    }
}

0 个答案:

没有答案