与VB.NET相比,为什么缺少IntelliSense对C#的支持? [英] Why is IntelliSense support for C# lacking when compared to VB.NET?

查看:120
本文介绍了与VB.NET相比,为什么缺少IntelliSense对C#的支持?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对我来说,为Java生态系统开发已经花了很多年的时间.但是,几年来,我主要从事.Net领域的工作.最初,我向.Net世界过渡的过程包括编写和维护VB.Net代码.经过多年使用Eclipse/Java组合,VS提供了几乎所有我期望的出色的智能感知支持.最终,我的雇主决定使用C#进行新开发.我对C#的智能支持的最初印象不甚出色.有时,似乎VS没有C#的后台编译器,但有时它做的很聪明,表明那里有一些后台处理,但不足以真正地以有意义的方式提高生产力.对于两种语言之间的智能感知支持,是否有任何理智的技术原因?

For me, developing for the Java ecosystem payed the bills for many years. However, for several years now, I have been working primarily in the .Net space. Initially, my transition into the .Net world consisted of writing and maintaining VB.Net code. VS provided almost all of the nice intellisense support I came to expect after years of working with the Eclipse/Java combo. Eventually my employer decided to do new development in C#. My initial impression of the intellisense support for C# was less than stellar. At times it seems as if VS has no background compiler for C#, but occasionally it does something smart, indicating there is some background processing there, but not quite enough to really boost productivity in meaningful ways. Is there any sane technical reason for this discrepancy regarding intellisense support between the two languages?

推荐答案

C#和VB之间暂时存在差距. VB为您生成了很多代码.例如,如果您未填写"If"语句,则在按回车键后会自动在该行的末尾添加"Then",然后使用"End If"部分将其关闭.在C#中,您可以自行添加开始和结束{}大括号.

There has been a gap between C# and VB for awhile now. VB generates a lot of code for you. For example, hitting enter after finishing an "If" statement will automatically add the "Then" at the end of that line if you left it off, and close it off with the "End If" portion. In C# it's up to you to add those starting and closing {} curly braces.

VB在C#之前就已经进行了后台编译.实际上,这是使用提供这种功能的ReSharper的主要吸引力之一.但是,从VS 2008/.NET 3.5 SP1开始,这一切都发生了变化.您可以阅读Scott Scott关于该

VB has had background compilation long before C#. In fact, that was one of the major appealing factors of using ReSharper, which provided such functionality. However, as of VS 2008 / .NET 3.5 SP1 that all changed. You can read Scott Gu's post about that here, but I'll paste the relevant part:

"C#代码编辑器现在可以识别并 对许多人显示红色花样错误 以前的语义代码问题 需要一个明确的编译来 确认.例如,如果您尝试 在中声明并使用未知类型 今天的C#代码编辑器您不会看到 编译错误,直到您进行构建为止. 现在使用SP1,您将看到实时红色 立即混淆错误(否 显式编译)."

"The C# code editor now identifies and displays red squiggle errors for many semantic code issues that previously required an explicit compilation to identify. For example, if you try to declare and use an unknown type in the C# code-editor today you won't see a compile error until you do a build. Now with SP1 you'll see live red squiggle errors immediately (no explicit compile required)."

使用CodeRush或ReSharper可以通过自动完成常见语句来增强体验,这会使VB开发人员感到无缝过渡.

Using CodeRush or ReSharper definitely enhances the experience with the autocompletion of common statements which would make a VB developer feel like there has been a seamless transition.

这并不能完全解决技术问题,但是开发团队是不同的,不一定要做相同的事情.换句话说,不可能有一种共享的方法. 此博客文章 摘录,由VB团队的技术负责人支持:

That doesn't quite address technical concerns, but the development teams are different and didn't necessarily do the same thing. In other words, there's not likely to be a shared approach. This blog post excerpt, by a Technical Lead on the VB team, supports this:

背景编辑"是 VB中的功能可为您提供 输入时完整的错误集. 在之间来回移动的人 VB和C#注意到了这一点,但仅VB 开发人员可能没有意识到其他 诸如C#之类的语言并不总是 您100%准确的Intellisense和 不要总是给你所有的 您的代码中存在的错误.这 是因为他们的Intellisense引擎 是单独的,按比例缩小的编译器 不会在 背景.另一方面,VB 从编译整个项目 随着Visual Studio的安装开始完成 闲着,让我们立即 完全填充任务列表 准确的错误,使我们能够 给你完全准确 智能感知.

"Background compilation" is the feature in VB that gives you a complete set of errors as you type. People who move back and forth between VB and C# notice this, but VB-only developers may not realize that other languages such as C# don’t always give you 100% accurate Intellisense and don’t always give you all of the errors that exist in your code. This is because their Intellisense engines are separate, scaled-down compilers that don’t do full compilation in the background. VB, on the other hand, compiles your entire project from start to finish as Visual Studio sits idle, allowing us to immediately populate the task list with completely accurate errors and allowing us to give you completely accurate Intellisense.

最后一个说明是对C#/VB/F#团队的组长Luca Bolognese进行的最近Channel9采访 ,他强调了语言将不再走迷路的情况朝着不同的方向发展,并将开始分享它们的相似之处.因此,看起来未来拥有美好的事物!

One final note is the recent Channel9 interview with the Group PM of the C#/VB/F# team, Luca Bolognese, where he emphasized how the languages are no longer going to stray off in different directions and will begin to share their similarities. So it looks like the future holds great things!

这篇关于与VB.NET相比,为什么缺少IntelliSense对C#的支持?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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