SonarSource / sonar-dotnet

Code analyzer for C# and VB.NET projects
https://redirect.sonarsource.com/plugins/csharp.html
GNU Lesser General Public License v3.0
797 stars 229 forks source link

Fix S4056 AD0001: .NET 9 RC1 #9670

Closed bart-vmware closed 1 month ago

bart-vmware commented 2 months ago

Description

Building our codebase against .NET 9 RC1 produces the following warning:

CSC : warning AD0001: Analyzer 'SonarAnalyzer.Rules.CSharp.SpecifyIFormatProviderOrCultureInfo' threw an exception of type 'System.NullReferenceException' with message 'Object reference not set to an instance of an object.'.

Repro steps

public class Graph
{
    private const long One = 1;
    private const long Two = 2;

    public override string ToString()
    {
        return string.Format("{0} {1} {2:f3} {3:f3}", One, One, Two / 0.5, One);
    }
}

Known workarounds

None.

Related information

bart-vmware commented 2 months ago

Here's a runnable project, in case it helps.

SonarAnalyzerCrash.zip

mary-georgiou-sonarsource commented 1 month ago

Hello, thanks for reporting this bug. It will be fixed in the next release.

bart-vmware commented 1 month ago

Is there no public PR for the fix?

mary-georgiou-sonarsource commented 1 month ago

@bart-vmware There will be, we're preparing .NET 9 support.

bart-vmware commented 1 month ago

Then why was this issue closed, while the fix hasn't been implemented/merged yet? I'm concerned this may slip through.

pavel-mikula-sonarsource commented 1 month ago

Hi Bart,

We have an internal working document that we're using to plan the entire .NET 9 support topic, and this document will make sure it will not be missed. We're closing the external issues, as they'll become redundant once we start the implementation.