Space after if statement.

I've suffered this problem for a long time but today I found an answer. In VS' options, look under Text Editor > C# > Formatting > Spacing. There's a tickbox under "Set other spacing options" called "Insert space after keywords in control flow statements". My setting was ticked. I unticked this and, voila, the long-term problem where a space always appeared between an "if" and it's bracket is now fixed. If I copy and paste an "if" block, the reformatting also no longer inserts a space.

Now, compare that to RS' (8.2 installed) option under Code editing > C# > Formatting Style > Spaces > Before Parentheses. My "if parentheses" setting is not checked. The code fragment at the bottom shows the expected effect that RS should produce.

The question is, who has precedence? VS? RS? I was under the impression that any settings I use in RS' options took precedence over any VS equivalent. Is that correct? If it is, why does VS' setting override RS'?

If it isn't and VS' setting is ticked and I set RS' setting to unticked why can't RS display a message on the lines of "You don't want a space to appear between an if and it's opening bracket but we thought you'd like to know that VS is going to do just that."

Maybe I've missed the point or I've missed something because VS and RS can't both be right when the settings conflict. Could someone from the JB team explain it to me? I've lived with this problem for a few years now so if I have to wait another week or month for a definitive explanation, I have time on my hands.:^O

Please sign in to leave a comment.