R# Code Cleanup breaks SA1019, SA1110 and SA1500

Jun 7, 2012 at 8:19 AM

I find Resharper 6.1.1000.82 code cleanup ends up on occasion breaking SA1019, SA1110 and SA1500 as it tries to insert line breaks for long lines of code.

For example it may leave the member access symbol (.) at the end of a line and place the member at the start of the next line, which violates SA1019: Invalid spacing around the member access symbol.

Or it may leave a method name at the end of a line and place the (); on the next line. which violates SA1110: The opening parenthesis or bracket must be placed on the same line as the name of the accessor.

And I've also seen it break SA1500: If a statement spans multiple lines, the opening curly bracket must be placed on its own line.

I can fix all these things manually but the next time Code Cleanup runs it's all broken again.

Is this something that can be fixed by the StyleCop for Reshareper plugin, or is this something I can configure in Resharper 6.1.1000.82, or is this something that requires a fix in Resharper itself?

Jun 7, 2012 at 5:04 PM

Hi. Please open a work item and attach a file that clearly repros the problem and I will fix it.

Jun 13, 2012 at 3:14 PM

very easy to demonstrate this problem. take a line like the following, complete with the initial spaces:

            modelBuilder.Entity<JobPacketEntity>().HasOptional(jp => jp.FieldTicket).WithRequired(c => c.JobPacket).WillCascadeOnDelete(true);

When R# wraps, it does this:
            modelBuilder.Entity<JobPacketEntity>().HasOptional(jp => jp.FieldTicket).
                WithRequired(c => c.JobPacket).WillCascadeOnDelete(true);

but it should do this:

            modelBuilder.Entity<JobPacketEntity>().HasOptional(jp => jp.FieldTicket)
                .WithRequired(c => c.JobPacket).WillCascadeOnDelete(true);
Jun 13, 2012 at 3:48 PM

Is this the StyleCop plugin or R# doing this? Turn off the plugin and reformat the line again to check.

Apr 1, 2013 at 11:37 AM
@andyr - Speaking specifically about SA1019, I am quite certain R# wraps the same way even without the plugin, but what I am interested in is if there is an option in R# that can be set to prevent this.
Apr 3, 2013 at 4:58 PM
There are changes in 7.1 for this. However there is no option in 6.1.