resharper

ReSharper formatting: align equal operands

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-26 12:31:09
问题 Note to Googlers , this question is somewhat out of date as the requested feature is now supported in the current version of ReSharper 2017.3.1 I like to formatting my code to align right side of equal operands. Like here: bool canRead = false; bool canReadClass = true; string className = boType.Name; I\'ve switch to ReSharper recently and found it very useful but cannot find option allowing me format code in described way. Do you know if there is such option / plugin? Maybe you know other

Custom Brace formatting with Resharper

随声附和 提交于 2019-11-26 11:53:50
问题 I\'m using Resharper 4.5 and I need custom formatting of braces when writing an array or object initializer. Resharper supports some styles: Gnu Style: int[] array = new int[] { 1, 2, 3 } but I need: int[] array = new int[] { 1, 2, 3 } Is there any way to customize this templates? 回答1: You can customize ReSharper to do just that, you'll need to do the following (All in ReSharper -> Options -> C# -> Formatting Style ): In Braces Layout , set Array and object initializer to At Next line (BSD

String Interpolation vs String.Format

∥☆過路亽.° 提交于 2019-11-26 11:00:03
问题 Is there a noticable performance difference between using string interpolation: myString += $\"{x:x2}\"; vs String.Format()? myString += String.Format(\"{0:x2}\", x); I am only asking because Resharper is prompting the fix, and I have been fooled before. 回答1: Noticable is relative. However: string interpolation is turned into string.Format() at compile-time so they should end up with the same result. There are subtle differences though: as we can tell from this question, string concatenation

ReSharper complains when method can be static, but isn't

孤者浪人 提交于 2019-11-26 09:31:25
问题 Why does ReSharper complain when a method can become static, but is not? Is it because only one instance of a static method is created (on the type) and thus save on performance? 回答1: I find that comment very useful as it points out two important things: It makes me ask myself if the method in question should actually be part of the type or not. Since it doesn't use any instance data, you should at least consider if it could be moved to its own type. Is it an integral part of the type, or is

ReSharper conventions for names of event handlers

好久不见. 提交于 2019-11-26 09:24:37
问题 When I add new event handler for any event, VS creates method like object_Click . But ReSharper underlines this method as Warning, because all methods should not have any delimeters such as \"_\". How can I customize rules of ReSharper so that it doesn\'t underline such methods? Or may be I should rename such methods? Thanks in advance. 回答1: Personally, I'd suggest renaming the methods. Generally I think VS comes up with terrible names for both controls and events. I prefer to make a method

Why is '397' used for ReSharper GetHashCode override?

自作多情 提交于 2019-11-26 09:16:35
问题 Like many of you, I use ReSharper to speed up the development process. When you use it to override the equality members of a class, the code-gen it produces for GetHashCode() looks like: public override int GetHashCode() { unchecked { int result = (Key != null ? Key.GetHashCode() : 0); result = (result * 397) ^ (EditableProperty != null ? EditableProperty.GetHashCode() : 0); result = (result * 397) ^ ObjectId; return result; } } Of course I have some of my own members in there, but what I am

ReSharper and var [duplicate]

倖福魔咒の 提交于 2019-11-26 09:09:31
问题 Possible Duplicate: Why does ReSharper want to use 'var' for everything? I have ReSharper 4.5 and have found it invaluable so far but I have a concern; It seems to want to make every variable declaration implicit (var). As a relatively new developer, how much should I trust ReSharper when it comes to this? Take the below code snippet from a method that Paints Tab Headers. TabPage currentTab = tabCaseNotes.TabPages[e.Index]; Rectangle itemRect = tabCaseNotes.GetTabRect(e.Index); SolidBrush

How do I generate a constructor from class fields using Visual Studio (and/or ReSharper)?

落爺英雄遲暮 提交于 2019-11-26 07:25:40
问题 I\'ve gotten accustomed to many of the Java IDEs (Eclipse, NetBeans, and IntelliJ IDEA) providing you with a command to generate a default constructor for a class based on the fields in the class. For example: public class Example { public decimal MyNumber { get; set; } public string Description { get; set; } public int SomeInteger { get; set; } // ↓↓↓ This is what I want generated ↓↓↓ public Example(decimal myNumber, string description, int someInteger) { MyNumber = myNumber; Description =

ReSharper Warning - Access to Modified Closure

为君一笑 提交于 2019-11-26 06:47:35
问题 I have the following code: string acctStatus = account.AccountStatus.ToString(); if (!SettableStatuses().Any(status => status == acctStatus)) acctStatus = ACCOUNTSTATUS.Pending.ToString(); Note that account.AccountStatus is an enum of type ACCOUNTSTATUS. On the second line, ReSharper is giving me the warning \"Access to Modified Closure\" for acctStatus. When I do the recommended operation, Copy to local variable , it modifies the code to the following: string acctStatus = realAccount

How do you find all implementations of an interface?

旧街凉风 提交于 2019-11-26 06:36:58
问题 Suppose you have an interface defined in C#. What is the easiest method to find all classes that provide an implementation of the interface? The brute force method would be to use \"Find References\" in Visual Studio and manually look through the results to separate out the usages from the implementations, but for an interface in a large codebase that is heavily referenced with relatively few implementations, this can be time consuming and error prone. In Java, running javadoc on the codebase