2023-05-03 11:06:20 +02:00
|
|
|
== Why is this an issue?
|
|
|
|
|
2020-06-30 12:48:07 +02:00
|
|
|
Shared naming conventions allow teams to collaborate efficiently. This rule checks that all enum names match a provided regular expression.
|
|
|
|
|
2021-02-02 15:02:10 +01:00
|
|
|
|
2020-06-30 12:48:07 +02:00
|
|
|
The default configuration is the one recommended by Microsoft:
|
2020-06-30 14:49:38 +02:00
|
|
|
|
2020-06-30 12:48:07 +02:00
|
|
|
* Pascal casing, starting with an upper case character, e.g. BackColor
|
|
|
|
* Short abbreviations of 2 letters can be capitalized, e.g. GetID
|
|
|
|
* Longer abbreviations need to be lower case, e.g. GetHtml
|
|
|
|
* If the enum is marked as [Flags] then its name should be plural (e.g. MyOptions), otherwise, names should be singular (e.g. MyOption)
|
|
|
|
|
2023-05-03 11:06:20 +02:00
|
|
|
=== Noncompliant code example
|
2020-06-30 12:48:07 +02:00
|
|
|
|
2021-01-27 13:42:22 +01:00
|
|
|
With the default regular expression for non-flags enums: ``++^([A-Z]{1,3}[a-z0-9]+)*([A-Z]{2})?$++``
|
2020-06-30 14:49:38 +02:00
|
|
|
|
2022-02-04 17:28:24 +01:00
|
|
|
[source,vbnet]
|
2020-06-30 12:48:07 +02:00
|
|
|
----
|
|
|
|
Public Enum foo ' Noncompliant
|
|
|
|
FooValue = 0
|
|
|
|
End Enum
|
|
|
|
----
|
2021-01-27 13:42:22 +01:00
|
|
|
With the default regular expression for flags enums: ``++^([A-Z]{1,3}[a-z0-9]+)*([A-Z]{2})?s$++``
|
2020-06-30 14:49:38 +02:00
|
|
|
|
2022-02-04 17:28:24 +01:00
|
|
|
[source,vbnet]
|
2020-06-30 12:48:07 +02:00
|
|
|
----
|
|
|
|
<Flags()>
|
|
|
|
Public Enum Option ' Noncompliant
|
|
|
|
None = 0,
|
|
|
|
Option1 = 1,
|
|
|
|
Option2 = 2
|
|
|
|
End Enum
|
|
|
|
----
|
|
|
|
|
2023-05-03 11:06:20 +02:00
|
|
|
=== Compliant solution
|
2020-06-30 12:48:07 +02:00
|
|
|
|
2022-02-04 17:28:24 +01:00
|
|
|
[source,vbnet]
|
2020-06-30 12:48:07 +02:00
|
|
|
----
|
|
|
|
Public Enum Foo
|
|
|
|
FooValue = 0
|
|
|
|
End Enum
|
|
|
|
----
|
2020-06-30 14:49:38 +02:00
|
|
|
|
2022-02-04 17:28:24 +01:00
|
|
|
[source,vbnet]
|
2020-06-30 12:48:07 +02:00
|
|
|
----
|
|
|
|
<Flags()>
|
|
|
|
Public Enum Options
|
|
|
|
None = 0,
|
|
|
|
Option1 = 1,
|
|
|
|
Option2 = 2
|
|
|
|
End Enum
|
|
|
|
----
|
2021-09-20 15:38:42 +02:00
|
|
|
ifdef::env-github,rspecator-view[]
|
|
|
|
|
|
|
|
'''
|
|
|
|
== Implementation Specification
|
|
|
|
(visible only on this page)
|
|
|
|
|
|
|
|
include::../message.adoc[]
|
|
|
|
|
2023-05-25 14:18:12 +02:00
|
|
|
=== Parameters
|
|
|
|
|
|
|
|
.format
|
|
|
|
****
|
|
|
|
|
|
|
|
----
|
|
|
|
^([A-Z]{1,3}[a-z0-9]+)*([A-Z]{2})?$
|
|
|
|
----
|
|
|
|
|
|
|
|
Regular expression used to check the enumeration type names against
|
|
|
|
****
|
|
|
|
.flagsAttributeFormat
|
|
|
|
****
|
|
|
|
|
|
|
|
----
|
|
|
|
^([A-Z]{1,3}[a-z0-9]+)*([A-Z]{2})?s$
|
|
|
|
----
|
|
|
|
|
|
|
|
Regular expression used to check FlagsAttribute enumeration type names against
|
|
|
|
****
|
|
|
|
|
2021-09-20 15:38:42 +02:00
|
|
|
|
|
|
|
endif::env-github,rspecator-view[]
|