How to separate multiple declarations in C#? ("var a, b, c;")

Very recently it seems like ReSharper no longer supports inspecting for, and code cleanup of, multiple declarations in a single statement in C#. "var a, b, c;"

Was this intentionally removed from ReSharper, or did something change in how we are supposed to configure things?


Comment actions Permalink

Hello Brian!


Thank you for contacting us.

The specified inspection is available in the latest ReSharper 2017.2.1 version.

Could you please provide some screenshot illustrating its absense?

Thank you.

Comment actions Permalink

I don't see it as an INSPECTION for C#, nor available within CODE CLEANUP. But under CONTEXT ACTIONS I do see "Split declaration list" which appears to be what I am looking for. This does work.

However, I thought in previous releases that CODE CLEANUP would apply this (optionally), and that there would be a red-squiggly indication of violations (if configured as ERROR).

It would take about a dozen or so screenshots to send you what I found searching for MULTIPLE, DECLARATION, SEVERAL, SPLIT, etc. which is too much for this medium. But if there is an INSPECTION or CODE CLEANUP rule that would report or fix this automatically, please post a link to the relevant documentation. Or perhaps post the relevant lines that could be in the DotSettings file.

Again I am looking for INSPECTION or CODE CLEANUP settings that report the multiple "int" declarations in this example as ERROR, and will automatically cleanup via CTRL+E+C:

        protected static int _next;

        private static void ReSharperMultipleDeclarations ( )
            int a = _next++,
                b = _next++,
                c = _next++;
            Console.WriteLine ( $"{a}, {b}, {c}" );





Please sign in to leave a comment.