2

Keywords are still recognized but only new user-defined classes are recognized, using namespaces isn't recognized either, code runs fine but really annoying to code like this.

Tried everything for hours, even to the point of running a Windows 10 VM, with a new user doing a clean install of VS Code (with only the C# and .NET Install Tool for Extension Authors extensions) and .NET 7.0 SDK but still not working.

I was considering re-installing Windows on my main system but seeing as how it's not working on the VM either that would be pointless, anyone else having this problem too?

Petter Hesselberg
  • 5,062
  • 2
  • 24
  • 42
M. C.
  • 23
  • 2
  • Does this answer your question? [What changed about the C# extension for VS Code's IntelliSense in the v2.0.320 release?](https://stackoverflow.com/questions/76850403/what-changed-about-the-c-sharp-extension-for-vs-codes-intellisense-in-the-v2-0) – starball Aug 09 '23 at 02:01

1 Answers1

5

TL;DR

The issues is caused by v2.x.x of the Visual Studio Code C# extension which does not have the same set of features (includes some unprecedented features, but also lacks some features) as the current v1.x.x (= OmniSharp or O#) versions. The goal in the future however is for v2.x.x to support what v1.x.x has already been supporting.

You have one of four options:

  • Stay on >= v2.0.320 and add a solution file (see section Update 2023-08-05) which includes your project
  • Revert back to a OmniSharp powered version (versions <= v1.x.x) (see section Original answer)
  • Go back to OmniSharp by going to the Extension settings and setting dotnet.server.useOmnisharp to true. Next, uninstall or disable C# Dev Kit. Finally, restart VS Code for this to take effect. (quoted from Github - dotnet/vscode-csharp - How to use OmniSharp)
  • Wait for the feature parity to come in future v2.x.x versions (see linked Github issues in section Update 2023-08-09)

Update 2023-08-09

As pointed out in the comments below by starball and the thread What changed about the C# extension for VS Code's IntelliSense in the v2.0.320 release? on SO the general issue is that with versions >= v2.0.320 Microsoft has decided to switch to the new Roslyn Language Server instead of using OmniSharp (also often referred to as O#) which it has been using for versions prior to that (See Github Releases - Changelog v2.0.320). Microsoft did get some heat for that (see Visual Studio Magazine) as this will introduce closed-source functionality.

The new v2, as of now, lacks some features the OmniSharp versions provided. Looking at the list of known issues there are however plans to reach a feature parity between the two versions in the future.

Here the known issues as of 2023-08-09 based on Github - dotnet/vscode-csharp - Known Issues in v2.0.320:

  • Diagnostics related feature requests and improvements #5951
  • [O# Parity] FixAll support for code fixes and refactorings #5735
  • [O# Parity] Nuget restore #5725
  • [O# Parity] Support loading projects/files without a solution file #5722
  • [O# Parity] Some csproj projects will not correctly load #5721
  • [O# Parity] Run and debug tests in context #5719
  • Debug from .csproj and .sln #5876

Note that issue #5722 - [O# Parity] Support loading projects/files without a solution addresses the problem faced here.

With that being said, you have the possibilites as outlined in my previous answers:

  • Stay on >= v2.0.320 and add a solution file (see section Update 2023-08-05) which includes your project
  • Revert back to a OmniSharp powered version (versions <= v1.x.x) (see section Original answer)
  • Go back to OmniSharp by going to the Extension settings and setting dotnet.server.useOmnisharp to true. Next, uninstall or disable C# Dev Kit. Finally, restart VS Code for this to take effect. (quoted from Github - dotnet/vscode-csharp - How to use OmniSharp)
  • Wait for the feature parity to come in future versions (see linked Github issues)

Update 2023-08-05

It seems the issue only occurs if you have a project which is not listed in a solution file, so you can create a solution file e.g. using dotnet new sln --name <solution name> and then add the project(s) to that solution using dotnet sln add <project path>.

It is working with the new version v2.0.328 (released today 2023-08-05) for me when I have all my projects added to a solution file.

Original answer

I've faced the same issue today (2023-08-04). This is due to an update of the extension to v2.0.320. You can fix this by reverting back to version v1.26.0.

You can revert using the UI by going to Extensions -> C# -> Install Another Version: Revert C# Extension version

There also is an open Github issue related to this.

Mushroomator
  • 6,516
  • 1
  • 10
  • 27