Visual studio 2010 + resharper bracket indentation problem
Asked Answered
T

1

8

I'm using VS 2010 + resharper, and i'm tired reformatting bracket indentation in code as i want it. As example if i have code like:

operators.Keys
    .ToList()
    .ForEach(k => filters
        .AddRange(CustomHtmlHelpers.GetIdAndValueListByPrefix(queryString, k)
            .Select(t => new QueryFilter()
            {
                Operation = operators[k],
                PropertyName = t.Item1,
                Value = t.Item2
            })))

And if i put ; in the end VS (or resharper) 'fixes' bracket indentation so code becomes like:

operators.Keys
    .ToList()
    .ForEach(k => filters
                        .AddRange(CustomHtmlHelpers.GetIdAndValueListByPrefix(queryString, k)
                                    .Select(t => new QueryFilter()
                                    {
                                        Operation = operators[k],
                                        PropertyName = t.Item1,
                                        Value = t.Item2
                                    })));

Same happens if i use resharper's code cleanup. I probably could turn off automatic code reformatting on ; but i need it in other situations. I tried changing code formating options both in VS and resharper setting but never got indentation as i want it.

How could i configure vs or resharper so that it would not do more than one tab formating? Or maybe there is other plugin i can use (together with r#) specificly for this purpose?

EDIT: for anyone interested in this problem here is same question in r# forum http://devnet.jetbrains.net/thread/304794 anyone who would like to see better nested code indentation from r# are welcome to vote for it here http://youtrack.jetbrains.net/issue/RSRP-88220

Talon answered 3/6, 2011 at 7:34 Comment(5)
Stop writing heavily nested code? Introduce smaller well named methods, explaining variables, and clearer return values.Parlous
@Ritch Melton i like it that way, i usually get less bugs if i write it in such way. This code snippet is from my current feature that i'm working on now, it didn't went through refactoring phase so please don't judge it.Talon
I tend to like code like this as well. This isn't the best example, but generally linked method calls LINQ style is more expressive and readable. At least to me. I guess it's a matter of taste and coding style.Niigata
At any rate he didn't ask for how to write code, he asked how to configure resharperHoof
if you are a paying customer of resharper, have you try seek solution from them?Peddling
T
1

just guessing...

go to ReSharper -> options -> Code Editing -> c# -> Formatting Style -> Other

Search in Align Multiline Constructs and try toggling the state of checkbox "Chained method calls" (I suppose your value is 'checked' for this checkbox).

if not this one, i expect that required setting is somewhere very near :-)

Teplitz answered 30/7, 2013 at 9:24 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.