RalfKoban / MiKo-Analyzers

Provides analyzers that are based on the .NET Compiler Platform.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Enum members shall have value assigned explicitly

RalfKoban opened this issue · comments

Enum members can have a value assigned explicitly, such as None = 0;
If an enum now gets modified (such new enum members get added, they get resorted (e.g. alphabetically), some get deleted (which should not be done at all) ), and they do not have values assigned explicitly, then they get different values re-assigned.

This causes trouble as soon as they are somehow persisted, compiled or exchanged with other languages (such as C++) because normally the backing values are stored and not the enum names. So when they get their values re-assigned, the code suddenly behaves unexpectedly as these values now have a different meaning.

Therefore we should report enum values without an explicit value assigned.