Skip to content

False positive on switch expression with await  #3460

@karol-gro

Description

@karol-gro

Stylecop version: 1.2.0-beta.406

I get false positive issue on following code:

// this gives SA1119 
await (someBool switch
{
	true => DoOneThing(),
	false => DoAnother(),
});

// after applying suggestions we got not compiling code (await is applied on bool, so parentheses are required to change order of operations)
await someBool switch
{
	true => DoOneThing(),
	false => DoAnother(),
};

Of course in this case one should use if, but this is minimized version of issue found in our code

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions