graphql-dotnet / graphql-dotnet/graphql-client
Strip down or remove GetHashCode / Equals
- Dominant language
- C#
- Stars
- 648
- Forks
- 136
- PR merge metrics
- No merged PRs in 30d
Description
I have long wanted to ask what is the reason for the presence of such code.
```c#
public override int GetHashCode()
{
unchecked
{
var hashCode = EqualityComparer.Default.GetHashCode(Data);
{
if (Errors != null)
{
foreach (var element in Errors)
{
hashCode = (hashCode * 397) ^ EqualityComparer.Default.GetHashCode(element);
}
}
else
{
hashCode = (hashCode * 397) ^ 0;
}
if (Extensions != null)
{
foreach (var element in Extensions)
{
hashCode = (hashCode * 397) ^ EqualityComparer>.Default.GetHashCode(element);
}
}
else
{
hashCode = (hashCode * 397) ^ 0;
}
}
return hashCode;
}
}
public static bool operator ==(GraphQLResponse? response1, GraphQLResponse? response2) => EqualityComparer?>.Default.Equals(response1, response2);
public static bool operator !=(GraphQLResponse? response1, GraphQLResponse? response2) => !(response1 == response2);
```
It takes up quite a bit of space and is repeated for `GraphQLError`, `GraphQLLocation`, `GraphQLRequest`, `GraphQLResponse` . I want to note right away that I understand **what** this code is doing. I don’t understand why this is necessary and whether it makes sense. It always seemed to me redundant. My suggestion is to remove all this code and thereby simplify the perception of the rest.
@rose-a Also, some time ago, I wrote that sooner or later I’ll take up the review of this project since I have plans for its reverse integration into my projects. The time has come.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.