new() or new () #937
Replies: 2 comments 1 reply
-
CodeMaid invokes Visual Studio's native formatting which I suspect is where this space is being removed. If you invoke Edit->Advanced->Format Document do you see the same behavior? Looking at the StyleCop documentation linked above it seems like it depends on the context of where it's being used:
|
Beta Was this translation helpful? Give feedback.
-
If i have the following code:
CodeMaid will change it to:
And invoking Format Document as you have mentioned changes the initial code to:
So it works the same as CodeMaid. Now I can see that in Microsoft Docs the new keyword for creating new objects omitting the type name is written without the space. It leads to the conclusion, that StyleCop's rules have not been updated to cover the case for this kind of usage of new operator introduced in C# 9.0 |
Beta Was this translation helpful? Give feedback.
-
Codemaid cleans my code to leave no space after a new keyword, but StyleCop suggests that there should be a space after the new keyword.
Which way is actually the preferred way? Or is this completely up to somebody's personal taste?
1 vote ·
Beta Was this translation helpful? Give feedback.
All reactions