Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can ReSharper use keyword for declarations but type name for member access?

Tags:

c#

resharper

ReSharper has features that look for inconsistencies in the use of keywords aliasing a type name. For example, it would see these two declarations and urge you to change one to be like the other (depending on which is set as your preference):

string myString1 = "String 1";
String myString2 = "String 2";

This is handy, because I always prefer using the keyword alias for the CLR types when declaring variables, and thus in the above example, I would want to correct the second line. However, this is also problematic because when using static members of the CLR types, I always prefer to use the type names and NOT the keywords. Consider the below example:

string myString1 = "String 1";
string myString2 = String.Format("{0} is String 1.", myString1);

If the option is set to prefer using the keyword, then ReSharper does not complain about the declarations, but it DOES complain about using the type name to access the static String.Format() method.

So, my question is... Is there any way to configure ReSharper such that it will prefer keywords for declarations but type names for static member access? In other words, can I configure it to not complain about any of the code in my second example above.

like image 825
bubbleking Avatar asked May 08 '15 20:05

bubbleking


2 Answers

As of R# 2018.2, this is now possible:

enter image description here

like image 170
Lennart Avatar answered Nov 01 '22 17:11

Lennart


Well, you can`t do that on ReSharper, it is already suggested, as in your post comments, in here. Anyways, the best thing you can do is ignoring it, i made a gif for it. (Please, ignore other codelines in the gif). I'm using ReSharper 9.1.3, FSF Licensed. I hope this helps.

like image 21
TheCrimulo Avatar answered Nov 01 '22 16:11

TheCrimulo