Hi,
I couldn't find a way to make CodeRush format C# switch expression in an IMHO readable manner. What I get now:
C#Type pluginStartupType = pluginStartupTypes.Length switch
{
0 => throw new PluginLoadException(
$"Plugin \"{loadConfiguration.DllPath}\" does not contain an implementation of {nameof(IPluginStartup)}",
loadConfiguration.DllPath,
null),
1 => pluginStartupTypes[0],
_ => throw new PluginLoadException($"Multiple implementations of {nameof(IPluginStartup)} in \"{loadConfiguration.DllPath}\"", loadConfiguration.DllPath, null)
};
I'd prefer:
C#Type pluginStartupType = pluginStartupTypes.Length switch
{
0 => throw new PluginLoadException(
$"Plugin \"{loadConfiguration.DllPath}\" does not contain an implementation of {nameof(IPluginStartup)}",
loadConfiguration.DllPath,
null),
1 => pluginStartupTypes[0],
_ => throw new PluginLoadException(
$"Multiple implementations of {nameof(IPluginStartup)} in \"{loadConfiguration.DllPath}\"",
loadConfiguration.DllPath,
null)
};
or at least a way to configure CodeRush to leave my own manual formatting as I typed it.
TIA
Michael
Hi Michael,
Unfortunately, CodeRush Formatting doesn't support the C# 8.0 switch expression. We are familiar with the issue and we will try to fix it and support the C# 8.0 syntax for CodeRush formatting as soon as possible. We will notify you about this in this ticket.
As a workaround, you can disable the checkbox "CodeRush->Options->Editor->C#->Formatting->Wrapping->Arguments" and press the OK button. In this case, CodeRush formatting will not work for any arguments in your code.
We have fixed the issue. Please note that CodeRush Formatting options should be set as shown in the image below so that the fix works in the way you demonstrated in your latest code snippet.
Hi,
as always – an excellent answer to my request!
Thank you
Michael
You are welcome.