How to ensure that a field of enum be referenced only once

Hi

I have a enum which looks like:

```

public enum Code{

Code1, Code2, Code3, ….

}

```

I want every individual Code be referenced only once, if a Code is being used more than one place, a warning or error will show so that I can fix it

0
3 comments

Or is there any setting for me to see how many references for the enum so that I will check them one by one to see if over used reference exists

0

Zhoujiazhiwork , thanks for your comments.

You can use Find Usages Advanced functionality in Rider. 

Right-click on the enum element in editor, and select Find Usages Advanced. All usages will be listed in Find window.

Or you can just have a quick check on the enum object Code Vision in editor. For example, I have 7 elements in my enum declaration and the Code Vision show “9 usages”. In this situation, you can use Find Usage Advanced to review all usages in your solution.

0

In case you cannot see the Code Vision result in your editor, make sure you have enabled it in Settings | Editor | Code Vision | Usages as below.

0

Please sign in to leave a comment.