Visual Studio invalid rule The enum member 'NewProducts' has the same constant value '6' as member 'NewProducts'

Viewed 105

ASP.NET Core 5 MVC shopping cart application defines enum in controllers namespace like this:

namespace Store.Controllers
{
    public enum FixedCategories
    {
        NewProducts = 6
    }
}

Visual Studio 2019 shows strange hint about this

The enum member 'NewProducts' has the same constant value '6' as member 'NewProducts'

Enum integer value 6 is stored in database and used to compare with this enum vale. So it must be 6.

https://docs.microsoft.com/et-ee/dotnet/fundamentals/code-analysis/quality-rules/ca1069

states that this is caused by duplicate enum value and

Do not suppress violations of this rule.

As seen in code, enum contains only single member. So it cannot be duplicate.

Why is VS complaining about this? How to fix it?

Quick action button does not show any reasonable fix.

enter image description here

0 Answers
Related