Skip to content
This repository was archived by the owner on Nov 20, 2018. It is now read-only.

Should StringValues implement Equals? #384

Closed
Tratcher opened this issue Sep 2, 2015 · 6 comments
Closed

Should StringValues implement Equals? #384

Tratcher opened this issue Sep 2, 2015 · 6 comments

Comments

@Tratcher
Copy link
Member

Tratcher commented Sep 2, 2015

StringValues does not currently implement Equals (or GetHashCode). MVC implements their own wrapper that has Equals. If so, what should be considered equal?
"string" == new[] { "string" }?
string.Empty == null?
null == new[] { null }?
"value1,value2" == new[] { "value1", "value2" }?
Ordinal?

@atifaziz
Copy link

atifaziz commented Sep 2, 2015

Since StringValues is logically just an array of strings with some internal optimizations, its equality and hashing should behave like that of an array when being checked for structural equality. That would provide the least surprises and yet still permit some customization when needed (e.g. ignore case when comparing each element).

@glennc glennc added this to the 1.0.0-beta8 milestone Sep 3, 2015
@glennc
Copy link
Member

glennc commented Sep 3, 2015

@Tratcher can you round up @lodejard and @davidfowl to get an answer for this now-ish?

@davidfowl
Copy link
Member

@rynowak we did this right?

@khellang
Copy link
Contributor

@rynowak
Copy link
Member

rynowak commented Oct 30, 2015

@davidfowl - it implements .Equals. We should think about removing some of the overloaded == operators. Right now if you try to compare with null you get an error about ambiguity when you should get the 'Hey, it's a struct buddy' error.

@aspnet-hello
Copy link

This issue was moved to dotnet/aspnetcore#2726

@aspnet aspnet locked and limited conversation to collaborators Jan 2, 2018
@aspnet-hello aspnet-hello removed this from the Backlog milestone Jan 2, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

8 participants