在CodeRush中自动添加`using` [英] Automatic addition of `using` in CodeRush

查看:134
本文介绍了在CodeRush中自动添加`using`的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚为Visual Studio安装了CodeRush Pro(评估版),可以说到目前为止我非常喜欢它.与Resharper相比,我真的只缺少一种功能.这是CodeRush处理using的方式.当我键入使用中列出的某些程序包中未声明的某个类名时,CodeRush将其下划线标为红色(表示错误),但是如果我将光标悬停在它上面,它不会为我添加使用,它只是说出来是未声明的元素".

I just installed CodeRush Pro (evaluation trial) for Visual Studio and I can say I like it much so far. Comparing to Resharper there is only one type of feature I'm really missing. It is the way CodeRush deals with using. When I type some class name that is not declared in some package listed in using, CodeRush underlines it red as an error(what it is) but if I hover over it with cursor it does not offer me to add using, it merely says it is "Undeclared element".

我必须使用VS default并使用加法(将插入符号移至标识符,将光标悬停在出现在第一个字母下方的那个非常小的框上,单击出现的按钮,然后从下拉菜单中选择例如using System).

I have to use VS default using addition (move caret to the identifier, hover cursor over that really small box that appears under first letter, click the button that appears and choose for example using System form a drop down menu).

当我将光标悬停在突出显示的问题"(即未声明的元素)上时,是否有一种方法可以配置CodeRush以提供mi add?

Is there a way how to configure CodeRush to offer mi add using when I hover a cursor over highlighted "issue"(that says Undeclared element)?

第二部分是Resharper有一种叫做类型名称完成的思想.它在智能感知方面有所改进.假设您的文件中没有using声明.然后键入ICompar之类的内容,然后按CTRL + SPACE.当然,不会有任何建议.但是,使用Resharper时,您可以按CTRL + ALT + SPACE,即使没有使用,您也会获得以ICompar开头的所有类的建议.当您选择其中之一时,会自动为您添加正确的用法.

The second part of this is that Resharper has somethink called Type name completion. It some improved intellisense. Lets say you have no using declaration in your file. Then you type something like ICompar and press CTRL+SPACE. Of cause there will be no suggestions. But with Resharper you can press CTRL+ALT+SPACE and you get suggestions of all classes starting with ICompar even if they are not in using. When you choose one of them the correct using is automatically added for you.

有没有办法让CodeRush如此行事?

Is there a way to make CodeRush behave this way ?

推荐答案

PART I

Visual Studio

您提到的默认VS机制是使用Ctrl +或Shift + Alt + F10触发的

The default VS mechanism you mention is tripped using Ctrl+Period or Shift+Alt+F10

CodeRush模板

让我为此部分引用Mark Miller(CodeRush的首席架构师):

Let me quote Mark Miller (Chief architect of CodeRush) for this part:

" CodeRush模板(如类固醇上的VS代码段)将根据需要添加名称空间,因此,如果您使用模板来创建类,方法,变量,属性,事件和类型引用,则将添加名称空间引用自动开始,您几乎不需要使用VS功能来添加名称空间.要开始使用模板,我们建议将CodeRush培训窗口(DevExpress | Tool Windows | CodeRush)停靠在编辑器的侧面,并检查该培训窗口以获取提示以及可用于生成所需代码的模板.只需在窗口中显示的模板中键入模板,然后使用空格键将其展开即可."

尝试使用v系列,m系列,n系列和t系列.

Try the v-series, the m-series, the n-series and the t-series.

所以我的意思是:

  • 启动CodeRush培训窗口(DevExpress \ Tool Windows \ CodeRush)
  • 将其停靠在左侧
  • 返回编辑器
  • 键入"v"(无引号)
    • 小心,这是上下文敏感的
      • 插入符号在课堂上尝试.
      • 在插入符处于方法中时尝试此操作.
      • Launch the CodeRush training window (DevExpress\Tool Windows\CodeRush)
      • Dock it to the left
      • Back to the editor
      • Type 'v' (no quotes)
        • Careful this is context sensitive
          • Try this whilst the caret is in a class.
          • Try this whilst the caret is in a method.

          那是您对v系列模板的介绍.

          That was your introduction to the v-series of templates.

          随时查看m系列,n系列和t系列.

          Feel free to check out the m-series, the n-series and the t-series.

          还请注意,当您处于空白行时,培训窗口还会提供建议.

          Also note that the training window also provides suggestions when you are on a blank line.

          社区插件

          CodeRush内置任何功能,无法提供为此类型添加使用"功能.

          There is nothing built into CodeRush which provides "Add using for this type" functionality.

          但是,有很多社区插件,它们为CodeRush.这种可扩展性是CodeRush的最佳功能之一.

          However there are numerous Community Plugins which add all sorts of functionality to CodeRush. This extensibility is one of the best features of CodeRush.

          特别是一个插件 Refactor_Resolve 所具有的功能可能接近你描述.

          One plugin in particular Refactor_Resolve has functionality that might come close to what you describe.

          PART II

          我不认为CodeRush目前提供了任何智能感知增强功能.

          I don't believe there are any intellisense enhancements provided by CodeRush at this time.

          对不起

          这篇关于在CodeRush中自动添加`using`的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆