Are you using SonarLint? If so, what is your SonarLint version?
Or are you referencing the SonarAnalyzer as a nuget package? If so, what is the package’s version?
Sorry for the delay,
I am typically on the most recent version of SonarLint, Which at this point is 8.20 i believe.
However, i’m not getting this from SonarLint, I think.
We run a post build process from Visual Studio, that executes a scan for our SonarQube server, using the latest 5.10 scanner for .Net Framework.
That is where i believe the error is occurring.
Either way, it seems to be almost random when this error will or won’t occur as some projects work just fine but others do not.
I can confirm this is not a SonarLint issue at this point. I have removed the SonarAnalyzer.CSharp nuget package from the project, and i still get this error when running our post build scan using the “SonarScanner.MSBuild.exe” standalone scanner for SonarQube.
I have also honed in on the nature of the cause: Implicit Object Creation.
I haven’t worked out exactly when the scanner allows for Implicit Object Creation, but thus far doing anything other than
MyType x = new(); //When MyType is defined in the current assembly
Any other usage of the Implict Object Creator, causes this error to arise. If there are parameters in the constructor, or if implicit creation is part of a “using” expression, or if the implicit constructor is followed by an object initialization block.
When i carte blanche replace all instances of IDE0090 info-hint in my code, i run a chance of incurring this flaw in the scanner.
To get the latest SonarCSharp version, you would need to update to the latest SonarQube version 8.8. In SonarCSharp 8.16 we’ve fixed #3814, and in 8.18 we’ve removed S3949 from SonarWay due to its performance problems and currently limited functionality.
We even have a unit test case with target-typed new to make sure it doesn’t throw.
To avoid having noise in your logs, you can either update your SQ instance to benefit of the latest analyzers, or remove S3949 from your Quality Profile.