C# StyleCop 格式

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1063701/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 07:21:06  来源:igfitidea点击:

StyleCop formatting

c#stylecop

提问by

How can I format the following line to eliminate StyleCop warnings:

如何格式化以下行以消除 StyleCop 警告:

this.BeginInvoke(this.updateHandler,new object[]{this.tmpbuf});

Now, I get 4 warnings:

现在,我收到 4 个警告:

  • Warning 4 SA1001: Invalid spacing around the comma.
  • Warning 5 SA1011: Invalid spacing around the closing square bracket.
  • Warning 6 SA1012: Invalid spacing around the opening curly bracket.
  • Warning 7 SA1013: Invalid spacing around the closing curly bracket.
  • Warning 4 SA1001: Invalid spacing around the comma.
  • Warning 5 SA1011: Invalid spacing around the closing square bracket.
  • Warning 6 SA1012: Invalid spacing around the opening curly bracket.
  • Warning 7 SA1013: Invalid spacing around the closing curly bracket.

采纳答案by Knut Haugen

this.BeginInvoke(this.updateHandler, new object[] { this.tmpbuf });
  • SA1001 requires space after a comma
  • SA1011 requires space after closing square bracket
  • SA1012 requires space after opening curly bracket
  • SA1013 requires space before closing curly bracket
  • SA1001 需要逗号后的空格
  • SA1011 关闭方括号后需要空格
  • SA1012 打开大括号后需要空间
  • SA1013 在关闭大括号之前需要空格

See StyleCop spacing rulesfor full description of the relevant rules.

有关相关规则的完整说明,请参阅StyleCop 间距规则。