Questions tagged [resharper]

ReSharper is a refactoring and productivity extension by JetBrains that extends native functionality of Microsoft Visual Studio versions since 2003.

ReSharper is a productivity tool for Visual Studio that aims to improve the developer experience. Providing additional features for error correction, code completion, navigation, search, syntax highlighting, formatting and cleanup, code generation and optimization, it carries out a large number of automated refactorings and streamlines unit testing using NUnit, MSTest, xUnit.net, MSpec (via plugin), amongst other features (all without the need to compile).

Current ReSharper releases support Visual Studio 2010-2019; previous versions supported Visual Studio 2003-2008.

ReSharper currently supports C#, VB.NET, ASP.NET, ASP.NET MVC, Razor, TypeScript, JavaScript, CSS, HTML, XML, XAML, MSBuild and NAnt build scripts.

ReSharper's functionality can be significantly extended with its Open API. In fact, most of ReSharper's features are implemented using this same API that is available in ReSharper plugins.

4908 questions
129
votes
2 answers

Resharper- Find all unused classes

I know how to find unused references of a single file by right clicking on the file and selecting the "Find Usages" option. Is there any way I can see or get the list of all the unused classes or files in my project ?
Rocky Singh
  • 15,128
  • 29
  • 99
  • 146
127
votes
3 answers

"Delegate subtraction has unpredictable result" in ReSharper/C#?

When using myDelegate -= eventHandler ReSharper (version 6) issues: Delegate subtraction has unpredictable result The rational behind this is explained by JetBrains here. The explanation makes sense and, after reading it, I'm doubting all my uses…
user166390
124
votes
7 answers

'is' versus try cast with null check

I noticed that Resharper suggests that I turn this: if (myObj.myProp is MyType) { ... } into this: var myObjRef = myObj.myProp as MyType; if (myObjRef != null) { ... } Why would it suggest this change? I'm used to Resharper suggesting…
HotN
  • 4,216
  • 3
  • 40
  • 51
123
votes
7 answers

Visual Studio or Resharper functionality for placement of using directives

I like to put my using directives inside the current namespace, and not outside as VS and Resharper per default puts them. Does anyone know of a macro/standard functionality that sorts/removes unused using directives and puts them inside the current…
larsw
  • 3,790
  • 2
  • 25
  • 37
123
votes
7 answers

ReSharper Curiosity: "Parameter is only used for precondition check(s)."

Why is ReSharper judging me for this code? private Control GetCorrespondingInputControl(SupportedType supportedType, object settingValue) { this.ValidateCorrespondingValueType(supportedType, settingValue); …
Corpsekicker
  • 3,276
  • 6
  • 25
  • 34
118
votes
1 answer

How do you tell Resharper that a method parameter is a string containing a CSS class?

[Enable intellisense on HTMLHelper attribute for css classes] I have this HTMLhelper: public IHtmlString MyTextBoxFor( this HtmlHelper html, Expression> propertyExpression, string…
Raif Atef
  • 2,878
  • 1
  • 25
  • 31
116
votes
3 answers

Moq: Invalid setup on a non-overridable member: x => x.GetByTitle("asdf")

Not sure how I can fix this, trying to do a unit test on the method "GetByTitle" Here are my definitions: public class ArticleDAO : GenericNHibernateDAO(IArticle, int>, IArticleDAO { public IArticle GetByTitle(string title) { IQuery…
mrblah
  • 99,669
  • 140
  • 310
  • 420
115
votes
5 answers

Uninstall ReSharper 4.5

I have ReSharper 4.5 in Visual Studio 2008. Now I want to install ReSharper 5, but I can't do it before I uninstall ReSharper 4.5. How can I uninstall ReSharper 4.5?
114
votes
1 answer

Extract method to already existing interface with ReSharper

I'm adding a new method to a class that implements an interface, and I like to use the "Extract Interface" refactoring and just add the method to the interface. But it doesn't seem like ReSharper supports adding a method signature to an already…
Johan Danforth
  • 4,469
  • 6
  • 37
  • 36
107
votes
7 answers

ReSharper - force curly braces around single line

Can I configure ReSharper to fix C# code when curly braces are not used to surround a single-line code block, like this: if (blnSomeCondition) DoSomething(); // complain if (blnSomeOtherCondition) { DoSomethingElse(); // don't…
Booberry
  • 1,746
  • 2
  • 14
  • 17
107
votes
2 answers

Do I need to maintain ReSharper's dotsettings.user file in Source Control?

I noticed ReSharper has created a dotsettings.user in my Source folder. Do I need to keep this in my Source Control (TFS)? If I exclude it, what are the consequences? If I get latest on another machine, will my customized ReSharper settings be…
Shiva
  • 20,575
  • 14
  • 82
  • 112
101
votes
1 answer

Access to Modified Closure (2)

This is an extension of question from Access to Modified Closure. I just want to verify if the following is actually safe enough for production use. List lists = new List(); //Code to retrieve lists from DB foreach (string list…
faulty
  • 8,117
  • 12
  • 44
  • 61
100
votes
1 answer

How can I use ReSharper to list unused methods in a solution?

In a legacy ASP.NET project I have inherited, there are an abundance of methods defined which are used absolutely nowhere. I'm familiar with the "Find usages" functionality, but would like to be able to generate a list of methods which are not…
Micheal Wells
  • 1,149
  • 2
  • 8
  • 8
96
votes
8 answers

Advantages of using const instead of variables inside methods

Whenever I have local variables in a method, ReSharper suggests to convert them to constants: // instead of this: var s = "some string"; var flags = BindingFlags.Public | BindingFlags.Instance; // ReSharper suggest to use this: const string s =…
M4N
  • 94,805
  • 45
  • 217
  • 260
96
votes
2 answers

ReSharper Error: "The output has reached the limit and was truncated. To view the full output use 'Show Stack Trace in a new window' action."

When running unit tests in ReSharper, if the output is too long, it gives this error: The output has reached the limit and was truncated. To view the full output use 'Show Stack Trace in a new window' action. Update ReSharper fixed this issue in…
Contango
  • 76,540
  • 58
  • 260
  • 305