【问题标题】:Format inline anonymous type with ReSharper to be compliant with StyleCop使用 ReSharper 格式化内联匿名类型以符合 StyleCop
【发布时间】:2018-03-28 21:14:21
【问题描述】:

我有以下代码:

var newItems = items.Select(x => new { x.Id, x.Name });

ReSharper 将其重新格式化为:

var newItems = items.Select(x => new {x.Id, x.Name});

这会给出 StyleCop 警告 SA1012SA1013 我试过this solution,但它似乎不适用于匿名类型。

我需要在 ReSharper 中修改哪些设置以确保重新格式化符合 StyleCop?

【问题讨论】:

标签: c# resharper anonymous-types stylecop


【解决方案1】:

有一个选项可以确定预期的行为:
C# -> Formatting Style -> Spaces -> Within single-line initializer braces.

此外,您可能需要暂停并重新启动 Resharper 或重新启动 Visual Studio。

【讨论】:

    猜你喜欢
    • 2019-06-01
    • 1970-01-01
    • 1970-01-01
    • 2010-11-05
    • 1970-01-01
    • 1970-01-01
    • 2013-03-15
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多