简体   繁体   中英

Stylecop SA1001 warning

why does the following code give me a SA1001 warning?

Class test = new Test
{
    Test1 = "1"
    , Test2 = "2"
    , Test3 = "3"
};

I've checked documentation which says that to avoid this warning my commas should not be preceeded by a space unless they're the first thing on a line, and should have a space after them unless they're the last thing on the line, but this isn't getting rid of the warning. I don't want to supress the rule in general only in this specific case.

Your , are place wrongly. It should be like below; which will get rid off that said StyleCop error

Class test = new Test
{
    Test1 = "1",
    Test2 = "2",
    Test3 = "3", //also ends with another ,
};

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM