# C# S9129 not raised in SonarQube for VS Code

**URL:** <https://community.sonarsource.com/t/c-s9129-not-raised-in-sonarqube-for-vs-code/189352>\
**Category:** VS Code\
**Tags:** csharp, vscode, sonarqube-ide\
**Created:** [October 7, 2026, 2:24pm UTC](https://community.sonarsource.com/t/c-s9129-not-raised-in-sonarqube-for-vs-code/189352 "2026-10-07T14:24:54Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![dukedagmor](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/dukedagmor/32/67608_2.png) [@dukedagmor](https://community.sonarsource.com/u/dukedagmor)\
**Post date:** [October 7, 2026, 2:24pm UTC](https://community.sonarsource.com/t/c-s9129-not-raised-in-sonarqube-for-vs-code/189352/1 "2026-10-07T14:24:54Z")

</div>

**Title:** C# S9129 not raised in SonarQube for VS Code for an `Include(collection).ThenInclude(reference).ThenInclude(...)` chain that a build with the same analyzers reports

### Environment

- Operating system: Windows 11 x64
- IDE: VS Code Insiders 1.141
- SonarQube for IDE: 6.0.1
- Connected mode: yes, SonarQube Server 2026.5.1
- C# analyzers used by the extension: `SonarAnalyzer.CSharp` and `SonarAnalyzer.Enterprise.CSharp` 10.34.0.3385
- OmniSharp host used by the extension: 1.39.15.1-sonar (Roslyn 5.3.0)
- .NET SDK 10.0.401, EF Core 10.0.7

### Problem

S9129 (“Include” and “ThenInclude” chains of reference navigations should be merged) is not raised in VS Code for a chain where a collection navigation is followed by reference navigations. The rule description lists exactly this pattern as noncompliant (“A collection navigation earlier in the chain doesn’t block merging the references that follow it”).

A normal `dotnet build` that loads the same two analyzer DLLs as the extension reports the issue. I confirmed by file hash that the DLLs are identical to the ones loaded in the extension’s OmniSharp process.

The analysis of the statement does run in VS Code: S8733 is reported for the same `Include` chain. All other findings in the file match between VS Code and the build; only S9129 is missing.

In our real project, VS Code reports 6 of the 9 S9129 issues in one file and none in another. The server analysis reports all of them.

### Minimal reproducer

`S9129Repro.csproj`

```xml
<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net10.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="10.0.7" />
  </ItemGroup>

</Project>

```

`Program.cs`

```csharp
using Microsoft.EntityFrameworkCore;

using var db = new ReproContext();

IQueryable<Customer> query = db.Customers;
query = query
    .Include(c => c.Contracts) // S8733 (control): reported by the build and by SonarQube for VS Code
    .Include(c => c.Processors)
        .ThenInclude(cp => cp.Processor) // S9129: reported by the build, missing in SonarQube for VS Code
            .ThenInclude(p => p.Statuses);

Console.WriteLine($"Customers: {query.Count()}");

public class ReproContext : DbContext
{
    public DbSet<Customer> Customers => Set<Customer>();

    protected override void OnConfiguring(DbContextOptionsBuilder options) => options.UseInMemoryDatabase("S9129");
}

public class Customer
{
    public int Id { get; set; }
    public ICollection<Contract> Contracts { get; set; } = [];
    public ICollection<ProcessorCustomer> Processors { get; set; } = [];
}

public class Contract
{
    public int Id { get; set; }
}

public class ProcessorCustomer
{
    public int Id { get; set; }
    public Processor Processor { get; set; } = null!;
}

public class Processor
{
    public int Id { get; set; }
    public ICollection<ProcessorStatus> Statuses { get; set; } = [];
}

public class ProcessorStatus
{
    public int Id { get; set; }
}

```

### Steps to reproduce

1. Put both files in a folder and run `dotnet run`. It prints `Customers: 0`, which also restores the packages; the extension’s OmniSharp doesn’t restore them itself.

2. Open the folder in VS Code with SonarQube for IDE 6.0.1 and analyze `Program.cs`.

3. For comparison, build with the extension’s analyzers. Take the DLLs from its `slServices\analyzers` folder under `~/.sonarlint/work`, put them in a targets file, and run:  
`dotnet build -t:Rebuild -p:CustomAfterMicrosoftCommonTargets=<path>\probe.targets`

### Expected

S9129 on line 9 (`.ThenInclude(cp => cp.Processor)`), as reported by the build:

```auto
Program.cs(9,31): warning S9129: Combine this "Include" call with the "ThenInclude" call that follows it into a single "Include" call.

```

### Actual

VS Code reports S8733 on line 7, S6966 on line 12, S927 on line 18 and S3903 on the six classes. These are all the same as the build, but S9129 on line 9 is missing.

### Already ruled out

- The rule is active in the bound quality profile, and the server issues are open (not accepted or marked as false positive).
- Both analyzer DLLs are loaded in the extension’s OmniSharp process, and the project loads successfully.
- The result is the same after restarting VS Code and OmniSharp, and on two consecutive days.
- Updating VSCode and reinstalling the sonarqube extension did not change the results
- The SonarQube MCP server’s `analyze_file_list`, which returns the extension’s findings directly without using the Problems view, also reports S8733 but not S9129. So the issue is not hidden by the display; the extension’s analysis does not produce it.

---

<div class="post-metadata">

**Author:** ![andres](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/andres/32/76342_2.png) [@andres](https://community.sonarsource.com/u/andres)\
**Post date:** [October 12, 2026, 4:08pm UTC](https://community.sonarsource.com/t/c-s9129-not-raised-in-sonarqube-for-vs-code/189352/2 "2026-10-12T16:08:21Z")

</div>

Hey @dukedagmor, so just to clarify, what you’re saying is that the issue does pop up when you run a normal analysis (not an IDE-extension analysis)? I’m mostly trying to understand what do you mean by:

> A normal `dotnet build` that loads the same two analyzer DLLs as the extension reports the issue.

Could you share a screenshot of the issue as reported on SonarQube Server?

---

<div class="post-metadata">

**Author:** ![dukedagmor](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/dukedagmor/32/67608_2.png) [@dukedagmor](https://community.sonarsource.com/u/dukedagmor)\
**Post date:** [October 15, 2026, 8:23am UTC](https://community.sonarsource.com/t/c-s9129-not-raised-in-sonarqube-for-vs-code/189352/3 "2026-10-15T08:23:43Z")

</div>

SonarQube Server reports the issue on the real-project code that the VS Code extension misses. SonarQube for Visual Studio also reports it.

I meant a local build with the extension’s analyzer DLLs explicitly added to the compiler.

To do that, I created a temporary `probe.targets` file referencing the two DLLs from the extension’s `slServices\analyzers` folder under `~/.sonarlint/work`:

```xml
<Project>
  <ItemGroup>
    <Analyzer Include="C:\path\to\analyzers\SonarAnalyzer.CSharp.dll" />
    <Analyzer Include="C:\path\to\analyzers\SonarAnalyzer.Enterprise.CSharp.dll" />
  </ItemGroup>
</Project>

```

I then imported that file for the build using:

```powershell
dotnet build -t:Rebuild "-p:CustomAfterMicrosoftCommonTargets=C:\path\to\probe.targets"

```

This adds the DLLs as Roslyn analyzers for that build without requiring a permanent change to the project. Both DLLs were version `10.34.0.3385`, and I verified that their file hashes matched the DLLs loaded by the extension’s OmniSharp process.

For the minimal reproducer, that build reported:

```plaintext
Program.cs(9,31): warning S9129: Combine this "Include" call with the "ThenInclude" call that follows it into a single "Include" call.

```

The VS Code extension reported S8733 on the same Include chain but did not report S9129. The purpose of this comparison was to establish that the same analyzer binaries detect the issue when run through the compiler, but miss it in the extension’s analysis.

---

<div class="post-metadata">

**Author:** ![andres](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/andres/32/76342_2.png) [@andres](https://community.sonarsource.com/u/andres)\
**Post date:** [October 15, 2026, 12:25pm UTC](https://community.sonarsource.com/t/c-s9129-not-raised-in-sonarqube-for-vs-code/189352/4 "2026-10-15T12:25:11Z")

</div>

Hey @dukedagmor, that’s a neat trick, thanks for clarifying and for sharing the steps to reproduce with such detail. I’ll flag this for the team.

---

<div class="post-metadata">

**Author:** ![nicolas.quinquenel](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/nicolas.quinquenel/32/40740_2.png) [@nicolas.quinquenel](https://community.sonarsource.com/u/nicolas.quinquenel)\
**Post date:** [October 16, 2026, 9:18am UTC](https://community.sonarsource.com/t/c-s9129-not-raised-in-sonarqube-for-vs-code/189352/7 "2026-10-16T09:18:55Z")

</div>

Hi @dukedagmor,

Thanks for the detailed reproducer and the comparison using the same analyzer DLLs. I reproduced the issue with version 10.34.0.3385 and I think I identified the cause.

S9129 is actually generated, but Roslyn classifies it as a “non-local” diagnostic.

We will look for a fix and will keep you updated!

---

<div class="post-metadata">

**Author:** ![Martin\_Strecker](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/martin_strecker/32/32318_2.png) [@Martin\_Strecker](https://community.sonarsource.com/u/Martin_Strecker)\
**Post date:** [November 17, 2026, 5:40pm UTC](https://community.sonarsource.com/t/c-s9129-not-raised-in-sonarqube-for-vs-code/189352/12 "2026-11-17T17:40:38Z")

</div>

Hi @dukedagmor,

Thanks again for the detailed reproducer. As Nicolas noted above, S9129 is raised, but Roslyn classifies it as a non-local diagnostic.

This is by design in how Roslyn’s analyzer driver works. When an IDE analyzes a document, Roslyn treats a diagnostic as local only if its location lies inside the syntax node that the analyzer callback ran on. S9129 reports on a later call of the `Include`/`ThenInclude` chain, outside that node, so Roslyn leaves it out of the per-document results that IDE integrations use. A build or a server analysis doesn’t apply this filter, which is why you see the issue there. The Roslyn change that introduced the rule is [dotnet/roslyn#67275](https://github.com/dotnet/roslyn/pull/67275) (“any diagnostic reported outside the span of the callback operation/node should be considered a non-local diagnostic”, and it notes that batch compilation isn’t affected).

We are looking into fixing this by working around it in the rule, so that S9129 reports from a node that covers the whole chain. I can’t give a date yet.
