visual-studio Visual Studio 未在编辑器中显示编译时错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2094125/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-22 11:26:07  来源:igfitidea点击:

Visual Studio not displaying compile time errors in editor

visual-studiovisual-studio-2008

提问by geejay

For example, when I write:

例如,当我写:

string x = "turtle";
x.Go();

There is no red squiggly line detecting the absence of the Go() method on String.

没有红色波浪线检测 String 上没有 Go() 方法。

Only when I compile does the error get detected.

只有当我编译时才会检测到错误。

I've just upgraded to Windows 7, I have Visual Studio 2008.

我刚刚升级到 Windows 7,我有 Visual Studio 2008。

In my old environment the errors were detected before the actual compile.

在我的旧环境中,在实际编译之前检测到错误。

Is there a setting that I am missing?

是否有我遗漏的设置?

EDIT: "Tools -> Options -> Text Editor -> C# -> Underline errors in the editor" is checked.

编辑:选中“工具 -> 选项 -> 文本编辑器 -> C# -> 编辑器中的下划线错误”。

I dont have the "Live Semantic" option. Maybe I need to go to SP1?

我没有“实时语义”选项。也许我需要去 SP1?

回答by Andrew Hare

You need to turn on the underline errors in the editorand show live semantic errorsoptions in Visual Studio.

您需要在编辑器中打开下划线错误并在 Visual Studio 中显示实时语义错误选项。

These options can be found here:

这些选项可以在这里找到:

Tools > Options > Text Editor > C# > Advanced > Editor Help

Tools > Options > Text Editor > C# > Advanced > Editor Help

Edit:You will need to install SP1 for this functionality to work.

编辑:您需要安装 SP1 才能使用此功能

回答by Dan McClain

Select Tool-> Options, then Text Editor. Under the language you are using (ie C#), go to the Advancedand make sure the Underline errors in the editorand Show live semantic errorsare checked

选择工具->选项,然后选择文本编辑器。在您使用的语言(即 C#)下,转到高级并确保检查编辑器中下划线错误显示实时语义错误

回答by Nick N.

For visual studio 2015and higher:

对于Visual Studio 2015及更高版本:

Go to: Tools > Options > Text Editor > C# > Advanced > Editor Help

去: Tools > Options > Text Editor > C# > Advanced > Editor Help

Then select: Enable Full solution analysis

然后选择: Enable Full solution analysis

回答by Brissles

I had the same issue and had SP1 installed andhad Underline errors in the editorand Show live semantic errorschecked in VS2008's options.

我遇到了同样的问题,并且安装了 SP1,并且在编辑器中出现下划线错误,并在 VS2008 的选项中检查了显示实时语义错误

My solution was to download Microsoft Visual Studio 2008 Service Pack 1 (Installer) and re-install the package. It wasn't classified as a 'repair' or a 're-install' despite the fact it was already installed, but it worked.

我的解决方案是下载 Microsoft Visual Studio 2008 Service Pack 1(安装程序)并重新安装该软件包。尽管它已经安装,但它并未被归类为“修复”或“重新安装”,但它确实有效。

回答by G?khan Yal??n

Restarting VS solved my problem once.

重新启动 VS 一次解决了我的问题。

回答by Ori Barmatz

my solution; I know it won't help like 80% of the viewers, but for the sake of who it will: i have had a lot of noise in the IOS part of the solution, a VS bug that showed a lot of errors that weren't supposed to appear, so I just deleted the IOS part because I didn't really needed it as I didn't even had a Mac server to test it on... Something happened after that and the squiggly line returned! Seriously, VS team, fix your bugs...

我的解决方案;我知道它不会像 80% 的观众一样有帮助,但对于它会帮助谁:我在解决方案的 IOS 部分有很多噪音,一个 VS 错误显示了很多错误t 应该出现,所以我只是删除了 IOS 部分,因为我真的不需要它,因为我什至没有 Mac 服务器来测试它......在那之后发生了一些事情,波浪线又回来了!说真的,VS 团队,修复您的错误...

回答by Srinivasan Kasiram

JavaScript Type Checking Sometimes type checking your JavaScript code can help you spot mistakes you might have not caught otherwise. You can run the TypeScript type checker against your existing JavaScript code by simply adding a // @ts-check comment to the top of your file.

JavaScript 类型检查 有时,类型检查您的 JavaScript 代码可以帮助您发现您可能没有发现的错误。您只需在文件顶部添加 // @ts-check 注释,即可针对现有 JavaScript 代码运行 TypeScript 类型检查器。

// @ts-nocheck 

let easy = true;
easy = 42;

Tip: You can also enable the checks workspace or application wide by adding "javascript.implicitProjectConfig.checkJs": true to your workspace or user settings and explicitly ignoring files or lines using // @ts-nocheck and // @ts-ignore. Check out the docs on JavaScript in VS Code to learn more.

提示:您还可以通过将 "javascript.implicitProjectConfig.checkJs": true 添加到您的工作区或用户设置并使用 // @ts-nocheck 和 // @ts-ignore 显式忽略文件或行来启用检查工作区或应用程序范围。查看 VS Code 中有关 JavaScript 的文档以了解更多信息。