Visual Studio 2010 - IDE 命令查找扩展方法命名空间?
我大量使用 + <.>查找类型的命名空间并使 VS.NET 将这些类型导入到我的类文件中。与此类似,假设我有一个名为 ToWebsiteString()
的 DateTime 扩展方法。我希望能够输入 myDateTime.ToWebsiteString
,然后点击相当于 + <.> 的内容。并让 IDE 显示具有该扩展方法的所有可用命名空间的列表,以便我可以简单地选择命名空间并让 VS.NET 将其导入到我正在使用的类文件中。它已经存在吗?
如果没有,您发现导入扩展方法命名空间最有效的方法是什么?
编辑: 有没有免费的解决方案?
编辑: 除了付费使用 Resharper 之外,似乎没有任何免费的解决方案,所以我已经关闭了这个问题。
谢谢
I make heavy use of + <.> to find the namespace of types and have VS.NET import those types into my class files. Similar to that, suppose I have a DateTime extension method called ToWebsiteString()
. I'd like to be able to type myDateTime.ToWebsiteString
, and then hit the equivalent of + <.> and have the IDE display a list of all available namespaces with that extension method, so that I can simply select the namespace and have VS.NET import it into the class file that I'm working in. Does that already exist?
If not, what is the most productive way you've found to import your extension method namespaces?
Edit:
Are there any free solutions for this?
Edit:
Other than the pay for Resharper, it doesn't appear that there are any free solutions for this, so I've closed this question.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Resharper 可以为您做到这一点。
输入 myDateTime.ToWebsiteString,按 Alt+Enter,Resharper 将显示可供选择的命名空间列表。
Resharper can do this for you.
Type
myDateTime.ToWebsiteString
, hitAlt+Enter
and Resharper will show a list of namespaces to select from.如果您键入/选择扩展方法,例如:
然后将光标放在扩展方法名称内按 F12,Visual Studio 将带您到添加该扩展方法的类(和命名空间),即使它隐藏在某个 DLL 中(它向您显示了公共方法存根)。足够好,无需 Resharper 即可工作。
If you type/select the extension method, like:
Then hit F12 with the cursor inside the extension method name, Visual Studio will take you to the class (and namespace) that adds that Extension Method, even if it's buried in some DLL somewhere (it shows you the public method stubs). Good enough, works without Resharper.