Resharper changes casing of Keywords: Bug or Feature?

Hello,

I hope this is the right place to post this, if not feel free to point me in the right direction :-)
Once in a while when I commit some changes into our repository I observe the following:

  • Resharper changes string.IsNullOrEmpty into String.IsNullOrEmpty
  • int.Parse to Int32.Parse
  • etc.


This happens to sections i definitely haven't touched. Of course this is annoying, changes in the code file show up where i didn't change anything. I couldn't identify yet, when exactly this happens...I don't do any mass operations like code cleanup, either.
I searched resharper's settings, the bugtracker and the internet, whether this is some feature, some bug, maybe some unknown key combination i'm accidentally pressing, but couldn't come up with a solution.
Do you know of any resharper setting/feature that does this or can tell me how i can prevent this from happening?

Greetings,
Michael

9 comments
Comment actions Permalink

Hello Jason
     ReSharper should not change code in such way. Could you please monitor this situation for some time and note which actions exactly lead to such changes?

Andrey Serebryansky

Senior Support Engineer

JetBrains, Inc

http://www.jetbrains.com

"Develop with pleasure!"

0
Comment actions Permalink

Hi Andrey,

sorry for the delay, christmas holiday ;-)
I will report back on that issue as soon as i have some more information. Of course tracking it down is pretty difficult, because it is such a small change (an "s" to an "S" in "String"...) and most of the time i only realyze it when i check in my changes. Maybe I'll use VS 2010 without ReSharper for a week, maybe it isn't RS fault after all...
But in general: You say ReSharper doesn't have a feature where it changes string to String and int to Int32 and such? Not in combination with some other code cleanup feature, reformatting or anything? If it doesn't have the possibility then maybe its VS 2010 itself after all...

Greetings,
Michael

0
Comment actions Permalink

Hello Jason
     Yes, ReSharper doesn't have a special functionality to change string to String etc during code cleanup or some refactoring. However, we'd really like to know if this behavior is caused by ReSharper, some other extension or Visual Studio itself, so please let me know if you'll find out more. Thank you!

Andrey Serebryansky

Senior Support Engineer

JetBrains, Inc

http://www.jetbrains.com

"Develop with pleasure!"

0
Comment actions Permalink

I'm seeing this same odd behavior in ReSharper 6.1 with VS 2008 SP1 that did not occur in  ReSharper 6.0:

string.Format(...............)

gets "magically changed" to:

String.Format(..............)


Is this an "Options" setting in ReSharper that can be adjusted or turned off or is this a genuine bug?

0
Comment actions Permalink

I haven't progressed in investigating the issue, but this is very interesting. I thought maybe it's some obscure feature of VS2010, but given you are using VS2008, it can't be...

0
Comment actions Permalink

Ah, finally I could reproduce the behavior! It occurs in context with the "move to another type" resharper command. In the following code example, if i move method ResharperTest from Class2 to Class1,all the calls to the String class in Class1.AnyMethod get converted from "string" to "String". See the second codeblock for the situation after the refactoring...
Should I open a bug for that? (Havent done that before)

public class Class1
    {
        public void AnyMethod()
        {
            string a = "hallo";
            string s = string.Format("blablub{0}", "hallo");
            if (string.IsNullOrEmpty(s) || string.IsNullOrEmpty(a))
            {
                Console.WriteLine(s);
                Console.WriteLine(a);
            }
        }
    }

    public class Class2
    {
        public void AnyMethod()
        {
            string a = "hallo";
            string s = string.Format("blablub{0}", "hallo");
            if (string.IsNullOrEmpty(s) || string.IsNullOrEmpty(a))
            {
                Console.WriteLine(s);
                Console.WriteLine(a);
            }
        }

        public static void ResharperTest()
        {
        }
    }


After Refactoring (notice differences in Class1.AnyMethod):

using System;
using System.Text.RegularExpressions;

namespace ClassLibrary1
{
    public class Class1
    {
        public void AnyMethod()
        {
            string a = "hallo";
            string s = String.Format("blablub{0}", "hallo");
            if (String.IsNullOrEmpty(s) || String.IsNullOrEmpty(a))
            {
                Console.WriteLine(s);
                Console.WriteLine(a);
            }
        }

        public static void ResharperTest()
        {
        }
    }

    public class Class2
    {
        public void AnyMethod()
        {
            string a = "hallo";
            string s = string.Format("blablub{0}", "hallo");
            if (string.IsNullOrEmpty(s) || string.IsNullOrEmpty(a))
            {
                Console.WriteLine(s);
                Console.WriteLine(a);
            }
        }
    }
}

0
Comment actions Permalink

Definitely looks like a bug to me. I've just reproduced it on a clean PC with no other extensions installed.

0
Comment actions Permalink

Hell Jason
     Thank you very much for the example! I was able to reproduce this behavior as well, so I've filed a bug-report: http://youtrack.jetbrains.com/issue/RSRP-289293 and you're welcome to vote for it.

Andrey Serebryansky

Senior Support Engineer

JetBrains, Inc

http://www.jetbrains.com

"Develop with pleasure!"

0
Comment actions Permalink

Still present in ReSharper 2016.1.2. It doesn't look like the bug has been touched :(.

0

Please sign in to leave a comment.