.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.

Denis

3 Likes

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.

Denis

2 Likes

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

Denis

1 Like