"iPhone"的重新共享命名异常 [英] Resharper Naming Exception for "iPhone"

查看:140
本文介绍了"iPhone"的重新共享命名异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在Resharper命名约定中为特定单词添加例外?特别是,尽管我通常更喜欢PascalCase作为枚举值,但我仍希望能够将枚举值设置为"iPhone".

Is it possible to add an exception to Resharper naming conventions for a specific word? In particular, I'd like to be able to make an enum value "iPhone", even though I generally prefer PascalCase for enum values.

我签出了 Resharper的命名样式文档,但没有看到任何添加自定义异常的方法.我还尝试使用自定义缩写列表,但这仅适用于所有大写字母.

I checked out Resharper's naming style documentation, but didn't see any way to add a custom exception. I also tried using the custom abbreviations list, but that only works for all caps.

推荐答案

您不能为特定单词添加例外,但是有一些解决方法.

You can't add an exception for specific word, but there's some kind of workaround.

使用ReSharper,您可以为一个成员添加多个命名规则.您可以为枚举成员"设置添加新规则,并将其名称前缀设置为"iPhone".使用此设置,您将可以定义"iPhone"枚举值.请注意,使用此设置,您还可以定义"iPhoneWithReallyCoolFeature"枚举值,因为它不违反此规则.

With ReSharper you can add more than one naming rules for a member. You can add new rule for "enum members" settings and set its name prefix to "iPhone". With this setting you'll be able to define "iPhone" enum value. Notice that with this setting you'll also be able to define "iPhoneWithReallyCoolFeature" enum value, because it doesn't violate this rule.

设置屏幕截图:

更新:

如果您不介意污染代码,则可以添加

If you don't mind of polluting your code, you can add

// ReSharper disable once InconsistentNaming

就在您的"iPhone"枚举成员之前.

just before your "iPhone" enum member.

这篇关于"iPhone"的重新共享命名异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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