需要通过从现成的(和工作的)自定义属性继承来修改 Log4PostSharp 项目。它看起来类似于:
[AttributeUsage(
AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Module | AttributeTargets.Struct,
AllowMultiple = true,
Inherited = false)]
[MulticastAttributeUsage(
MulticastTargets.InstanceConstructor | MulticastTargets.StaticConstructor | MulticastTargets.Method,
AllowMultiple = true)]
#if SILVERLIGHT
[RequirePostSharp("Log4PostSharp", "Log4PostSharp.Weaver.SilverlightLogTask")]
#else
[RequirePostSharp("Log4PostSharp", "Log4PostSharp.Weaver.LogTask")]
[Serializable]
#endif
public sealed class LogWithExceptionAttribute : LogAttribute
{
public LogWithExceptionAttribute()
{
ExceptionLevel = LogLevel.Error;
}
...
}
这就是我选择注释一些单元测试代码的方式:
[LogWithException]
private void DoThrowException()
{
throw new Exception("test exception");
}
想尝试调试编译时进程,尝试从命令行编译但无法得到任何提示:
> msbuild Log4PostSharp.Test.csproj /p:PostSharpBuild=Diag /p:PostSharpTrace="AssemblyBinding;Project" /v:detailed
哪个是解决问题的正确方法?我想做的错事是什么?