对委托C#语法分析器漏洞? [英] C# Parser Bug on delegate?

查看:131
本文介绍了对委托C#语法分析器漏洞?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:结果
代理System.Action'不拿0参数。这是一个C#编译器的bug(lambda表达式+两个项目)?

当我。在做一个测试框架,用于重拉姆达使用我的事情我一个解析器错误绊倒

When I was doing a testing framework that used heavy lambda usage I thing I stumbled on a parser bug.

public class CSpecTestRunnerSpec : CSpecFacade<CSpecTestRunner>
{
    public CSpecTestRunnerSpec()
        : base(new CSpecTestRunner())
    {
        CreateOperations();
    }

    private MyClassSpec myClassSpec;
    private DescribeAll run_on_type;

    protected override void BeforeOperation()
    {
        myClassSpec = new MyClassSpec();
    }

    private void CreateOperations()
    {
        run_on_type =
           (@it, @do) =>
           {
               @it("Runs all of the operations contained in a type");
               @do.RunTestOnType(myClassSpec.GetType());
           };
    }



DescribeAll代表来自于基类和它的接口看起来像这样:

DescribeAll delegate comes from the base class and it's interface looks like so:

编辑的代码看起来像这样:

EDIT the code looks like so:

public delegate void DescribeAll(Action<string> description, TClass objSpec);



我得到的例外是代表行动并不需要1个参数但它完全不会!并增加了虚拟委托我的类代码后:

The exception I'm getting is "Delegate Action does not take 1 arguments" But it totally does! and after adding a dummy delegate to code of my class:

    private Action<string> dummy;



它开始工作。 : - )

It started to work. :-)

相比之下,相同的代码工作没有错误单声道,没有它是与.NET 3.5和4.0多台机器测试假人代表

By contrast the same code works without errors in mono without the dummy delegate it was tested on multiple machines with NET 3.5 and 4.0.

所以我的问题是,这是编译器侧面或一个错误我身边?以及如何解决这个问题?

So my question is, is this a bug on the compiler side or my side?, and how to resolve the issue?

PS该框架是 CodePlex上这样你就可以得到完整的代码和测试它自己。

p.s the framework is on codeplex so you can get the full code and test it yourself.

推荐答案

该错误已给您带来不便固定在C#5.再次道歉, ,并感谢该报告

UPDATE:

The bug has been fixed in C# 5. Apologies again for the inconvenience, and thanks for the report.

这是在编译器中一个已知的bug,虽然它不是在解析器;它在语义分析和元数据导入缓存之间的相互作用。我的错误的分析是在这里:

That is a known bug in the compiler, though it is not in the parser; it's in the interaction between the semantic analyzer and the metadata import cache. My analysis of the bug is here:

'代表'System.Action不带0的参数。这是一个C#编译器的bug(lambda表达式+两个项目)

这一次是我的错?;我带来的不便表示歉意。我们要想方设法把它固定在未来的版本。

This one was my fault; I apologize for the inconvenience. We'll try to get it fixed for the next version.

这篇关于对委托C#语法分析器漏洞?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆