resharper

modified closure warning in ReSharper

时光总嘲笑我的痴心妄想 提交于 2019-12-20 01:38:28
问题 I was hoping someone could explain to me what bad thing could happen in this code, which causes ReSharper to give an 'Access to modified closure' warning: bool result = true; foreach (string key in keys.TakeWhile(key => result)) { result = result && ContainsKey(key); } return result; Even if the code above seems safe, what bad things could happen in other 'modified closure' instances? I often see this warning as a result of using LINQ queries, and I tend to ignore it because I don't know what

How do i automate adding a “using” statement to every files in a folder, namespace or project with Visual Studio 2005 / resharper

最后都变了- 提交于 2019-12-19 16:55:16
问题 I am using resharper to do a big refactoring and i keep going from file to file and adding the same namespace over and over again in the "using" section is there anyway to add a "using" statement to every single file in a folder, namespace or project? Even though some files wont need the reference, most do, so it will save lots of time. 回答1: I'd try a regex in the "Find and Replace" dialog: Replace ^using System;$ with using System;\nusing xxx; This works only for files using the System

Make ReSharper respect your preference for code order

强颜欢笑 提交于 2019-12-19 10:54:10
问题 Related to my other question: What's the best way to layout a C# class? Is there a way in ReSharper to define the order you want your members to be in, so that ReSharper will maintain it? 回答1: From this answer: Check under Type Members Layout in Options (under the C# node). It's not simple, but it is possible to change the layout order. 来源: https://stackoverflow.com/questions/603805/make-resharper-respect-your-preference-for-code-order

C# Is this initialiser really redundant?

自闭症网瘾萝莉.ら 提交于 2019-12-19 10:26:38
问题 I have the following line of code: var dmrReceived = new DownloadMessagesReport(); StyleCop and ReSharper are suggesting I remove the redundant initializer. However if I replace it with DownloadMessagesReport dmrReceived; surely this will generate an object reference not set to an instance of an object? I am using .NET 3.5. Do you no longer manually have to instantiate objects? Next line that follows is: dmrReceived = dc.DownloadNewMessages(param, param2, param3); It's worth noting that dc is

Call is ambiguous error using Linq

我怕爱的太早我们不能终老 提交于 2019-12-19 07:18:27
问题 First of all, sorry for excesive generic name classes. My employer is paranoid and I know for sure he roams this site. Ok, so I have this code: var fooObj = new MyFooClass() { fooField1 = MyEnum.Value3, fooField2 = false, fooField3 = false, fooField4 = otherEntity.OneCollection.ElementAt(0) as MyBarClass } where otherEntity.OneCollection is an ISet. ISet is a NHibernate collection class that implements IEnumerable. If I try to compile this code I get this error: Error 2 The call is ambiguous

Call is ambiguous error using Linq

我怕爱的太早我们不能终老 提交于 2019-12-19 07:18:20
问题 First of all, sorry for excesive generic name classes. My employer is paranoid and I know for sure he roams this site. Ok, so I have this code: var fooObj = new MyFooClass() { fooField1 = MyEnum.Value3, fooField2 = false, fooField3 = false, fooField4 = otherEntity.OneCollection.ElementAt(0) as MyBarClass } where otherEntity.OneCollection is an ISet. ISet is a NHibernate collection class that implements IEnumerable. If I try to compile this code I get this error: Error 2 The call is ambiguous

Visual Studio 2012: List of all Methods in class

前提是你 提交于 2019-12-19 06:54:11
问题 In VS 2010, is there a way to see all the Methods in a docked window for the currently viewed class. Clicking the method would let me navigate to it. This question is for design mode, while editing a class in the IDE. I own Resharper, but don't see a way to see all the methods in a nice list as a feature. 回答1: View -> Class View or Ctrl + Shift + C You see the different classes on the top panel and the methods on the bottom panel. Also, you have the method list on the top part of your tab:

Using IReadOnlyCollection<T> instead of IEnumerable<T> for parameters to avoid possible multiple enumeration

你说的曾经没有我的故事 提交于 2019-12-19 05:35:08
问题 My question is related to this one concerning the use of IEnumerable<T> vs IReadOnlyCollection<T> . I too have always used IEnumerable<T> to expose collections as both return types and parameters because it benefits from being both immutable and lazily executed. However, I am becoming increasingly concerned about the proliferation of places in my code where I must enumerate a parameter to avoid the possible multiple enumeration warning that ReSharper gives. I understand why ReSharper suggests

Using IReadOnlyCollection<T> instead of IEnumerable<T> for parameters to avoid possible multiple enumeration

耗尽温柔 提交于 2019-12-19 05:35:08
问题 My question is related to this one concerning the use of IEnumerable<T> vs IReadOnlyCollection<T> . I too have always used IEnumerable<T> to expose collections as both return types and parameters because it benefits from being both immutable and lazily executed. However, I am becoming increasingly concerned about the proliferation of places in my code where I must enumerate a parameter to avoid the possible multiple enumeration warning that ReSharper gives. I understand why ReSharper suggests

Resharper 8.1 Test Runner slowing down Visual Studio Text Editing

坚强是说给别人听的谎言 提交于 2019-12-19 05:33:11
问题 I've got a fairly small C# solution with about 5 projects in it. I am using Visual Studio 2012 with Update 4, and Resharper 8.1 (build 8.1.23.546). It's on an I7 with an SSD and 16GB RAM, with oodles of disk space. Performance on this machine is fantastic for everything else. I have R# set to be my unit test runner, and I've noticed that as soon as I run any unit tests (one or many, pass or fail, makes no difference), the Visual Studio text editor becomes almost unusable. Typing into the