ReSharper inserts Space after Cast when creating array with collection expression

I was writing this piece of code:
var list = (double[])[1, 2, 3, 4];

but after reformatting with ReSharper it inserted a space after the cast:
var list = (double[]) [1, 2, 3, 4];

This is a violation against the StyleCop configuration and also against the styles we've set in the editorconfig:

csharp_space_before_open_square_brackets = false
csharp_space_before_array_access_brackets = false
csharp_space_after_cast = false

Is this a bug in the ReSharper Formater or have I overlooked an editorconfig setting

 

0
5 comments
Hello,
thank you for contacting us.
Please look at the following setting: ReSharper | Options | Code Editing | C# | Formatting Style | Braces Layout | Expressions (initializers, switch expressions, patterns, collections expressions). Try to set it up to "At the end of line (no space)".
Thank you!
0

I just tried that and it works for this specific case, but it also causes this syntax in a different place:
List<int> a =[1, 2, 3, 4, 5];

See there is now no Space between the equals sign and the braces, which is again a violation of the StyleCop configuration.

Why does the Formatter not follow those rules which I've set and clearly define what I want the formatter to do?

csharp_space_before_open_square_brackets = false
csharp_space_before_array_access_brackets = false
csharp_space_after_cast = false

0

I'm on the latest Version of ReSharper:

0
Hello,
thank you for the answer.
It looks like you were faced with this issue: https://youtrack.jetbrains.com/issue/RSRP-497284/Editorconfig-csharpnewlinebeforeopenbrace-conflicts-with-csharpspaceaftercast
It is not fixed yet.
We are sorry for the inconvenience.
0

Please sign in to leave a comment.