Visual Studio的“自动解析"功能功能不适用于扩展方法-现在怎么办? [英] Visual Studio's "auto-resolve" feature doesn't work for extension methods - what now?

查看:102
本文介绍了Visual Studio的“自动解析"功能功能不适用于扩展方法-现在怎么办?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我喜欢Visual Studio中的解决"功能.

I love the "Resolve" feature in visual studio.

典型情况:

  1. 键入Debug
  2. 键入.
  3. 请注意,没有智能提示出现
  4. 右键单击
  5. 选择解决
  6. 选择using System.DiagnosticsSystem.Diagnostics.Debug
  1. Type in Debug
  2. Type .
  3. Notice that no intellisense appears
  4. Right-click
  5. Select Resolve
  6. Choose using System.Diagnostics or System.Diagnostics.Debug

美丽.一直使用它.

扩展方法方案:

  1. 键入var maxNumber = new int[] {1, 2, 3, 4}
  2. 键入.
  3. 请注意,intellisense提供了数组方法,但没有LINQ扩展方法
  4. 手动输入Max()
  5. 右键单击Max()
  6. 找不到解决方法
  7. 右键单击int[]
  8. 仍然找不到解决方法
  9. 可滚动地滚动到页面顶部,然后输入using System.Linq; *

  1. Type in var maxNumber = new int[] {1, 2, 3, 4}
  2. Type .
  3. Notice that intellisense brings up array methods but no LINQ extension methods
  4. Manually type Max()
  5. Right-click Max()
  6. No Resolve to be found
  7. Right click on int[]
  8. Still no Resolve to be found
  9. Begrudgingly scroll to the top of the page and enter using System.Linq;*

*假设您内心深知,否则会打扰您的大脑或尝试查找它

*assuming you know it by heart, otherwise wrack your brains or try to look it up

实施思路:

如果要发明此功能,则一个想法是当我键入.进行阅读时出现的第一个智能感知项目,<extension methods...>,如果单击该项目,它将弹出一个Resolve列表.包含所涉及类的扩展方法的名称空间.

If this feature were to be invented, one idea would be for the first intellisense item that appears when I type . to read, <extension methods...>, and if I click that item, it brings up a Resolve list of all namespaces that contain extension methods for the class in question.

偶发问题:

  1. 此功能是否适用于Visual Studio的未来版本?
  2. 找到适用于特定类的扩展方法(和相应的名称空间)的任何变通方法/提示吗?

推荐答案

我真的很讨厌不得不仅仅知道"使用哪个命名空间来支持任何给定的类.我的意思是,有成千上万的人.谁知道您需要什么命名空间?没有可以用作提示的命名约定.

I really HATE having to "just know" what namespace to use to support any given class. I mean, there are THOUSANDS OF THEM. Who knows what namespace you need? There's no naming convention that can be used as a clue.

很遗憾,因为我也使用Java的Netbeans IDE,并且解析导入"对所有内容都完美无缺.

It's a shame because I also use Netbeans IDE for Java, and "resolve imports" works flawlessly for everything.

这篇关于Visual Studio的“自动解析"功能功能不适用于扩展方法-现在怎么办?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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