csharp_space_after_unary_operator
Space after unary minus/plus, logical not, and the unsafe pointer prefix operators. Not bitwise complement or prefix increment/decrement.
| Value | Notes |
|---|---|
true |
|
false |
Default: false
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_after_unary_operator is a ReSharper generalized key (space_after_unary_operator) dotnet format does not recognise at all. Measured: dotnet format whitespace always normalises
- x/+ x/! xback to-x/+x/!xregardless of any .editorconfig setting, since it has its own fixed, unconfigurable opinion here. Setting the key to true is a permanent, structural divergence from dotnet format for any file containing a unary expression — there is no shape Curb could pick that satisfies both dotnet format's fixed opinion and the key's own request at once. (SpacingTests.Unary_minus_plus_and_not_take_a_space_when_asked) - dotnet-format-whitespace: Same permanent divergence as SpacingTests.Unary_minus_plus_and_not_take_a_space_when_asked, exercised for the two unsafe pointer prefix operators (pointer indirection
*p, address-of&x) rather than unary minus/plus/not — dotnet format normalises* p/& xback to*p/&xjust as unconditionally. (SpacingTests.The_unsafe_pointer_prefix_operators_take_a_space_too) - 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 space back out), now confirmed under a real
dotnet build -p:EnforceCodeStyleInBuild=trueas well as thedotnet format whitespaceCLI. (SpacingTests.Unary_minus_plus_and_not_take_a_space_when_asked)
csharp_space_after_unary_operator = true
namespace N;
public class Widget
{
public int Negate(int x)
{
int a = -x;
bool b = !(x > 0);
int c = ~x;
return a + c;
}
}
namespace N;
public class Widget
{
public int Negate(int x)
{
int a = - x;
bool b = ! (x > 0);
int c = ~x;
return a + c;
}
}
csharp_space_after_unary_operator = false
namespace N;
public class Widget
{
public int Negate(int x)
{
int a = -x;
bool b = !(x > 0);
int c = ~x;
return a + c;
}
}
namespace N;
public class Widget
{
public int Negate(int x)
{
int a = -x;
bool b = !(x > 0);
int c = ~x;
return a + c;
}
}