Visual Studio的“自动解析"功能功能不适用于扩展方法-现在怎么办? [英] Visual Studio's "auto-resolve" feature doesn't work for extension methods - what now?
问题描述
我喜欢Visual Studio中的解决"功能.
I love the "Resolve" feature in visual studio.
典型情况:
- 键入
Debug
- 键入
.
- 请注意,没有智能提示出现
- 右键单击
- 选择解决
- 选择
using System.Diagnostics
或System.Diagnostics.Debug
- Type in
Debug
- Type
.
- Notice that no intellisense appears
- Right-click
- Select Resolve
- Choose
using System.Diagnostics
orSystem.Diagnostics.Debug
美丽.一直使用它.
扩展方法方案:
- 键入
var maxNumber = new int[] {1, 2, 3, 4}
- 键入
.
- 请注意,intellisense提供了数组方法,但没有LINQ扩展方法
- 手动输入
Max()
- 右键单击
Max()
- 找不到解决方法
- 右键单击
int[]
- 仍然找不到解决方法
-
可滚动地滚动到页面顶部,然后输入
using System.Linq;
*
- Type in
var maxNumber = new int[] {1, 2, 3, 4}
- Type
.
- Notice that intellisense brings up array methods but no LINQ extension methods
- Manually type
Max()
- Right-click
Max()
- No Resolve to be found
- Right click on
int[]
- Still no Resolve to be found
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.
偶发问题:
- 此功能是否适用于Visual Studio的未来版本?
- 找到适用于特定类的扩展方法(和相应的名称空间)的任何变通方法/提示吗?
推荐答案
我真的很讨厌不得不仅仅知道"使用哪个命名空间来支持任何给定的类.我的意思是,有成千上万的人.谁知道您需要什么命名空间?没有可以用作提示的命名约定.
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屋!