.NET 8 and C# 12 support

Hi .NETers

In advance of the upcoming .NET release, we are very happy to announce that we have added support for C#12 & .NET 8.

We now find issues in the new syntax in C#12 such as primary constructors, collection expressions, inline arrays, optional parameters in lambdas, ref readonly parameters and type aliases. The current release focuses on the rules contained in the “Sonar way” profile, improvements to non-Sonar way rules will follow.

This release is available today on SonarCloud and will be in the forthcoming SonarQube 10.3. Support for SonarLint will follow shortly in Visual Studio, Rider and Visual Studio Code (you have checked out SonarLint’s new C# in VS Code support, right?).

Feel free to leave any questions or feedback in the comments.



Will .NET 8 be supported in 9.9 LTS, or 10.3 only?

Hi Matthew,

I am afraid that this will not be the case. LTS versions are maintained for bug fixes and do not receive new features once released.



There seems to be an issue with primary constructors, as the following code:

public class ClaimsIdentityExpectedException() : CodeException(Properties.Resources.TtWkisEx0001ClaimsIdentityExpectedException,Properties.Resources.TtWkisEx0001ClaimsIdentityExpectedCode)

leeds to the following False Positive(?):

So I am passing paramters to the base class. I changed it from the “old fashion way”:

public class ClaimsIdentityExpectedException : CodeException
   public ClaimsIdentityExpectedException() : base(Properties.Resources.TtWkisEx0001ClaimsIdentityExpectedException, Properties.Resources.TtWkisEx0001ClaimsIdentityExpectedCode)

The old way is not making any trouble.

Any thoughts @denis.troller ?

Hey @DominikTouring

Can you raise a separate thread and follow these guidelines for reporting a false-positive?

Hi Dominik,

Thank you for reporting this issue!

I am afraid it is indeed a false positive. We are aware of this and it will be tackled in a future “hardening” sprint.
The issue is tracked on the github repository


1 Like

hi, we recently migrated code to .net 8 and using SonarQubePrepare@5 in PR builds. The PR containing .net 8 code did not report any code smells. But the Sonarqube platform show 67 code smells in main branch after code was merged.

Any idea on why code smells were not reported in PR build? Double checked that the code smells were introduced after migrating to .net 8 and quality gate was configured to fail.

Should we use SonarQubePrepare@ *** latest task ? If so what would be version that compatible with .net8


Hi there,

First, welcome to the community!
Second, to your point, the version of the task should only govern which version of the scanner you use, which is unrelated to support for .NET 8. This is only linked to which analyzer is used, and in turn to the version of SonarQube.

Last, as a rule of thumb, it is really better if you open a dedicated post to report problems (there is also a good template about the kind of information you can provide to make it easier). Would you mind doing that for this issue? That way we can more easily track and assign the issue, and you can provide full context.