Right Margin

Hi, I have been playing around with the option settings, namely: Code Style -> Line breaks and wrapping -> Right Margin.

I made this value really small and reformatted by whole project!

The problem is even if I put the value back to something reasonable, it will not correct the utter mess that I have now!!

Any way to correct this formatting automatically


Thanks for your help

Julian

12 comments
Comment actions Permalink

Which build number are you using?

--
Eugene Pasynkov
Developer
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"
"Julian" <supertramp1963@yahoo.co.uk> wrote in message
news:3912731.1171296038894.JavaMail.itn@is.intellij.net...

Hi, I have been playing around with the option settings, namely: Code
Style -> Line breaks and wrapping -> Right Margin.

>

I made this value really small and reformatted by whole project!

>

The problem is even if I put the value back to something reasonable, it
will not correct the utter mess that I have now!!

>

Any way to correct this formatting automatically

>
>

Thanks for your help

>

Julian



0
Comment actions Permalink

Eugene info requested:

#337 (2.5.337.0)

Julian

0
Comment actions Permalink

Hi I though I would restore a particularly large method that was all messed up. It turns out that there is a problem with the reformatting of this method.
This happens even when the right margin value is large.
I have attached a file that you can test, it will not compile by any means(does on my machine of course) but the effect is the same, gradually the formatting is getting worse and worse, like it's out of sink!

Hope this helps

I have attached the code style as well

Julian

Message was edited by:
Julian

Message was edited by:
Julian



Attachment(s):
Class1.cs
Code Style.xml
0
Comment actions Permalink


"Julian" <supertramp1963@yahoo.co.uk> schreef in bericht
news:3912731.1171296038894.JavaMail.itn@is.intellij.net...

Any way to correct this formatting automatically


Undo check out :)


0
Comment actions Permalink

Hi support, I really want to get some feedback on this issue before my trail period expires. I like ReSharper a lot but this problem is concerning me and would like to have your opinion on the formatting problem in the sample file and also the question of undoing Right Margin options first mentioned in my post.

Thank you

Julian

0
Comment actions Permalink

"Julian" <supertramp1963@yahoo.co.uk> wrote in message
news:9242742.1171443455681.JavaMail.itn@is.intellij.net...

Hi support, I really want to get some feedback on this issue before my
trail period expires. I like ReSharper a lot but this problem is
concerning me and would like to have your opinion on the formatting
problem in the sample file and also the question of undoing Right Margin
options first mentioned in my post.


Suggestion: why not fix the class first? You're not intending to keep that
huge if-else monstrosity, are you?

John


0
Comment actions Permalink

Agghhhhh. +1 for the refactor first comment :) :) :)

0
Comment actions Permalink

"James Hebben" <no_reply@jetbrains.com> wrote in message
news:23722039.1171460029243.JavaMail.itn@is.intellij.net...

Agghhhhh. +1 for the refactor first comment :) :) :)


I can't tell from your comment if you think my suggestion was a good one or
not.

I couldn't even look at that monster for long enough to get an idea of how
to characterize the formatting problem. I tried some minor refactoring, and
the OP may hit a few more ReSharper bugs - just the "introduce variable"
refactorings hit Out of Memory exeptions, but who could blame them? There
are over 20 duplicates of several simple expressions, all over the place.

If nothing else, use Surround With to throw some #region's around the
insides of the if's, so you can see the pattern:

if (.......)
{
#region Stuff
// stuff
#endregion
} else if (.......)
{
#region Stuff
// stuff
#endregion
}

Refactor out the duplicate expressions before using Extract Method on the
regions.

And I'm sure I don't need to tell anyone that the if-else's look like they
may be fairly complete, so maybe a two-dimensional array of delegates would
be an appropriate way to clarify the code.

John

P.S. There should be a penalty for anyone who posts code like that. My eyes
still hurt from reading it. ;)


0
Comment actions Permalink

OK guys I am feeling really bad now!

The code is a port from old code, it works and I have serious time constraints.

But agreed it needs refactoring, which now I will do, so may be I will not feel so stupid after!

Cheers

0
Comment actions Permalink

I thought your suggestion to refactor was a good one. My eyes just glazed over about half way through the code as I started laughing.

Not very fair of me though, laughing at some else's pain. So, Julian
didn't event write this stuff. That just makes it even harder to fix!

0
Comment actions Permalink

"James Hebben" <no_reply@jetbrains.com> wrote in message
news:5524875.1171465045852.JavaMail.itn@is.intellij.net...
>I thought your suggestion to refactor was a good one. My eyes just glazed
>over about half way through the code as I started laughing.
>

Not very fair of me though, laughing at some else's pain. So, Julian
didn't event write this stuff. That just makes it even harder to fix!


The nice thing about ReSharper is that it's pretty easy to fix this sort of
mess.

John


0
Comment actions Permalink

snip it works snip


Don't feel bad for having code like that. I have code resulting from years
of feature creep and time constraints that gives me the creeps when I open
the files. As long as it works, is contained in a class/method and is
readable/maintainable, I'd rather let the code stay untouched and instead
focus on issues that can increase revenue :)

Good luck!


0

Please sign in to leave a comment.