Skip to content

ValueProvider array of strings having a null value is processed wrong #40929

@alphons

Description

@alphons

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

public class SomeValueProvider : IValueProvider
{
  public bool ContainsPrefix(string prefix)
  {
    return true;
  }
  public ValueProviderResult GetValue(string key)
  {
    return new ValueProviderResult(new string[] { "a", "b", null, "c" });
  }
}

Controller method

public async Task<IActionResult> Index(List<string> list)
{
  await Task.Yield();

  // Returned list "a", b", "b",  "c"
  // Expected list "a", b", null, "c"

  return Content("<pre>returns "+string.Join(",", list)+ " expected a,b,,c</pre>", "text/html");
}

Expected Behavior

When using an Array of strings having null values in it, it must not skip, nor must it repeat previous element values.

Steps To Reproduce

The bug is visible in this small test project:

https://github.com/alphons/ValueProviderBug

Exceptions (if any)

No exceptions, bug procudes wrong processing of Array elements having null values.

.NET Version

6.0.102

Anything else?

ASP.NET 6.0.2

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions