Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Roslynator CLI Reports CS0121 on a .NET 9 Project (Visual Studio & dotnet build OK)Β #1612

@fgimian

Description

@fgimian

Hey there, there's a very unusual issue with the Roslynator CLI whereby it reports CS0121 on valid .NET 9 code.

Simply create a new C# console application and replace the main program code with the following:

namespace Example;

internal class Program
{
    static void Main()
    {
        var text = string.Join(',', ["a", "b", "c"]);
        Console.WriteLine(text);
    }
}

Visual Studio shows no warnings:

Image

The application builds:

~\source\Example via .NET v9.0.102 🎯 net9.0 took 4s
πŸ•™ [ 04:03:53 PM ] ❯ dotnet build
Restore complete (0.5s)
  Example succeeded (2.8s) β†’ bin\Debug\net9.0\Example.dll

Build succeeded in 3.6s

But the Roslynator CLI reports CS0121:

~\source\Example via .NET v9.0.102 🎯 net9.0
πŸ•™ [ 04:03:40 PM ] ❯ roslynator.exe analyze .\Example.sln
Loading solution 'C:\Users\Fots\source\Example\Example.sln'...
Analyze solution 'C:\Users\Fots\source\Example\Example.sln'
Analyze 'Example' 1/1
  Program.cs(7,27): error CS0121: The call is ambiguous between the following methods or properties: 'string.Join(char, params ReadOnlySpan<object?>)' and 'string.Join(char, params ReadOnlySpan<string?>)'
Analyzed solution 'C:\Users\Fots\source\Example\Example.sln' (in 2.7 s)

1 CS0121

1 diagnostic found

Thanks heaps in advance!
Fotis

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions