问题描述
Visual Studio 2015提供了在同一窗口中显示Intellisense错误的选项,该窗口还显示常规的构建错误.我喜欢它,因为我什至不需要构建即可查看我的代码的语法是否正确.
Visual Studio 2015 offers the option to show Intellisense errors in the same window that also displays regular build errors. I like it because I don't even need to build in order to see if the syntax of my code is correct.
但是,该窗口还显示了一个误报错误,该错误似乎与Intellisense错误有关.有什么方法可以抑制特定代码区域或整个文件的智能错误?
However, the window also shows one false positive error which seems to be related to an Intellisense bug. Is there any way to suppress intellisense errors for specific code regions or entire files?
推荐答案
您找到答案了吗?您可以通过在发生错误的那一行代码中编写以下代码来做到这一点
Did you find an answer? You can do it by writing the following in your code on the line prior to where the error is raised
#pragma warning disable XXXX
其中XXXX是不带"CS"的错误代码
where XXXX is the error code without the "CS"
或者您可以尝试这些步骤来禁止显示针对Visual C#或F#的特定警告
Or you can try these steps to suppress specific warnings for Visual C# or F#
- 在解决方案资源管理器中,选择要在其中隐藏警告的项目.
- 在菜单栏上,依次选择视图",属性页".
- 选择构建"页面.
- 在禁止警告"框中,指定要禁止的警告的错误代码,以分号分隔,然后重新构建解决方案.
从此处获取 https://msdn.microsoft.com/zh-CN /library/jj715718.aspx
请注意,提到的是警告而不是错误,但对我来说,如果我选择在错误列表"窗口中显示抑制的错误",它们将被列为错误.您可能需要在错误列表"窗口中启用此列.
Note that warnings are mentioned rather than errors, but for me they are listed as errors if I choose to show Suppressed Errors in the Error List window. You might need to enable this column in the Error List window.
这篇关于如何抑制某些文件的Intellisense错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!