{"action":"opened","issue":{"url":"https://api.github.com/repos/dotnet/roslyn/issues/7338","labels_url":"https://api.github.com/repos/dotnet/roslyn/issues/7338/labels{/name}","comments_url":"https://api.github.com/repos/dotnet/roslyn/issues/7338/comments","events_url":"https://api.github.com/repos/dotnet/roslyn/issues/7338/events","html_url":"https://github.com/dotnet/roslyn/issues/7338","id":121112211,"number":7338,"title":"Unify the various code fixes related to implementing equality checking correctly","user":{"login":"amcasey","id":10508071,"avatar_url":"https://avatars.githubusercontent.com/u/10508071?v=3","gravatar_id":"","url":"https://api.github.com/users/amcasey","html_url":"https://github.com/amcasey","followers_url":"https://api.github.com/users/amcasey/followers","following_url":"https://api.github.com/users/amcasey/following{/other_user}","gists_url":"https://api.github.com/users/amcasey/gists{/gist_id}","starred_url":"https://api.github.com/users/amcasey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amcasey/subscriptions","organizations_url":"https://api.github.com/users/amcasey/orgs","repos_url":"https://api.github.com/users/amcasey/repos","events_url":"https://api.github.com/users/amcasey/events{/privacy}","received_events_url":"https://api.github.com/users/amcasey/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/dotnet/roslyn/labels/Area-IDE","name":"Area-IDE","color":"5319e7"},{"url":"https://api.github.com/repos/dotnet/roslyn/labels/Feature%20Request","name":"Feature Request","color":"fc2929"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-12-08T22:17:59Z","updated_at":"2015-12-08T22:17:59Z","closed_at":null,"body":"Spun off from a comment thread in https://github.com/dotnet/roslyn-analyzers/pull/743.\r\n\r\nPresently, we have a collection of fixes that each add a single method: if you have `==`, we add `Equals`; if you have `Equals` we add `GetHashCode`.  The simplest generalization would be to offer both methods at the same time (assuming neither already existed, of course).  However, a more general approach would be to detect that the user is trying to implement equality checking and offer a more comprehensive series of snippets.\r\n\r\nFor example, as soon as you have either `==` or `!=`, we should probably offer the other operator, `Equals`, `GetHashCode`, and maybe even `IEquatable<T>` (for value types).  We might also want to tie into the existing `Equals`/`GetHashCode` refactoring that generates a reasonable implementation from the fields (and readonly auto-properties) of the type.\r\n\r\nOne can imagine further extending this to comparisons, but that might be a separate work item."}}