Open
Description
Background and Motivation
Currently if appending a value to a StringValues
you need to use the static Concat
method:
headers.ContentLanguage = StringValues.Concat(headers.ContentLanguage, requestCulture.UICulture.Name);
Overloading operator+
would allow it to be much cleaner
headers.ContentLanguage += requestCulture.UICulture.Name;
Proposed API
Please provide the specific public API signature diff that you are proposing. For example:
namespace Microsoft.Extensions.Primitives
{
public readonly partial struct StringValues
{
public static StringValues operator +(StringValues left, StringValues right);
public static StringValues operator +(string left, StringValues right);
public static StringValues operator +(StringValues left, string right);
public static StringValues operator +(string[] left, StringValues right);
public static StringValues operator +(StringValues left, string[] right);
}
}
Risks
Currently
headers.ContentLanguage += requestCulture.UICulture.Name;
Will compile; however it will implicitly convert the StringValues
to a string
add the two string
s and then implictly convert back to a single value StringValue
.
However; hopefully no-one is doing that as it will append the add in an incorrect way.