Version Used:
Microsoft Visual Studio Enterprise 2017 RC
Version 15.0.26014.0 D15REL
Steps to Reproduce:
switch (o)
{
case int i when i % 2 == 0:
// ...
}
Expected Behavior:
Require that the Boolean expression be enclosed in parenthesis.
Actual Behavior:
The Boolean expression is not required to be enclosed in parenthesis.
Comments
It's probably too late, but this is not coherent with other states that have Boolean expression. As far as I can remember, other statements require the condition to be enclosed in parenthesis:
if (condition)while (condition)case (Exception ex) when (condition)It is not ambigious anyways. Note that when in catch clause does require a pair of parentheses because it is always followed by a block.
from x in y where z select w shows that there is no necessity for conditions to be parenthesized.
@CyrusNajmabadi, nor does any聽subexpression in a condition expression.
is from x in y where z select w a statement?
No, it's not a statement. But neither is a 'case clause' a statement either :)
It's part of a statement.
Even if I agreed with this, it is too late in the C# 7 cycle to consider significant breaking changes from previous previews for such aesthetics.
Most helpful comment
Even if I agreed with this, it is too late in the C# 7 cycle to consider significant breaking changes from previous previews for such aesthetics.