Open RikkiGibson opened 2 years ago
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.
Tagging subscribers to this area: @dotnet/area-meta See info in area-owners.md if you want to be subscribed.
Author: | RikkiGibson |
---|---|
Assignees: | - |
Labels: | `area-Meta`, `untriaged`, `code-analyzer` |
Milestone: | - |
Tagging subscribers to this area: @dotnet/area-system-runtime See info in area-owners.md if you want to be subscribed.
Author: | RikkiGibson |
---|---|
Assignees: | - |
Labels: | `area-System.Runtime`, `untriaged`, `code-analyzer` |
Milestone: | - |
Describe the problem you are trying to solve
In Roslyn, we often add new entries to ErrorCode in feature branches. When the feature branches merge, there are issues with duplicates, which are caught already by CA1069.
Even when there aren't duplicates, though, we can have issues with misordering of the error codes:
https://github.com/dotnet/roslyn/blob/d47bc385061323c9d1350e1a4de1cb7a256759e1/src/Compilers/CSharp/Portable/Errors/ErrorCode.cs#L2008-L2021
Here, a feature branch was merged and included some new entries in the "middle" of the sequence. This makes navigating and interpreting the error code list more difficult, so we'd like to avoid it.
I think this analyzer would have to be opt-in, similar to CA1069, since many enums intentionally do not adhere to such ordering.
Describe suggestions on how to achieve the rule
ERR_CannotBeMadeNullable
would move to appear directly afterERR_CannotUseRefInUnmanagedCallersOnly
.For flags enums, it's not clear when/if this rule should be enforced. Perhaps you could identify when a field initializer consists only of references to other enum fields and exclude it from the rule.