【问题标题】:How can I stop ReSharper from adding an unwanted newline after a line preceded by a comment?如何阻止 ReSharper 在注释前面的行之后添加不需要的换行符?
【发布时间】:2018-01-07 23:28:50
【问题描述】:

我有时会像这样使用 cmets 来“分组”成员:

// unary operators:
public static readonly string Not = Create(nameof(Not));
public static readonly string Negate = Create(nameof(Negate), "-");

// mathematical operators:
public static readonly string Add = Create(nameof(Add), "+");
public static readonly string Subtract = Create(nameof(Subtract), "-");

快速格式将在前面有注释的行之后插入换行符:

// unary operators:
public static readonly string Not = Create(nameof(Not));

public static readonly string Negate = Create(nameof(Negate), "-");

// mathematical operators:
public static readonly string Add = Create(nameof(Add), "+");

public static readonly string Subtract = Create(nameof(Subtract), "-");

我在哪里关闭它?

对我来说,如果评论是 XML 文档 (/// <summary>...),ReSharper 插入这样的换行符是有意义的,但对于常规 cmets(只有两个斜杠)我不希望这样。

如果没有两个斜线 cmets 的单独选项,我宁愿完全关闭它。

【问题讨论】:

    标签: resharper


    【解决方案1】:

    我询问了 ReSharper 支持the same question,他们为我提供了答案:

    请更改以下选项 - ReSharper |选项 |代码编辑 | C# |格式样式 |空行 |字段周围为 0。

    我认为该选项不会影响我的字段,因为还有一个 Around single-line fields 选项。结果表明 cmets 被认为是该字段的一部分,这就是该选项无效的原因。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-03-07
      • 2016-05-14
      • 2019-09-27
      • 2013-12-28
      • 2022-12-18
      • 1970-01-01
      • 2023-03-31
      • 1970-01-01
      相关资源
      最近更新 更多