Weird spacing after formatting ternary operator
- Dominant language
- No language data
- Stars
- 1.9k
- Forks
- 173
- Avg merge
- 10d 13h
- Merged PRs (30d)
- 1
Description
This is with a C# project with LangVersion 10 using `dotnet-format` 7.0.321101.
.editorconfig
```
[*.{cs,cshtml,css,js,jsx,less,ts,tsx}]
indent_style = tab
[*.cs]
# Default to file-scoped namespaces
csharp_style_namespace_declarations = file_scoped:warning
```
C# file (before)
```
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Reflection;
using System.Runtime.CompilerServices;
namespace MyNamespace
{
internal class Repro
{
public void Method(bool condition, [CallerArgumentExpression("condition")] string message = "")
{
}
public string? Method1(string description, object arg, string expectedResult)
{
var result = arg is byte[]
? Convert.ToBase64String((byte[])arg)
: arg is IEnumerable
? string.Join(string.Empty, (IEnumerable)arg)
: arg is Type
? ((Type)arg).FullName
: null;
return result;
}
}
}
```
C# file (after):
```
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Reflection;
using System.Runtime.CompilerServices;
namespace MyNamespace
{
internal class Repro
{
public string? Method(string description, object arg, string expectedResult)
{
var result = arg is byte[]? Convert.ToBase64String((byte[])arg)
: arg is IEnumerable
? string.Join(string.Empty, (IEnumerable)arg)
: arg is Type
? ((Type)arg).FullName
: null;
return result;
}
}
}
```
Note the weird spacing around `arg is byte[]?`.
I'm running ` dotnet-format My.sln --diagnostics=IDE0161`
Yes, I know that this could be rewritten with pattern matching; I still think this is indicative of a bug in the formatter.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.