VS Code - Error check missing in some projects

Viewed 21

I made a new solution in .NET with a class library (dotnet new classlib) and an XUnit test project (dotnet new xunit). I then added a reference to the class library, from the test project (dotnet add <test-project> reference <class-library>).

Now I have live error checking (syntax highlighting) in the class library, but no in the test project. You can see an example below, where the class Foo doesn't exist anywhere, but doesn't generate a live warning in the unit test project (it still fails on build).

This is a VS Code issue only. If I open it in Visual Studio 2022, it works just fine.

What's going on here?

Screenshot from VS Code

2 Answers

was been worng method publice class in method impliment

class method in not accpcet css file

All test classes are public All test classes are having the [TestClass] attribute declared All test methods are using the [TestMethod] attribute Both the productivity code and the test projects are targeting .NET 3.5. I have already tried to clean build my solution, and / or delete all obj, bin, Debug and Release folders I'd appreciate any hints which would explain this behaviour.

Thanks to this answer on Twitter I found a way to fix it...

I had to restart OmniSharp (the C# extension for VS Code). It can be done in the command palette (Ctrl+Shift+P). Search for "OmniSharp" and select "OmniSharp: Restart OmniSharp".

Restart OmniSharp from the command palette in VS Code.

Related