dotnet / roslyn

The Roslyn .NET compiler provides C# and Visual Basic languages with rich code analysis APIs.
https://docs.microsoft.com/dotnet/csharp/roslyn-sdk/
MIT License
19.03k stars 4.03k forks source link

`fixed` keyword formatting doesn't respect `Insert space after keywords in control flow statements` #29341

Open DavidKarlas opened 6 years ago

DavidKarlas commented 6 years ago

Version Used: Any.

Steps to Reproduce:

  1. Disable Insert space after keywords in control flow statements in formatting settings
  2. Format document that contains fixed keyword
  3. Observe that fixed (...) still has space.

Expected Behavior: Respect setting. Actual Behavior: Doesn't respect setting.

I did quick look at code, seems to me like https://github.com/dotnet/roslyn/blob/d82d04a4174460ca67955dc0b4b2a2f5de5c5042/src/Workspaces/CSharp/Portable/Formatting/Rules/SpacingFormattingRule.cs#L105 should just call https://github.com/dotnet/roslyn/blob/d82d04a4174460ca67955dc0b4b2a2f5de5c5042/src/Workspaces/CSharp/Portable/Formatting/Rules/SpacingFormattingRule.cs#L381

This bug was originally reported against VSfM: https://developercommunity.visualstudio.com/content/problem/311355/fixed-statement-unaffected-by-control-flow-keyword.html

tannergooding commented 6 years ago

I don't believe fixed is a control flow statement, it does nothing to impact control flow.

DavidKarlas commented 6 years ago

Notice that using which is very similar to fixed is effected by this formatting setting.

sharwell commented 6 years ago

I don't believe fixed is a control flow statement, it does nothing to impact control flow.

I can't imagine anyone drawing a conclusion of this as expected behavior in this context.