SonarCloud in GitHub doesn't recognise C# 12 primary constructors

141 Views Asked by At

SonarCloud in GitHub doesn't recognise C# 12 primary constructors and this triggers various false negatives in validation rules.

One example is below, here Sonar interprets a class with primary constructor as an empty class - which is not empty. There are other issues, but it seems like SonarCloud is either not up to date or some configuration might be required?

enter image description here

enter image description here

2

There are 2 best solutions below

0
On

After some more digging found this :

https://community.sonarsource.com/t/net-8-and-c-12-support/103931

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.

Looks like we'll have to wait until it's sorted out.

0
On

Looks like C# 12 is not supported yet. On their website it states that ATM (Nov-2023):

Language Versions

  • To C#11