如何使Visual Studio快速注释在双斜杠后添加空格以避免SA1005? [英] How to get Visual Studio quick comments to add a space after the double slash to avoid SA1005?

查看:883
本文介绍了如何使Visual Studio快速注释在双斜杠后添加空格以避免SA1005?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Visual Studio中,我有一段代码.我将其突出显示,然后使用Ctrl + k + c注释掉该块.在我突出显示的每一行的开头都添加了"//".然后,我尝试提交我的代码...,然后遇到StyleCop规则"SA1005",该规则要求所有////后跟一个空格或更改为////.我真的很想修改Visual Studio,以便ctrl + k + c添加"//".我还没有找到任何实现此目的的扩展程序或选项.有谁知道进行此更改的方法(不编写我自己的新VS扩展)?

In Visual Studio, I have a block of code. I highlight it and use Ctrl+k+c to comment out the block. That adds "//" at the start of every line I highlighted. I then try to submit my code... and I run into StyleCop rule "SA1005" that requires all // to be followed by a space or be changed to ////. I would really like to modify Visual Studio so that ctrl+k+c adds "// ". I have not found any extensions or options that make that happen. Does anyone know of a way to do that change (short of writing my own new VS extension)?

推荐答案

同事告诉我,您也可以只按Ctrl + K + C Ctrl + K + C(即应用注释两次),它将做////代码.那将通过样式警察.进行两次取消注释快捷键以撤消.显然,StyleCop不在乎四个斜杠后是否有空格,仅在两个斜杠后是否有空格.

Co-worker tells me that you can also just hit Ctrl+K+C Ctrl+K+C (that is, apply commenting twice), and it will do ////code. That will pass style cop. Do the uncomment shortcut key twice to undo. Apparently, StyleCop doesn't care if there's a space after four slashes, only after two slashes.

似乎有些人真的很喜欢这种规则行为.如果人们在玩东西,但又不想忘记并以这种方式检查代码,人们将使用一组//注释掉代码. SA将失败,并且代码也不会加入.一旦您真的想注释掉代码并检入,然后再次将其注释掉,就可以了.他们声称,这避免了因办理登机手续不当而导致的许多事故.

Seems some people really like this rule behavior. People will comment out code with a single set of // if they are playing around with stuff but do not want to forget and check it in that way. SA will fail and the code will not go in. Once you really mean to comment out of the code and check it in then you comment it out again and you are good to go. This, they claim, has saved many from a bad check-in.

这篇关于如何使Visual Studio快速注释在双斜杠后添加空格以避免SA1005?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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