Resharper Naming Exception for “iPhone”

大城市里の小女人 提交于 2019-12-10 16:45:28

问题


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.

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.


回答1:


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

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.

Screenshot for settings:

Update:

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

// ReSharper disable once InconsistentNaming

just before your "iPhone" enum member.



来源:https://stackoverflow.com/questions/18774438/resharper-naming-exception-for-iphone

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!