Roslyn: Complete Statement should put semicolon at end of all postfix expressions

Created on 30 Jul 2019  路  2Comments  路  Source: dotnet/roslyn

As discussed in the comments here, https://github.com/dotnet/roslyn/issues/36945

new[]
{
    1,
    2,
    3,
}.Select(x => 2 * x).Where(x => x < 4$$).Select(x => 2 / x).ToList();

Expected:
Entering a semicolon where the $$ is should move the semicolon to be after ToList()

Actual:
Semicolon is placed prior to .Select().

Area-IDE Bug IDE-CodeStyle Need Design Review

All 2 comments

:memo: This has a direct conflict with #34983.

We generally have had to write logic many times that deals with the attribute ambiguity. In general, the rule is pretty simple: If you have a construct that could be followed by an attribute, and you have the indexoperation, it's postfix if it's on the same line, otherwise it's an attribute. You can also do a few more checks to isolate out things that couldn't be attributes. But, in general, you don't need to.

Was this page helpful?
0 / 5 - 0 ratings