Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New warning CS9220 for Razor code using string.Join #73643

Closed
eerhardt opened this issue May 22, 2024 · 1 comment · Fixed by #73829
Closed

New warning CS9220 for Razor code using string.Join #73643

eerhardt opened this issue May 22, 2024 · 1 comment · Fixed by #73829
Assignees
Labels
Area-Compilers New Feature - ParamsCollections untriaged Issues and PRs which have not yet been triaged by a lead
Milestone

Comments

@eerhardt
Copy link
Member

eerhardt commented May 22, 2024

See dotnet/aspnetcore#55780 (comment) for the original conversation

Version Used: .NET SDK 9.0.100-preview.5.24262.2

Steps to Reproduce:

  1. In a .cshtml MVC file write the following code:
<cache>Products: @string.Join(", ", ProductsService.GetProductNames(ViewBag.Category)) (@ViewBag.CorrelationId)</cache> 

Where the ProductsService.GetProductNames method looks like:

public IEnumerable<string> GetProductNames(string category) 
{
    return new string[] { "one", "two" };
}

A minimal repro, with source-code provided, is ideal. Using sharplab is preferred for compiler/language issues whenever possible.

Diagnostic Id: CS9220

Expected Behavior:

Before .NET 9, the above code compiled successfully without warnings.

Actual Behavior:

Using .NET 9, the code now produces a new warning:

src/Mvc/test/WebSites/HtmlGenerationWebSite/Views/Catalog_CacheTagHelper/ListCategories.cshtml(4,19): error CS9220: (NETCORE_ENGINEERING_TELEMETRY=Build) One or more overloads of method 'Join' having non-array params collection parameter might be applicable only in expanded form which is not supported during dynamic dispatch.

This was discovered when taking a new dotnet/runtime version with dotnet/runtime#101499 which added the params keyword to parameters of string.Join.

cc @AlekseyTs @jaredpar @jozkee @javiercn

@AlekseyTs
Copy link
Contributor

I will add this to LDM agenda

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Compilers New Feature - ParamsCollections untriaged Issues and PRs which have not yet been triaged by a lead
Projects
None yet
3 participants