[UWP] [VB]代码风格 - >命名:事件处理程序的小写 [英] [UWP][VB]Code Style -> Naming: Lower Case for Event Handlers

查看:61
本文介绍了[UWP] [VB]代码风格 - >命名:事件处理程序的小写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


在Visual Studio 2017中,选项中的一个选项 - >文字编辑器 - >基本 - >代码样式部分是命名。当我在我的XAML中命名我的元素时,我经常使用以下名称:

In Visual Studio 2017, one of the options in the Options -> Text Editor -> Basic -> Code Style section is Naming. When I name my elements in my XAML, I often use names such as:

btnReset

对于像Button这样的东西,我开始使用3(或极少数情况下为2或4)小写字母表示它是什么类型的元素。在我的代码隐藏中,我通常将处理程序命名为btnReset_Click(元素名称,下划线和
事件名称)。但是,这会(在大多数情况下)给处理程序一个以小写字母开头的名称,默认命名设置不喜欢(它不会给出错误或警告,只是建议,但我仍然不想要它不喜欢我的
风格)。我想添加一个规范,允许我给我的事件处理程序任何有效的名称 我想要没有抱怨。规范的选择不包括任何看起来像事件处理程序的东西,我能找到的最接近的是Private
Method。我在管理样式中也找不到允许任何情况的任何内容(它们都需要上限或下限,但没有一个不关心)。有没有办法可以让它停止抱怨我的处理程序命名?谢谢。

for something like a Button, I start the name with 3 (or in rare cases 2 or 4) lower case letters to indicate what type of element it is. And in my codebehind, I usually name the handler something like btnReset_Click (the element name, an underscore, and the event name). However, this would (in most cases) give the handler a name starting with a lower case letter, which the default Naming settings do not like (it doesn't give errors or warnings, just suggestions, but I still don't want it to dislike my style). I want to add a Specification that will allow me to give my event handlers any valid name I want without complaining. The choices for Specification did not include anything that looked like event handlers, the closest thing I could find was Private Method. I also could not find anything in the Manage Styles that allowed for any case (they all required either upper or lower, but none of them didn't care). Is there any way I can make it stop complaining about my handler naming? Thanks.

推荐答案

嗨Nathan, 

Hi Nathan, 

如你所说,没有<规范中的strong>事件处理程序,不确定私有方法是否适合您。 

As you said, there is no Event handler in Specification, not sure Private method works for you. 

但我确实看到还有其他必需的样式: 

But I did see there are other required styles: 

点击 M anage styles : 

Click Manage styles

点击加号按钮: 

Click Plus button: 

然后我们可以看到这些选项:

then we could see these options:

 

并且严重程度:您还可以将其设置为"无",如果您不喜欢不需要建议显示: 

And in Severity: you could also set it to "None", if you don't need the suggestions show: 

何pe它可能会有所帮助。 

Hope it could be helpful. 




祝你好运, 

Best regards, 

Fletch


这篇关于[UWP] [VB]代码风格 - &gt;命名:事件处理程序的小写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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