本文介绍了我如何自动添加“使用中"邮件? Visual Studio 2005/resharper对文件夹,名称空间或项目中的每个文件的声明的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用resharper进行大量的重构,我不断在文件之间切换,并在使用"部分中一遍又一遍地添加相同的名称空间

I am using resharper to do a big refactoring and i keep going from file to file and adding the same namespace over and over again in the "using" section

是否在文件夹,名称空间或项目中的每个文件中添加使用"语句?即使某些文件不需要引用,但大多数文件都需要引用,因此可以节省大量时间.

is there anyway to add a "using" statement to every single file in a folder, namespace or project? Even though some files wont need the reference, most do, so it will save lots of time.

推荐答案

我会在查找和替换"对话框中尝试使用正则表达式:

I'd try a regex in the "Find and Replace" dialog:

替换

^using System;$

使用

using System;\nusing xxx;

这仅适用于使用System命名空间的文件,但也许您会发现另一个常见的命名空间或结构元素.这样做之后,您可以使用重新共享程序重构解决方案(/folder)中的所有文件.这将消除使用率翻倍的情况.

This works only for files using the System namespace, but maybe you find another common namespace or structure element. After doing so you can refactor all files in your solution(/folder) with the resharper. That will remove doubled usings.

更新:您是否为现有类型引入了新的名称空间?有一个称为移动"的重构功能.它将把您的类型移动到新的名称空间并保留引用.

Update: Did you introduce new namespaces for existing types? There is a refactor function called "move". It will move your type to a new namespace and preserve the references.

这篇关于我如何自动添加“使用中"邮件? Visual Studio 2005/resharper对文件夹,名称空间或项目中的每个文件的声明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 18:15