Skip to content

RCS1096 does not work correctly with composite flags #1555

@Genbox

Description

@Genbox

This seems to have been reported before, but it is still not working correctly.

Repo:

internal class Program
{
    private static FileAttributes _skipMask = FileAttributes.Device | FileAttributes.Offline;

    internal static void Main()
    {
        var fileAttr = FileAttributes.Device;

        //RCS1096 is reported here
        if ((fileAttr & _skipMask) != 0)
            Console.WriteLine("AndCheck: Flags were present");
        else
            Console.WriteLine("AndCheck: Flags not present");

        if (fileAttr.HasFlag(_skipMask))
            Console.WriteLine("HasFlag: Flags were present");
        else
            Console.WriteLine("HasFlag: Flags not present");
    }
}

Output:

AndCheck: Flags were present
HasFlag: Flags not present

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions