Visual Studio 11 CTP3 错误?

发布于 2024-12-25 12:26:09 字数 1534 浏览 1 评论 0原文

Visual Studio 11 预览版有错误吗?

我尝试编译以下示例并收到意外的编译错误。

示例 1:

async = System.Threading.Tasks.Task;
partial = System.Threading.Tasks.Task;

class C
{

    async async async(async async) { } // ok

    async partial async(async async) { } // error CS1002: ; expected
}

示例 2:

using System.Threading.Tasks;

class C
{
    delegate Task<dynamic> ady(dynamic i);

    delegate Task adv();

    void f()
    {

        ady d11 = new ady(async j => await j); // ok

        ady d12 = new ady((async j => await j)); // error CS0149: Method name expected

        ady d21 = new ady(async (j) => await j); // ok

        ady d22 = new ady((async (j) => await j)); // error CS0149: Method name expected

        adv d31 = new adv(async () => { dynamic d = 0; await d; }); // ok

        adv d32 = new adv((async () => { dynamic d = 0; await d; })); // error CS0149: Method name expected

        adv d41 = new adv(async delegate { }); // ok

        adv d42 = new adv((async delegate { })); // error CS0149: Method name expected

        adv d61 = new adv(async delegate { }); // ok

        adv d62 = new adv((async delegate { })); // error CS0149: Method name expected

        ady d71 = new ady(async delegate(dynamic d) { return await d; }); // ok

        ady d72 = new ady((async delegate(dynamic d) { return await d; })); // error CS0149: Method name expected
    }
}

Visual Studio 11 Preview bugs?

I tryed to compile following examples and receive unexpected compilation errors.

Example 1:

async = System.Threading.Tasks.Task;
partial = System.Threading.Tasks.Task;

class C
{

    async async async(async async) { } // ok

    async partial async(async async) { } // error CS1002: ; expected
}

Example 2:

using System.Threading.Tasks;

class C
{
    delegate Task<dynamic> ady(dynamic i);

    delegate Task adv();

    void f()
    {

        ady d11 = new ady(async j => await j); // ok

        ady d12 = new ady((async j => await j)); // error CS0149: Method name expected

        ady d21 = new ady(async (j) => await j); // ok

        ady d22 = new ady((async (j) => await j)); // error CS0149: Method name expected

        adv d31 = new adv(async () => { dynamic d = 0; await d; }); // ok

        adv d32 = new adv((async () => { dynamic d = 0; await d; })); // error CS0149: Method name expected

        adv d41 = new adv(async delegate { }); // ok

        adv d42 = new adv((async delegate { })); // error CS0149: Method name expected

        adv d61 = new adv(async delegate { }); // ok

        adv d62 = new adv((async delegate { })); // error CS0149: Method name expected

        ady d71 = new ady(async delegate(dynamic d) { return await d; }); // ok

        ady d72 = new ady((async delegate(dynamic d) { return await d; })); // error CS0149: Method name expected
    }
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

恋你朝朝暮暮 2025-01-01 12:26:09

由于

var a = new Action((() => {}));

在 VS 2010 中无法编译,我认为示例 2 不是一个错误。或者如果是的话,它与async无关。

奇怪的是,Resharper 并没有将其标记为错误并且

Action a = (() => {});

确实工作。

Since

var a = new Action((() => {}));

doesn't compile in VS 2010, I think Example 2 is not a bug. Or if it is, it's not related to async.

Curiously, Resharper doesn't mark it as an error and

Action a = (() => {});

does work.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文