Do not rely on the implicit StringValues to array converter.#1009
Conversation
|
Should public static implicit operator string[] (StringValues value)
{
return value.GetArrayValue();
}to public static implicit operator string[] (StringValues value)
{
return value.ToArray();
}Previously (Though is fixed by not relying on it being non-null) |
|
The implicit converters should round trip, calling ToArray just inverts the problem. |
|
@Tratcher Is it critical for converters to round trip if they stabilize to a conical form? I'm thinking that @benaadams might be right. Converting empty StringValues to an empty array instead of a null array seems safer. If we did this, would this get Universe passing? |
|
Prior to the change Count == 0
Count == 1
Count == 2
This means the check if ((_value != null ? 1 : (_values?.Length ?? 0)) == 0)So the cast of a After dotnet/extensions#323 there is a single (internal) representation for each count Count == 0
Count == 1
Count == 2
There is a fast path for if (_value == null && _values == null)Obviously the inverse for And the cast of a Though, its easy enough to have it return |
|
I think there is a different change needed... |
|
Is this the change that's needed to fix Universe? #1010 |
Fixes http://aspnetci/viewLog.html?buildId=425449&tab=buildResultsDiv&buildTypeId=Lite_UniverseTest
dotnet/extensions#323 made a subtle change that causes
string[] myArray = new StringValues(new string[0])to implicitly become null. This broke many components up stack that were expecting GetCommaSeparatedValues to return a non-null value even for an empty or missing header resulting in and caused 76 tests failures.This should fix everything except the MVC test ValueProviderResultTest.Construct_With_None.
@benaadams @ryanbrandenburg