{"action":"created","issue":{"url":"https://api.github.com/repos/dotnet/corefx/issues/1254","labels_url":"https://api.github.com/repos/dotnet/corefx/issues/1254/labels{/name}","comments_url":"https://api.github.com/repos/dotnet/corefx/issues/1254/comments","events_url":"https://api.github.com/repos/dotnet/corefx/issues/1254/events","html_url":"https://github.com/dotnet/corefx/issues/1254","id":64541166,"number":1254,"title":"Enumerable.Single and Enumerable.SingleOrDefault overloaded implementations are inconsistent","user":{"login":"rverdier","id":52016,"avatar_url":"https://avatars.githubusercontent.com/u/52016?v=3","gravatar_id":"","url":"https://api.github.com/users/rverdier","html_url":"https://github.com/rverdier","followers_url":"https://api.github.com/users/rverdier/followers","following_url":"https://api.github.com/users/rverdier/following{/other_user}","gists_url":"https://api.github.com/users/rverdier/gists{/gist_id}","starred_url":"https://api.github.com/users/rverdier/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rverdier/subscriptions","organizations_url":"https://api.github.com/users/rverdier/orgs","repos_url":"https://api.github.com/users/rverdier/repos","events_url":"https://api.github.com/users/rverdier/events{/privacy}","received_events_url":"https://api.github.com/users/rverdier/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/dotnet/corefx/labels/System.Linq","name":"System.Linq","color":"d4c5f9"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-03-26T14:31:12Z","updated_at":"2015-03-28T23:34:22Z","closed_at":null,"body":"There is an inconsistency between the implementations of [Enumerable.Single()][1] and [Enumerable.Single(predicate)][2]. Similarly there is another similar inconsistency between the implementations of [Enumerable.SingleOrDefault()][3] and [Enumerable.SingleOrDefault(predicate)][4]\r\n\r\nThe overloads which accept a predicate enumerate the whole sequence before eventually throwing, even if more than one matching elements were already found:\r\n\r\nFor consistency and performance reasons, it may be a good idea to make [Enumerable.Single(predicate)][2] and [Enumerable.SingleOrDefault(predicate)][4] methods able to fail fast and to throw an `InvalidOperationException` as soon as a second matching element is found.\r\n\r\nIf that seems like a reasonable change, I would gladly submit a pull request.\r\n\r\n  [1]: https://github.com/dotnet/corefx/blob/master/src/System.Linq/src/System/Linq/Enumerable.cs#L1260\r\n  [2]: https://github.com/dotnet/corefx/blob/master/src/System.Linq/src/System/Linq/Enumerable.cs#L1284\r\n  [3]: https://github.com/dotnet/corefx/blob/master/src/System.Linq/src/System/Linq/Enumerable.cs#L1306\r\n  [4]: https://github.com/dotnet/corefx/blob/master/src/System.Linq/src/System/Linq/Enumerable.cs#L1330"},"comment":{"url":"https://api.github.com/repos/dotnet/corefx/issues/comments/87329931","html_url":"https://github.com/dotnet/corefx/issues/1254#issuecomment-87329931","issue_url":"https://api.github.com/repos/dotnet/corefx/issues/1254","id":87329931,"user":{"login":"MarcinJuraszek","id":6841973,"avatar_url":"https://avatars.githubusercontent.com/u/6841973?v=3","gravatar_id":"","url":"https://api.github.com/users/MarcinJuraszek","html_url":"https://github.com/MarcinJuraszek","followers_url":"https://api.github.com/users/MarcinJuraszek/followers","following_url":"https://api.github.com/users/MarcinJuraszek/following{/other_user}","gists_url":"https://api.github.com/users/MarcinJuraszek/gists{/gist_id}","starred_url":"https://api.github.com/users/MarcinJuraszek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MarcinJuraszek/subscriptions","organizations_url":"https://api.github.com/users/MarcinJuraszek/orgs","repos_url":"https://api.github.com/users/MarcinJuraszek/repos","events_url":"https://api.github.com/users/MarcinJuraszek/events{/privacy}","received_events_url":"https://api.github.com/users/MarcinJuraszek/received_events","type":"User","site_admin":false},"created_at":"2015-03-28T23:34:22Z","updated_at":"2015-03-28T23:34:22Z","body":"There is a really old Connect report about that by Jon Skeet that was *Won't Fix*ed: https://connect.microsoft.com/VisualStudio/feedback/details/639955"}}