C# 10 Why SQ requires us to move public partial class Program to a named namespace?

Version: SonarQube Developer Edition Version 9.3 (build 51899)

We have an ASP.NET Core 6 Web Api application, using C# 10.

We have introduced Integration tests as described in Microsoft’s documentation here.

To make Program.cs visible to the Integration tests project we have added the following to Program.cs file as is recommended by Microsoft:

  • public partial class Program { }

However, at this line we get the following error by SonarQube:

Move ‘Program’ into a named namespace.

In Asp.net core 6 Program.cs does not have a namespace.

As I read here SonarQube should support top-level statements.

Then why do we get this error from SonarQube?

Is there any additional setting we should make or should I report this to the false-positive section?

Hey there.

We’ve continued to improve support and this false-positive will be fixed with the next release of SonarQube (v9.6) next week. Rule S3903: False Positive when using top level statments and partial Program · Issue #5660 · SonarSource/sonar-dotnet · GitHub

1 Like