csharp_space_around_ternary_operator
Space around the ?/: of a ternary conditional expression.
| Value | Notes |
|---|---|
true |
|
false |
Default: true
Curb's output is not always a fixed point of the tool(s) below for this key — see conformance divergences for the full registry.
- dotnet-format-whitespace: csharp_space_around_ternary_operator is a ReSharper generalized key (space_around_ternary_operator) dotnet format does not recognise at all. Measured: dotnet format whitespace always normalises
x > 0?x:0back tox > 0 ? x : 0regardless of any .editorconfig setting — spacing around a ternary's ?/: is not configurable there. Setting the key to false is a permanent, structural divergence from dotnet format for any file containing a ternary expression. (SpacingTests.The_ternary_operator_can_lose_its_surrounding_space) - dotnet-format-whitespace: Same permanent divergence as SpacingTests.The_ternary_operator_can_lose_its_surrounding_space, exercised on a ternary long enough to wrap under max_line_length — the wrap point itself (a SoftLine) is unaffected by the option, only the flat spacing dotnet format keeps re-adding is. (
SpacingTests.A_wrapped_ternary_still_breaks_without_the_space) - ide0055: Same permanent divergence as the dotnet-format-whitespace entry above (a ReSharper-only key dotnet format has no concept of, so it always normalises the spacing back), now confirmed under a real
dotnet build -p:EnforceCodeStyleInBuild=trueas well as thedotnet format whitespaceCLI. (SpacingTests.The_ternary_operator_can_lose_its_surrounding_space) - ide0055: Same permanent divergence as SpacingTests.The_ternary_operator_can_lose_its_surrounding_space above, exercised on a wrapped ternary, now confirmed under a real
dotnet build -p:EnforceCodeStyleInBuild=trueas well as thedotnet format whitespaceCLI. (SpacingTests.A_wrapped_ternary_still_breaks_without_the_space)
csharp_space_around_ternary_operator = true
namespace N;
public class Widget
{
public int Clamp(int x)
{
return x > 0 ? x : 0;
}
}
namespace N;
public class Widget
{
public int Clamp(int x)
{
return x > 0 ? x : 0;
}
}
csharp_space_around_ternary_operator = false
namespace N;
public class Widget
{
public int Clamp(int x)
{
return x > 0 ? x : 0;
}
}
namespace N;
public class Widget
{
public int Clamp(int x)
{
return x > 0?x:0;
}
}