Can’t found any C# questions

Hi, I found Sonarlint extension can’t found any C# questions. But other language like Python or Java is normal. Can you tell me what’s wrong or how to configure it?

I think I’m not the only one running into this problem.

Hey there.

  • A good start would be – what version of Sonarlint for VSCode are you using?
  • Have you checked the documentation for C# Analysis?
  • Do you have C# support installed for VS Code? C# - Visual Studio Marketplace
  1. System Info
VSCode Version: 1.85.2
Commit: 8b3775030ed1a69b13e4f4c628c612102e30a681
Date: 2024-01-18T06:40:11.430Z
Electron: 25.9.7
ElectronBuildId: 26354273
Chromium: 114.0.5735.289
Node.js: 18.15.0
V8: 11.4.183.29-electron.0
OS: Darwin arm64 23.3.0
SonarLint  `v4.5.0`
C# Dev Kit  `v1.4.29`
C#  `v2.23.15`
  1. I think I don’t change any default settings for C# Analysis

  2. Yes, the C# extension version is v2.23.15

Below is my test code

Classes should not be empty (csharpsquid:S2094)

public class Empty // TODO Noncompliant
{
}

It should some lint error but nothing happend.

Thanks. I have no issue getting an issue to raise here.

Is your .cs file actually a part of a project/solution?

Thanks. This solved my problem.

I think C# files must be under a project to be scanned for problems by sonarlint, unlike Python, where a single file can be scanned.

2 Likes

Yes, this is very likely the root cause, thanks for sharing it!

The main reason behind this is that C# analysis relies on Roslyn (in this case, powered by OmniSharp) which requires a valid .Net project/solution to be loaded in the IDE (e.g. to resolve types).

1 Like