你用ReSharper做什么?

时间:2022-03-10 21:04:58

I'm in the middle of an ASP.NET MVC project and recently installed the free trial of ReSharper 4.5. Immediately I realized the benefits, simply because of the refactoring it wanted me to do.

我在ASP中。NET MVC项目,最近安装免费试用ReSharper 4.5。我立刻意识到它的好处,仅仅是因为它要我做的重构。

Things like inverting if statements to reduce nesting, changing some of my if/else statements that were returning Views to ?/?? operators - drastically reduced the number of lines of code in my application.

比如反转if语句以减少嵌套,改变将视图返回到?/?的if/else语句。操作符——大大减少了应用程序中的代码行数。

The capability of performing a null reference check from a single click, removing unused directives/variables or removing redundant code (calling .ToString() when it wasn't necessary). Or, that it can see into my views to let me know I'm accessing a property that no longer exists, makes solution-wide renames more thorough... really saves a lot of time.

从一次单击执行空引用检查、删除未使用的指令/变量或删除不必要的冗余代码(调用. tostring())的功能。或者,它可以看穿我的视图,让我知道我正在访问一个不再存在的属性,从而使解决方案范围内的重命名更彻底……真的可以节省很多时间。

But I get the feeling that I'm only seeing the tip of the iceberg. So I ask this:

但我觉得我只是看到了冰山的一角。所以我问:

What do YOU use ReSharper for? Anything beyond the immediate benefits I described above?

你用ReSharper做什么?除了上面所描述的直接好处之外,还有什么其他的吗?

7 个解决方案

#1


12  

ReSharper provides a huge set of tools beyond the simple refactorings it suggests. In addition to providing additional code auto-formatting capabilities, ReSharper provides an integrated unit test runner that works with all of the known unit-test frameworks (such as NUnit, MBUnit, and my personal favorite, XUnit.NET). ReSharper also provides a very powerful template-based code generation platform that can improve your productivity by leaps and bounds.

ReSharper提供了大量的工具,而不仅仅是简单的重构。除了提供额外的代码自动格式化功能之外,ReSharper还提供了一个集成的单元测试运行器,它与所有已知的单元测试框架(比如NUnit、MBUnit和我个人最喜欢的XUnit.NET)一起工作。ReSharper还提供了一个非常强大的基于模板的代码生成平台,这可以大大提高你的效率。

For a full list of all the capabilities ReSharper can offer you, check here:

关于ReSharper提供的所有功能的完整列表,请点击这里:

http://www.jetbrains.com/resharper/features/index.html

http://www.jetbrains.com/resharper/features/index.html

#2


4  

What don't I use it for is more like it. Here's a shortlist of my most often-used shortcuts:

我不使用它的原因更像是它。下面是我最常使用的快捷方式列表:

  • Running unit tests. Their GUI unit test runner is awesome (sort by project/namespace is great), and I shortcut Alt+X to run a test.

    运行单元测试。他们的GUI单元测试运行器非常棒(按项目/名称空间排序很好),我使用Alt+X快捷方式运行测试。

  • Adding a class for unit tests, templated out with live templates

    为单元测试添加一个类,用活动模板进行模板化

  • Multiple custom livetemplates for filling in code, especially complex attributes

    用于填充代码的多个自定义live模板,特别是复杂的属性。

  • Weeding dead code on our enterprise codebases

    在企业代码库中清除无用代码

  • Converting properties to auto-properties

    将属性转换为自动属性

  • Combining variable declarations with their setup code

    将变量声明与它们的设置代码组合在一起

  • Making methods static that can and should be static

    使方法保持静态,可以并且应该保持静态

  • Looking at the pre-compilation errors/warnings bar saves me tons of time

    查看预编译错误/警告栏可以节省大量时间

  • StyleCop for ReSharper puts all my styling warnings inline for me.
  • ReSharper StyleCop为我嵌入了所有的样式警告。

Pretty much most of these are done with just Alt+Enter. The time saved is incalculable.

大部分都是通过Alt+Enter完成的。节省的时间是无法计算的。

#3


3  

Geez, where to begin?

天啊,从哪里开始?

  • Refactoring.
  • 重构。
  • Code formatting.
  • 代码格式化。
  • Code templates.
  • 代码模板。
  • Marker bar (the red/yellow/green stripes in the sidebar to show code warnings).
  • 标记条(工具条中的红色/黄色/绿色条纹显示代码警告)。
  • Highlighting of unused code.
  • 高亮显示未使用的代码。
  • Code generation.
  • 代码生成。
  • Shortcuts to save typing (for example, Alt + Enter to remove unneeded braces, change visibility, etc.)
  • 保存输入的快捷方式(例如,Alt + Enter删除不需要的大括号、更改可见性等)。
  • Code browsing. (Find References, Class Hierarchy, etc.)
  • 代码浏览。(查找引用、类层次结构等)
  • Unit testing.
  • 单元测试。
  • I could go on...
  • 我可以继续…

If you want a thorough overview of what ReSharper can do, check out my blog series, 31 Days of ReSharper. It's missing the latest and greatest features (it was written for ReSharper 2.5), but it shows a lot of ReSharper in action.

如果你想全面了解ReSharper所能做的事情,你可以看看我的博客系列,《31天ReSharper》。它缺少最新和最伟大的特性(它是为ReSharper 2.5编写的),但是它展示了很多ReSharper的动作。

#4


1  

It can be used to keep the headers of each file up to date in an open source project. By headers I mean license text.

它可以用于在一个开放源码项目中保持每个文件的标题最新。我说的标题是许可文本。

#5


1  

I used a really early version and found that it became really annoying when you were typing and the silly thing paused while it loaded the IntelliSense.

我使用了一个非常早期的版本,发现当你打字的时候它会变得非常烦人,当它装载智能感知的时候它会暂停。

No key strokes were lost, but the pause annoyed me to no end.

没有人划错键,但停顿让我烦透了。

Has this been fixed or not?

这是修好了吗?

So at the moment my answer is I don't.

所以现在我的回答是,我没有。

#6


0  

I use ReSharper for:

我使用ReSharper:

  1. Creating fields automatically.
  2. 自动创建字段。
  3. Generating classes and methods (while doing TDD).
  4. 生成类和方法(在执行TDD时)。
  5. Automatically adding namespaces.
  6. 自动添加名称空间。
  7. Finding usages.
  8. 发现用法。
  9. Solution wide background compilation.
  10. 解决方案的广泛背景编译。
  11. Templates to standardize conventions among a team.
  12. 在团队中标准化约定的模板。

#7


0  

If you're using ASP.NET MVC, you might be interested in the new ReSharper 5 beta. It adds some nice features specifically.

如果你使用ASP。NET MVC,您可能对新的ReSharper 5 beta感兴趣。它特别添加了一些很好的特性。

  • Ctrl + click navigation, find usages and refactoring from 'magic strings' ActionLink to Controllers/Actions.

    Ctrl +单击导航,查找用法和重构,从“神奇的字符串”ActionLink到控制器/操作。

  • Ctrl + click navigation find usages for your Views referenced in your controller actions, and to the partial views referenced in your views.

    按Ctrl +单击导航,找到控制器操作中引用的视图的用法,以及视图中引用的部分视图。

  • Displays errors (even solution wide) when your ActionLink references a non-existing Controller/Action and allows you to automatically create stubs for it.

    当您的ActionLink引用一个不存在的控制器/操作并允许您自动为其创建存根时,显示错误(甚至解决方案范围)。

#1


12  

ReSharper provides a huge set of tools beyond the simple refactorings it suggests. In addition to providing additional code auto-formatting capabilities, ReSharper provides an integrated unit test runner that works with all of the known unit-test frameworks (such as NUnit, MBUnit, and my personal favorite, XUnit.NET). ReSharper also provides a very powerful template-based code generation platform that can improve your productivity by leaps and bounds.

ReSharper提供了大量的工具,而不仅仅是简单的重构。除了提供额外的代码自动格式化功能之外,ReSharper还提供了一个集成的单元测试运行器,它与所有已知的单元测试框架(比如NUnit、MBUnit和我个人最喜欢的XUnit.NET)一起工作。ReSharper还提供了一个非常强大的基于模板的代码生成平台,这可以大大提高你的效率。

For a full list of all the capabilities ReSharper can offer you, check here:

关于ReSharper提供的所有功能的完整列表,请点击这里:

http://www.jetbrains.com/resharper/features/index.html

http://www.jetbrains.com/resharper/features/index.html

#2


4  

What don't I use it for is more like it. Here's a shortlist of my most often-used shortcuts:

我不使用它的原因更像是它。下面是我最常使用的快捷方式列表:

  • Running unit tests. Their GUI unit test runner is awesome (sort by project/namespace is great), and I shortcut Alt+X to run a test.

    运行单元测试。他们的GUI单元测试运行器非常棒(按项目/名称空间排序很好),我使用Alt+X快捷方式运行测试。

  • Adding a class for unit tests, templated out with live templates

    为单元测试添加一个类,用活动模板进行模板化

  • Multiple custom livetemplates for filling in code, especially complex attributes

    用于填充代码的多个自定义live模板,特别是复杂的属性。

  • Weeding dead code on our enterprise codebases

    在企业代码库中清除无用代码

  • Converting properties to auto-properties

    将属性转换为自动属性

  • Combining variable declarations with their setup code

    将变量声明与它们的设置代码组合在一起

  • Making methods static that can and should be static

    使方法保持静态,可以并且应该保持静态

  • Looking at the pre-compilation errors/warnings bar saves me tons of time

    查看预编译错误/警告栏可以节省大量时间

  • StyleCop for ReSharper puts all my styling warnings inline for me.
  • ReSharper StyleCop为我嵌入了所有的样式警告。

Pretty much most of these are done with just Alt+Enter. The time saved is incalculable.

大部分都是通过Alt+Enter完成的。节省的时间是无法计算的。

#3


3  

Geez, where to begin?

天啊,从哪里开始?

  • Refactoring.
  • 重构。
  • Code formatting.
  • 代码格式化。
  • Code templates.
  • 代码模板。
  • Marker bar (the red/yellow/green stripes in the sidebar to show code warnings).
  • 标记条(工具条中的红色/黄色/绿色条纹显示代码警告)。
  • Highlighting of unused code.
  • 高亮显示未使用的代码。
  • Code generation.
  • 代码生成。
  • Shortcuts to save typing (for example, Alt + Enter to remove unneeded braces, change visibility, etc.)
  • 保存输入的快捷方式(例如,Alt + Enter删除不需要的大括号、更改可见性等)。
  • Code browsing. (Find References, Class Hierarchy, etc.)
  • 代码浏览。(查找引用、类层次结构等)
  • Unit testing.
  • 单元测试。
  • I could go on...
  • 我可以继续…

If you want a thorough overview of what ReSharper can do, check out my blog series, 31 Days of ReSharper. It's missing the latest and greatest features (it was written for ReSharper 2.5), but it shows a lot of ReSharper in action.

如果你想全面了解ReSharper所能做的事情,你可以看看我的博客系列,《31天ReSharper》。它缺少最新和最伟大的特性(它是为ReSharper 2.5编写的),但是它展示了很多ReSharper的动作。

#4


1  

It can be used to keep the headers of each file up to date in an open source project. By headers I mean license text.

它可以用于在一个开放源码项目中保持每个文件的标题最新。我说的标题是许可文本。

#5


1  

I used a really early version and found that it became really annoying when you were typing and the silly thing paused while it loaded the IntelliSense.

我使用了一个非常早期的版本,发现当你打字的时候它会变得非常烦人,当它装载智能感知的时候它会暂停。

No key strokes were lost, but the pause annoyed me to no end.

没有人划错键,但停顿让我烦透了。

Has this been fixed or not?

这是修好了吗?

So at the moment my answer is I don't.

所以现在我的回答是,我没有。

#6


0  

I use ReSharper for:

我使用ReSharper:

  1. Creating fields automatically.
  2. 自动创建字段。
  3. Generating classes and methods (while doing TDD).
  4. 生成类和方法(在执行TDD时)。
  5. Automatically adding namespaces.
  6. 自动添加名称空间。
  7. Finding usages.
  8. 发现用法。
  9. Solution wide background compilation.
  10. 解决方案的广泛背景编译。
  11. Templates to standardize conventions among a team.
  12. 在团队中标准化约定的模板。

#7


0  

If you're using ASP.NET MVC, you might be interested in the new ReSharper 5 beta. It adds some nice features specifically.

如果你使用ASP。NET MVC,您可能对新的ReSharper 5 beta感兴趣。它特别添加了一些很好的特性。

  • Ctrl + click navigation, find usages and refactoring from 'magic strings' ActionLink to Controllers/Actions.

    Ctrl +单击导航,查找用法和重构,从“神奇的字符串”ActionLink到控制器/操作。

  • Ctrl + click navigation find usages for your Views referenced in your controller actions, and to the partial views referenced in your views.

    按Ctrl +单击导航,找到控制器操作中引用的视图的用法,以及视图中引用的部分视图。

  • Displays errors (even solution wide) when your ActionLink references a non-existing Controller/Action and allows you to automatically create stubs for it.

    当您的ActionLink引用一个不存在的控制器/操作并允许您自动为其创建存根时,显示错误(甚至解决方案范围)。