Visual Studio ruleset for coding guidelines - review
Was wondering about a warning the current ruleset gives to developers. When we write following code:
if (foo)
CallBar();
We get a warning stating { } should not be omitted. But when we look at the ReadMe of the project ( https://github.com/Microsoft/UWPCommunityToolkit/blob/master/contributing.md ) we see that everything is referenced to the .Net foundation guidelines. Now, looking at those ( https://github.com/dotnet/corefx/blob/master/Documentation/coding-guidelines/coding-style.md ) we see that it's actually allowed to omit the brackets for one line code blocks.
We use Allman style braces, where each brace begins on a new line. A single line statement block can go without braces but the block must be properly indented on its own line and it must not be nested in other statement blocks that use braces
So just wondering if we could stop the warning.
I'm in favor of this change, but only when exiting the current block. Examples: Exiting a method:
if(condition) return;
Continuing or exiting a loop
if(condition) continue;
if(condition2) break;
Not to spawn of a new war of We do, You do... ( I always omit single line { } also for ForEach, For and If statements ) But IF you ref the .Net foundation guidelines, you should keep to those and not bloat up the warnings list.
We will discuss it with core team to see if we keep the warning or not :) thanks for reporting
TOTALY in favor ;)
I have found that when having unordered Namespaces, that when you Auto-order them, they get inserted below the namespace. Is that an issue with the Ruleset?
I have the exact issue that @WilliamABradley mentioned in previous comments in 2 of my previous PR's. Is this something to do with the rulesets itself?
#1812 should prevent the namespaces from being moved.
In terms of the original request of this issue, we will keep the warning for single line blocks as there is no way to selectively ignore only lines exiting the block.