resharper

T4MVC and Resharper Navigation

…衆ロ難τιáo~ 提交于 2019-12-05 17:02:12
I frequently use Resharper's 'Go to Declaration' (ctrl + b in the Resharper Default Keymapping) keyboard shortcut to help with navigation within VS2010. Before I included a reference to T4MVC in my application, I would use "string refrences" and Resharper would know where I 'meant' to go. For example: @Html.Partial("_Continents" ) When I would use ctrl+b on the string "_Continents" , Resharper knew I wanted to go to the partial view named _Continents.cshtml. Since I have started using T4MVC, the same snippet above could be written: @Html.Partial( MVC.CascadingDropDownLists.DropDownAjaxPost

Allow same-line empty methods in ReSharper

天涯浪子 提交于 2019-12-05 15:01:24
Is there a way to tell ReSharper to allow same-line brackets for empty methods and constructors? For example: MyConstructor(int x) : BaseConstructor(x) { } protected virtual void Foo() { } Should not be converted to: MyConstructor(int x) : BaseConstructor(x) { } protected virtual void Foo() { } In the first case, I don't need a method body, I simply supply the parent constructor with its arguments. In the second case, I define an "optional abstract" method by making it virtual that therefore doesn't require a body. Go to ReSharper -> Options... -> Code Editing -> C# -> Formatting Style ->

Resharper: “Property 'VS100COMNTOOLS' is not defined”

ぐ巨炮叔叔 提交于 2019-12-05 14:37:00
I get the above as an issue upon code inspection of an MSTest project. The issue relates to the .csproj itself. What does it mean? Do I need to do anything about it ? I know about the %VS100COMNTOOLS% environment variable, so I am guessing Resharper expects that path to be in the runtime environment of the project, and for some reason it's not ? 来源: https://stackoverflow.com/questions/4045780/resharper-property-vs100comntools-is-not-defined

Have ReSharper keep 'using System;' when optimizing usings

会有一股神秘感。 提交于 2019-12-05 13:28:41
问题 I was wondering if there is some option to keep ReSharper from removing just the using System; directive? Perhaps this is configurable somewhere? Also, is there a way to have ReSharper sort the remaining directives just as Visual Studio 2008 does it (alphabetically, I think)? Thanks. 回答1: Yes, there is such an option: ReSharper->Languages->C#->Namespace Imports. You can add namespaces,that should not be removed, as well as namespaces, that should always be imported. 回答2: Yes, in the options (

Wrapping multiple statements in braces

僤鯓⒐⒋嵵緔 提交于 2019-12-05 13:07:21
问题 Is there a keyboard shortcut in Visual Studio 2010 (I'm using ReSharper 6.1 also) that will allow me to surround a selected block of text with curly braces? I tried "Surround With..." (Ctrl+K, Ctrl+S), but I didn't see an option in the list to choose curly braces as the surrounding element. The common use case for this is that I'll have an if-statement like the following: if (conditional) statement1; // the rest of the program I'll realize that there are some additional tasks that need to be

C#: alternative to Resharper, C# version [duplicate]

随声附和 提交于 2019-12-05 13:04:59
This question already has answers here : What are some alternatives to ReSharper? [closed] (9 answers) Closed 6 years ago . It's not quite cheap for me (149 USD). I tried it and I loved it though. The most cool thing for me is refactoring to LINQ. So I was wondering if there is a cheaper alternative that can do that same - refactor my loops into smaller LINQ ones? DevXpress Refactor! Pro is similar, and is $99 per license. Telerik also makes a refactoring add-in, but it's more expensive ($199). If you qualify for an academic license, you can get ReSharper cheaper. They even offer free licenses

Is it possible to get Visual Studio or Resharper to highlight enum's with a different color?

岁酱吖の 提交于 2019-12-05 12:21:40
I think code would be more readable if it highlighted enums properties with a different color to class properties. For VS2010 / VS2013 / VS2015 / VS2017: Tools->Options->Environment->Fonts and Colors: Show Settings For Text Editor Display Items: User Types (Enums) Change Item Foreground You have to enable "Color identifiers" in ReSharper -> Options -> Code Inspection -> Settings . Then you can define the forground/background colors for Enum identifiers in Tools -> Options -> Environment -> Fonts and Colors (select "ReSharper Enum Identifier" in the "Display items" list. Note: this is for VS

What is the perfect way to write “return” in a method

风格不统一 提交于 2019-12-05 12:18:30
I don't like methods have several return lines. So I created a return value with string result - and in every condition I write result = something... But when I write "try-catch" mechanism, I have to set public string result . Because, if I return a result in try, compiler will launch error, and says not all codes have return value. If I write result = string.Empty to end of the method, resharper says, it's not reachable code. So, here an example, and here is my question; "What is the perfect way to write "return" in a method ?" public static string PingThatAddress(string hostAddress) { try {

Is it possible to use Rosyln or Resharper to detect possible DivideByZero cases?

核能气质少年 提交于 2019-12-05 11:57:05
I'm trying to determine if there's a programmatic way to check for possible DivideByZeroException in my codebase. My codebase includes a series of relatively simple to relatively complex formulas, approximately 1500 of them (and growing). When new formulas are written, care must be taken to ensure that division is done safely to avoid exceptions during processing of these formulas. E.g. decimal val1 = 1.1m; decimal val2 = 0m; var res = val1/val2; //bad var res = val2 == 0 ? 0 : val1/val2; //good Is there any way to use Roslyn or Resharper, or other tools to inspect my codebase and identify

ReSharper confused my visual studio - reset visual studio with defaults

China☆狼群 提交于 2019-12-05 11:47:13
I used ReSharper in order to do some tasks and after uninstalled it because it confused me (all the highlights ad the quick links.. I prefer the default behaveior of visual studio). After I uninstalled it - compilation errors that used to be underlined with red line now has no underline at all. How can I reset visual studio with the defauld behaveior? Try Tools > Import/Export Settings > Reset All Settings The ReSharper team has accounted for this use case for the last few versions (Wanting to run VS without R#) So for next time there's an easier way: Tools > Options > ReSharper > Suspend Info