{"action":"created","issue":{"url":"https://api.github.com/repos/dotnet/corefx/issues/1187","labels_url":"https://api.github.com/repos/dotnet/corefx/issues/1187/labels{/name}","comments_url":"https://api.github.com/repos/dotnet/corefx/issues/1187/comments","events_url":"https://api.github.com/repos/dotnet/corefx/issues/1187/events","html_url":"https://github.com/dotnet/corefx/issues/1187","id":63158632,"number":1187,"title":"Improve the exception message of ToDictionary when keys are duplicated","user":{"login":"yufeih","id":511355,"avatar_url":"https://avatars.githubusercontent.com/u/511355?v=3","gravatar_id":"","url":"https://api.github.com/users/yufeih","html_url":"https://github.com/yufeih","followers_url":"https://api.github.com/users/yufeih/followers","following_url":"https://api.github.com/users/yufeih/following{/other_user}","gists_url":"https://api.github.com/users/yufeih/gists{/gist_id}","starred_url":"https://api.github.com/users/yufeih/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yufeih/subscriptions","organizations_url":"https://api.github.com/users/yufeih/orgs","repos_url":"https://api.github.com/users/yufeih/repos","events_url":"https://api.github.com/users/yufeih/events{/privacy}","received_events_url":"https://api.github.com/users/yufeih/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/dotnet/corefx/labels/enhancement","name":"enhancement","color":"207de5"},{"url":"https://api.github.com/repos/dotnet/corefx/labels/System.Collections","name":"System.Collections","color":"d4c5f9"},{"url":"https://api.github.com/repos/dotnet/corefx/labels/up%20for%20grabs","name":"up for grabs","color":"159818"}],"state":"open","locked":false,"assignee":{"login":"ellismg","id":9602953,"avatar_url":"https://avatars.githubusercontent.com/u/9602953?v=3","gravatar_id":"","url":"https://api.github.com/users/ellismg","html_url":"https://github.com/ellismg","followers_url":"https://api.github.com/users/ellismg/followers","following_url":"https://api.github.com/users/ellismg/following{/other_user}","gists_url":"https://api.github.com/users/ellismg/gists{/gist_id}","starred_url":"https://api.github.com/users/ellismg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ellismg/subscriptions","organizations_url":"https://api.github.com/users/ellismg/orgs","repos_url":"https://api.github.com/users/ellismg/repos","events_url":"https://api.github.com/users/ellismg/events{/privacy}","received_events_url":"https://api.github.com/users/ellismg/received_events","type":"User","site_admin":false},"milestone":null,"comments":34,"created_at":"2015-03-20T04:21:35Z","updated_at":"2015-08-29T03:13:38Z","closed_at":null,"body":"`Enumerable.ToDictionary` makes it easy to turn an array into a dictionary. But when the keys are duplicated in the source array, it just throws an `ArgumentException` that says **An entry with the same key already exists**. It is hard to know what keys are duplicated.\r\n\r\nTo improve the exception message without adding extra overhead, the exception message can be modified to **$\"An entry with the key { key }  already exists\"**.\r\n\r\n`ToDictionary` internally calls `Dictionary<TKey, TValue>.Add()`, so the improvement made to Dictionary.Add benefits all code that calls the method."},"comment":{"url":"https://api.github.com/repos/dotnet/corefx/issues/comments/135933930","html_url":"https://github.com/dotnet/corefx/issues/1187#issuecomment-135933930","issue_url":"https://api.github.com/repos/dotnet/corefx/issues/1187","id":135933930,"user":{"login":"Vannevelj","id":2777107,"avatar_url":"https://avatars.githubusercontent.com/u/2777107?v=3","gravatar_id":"","url":"https://api.github.com/users/Vannevelj","html_url":"https://github.com/Vannevelj","followers_url":"https://api.github.com/users/Vannevelj/followers","following_url":"https://api.github.com/users/Vannevelj/following{/other_user}","gists_url":"https://api.github.com/users/Vannevelj/gists{/gist_id}","starred_url":"https://api.github.com/users/Vannevelj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Vannevelj/subscriptions","organizations_url":"https://api.github.com/users/Vannevelj/orgs","repos_url":"https://api.github.com/users/Vannevelj/repos","events_url":"https://api.github.com/users/Vannevelj/events{/privacy}","received_events_url":"https://api.github.com/users/Vannevelj/received_events","type":"User","site_admin":false},"created_at":"2015-08-29T03:13:38Z","updated_at":"2015-08-29T03:13:38Z","body":"What would be the downsides of a compiler directive to only expose the information in a debug environment? I believe that covers both arguments, though it will become rather messy if you have to do this everywhere."}}