简体   繁体   English

Visual Studio Intellisense 颜色编码不起作用

[英]Visual studio Intellisense color-coding not working

Right now in my code suddenly some part of the code is not color-coded to Visual Studio classic theme colors. I am not sure if there is some error in my code but when I define some property for example:现在在我的代码中突然有些代码没有颜色编码到 Visual Studio 经典主题 colors。我不确定我的代码中是否有错误但是当我定义一些属性时:

public class VideoEncodeTest : AndroidPowerTest
    {
        [CptfConfigAcceptedParametersClass]
        public VideoEncodeTestParameters VideoEncodeTestParameters { get; set; }

        [CptfConfigAcceptedParametersClass]
        public IBundleStrategy Strategy { get; set; }

}

I expect Type of the properties, Name of the base class and name of the attribute to be in color-coded in blue at least.我希望属性的类型、基本名称 class 和属性的名称至少用蓝色进行颜色编码。 However, it is not and it is plain black.然而,它不是,它是纯黑色的。 This is only happening with this particular class and not happening with other classes.这只发生在这个特定的 class 上,而不会发生在其他类上。 I am not sure why and what can be the reason.我不确定为什么以及可能是什么原因。

Any ideas?有任何想法吗? prior experience?以往的经验?

I recently had this issue after updating Visual Studio 2019.我最近在更新 Visual Studio 2019 后遇到了这个问题。

I was able to fix it by heading to Tools > Options > Text Editor > C# > Advanced , and finally selecting Visual Studio 2019 in the Editor Color Scheme dropdown.我可以通过转到Tools > Options > Text Editor > C# > Advanced来修复它,最后在Editor Color Scheme下拉列表中选择Visual Studio 2019

截图供参考 . .

Are you sure your settings are all right, and the problem is elsewhere?你确定你的设置没问题,问题出在别处? You can check if your settings are not what you'd expect them to be in the 'Fonts and Colors' menu.您可以在“字体和颜色”菜单中检查您的设置是否不是您期望的那样。
(Tools -> Options -> Environment -> Fonts and Colors) (工具 -> 选项 -> 环境 -> 字体和颜色)

You may have plugins installed which are inflicting with your current settings.您可能安装了影响当前设置的插件。 If that's the case, you should try removing your add-ins, then re-installing them.如果是这种情况,您应该尝试删除加载项,然后重新安装它们。

If it's certain that the problem is with your VS intellisense, first try refreshing the IntelliSense cache by selecting the 'Refresh Local Cache' option in the Edit menu of VS under the IntelliSense item.如果确定问题出在 VS 智能感知上,请首先尝试通过选择智能感知项目下 VS 编辑菜单中的“刷新本地缓存”选项来刷新智能感知缓存。
(Edit -> IntelliSense -> Refresh Local Cache or just hit Ctrl+Shift+R) (编辑 -> IntelliSense -> 刷新本地缓存或直接按 Ctrl+Shift+R)

If you still experience the problem, you should try closing VS, deleting the %appdata%\\Microsoft\\VisualStudio\\11.0\\ReflectedSchemas folder, then starting it up again to check if the problem is solved.如果您仍然遇到问题,您应该尝试关闭 VS,删除%appdata%\\Microsoft\\VisualStudio\\11.0\\ReflectedSchemas文件夹,然后再次启动以检查问题是否已解决。

If neither of these could solve your problem, you can still try to reset all settings in VS.如果这些都不能解决您的问题,您仍然可以尝试重置 VS 中的所有设置。 It has some chance to work, but I don't recommend it.它有一些工作机会,但我不推荐它。
(Tools -> Import and Export Settings -> Reset all settings) (工具 -> 导入和导出设置 -> 重置所有设置)

This happened to me with a new project in a solution.这发生在我身上,解决方案中有一个新项目。 Another member in the team had created it and when I pulled it via git I got no color coding even though the code ran fine.团队中的另一个成员创建了它,当我通过git提取它时,即使代码运行良好,我也没有得到颜色编码。 I also had color coding in the other projects.我在其他项目中也有颜色编码。

What fixed it for me was simply adding a new class to the project with no color coding .对我来说修复它的只是在没有颜色编码的项目中添加一个新类 Then everything started working normally again.然后一切又开始正常工作。

My fix was to rename the file.我的解决方法是重命名文件。 I had originally created it as an html file.我最初将其创建为 html 文件。 When I renamed it my intellisense came back.当我重命名它时,我的智能感知又回来了。

In case anyone stumbles on this issue in 2022 (as it still happens), what works for me is to reload or create a specific project file for the code type I want IntelliSense to work with.万一有人在 2022 年偶然发现这个问题(因为它仍然会发生),对我有用的是为我希望 IntelliSense 使用的代码类型重新加载或创建一个特定的项目文件。

For example, if I had a C# and Python project in a solution, loading the solution, IntelliSense will only work for one of the two languages.例如,如果我在解决方案中有一个 C# 和 Python 项目,加载该解决方案时,IntelliSense 将仅适用于两种语言中的一种。 Manually loading the Python or C# project will fix both the color-code and IntelliSense for whichever language it's currently broken for.手动加载 Python 或 C# 项目将修复当前损坏的任何语言的颜色代码和 IntelliSense。

After trying everything above, so very many times, I was able to replicate and duplicate this in my multi-language solutions.在尝试了上述所有内容之后,我能够在我的多语言解决方案中复制和复制它。

Tools > Options > Environment > General: Color Theme - Blue工具 > 选项 > 环境 > 常规:颜色主题 - 蓝色

I had this issue with python and was able to fix it by reinstalling python addon我在 python 上遇到了这个问题,并且能够通过重新安装 python 插件来修复它

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM