{"action":"created","issue":{"url":"https://api.github.com/repos/dotnet/roslyn/issues/17713","repository_url":"https://api.github.com/repos/dotnet/roslyn","labels_url":"https://api.github.com/repos/dotnet/roslyn/issues/17713/labels{/name}","comments_url":"https://api.github.com/repos/dotnet/roslyn/issues/17713/comments","events_url":"https://api.github.com/repos/dotnet/roslyn/issues/17713/events","html_url":"https://github.com/dotnet/roslyn/issues/17713","id":213420746,"number":17713,"title":"(Named) value tuples and Linq","user":{"login":"myblindy","id":541998,"avatar_url":"https://avatars0.githubusercontent.com/u/541998?v=3","gravatar_id":"","url":"https://api.github.com/users/myblindy","html_url":"https://github.com/myblindy","followers_url":"https://api.github.com/users/myblindy/followers","following_url":"https://api.github.com/users/myblindy/following{/other_user}","gists_url":"https://api.github.com/users/myblindy/gists{/gist_id}","starred_url":"https://api.github.com/users/myblindy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/myblindy/subscriptions","organizations_url":"https://api.github.com/users/myblindy/orgs","repos_url":"https://api.github.com/users/myblindy/repos","events_url":"https://api.github.com/users/myblindy/events{/privacy}","received_events_url":"https://api.github.com/users/myblindy/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-03-10T18:47:08Z","updated_at":"2017-03-10T22:11:24Z","closed_at":null,"body":"**Steps to Reproduce**:\r\n```\r\nvar list = new(int value, string name)[] { (1, \"a\"), (2, \"b\"), (3, \"c\") };\r\nvar item = list.FirstOrDefault(w => w.value > 5);\r\n```\r\n\r\n**Expected Behavior**:\r\nI would expect `item` to be `(int, string)?` so I can use `??` or test of failure in a meaningful way.\r\n\r\n**Actual Behavior**:\r\nWhat I actually get is an actual value type with default values inside. This may or may not be useful (and indeed it is not in my case), since 0/null values inside the tuple can easily be valid entries.\r\n\r\nThis is worsened by functions such as this:\r\n```\r\n        internal static TValue SafeTryGet<TKey, TValue>(this IDictionary<TKey, TValue> list, TKey key) =>\r\n            key != null && list.TryGetValue(key, out TValue ret) ? ret : default(TValue);\r\n```\r\n There's no (obvious) way of overloading this function to return a nullable type for value types and a plain `default` for classes. The closest I've gotten is with a second helper function, but this isn't anywhere as clean as it could be:\r\n```\r\n        internal static TValue? SafeTryGetValue<TKey, TValue>(this IDictionary<TKey, TValue> list, TKey key) where TValue : struct =>\r\n            key != null && list.TryGetValue(key, out TValue ret) ? ret : new TValue?();\r\n```"},"comment":{"url":"https://api.github.com/repos/dotnet/roslyn/issues/comments/285798944","html_url":"https://github.com/dotnet/roslyn/issues/17713#issuecomment-285798944","issue_url":"https://api.github.com/repos/dotnet/roslyn/issues/17713","id":285798944,"user":{"login":"alrz","id":3105979,"avatar_url":"https://avatars1.githubusercontent.com/u/3105979?v=3","gravatar_id":"","url":"https://api.github.com/users/alrz","html_url":"https://github.com/alrz","followers_url":"https://api.github.com/users/alrz/followers","following_url":"https://api.github.com/users/alrz/following{/other_user}","gists_url":"https://api.github.com/users/alrz/gists{/gist_id}","starred_url":"https://api.github.com/users/alrz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alrz/subscriptions","organizations_url":"https://api.github.com/users/alrz/orgs","repos_url":"https://api.github.com/users/alrz/repos","events_url":"https://api.github.com/users/alrz/events{/privacy}","received_events_url":"https://api.github.com/users/alrz/received_events","type":"User","site_admin":false},"created_at":"2017-03-10T22:11:24Z","updated_at":"2017-03-10T22:11:24Z","body":"That's not how `FirstOrDefault` works, it literally returns `default(T)` where `T` is `(int, string)`.\r\n\r\nYou could use this instead:\r\n```cs\r\nvar list = new(int value, string name)?[] { (1, \"a\"), (2, \"b\"), (3, \"c\") };\r\nvar item = list.FirstOrDefault(w => w.value > 5);\r\n```"}}
{"actor":{"display_login":"alrz"}}