resharper

Resharper closing parenthesis indentation on function with multiple arguments

▼魔方 西西 提交于 2019-11-29 12:43:33
问题 I have some lines of code in c# that Resharper indents like this: Console.WriteLine("Hello"); this.MySuperFunction( argument1, argument2, argument3 ); Console.WriteLine("World"); Due to my personal coding style, I would like the above to appear with the closing parenthesis (or brace) without any indentation, like so: Console.WriteLine("Hello"); this.MySuperFunction( argument1, argument2, argument3 ); Console.WriteLine("World"); I tried playing with the various options on Resharper, but couldn

Resharper custom search pattern to warn IDisposable objects

旧城冷巷雨未停 提交于 2019-11-29 12:18:09
Since resharper still doesn't give out any warning regarding objects implementing IDisposable, I'd like to create some custom search patterns available in resharper 5.0. So far I have this: (And don't mind my replace comments in the patterns, I don't really care about it, I just want a clear warning in the code when dealing with disposable objects.) - <CustomPatterns> - <Pattern Severity="WARNING"> <Comment>This class implements IDisposable interface.</Comment> <ReplaceComment>Please use Using statement, or dispose the object manually when done using.</ReplaceComment> <SearchPattern>$type$<

NullReferenceException with object initializer suggested by resharper

只愿长相守 提交于 2019-11-29 12:08:41
I have a strange issue with the object initializer syntax. Here are my sample classes: public class Foo { public Bah BahProp { get; set; } } public class Bah { public int Id { get; set; } } Consider following three ways to initialize an object: The old, verbose but explicit way, working correctly: var foo1 = new Foo(); foo1.BahProp = new Bah(); foo1.BahProp.Id = 1; // correctly initialized The second way i'm always using, using object initializer syntax: var foo2 = new Foo { BahProp = new Bah { Id = 1 } }; // correctly initialized A third way resharper has suggested my collegue with a

Solving the 'Virtual method call in constructor' issue

痴心易碎 提交于 2019-11-29 11:50:36
问题 I am making a software in c#. I am using an abstract class, Instruction , that has these bits of code: protected Instruction(InstructionSet instructionSet, ExpressionElement newArgument, bool newDoesUseArgument, int newDefaultArgument, int newCostInBytes, bool newDoesUseRealInstruction) { //Some stuff if (DoesUseRealInstruction) { //The warning appears here. RealInstruction = GetRealInstruction(instructionSet, Argument); } } and public virtual Instruction GetRealInstruction(InstructionSet

How to get multiline TODO's in Resharper 8

Deadly 提交于 2019-11-29 11:43:26
问题 I have be trying to figure out how to change the regular expression in the Options -> To-Do's in resharper to color code and allow for multiple lines in a todo. Any Ideas? 回答1: I figured out the answer, easier than I thought Orignal regex for todo's in resharper (?<=\W|^)(?TODO)(\W|$)(.*) It is possible to do this using just regex... Go into Resharper -> Options -> To-Do Items and change the existing regex to (?s)(?<=\W|^)(?<TAG>TODO)(\W|$)(.*) The (?s) option allows for mutliline TODO's The

How do I tell ReSharper that an attribute means that a method is used?

╄→尐↘猪︶ㄣ 提交于 2019-11-29 10:49:06
问题 I'm playing with SpecFlow, and ReSharper thinks that my step definitions are unused (I guess because they're used via reflection): [Binding] public class StepDefinitions { // ... [When(@"I press add")] public void WhenIPressAdd() // R# thinks this is unused { _calculator.PressAdd(); } // ... } How can I tell ReSharper that methods with [Given] , [When] , [Then] attributes (etc.) are actually used? I don't want to use // ReSharper disable UnusedMember.Global comments. I could also mark each

How to stop ReSharper removing spaces in object initializer

独自空忆成欢 提交于 2019-11-29 10:36:49
问题 I like my object initializers to look like this: new Point { Label = g.Key.Name, Claims = g }; When hit the semicolon key, they get reformatted like this: new Point {Label = g.Key.Name, Claims = g}; Where is the option to stop my padding from being removed? 回答1: For R# 7, I can get this to vary by going to 1 ReSharper | Options | Code Editing | C# | Formatting Style | Spaces and toggling Other | Within single-line initializer braces the example for which is int[] x = new int[] {0, 1, 2};

Completely Disable Formatting and Completion in ReSharper for Visual Studio

泄露秘密 提交于 2019-11-29 10:33:23
问题 I like a lot of the features that ReSharper offers, but I absolutely can't stand the formatting and code completion it does. It trips me up every step of the way. In javascript it's constantly stealing braces attempting to reformat my code making it not work, and hard to find where pieces are missing. I would like to disable everything to do with ReSharper's formatting and code completion while still getting the benefits of the cool navigation stuff it has. Is there anyway to do a selective

Coloring instance variables in Visual Studio

限于喜欢 提交于 2019-11-29 09:15:09
Is it possible to color instance (and static) variables in C# code in Visual Studio 2010, perhaps using a lightweight extension? In following example name and age should be colored but test not. Of course, usages of variable highlighting is grat feature but this is something different. I want instance variables to be colored all and always. Many people use _underscores to distinguish instance variables but I prefer to use coloring. public class Kid { private string name; private int age; public Kid() { name = "N/A"; string test = "XYZ"; } } Reed Copsey This is not possible directly with Visual

Why does resharper say 'Catch clause with single 'throw' statement is redundant'?

二次信任 提交于 2019-11-29 09:10:01
I thought throwing an exception is good practice to let it bubble back up to the UI or somewhere where you log the exception and notify the user about it. Why does resharper say it is redundant? try { File.Open("FileNotFound.txt", FileMode.Open); } catch { throw; } Because try { File.Open("FileNotFound.txt", FileMode.Open); } catch { throw; } is no different than File.Open("FileNotFound.txt", FileMode.Open); If the call to File.Open(string, FileMode) fails, then in either sample the exact same exception will find its way up to the UI. In that catch clause above, you are simply catching and re