Reporter |
|
---|---|
Created | Apr 9, 2018 11:09:10 PM |
Updated | Apr 9, 2018 11:22:21 PM |
Subsystem | Code Style |
Assignee | Razmik Seysyan (razmik) |
Priority | Normal |
State | Submitted |
Type | Bug |
Fix version | No Fix versions |
Affected versions | 2018.1 |
Fixed In Version ReSharper | Undefined |
VsVersion | All Versions |
I have a C# solution with StyleCop analyzers. Solution has zero warnings. As long as StyleCop support is disabled, calling ReSharper's "reformat code" does not require any changes. The code looks like this:
But when StyleCop support is enabled, calling "reformat code" removes spaces around conditional operators (?:). My code is changed to this:
This change actually creates several new warnings for each conditional operator:
To reproduce: download the solution (attached), restore NuGet packages, open MyClass.cs, and use ReSharper's reformat feature.
System information:
Console.WriteLine(foo ? "bar" : "baz");
But when StyleCop support is enabled, calling "reformat code" removes spaces around conditional operators (?:). My code is changed to this:
Console.WriteLine(foo?"bar":"baz");
This change actually creates several new warnings for each conditional operator:
1>C:\SomePath\ClassLibrary1\MyClass.cs(16,40,16,41): warning SA1024: Colon must be preceded by a space.
1>C:\SomePath\ClassLibrary1\MyClass.cs(16,40,16,41): warning SA1024: Colon must be followed by a space.
1>C:\SomePath\ClassLibrary1\MyClass.cs(16,34,16,35): warning SA1003: Operator '?' must be preceded by whitespace.
1>C:\SomePath\ClassLibrary1\MyClass.cs(16,34,16,35): warning SA1003: Operator '?' must be followed by whitespace.
1>C:\SomePath\ClassLibrary1\MyClass.cs(16,40,16,41): warning SA1003: Operator ':' must be preceded by whitespace.
1>C:\SomePath\ClassLibrary1\MyClass.cs(16,40,16,41): warning SA1003: Operator ':' must be followed by whitespace.
To reproduce: download the solution (attached), restore NuGet packages, open MyClass.cs, and use ReSharper's reformat feature.
System information:
- ReSharper Ultimate 2018.1 EAP 6 (Checked Build 112.0.20180402.185705-eap06)
- Visual Studio Professional 2017 (Version 15.6.5)