c# - Visual Studio 2019 intellisense 在每个非 .NET 命名空间下显示红色波浪线

标签 c# visual-studio intellisense visual-studio-2019

Visual Studio 2019 intellisense 在每个非 .NET 命名空间下显示红色波浪线。该项目构建并运行良好。如果我在 VS 2017 中打开解决方案,它可以正常打开,没有错误。

我已经删除了 .vs 文件夹。我该如何解决这个问题?

编辑: 似乎共享项目已经丢失。如果我右键单击添加引用,则找不到其他项目。我尝试从解决方案中删除一个项目并重新添加它,但“共享项目”列表仍然是空的。我怀疑这与智能感知也找不到它们的问题有关。

如果此后我在 VS2017 中打开解决方案,一切正常,因此它似乎仅与 VS2019 相关。

enter image description here

enter image description here

最佳答案

我们的解决方案记录在此处: https://github.com/dotnet/roslyn/issues/40082

I was able to track down the root cause for this issue, and also provided a workaround to @rolandh offline.

Tagging @jasonmalinowski, who is expert on VS project system layer on our team, and @tmat who has been investigating how to properly report VS-specific diagnostics in Roslyn. Let me expand on the findings:

  1. Provided solution has a two projects which have a circular reference
    • Project P1 has a ProjectReference to project P2 and project P2 has a metadata Reference to P2.dll. Latter gets converted to a project reference via our metadata to project reference conversion logic.
  2. Above configuration leads our VS project code to throw an InvalidOperationException in CheckNotContainsTransitiveReference over here when attempting to add project and metadata references.
  3. Above exception seems to get handled somewhere down the call stack, so there is no user visible impact. However, it causes the project state for P1 to get corrupt - it ends up with no documents, no references, etc. This leads to a ton of cascading intellisense errors in all projects referencing P1.
  4. Building the project/solution on command line succeeds as P1's reference to P2.dll is unnecessary.
  5. Unfortunately, the above InvalidOperationException does not translate to any diagnostic in the error list, so user is given no information about what went wrong under the covers and how to resolve their issue. Ideally, the circular reference, or in fact any such project system anomalies for which we throw exceptions in the Workspace layer, should be translated to diagnostics in error list by VS layer, so it helps the user towards fixing their project/solution. @jasonmalinowski do we have any issue tracking such work? I can file one otherwise.

基本上,我们在项目中以某种方式获得了循环引用(无法通过 UI 实现),这会导致智能感知引擎中出现错误。

删除这个循环引用解决了这个问题。

关于c# - Visual Studio 2019 intellisense 在每个非 .NET 命名空间下显示红色波浪线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55174161/

相关文章:

c++ - 即使在 C++ 中没有反射,visual studio intellisense 如何识别类中的函数和属性?

c# - CodeAnalysisTreatWarningsAsErrors 没有破坏构建

c# - UWP/ Visual Studio : How to make different builds variants?

c# - 如何使用 C# 中的 Web/REST API 在 salesforce 中创建用户?

java - 如何开始黑莓开发

Visual Studio 中的 C 编程

python - vscode 不自动完成某些 Python 方法

visual-studio - Visual Studio 2017 中没有针对新 C# 文件的智能感知

c# - XML 序列化动态对象

c# - 我可以从 C# 中的同一类方法调用构造函数吗?