Hello,
Currently the code cleaning utility will change the following, valid C# code:
C#public override string ToString()
{
if ((_Numbers?.Length).GetValueOrDefault(0) == 0)
return "?";
return string.Join(".", Numbers);
}
… to this invalid code:
C#public override string ToString()
{
if (_Numbers?.Length.GetValueOrDefault(0) == 0)
return "?";
return string.Join(".", Numbers);
}
The parenthesis around _Numbers?.Length gets removed, causing the compiler to detect a syntax error. Truth is: parenthesis shouldn't have been removed in the first place.
Please advise. Thanks.
EDIT :
Some additional details: this seems to occur only if the following cleanup rule is set: "Apply 'optional parenthesis' style to explicitly declare precedence of expressions". Checking it off solves the issue.
Of course it doesn't change the fact that CodeRush should be smart enough to detect if it can safely remove parenthesis or not. :)
Hi David,
Thank you for reporting this issue.
I have managed to reproduce this problem locally. We are working on a solution. You will be notified when a fix is ready.