Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GetFlagEnumValues is not safe to use #387

Open
sm-g opened this issue Apr 3, 2023 · 0 comments
Open

GetFlagEnumValues is not safe to use #387

sm-g opened this issue Apr 3, 2023 · 0 comments

Comments

@sm-g
Copy link

sm-g commented Apr 3, 2023

It declares to return IEnumerable<TEnum>, so I except it is never null (https://rules.sonarsource.com/csharp/RSPEC-1168).

But MyEnum.FromValue(0) returns null.

public sealed class MyEnum : SmartFlagEnum<MyEnum>
    {
        public static readonly MyEnum X= new MyEnum(1);
        public static readonly MyEnum Y= new MyEnum(2);

private MyEnum (int value, [CallerMemberName] string name = null)
            : base(name, value)
        {
        }
   }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant