resharper

Remove redundant delegate constructor call?

痴心易碎 提交于 2019-12-03 11:22:01
I downloaded ReSharper and it is telling me to change this line: dispMap.OnDraw += new EventHandler(dispMap_OnDraw); To be this line: dispMap.OnDraw += dispMap_OnDraw; Because the first line is a "redundant delegate constructor call." Is this true? In the automatically generated designer code for forms the syntax is based on the first piece of code and when typing in dispMap.OnDraw += and hitting TAB the IDE automatically generates new EventHandler(dispMap_OnDraw) I'm just curious about this one. Does ReSharper have a point? Yes, this is correct. I have done this in several cases. The delegate

Autocompleting initializer with Resharper 6 in Visual Studio 2010

旧城冷巷雨未停 提交于 2019-12-03 11:14:35
I was wondering if there is any way to shortcut the process of object initialization with VS 2010 and Resharper (6). When presented with the yellow tool tip below I'd like to have it create an assignment for each field. For instance, it would generate: Contact = ; ContactId = ; CreateDate = ; etc, etc (one for each property). ReSharper code completion works exactly this way. As soon as you've typed in the braces, press Ctrl+Space to get the list of all properties: var data = new Data {|} Then, after entering a comma to delimit properties, ReSharper completion will only show properties that you

Compare string to null - Why does Resharper think this is always false?

前提是你 提交于 2019-12-03 11:10:17
I have this code in my custom MembershipProvider: public override void Initialize(string name, System.Collections.Specialized.NameValueCollection config) { if (config == null) throw new ArgumentNullException("config"); if (name == null) name = "MyCustomMembershipProvider"; ... } Resharper marks the second if-Statement and tells me, it would always evaluate to false. But why would this always evaluate to false? I could easily pass null to the method as a parameter. Is this a bug or is Resharper right here? PS 1: I use Resharper 6.1 PS 2: I know using string.IsNullOrEmpty() would be the way to

How can Resharper be made aware of the framework version?

邮差的信 提交于 2019-12-03 10:54:38
I am coding in VS2008 with Resharper 4.5.1, but the projects are set to target .NET Framework 2.0. Still, Resharper is making suggestions that are relevant to the .NET 3.5 framework. For instance, it tells me that I should be using collection initializers, etc... I've looked through the settings and can't seem to find the checkbox to tell it to give 2.0 specific advice. bdukes Select your project in the Solution Explorer and open the Properties tool window ( F4 in the standard keyboard layout or View > Properties Window after selecting the project). In the ReSharper section, there is a

Captilizing a name in a ReSharper template

ぐ巨炮叔叔 提交于 2019-12-03 10:38:44
Is there a way to create a template in ReSharper that capitalizes a name? For example I'd like to do something like this: private $type$ _$name$; public $type$ $uppercase_name$ { get { return _$name$; } set { _$name$ = value; } } So when I enter " city " for $name$ , $uppercase_name$ should automatically be " City ". Ok I did it: When adding a template, on the right there's a part where you can choose a macro. Click on " Choose Macro " for uppercase_name . Go to the end of the list. There's a macro called " Value of another variable with the first character in upper case ". Choose that. The

Resharper (Find and) fix all issues at once

最后都变了- 提交于 2019-12-03 10:26:54
问题 e.g. alt enter -> context menu -> Find all 'Redundant name qualifier' issues -> but now in the new window that lists all those issues in my project, is there a way to fix them all ? (rather than go through them individualy) ta. 回答1: For now, you have to go through the issues individually. There's an existing request to batch-apply fixes to all similar issues selected in the "Inspection Results" tool window. Code Cleanup does batch-remove certain issues in any given scope but it's quite

Performance concern when using LINQ “everywhere”?

我与影子孤独终老i 提交于 2019-12-03 09:59:48
After upgrading to ReSharper5 it gives me even more useful tips on code improvements. One I see everywhere now is a tip to replace foreach-statements with LINQ queries. Take this example: private Ninja FindNinjaById(int ninjaId) { foreach (var ninja in Ninjas) { if (ninja.Id == ninjaId) return ninja; } return null; } This is suggested replaced with the following using LINQ: private Ninja FindNinjaById(int ninjaId) { return Ninjas.FirstOrDefault(ninja => ninja.Id == ninjaId); } This looks all fine, and I'm sure it's no problem regarding performance to replace this one foreach. But is it

Is it possible to copy / paste References from one project to another in Visual Studio?

瘦欲@ 提交于 2019-12-03 09:52:28
Is there a way or tool that lets you to copy some references from one project and paste them to another -so that I do not bother my self again by using ADD REFERENCE? Yes, you could use the Power Commands extension to copy and paste references in VS2010. I had the same question in Visual Studio 2013 Preview. I couldn't find any "Power Commands" extensions yet, so I did it manually. Unload the source project. Edit Copy contents of tag tag that lists the tags. Unload the target project Edit Find the tag and paste Load the projects. Simple Solution - For External Libraries Click add references.

Add ReSharper_ToggleSuspended as toolbar button

丶灬走出姿态 提交于 2019-12-03 09:47:22
问题 I'd like to map the ReSharper_ToggleSuspended command to a button on a toolbar in VS 2012, but the command is not listed in the ReSharper category of Commands availabe in Customize > Commands dialog. Is there a way to do this? 回答1: Borrowed from the suggestion on the R# issue tracker for this issue. In the VS Package Manager Console, you can run these commands to add the ReSharper_ToggleSuspended command to an existing toolbar named "R#". $cmdBarName = "R#" $cmdName = "ReSharper

Break lines and wrapping in auto formatting of Visual Studio with ReSharper

我与影子孤独终老i 提交于 2019-12-03 09:18:42
I'm working in a C# project and using Visual Studio 2012. When Visual Studio tries to format my code, it breaks lines and make my code look difficult to read. The original code (what looks pretty nice to read for me and my team): if (list.Any(x => x.Type == (int) EnumType.Customer)) { } And when Visual Studio tries to format: if ( list.Any( x => x.Type == (int) EnumType.Customer)) { // Other break codes } There are a lot of other parts where it is breaking my code. I like auto formatting for some parts, but my question is: Is there a way to disable this break lines from auto formatting in