Automatic addition of `using` in CodeRush

五迷三道 提交于 2019-12-06 10:39:18

PART I

Visual Studio

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

CodeRush Templates

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

"CodeRush templates (like VS code snippets on steroids) will add namespaces as needed, so if you use templates to create classes, methods, variables, properties, events, and type references then the namespace references will be added automatically and you'll rarely need to use the VS feature for adding namespaces. To get started with the templates we recommend docking the CodeRush training window (DevExpress | Tool Windows | CodeRush) to the side of the editor and check that training window for tips and templates you can use to generate the code you need. Just type the template as it shows up in the window and expand it using the space bar."

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

So what I mean by this is:

  • 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.
  • Now look at the Training window.
  • You should see a few suggestions of further characters to type.
  • Type one of the suggestions and then hit space.

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

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.

Community Plugins

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

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

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

PART II

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

Sorry

Not an answer, but giving my best poor mans crap workaround in case there isnt a better one... is Ctrl-Home (top of file) then usl and <space> (expand to using System.Linq) then Ctrl-Minus(Back to where we were - of course you can use the CR markers too).

(I have a request in the CR bugbase for this to be sorted)

DX have built another sample around this. I wish it'd get into the CR product but I guess one shouldn't whine about free plugins (too much anyway).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!