-1

我遵循了 postsharp 1.5 附带的示例。我有两个简单的项目:

一个有这样的方面:

[Serializable]
public class MyAspectAttribute : OnMethodBoundaryAspect
{
    public override void OnEntry(MethodExecutionEventArgs eventArgs)
    {
        Console.WriteLine(eventArgs.Method.Name);
        base.OnEntry(eventArgs);
    }
}

在另一个项目中,我有一个这样的测试用例:

public class Test
{
    [MyAspect]
    public void DoSomething()
    {
        Console.Write("aa");
    }
}

在“测试”的同一个项目中,我有以下测试夹具:

[TestFixture]
public class TestFixture
{
    [Test]
    public void TestDoSomething()
    {
        var a = new Test();
        a.DoSomething();
    }}

由于 postsharp 异常,代码将无法编译:

Error   2   Unhandled exception: System.InvalidCastException: Unable to cast object of type 'PostSharp.CodeModel.TypeDefDeclaration' to type 'PostSharp.CodeModel.IMethod'.
   at PostSharp.Laos.Weaver.MethodLevelAspectWeaver.get_TargetMethod()
   at PostSharp.Laos.Weaver.MethodLevelAspectWeaver.Initialize()
   at PostSharp.Laos.Weaver.OnMethodBoundaryAspectWeaver.Initialize()
   at PostSharp.Laos.Weaver.LaosTask.Execute()
   at PostSharp.Extensibility.Project.ExecutePhase(String phase)
   at PostSharp.Extensibility.Project.Execute()
   at PostSharp.Extensibility.PostSharpObject.ExecuteProjects()
   at PostSharp.Extensibility.PostSharpObject.InvokeProject(ProjectInvocation projectInvocation)
   at PostSharp.MSBuild.PostSharpRemoteTask.Execute(PostSharpTaskParameters parameters, TaskLoggingHelper log)  MyExample.Tests

我应该怎么办?

4

1 回答 1

0

它看起来像一个错误,但我想知道你的样本是如何导致这个错误的。您尝试使用最新版本还是仅使用 RTM?

如果bug没有解决,可以发repro(一个独立的命令行项目)到support@sharpcrafters.com吗?

于 2010-03-06T13:31:45.950 回答