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
1470
votes
18 answers

Virtual member call in a constructor

I'm getting a warning from ReSharper about a call to a virtual member from my objects constructor. Why would this be something not to do?
JasonS
  • 23,480
  • 9
  • 41
  • 46
417
votes
9 answers

Handling warning for possible multiple enumeration of IEnumerable

In my code I need to use an IEnumerable<> several times, resulting in the ReSharper error of "Possible multiple enumeration of IEnumerable". Sample code: public List Foo(IEnumerable objects) { if (objects == null ||…
gdoron
  • 147,333
  • 58
  • 291
  • 367
415
votes
14 answers

Method can be made static, but should it?

ReSharper likes to point out multiple functions per ASP.NET page that could be made static. Does it help me if I do make them static? Should I make them static and move them to a utility class?
dlamblin
  • 43,965
  • 20
  • 101
  • 140
369
votes
13 answers

How can I disable ReSharper in Visual Studio and enable it again?

I installed ReSharper, and it works in Visual Studio, but how can I disable it? Whenever I search in the ReSharper menu, I can't find a disable option.
ali62b
  • 5,363
  • 4
  • 22
  • 25
360
votes
88 answers

Tests not running in Test Explorer

I am currently working on a solution that has currently 32 Unittests. I have been working with the resharper test runner - which works fine. All tests are running, all tests are showing the right test outcome. However, the tests are not running when…
ElGauchooo
  • 4,256
  • 2
  • 13
  • 16
338
votes
39 answers

Visual Studio displaying errors even if projects build

I have a problem with Visual Studio on a C# solution. It displays totally random errors, but the projects build. Right now, I have 33 files with errors, and I can see red squiggly lines in all of them. I tried cleaning / rebuilding the solution,…
Cydrick Trudel
  • 9,957
  • 8
  • 41
  • 63
326
votes
25 answers

Invert "if" statement to reduce nesting

When I ran ReSharper on my code, for example: if (some condition) { Some code... } ReSharper gave me the above warning (Invert "if" statement to reduce nesting), and suggested the following correction: if (!some…
Lea Cohen
  • 7,990
  • 18
  • 73
  • 99
323
votes
3 answers

Access to Modified Closure

string [] files = new string[2]; files[0] = "ThinkFarAhead.Example.Settings.Configuration_Local.xml"; files[1] = "ThinkFarAhead.Example.Settings.Configuration_Global.xml"; //Resharper complains this is an "access to modified closure" for (int i =…
Vyas Bharghava
  • 6,372
  • 9
  • 39
  • 59
310
votes
8 answers

LINQ: Not Any vs All Don't

Often I want to check if a provided value matches one in a list (e.g. when validating): if (!acceptedValues.Any(v => v == someValue)) { // exception logic } Recently, I've noticed ReSharper asking me to simplify these queries to: if…
Mark
  • 3,372
  • 2
  • 16
  • 14
303
votes
5 answers

Why does ReSharper tell me "implicitly captured closure"?

I have the following code: public double CalculateDailyProjectPullForceMax(DateTime date, string start = null, string end = null) { Log("Calculating Daily Pull Force Max..."); var pullForceList = start == null ?…
PiousVenom
  • 6,888
  • 11
  • 47
  • 86
290
votes
3 answers

Where do I mark a lambda expression async?

I've got this code: private async void ContextMenuForGroupRightTapped(object sender, RightTappedRoutedEventArgs args) { CheckBox ckbx = null; if (sender is CheckBox) { ckbx = sender as CheckBox; } if (null == ckbx) { …
284
votes
4 answers

ReSharper warns: "Static field in generic type"

public class EnumRouteConstraint : IRouteConstraint where T : struct { private static readonly Lazy> _enumNames; // <-- static EnumRouteConstraint() { if (!typeof(T).IsEnum) { throw new…
bevacqua
  • 47,502
  • 56
  • 171
  • 285
262
votes
17 answers

Resharper Alt Enter not working

Help, I can't function without Resharper. All of a sudden my Alt+Enter ↵ shortcut (to bring up the action list) has stopped working. Anybody experienced this or know how to fix?
JontyMC
  • 6,038
  • 6
  • 38
  • 39
260
votes
23 answers

Keyboard shortcuts are not active in Visual Studio with Resharper installed

I have Visual Studio 2012 + Resharper 7.1.1000.900 + StyleCop 4.7.44 installed. The problem is that no shortcuts are active since Resharper was installed. For example: I can still rename via 'Refactor > Rename'. But shorcut Ctrl+R does nothing. I…
Julia Meshcheryakova
  • 3,162
  • 3
  • 22
  • 42
231
votes
23 answers

Why does ReSharper want to use 'var' for everything?

I've just started using ReSharper with Visual Studio (after the many recommendations on SO). To try it out I opened up a recent ASP.NET MVC project. One of the first and most frequent things I've noticed it suggesting is to change most/all my…
Chris
  • 6,568
  • 3
  • 22
  • 21
1
2 3
99 100