-
-
Notifications
You must be signed in to change notification settings - Fork 128
Closed
Labels
Milestone
Description
There appears to be an extra line break in nested switch expressions, as well as for all default branches
Input:
public class ClassName {
public bool Foo(object entry)
{
return entry switch
{
string s => s.Length switch
{
1 => true,
2 => false,
_ => throw new ArgumentOutOfRangeException("this specific string length is not supported"),
},
int i => i,
_ => throw new ArgumentOutOfRangeException($"entry type {entry.GetType()} not supported"),
};
}
}
Output:
public class ClassName
{
public bool Foo(object entry)
{
return entry switch
{
string s
=> s.Length switch
{
1 => true,
2 => false,
_
=> throw new ArgumentOutOfRangeException(
"this specific string length is not supported"
),
},
int i => i,
_
=> throw new ArgumentOutOfRangeException(
$"entry type {entry.GetType()} not supported"
),
};
}
}
Expected behavior:
public class ClassName {
public bool Foo(object entry)
{
return entry switch
{
string s => s.Length switch
{
1 => true,
2 => false,
_ => throw new ArgumentOutOfRangeException(
"this specific string length is not supported"
),
},
int i => i,
_ => throw new ArgumentOutOfRangeException(
$"entry type {entry.GetType()} not supported"
),
};
}
}