Use object initialiser optimisation is not Style Cop Compliant

Consider the lines of C#
      var number = new NumberLiteral("number");
      number.DefaultIntTypes = new[] { TypeCode.Int32, TypeCode.Int64, NumberLiteral.TypeCodeBigInt };

Accepting the optimisation gives:
      var number = new NumberLiteral("number")
                     {
                       DefaultIntTypes = new[] {TypeCode.Int32, TypeCode.Int64, NumberLiteral.TypeCodeBigInt}
                     };

However it should be:
      var number = new NumberLiteral("number")
                     {
                       DefaultIntTypes = new[] { TypeCode.Int32, TypeCode.Int64, NumberLiteral.TypeCodeBigInt }
                     };
Note the space after the inner open brace and before the close open brace.

1 comment

Hello,

Have you tried turning on 'Within single-line initializer braces' option
under ReSharper | Options | Languages | C# | Code Style | Spaces? Thank you!

Andrey Serebryansky
Senior Support Engineer
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

Consider the lines of C#
var number = new NumberLiteral("number");
number.DefaultIntTypes = new[] { TypeCode.Int32, TypeCode.Int64,
NumberLiteral.TypeCodeBigInt };
Accepting the optimisation gives:
var number = new NumberLiteral("number")
{
DefaultIntTypes = new[] {TypeCode.Int32,
TypeCode.Int64, NumberLiteral.TypeCodeBigInt}
};
However it should be:
var number = new NumberLiteral("number")
{
DefaultIntTypes = new[] { TypeCode.Int32,
TypeCode.Int64, NumberLiteral.TypeCodeBigInt }
};
Note the space after the inner open brace and before the close open
brace.
---
Original message URL:
http://devnet.jetbrains.net/message/5301877#5301877



0

Please sign in to leave a comment.