To trigger RCS1258, it seems like only one bit needs to match between the flags. Below is a reproduction, Test1 shows the fix suggestion, Test2 is after, and some example input where they return different values before and after the fix.
using System;
public class Program
{
public static void Main()
{
Console.WriteLine(C.Test1(FooBar.Bar));
Console.WriteLine(C.Test2(FooBar.Bar));
}
[System.Flags]
internal enum FooBar
{
None = 0,
Shared = 1,
Foo = Shared | 2,
Bar = Shared | 4,
}
class C
{
// before fixer
public static bool Test1(FooBar x)
{
return x == (FooBar.Foo | FooBar.Bar);
}
// after fixer
public static bool Test2(FooBar x)
{
return x == (FooBar.Bar);
}
}
}
To trigger RCS1258, it seems like only one bit needs to match between the flags. Below is a reproduction,
Test1shows the fix suggestion,Test2is after, and some example input where they return different values before and after the fix.