{"action":"created","issue":{"url":"https://api.github.com/repos/dotnet/roslyn/issues/26666","repository_url":"https://api.github.com/repos/dotnet/roslyn","labels_url":"https://api.github.com/repos/dotnet/roslyn/issues/26666/labels{/name}","comments_url":"https://api.github.com/repos/dotnet/roslyn/issues/26666/comments","events_url":"https://api.github.com/repos/dotnet/roslyn/issues/26666/events","html_url":"https://github.com/dotnet/roslyn/issues/26666","id":320635467,"number":26666,"title":"DateTime.Parse(string s) should have a warning","user":{"login":"MohammadHamdyGhanem","id":29876310,"avatar_url":"https://avatars0.githubusercontent.com/u/29876310?v=4","gravatar_id":"","url":"https://api.github.com/users/MohammadHamdyGhanem","html_url":"https://github.com/MohammadHamdyGhanem","followers_url":"https://api.github.com/users/MohammadHamdyGhanem/followers","following_url":"https://api.github.com/users/MohammadHamdyGhanem/following{/other_user}","gists_url":"https://api.github.com/users/MohammadHamdyGhanem/gists{/gist_id}","starred_url":"https://api.github.com/users/MohammadHamdyGhanem/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MohammadHamdyGhanem/subscriptions","organizations_url":"https://api.github.com/users/MohammadHamdyGhanem/orgs","repos_url":"https://api.github.com/users/MohammadHamdyGhanem/repos","events_url":"https://api.github.com/users/MohammadHamdyGhanem/events{/privacy}","received_events_url":"https://api.github.com/users/MohammadHamdyGhanem/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-05-06T22:37:50Z","updated_at":"2018-05-06T22:57:08Z","closed_at":null,"author_association":"NONE","body":"According to docs at: https://docs.microsoft.com/ar-sa/dotnet/api/system.datetime.parse?view=netframework-4.7.1#System_DateTime_Parse_System_String_ :\r\n\r\n>This overload attempts to parse s by using the formatting conventions of the current culture. The current culture is indicated by the CultureInfo.CurrentCulture property.\r\n\r\nThis means:\r\n\r\n`var D = DateTime.Parse(\"1/15/2018\");`\r\n\r\nis equivilant to:\r\n\r\n`var D = DateTime.Parse(\"1/15/2018\", CultureInfo.CurrentCulture);`\r\n\r\nSo, that code will have different results on different PCs!.. On Windows with Arabic culture, that code will cause an exception, because this culture uses the format: \"dd/MM/yyyy\" and there is no 15th month!\r\n\r\nThis is a bad error-prone design! This overload should work with the Invariant Culture (\"en\"), and if anyone wants to change that, uses the second param. in the other overloads.\r\n\r\nI suggest that the IDE should warn us about this trap, and offer to replace any new DateTime.Parse(s) and it’s alike methods with DateTime.Parse(s, new CultureInfo(\"en\")). \r\nNote: the Convert.ToDateTime calls DateTime.Parse(s)!\r\n"},"comment":{"url":"https://api.github.com/repos/dotnet/roslyn/issues/comments/386923276","html_url":"https://github.com/dotnet/roslyn/issues/26666#issuecomment-386923276","issue_url":"https://api.github.com/repos/dotnet/roslyn/issues/26666","id":386923276,"user":{"login":"Neme12","id":11444821,"avatar_url":"https://avatars3.githubusercontent.com/u/11444821?v=4","gravatar_id":"","url":"https://api.github.com/users/Neme12","html_url":"https://github.com/Neme12","followers_url":"https://api.github.com/users/Neme12/followers","following_url":"https://api.github.com/users/Neme12/following{/other_user}","gists_url":"https://api.github.com/users/Neme12/gists{/gist_id}","starred_url":"https://api.github.com/users/Neme12/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Neme12/subscriptions","organizations_url":"https://api.github.com/users/Neme12/orgs","repos_url":"https://api.github.com/users/Neme12/repos","events_url":"https://api.github.com/users/Neme12/events{/privacy}","received_events_url":"https://api.github.com/users/Neme12/received_events","type":"User","site_admin":false},"created_at":"2018-05-06T22:57:08Z","updated_at":"2018-05-06T22:57:08Z","author_association":"CONTRIBUTOR","body":"You can definitely write a custom analyzer that would require explicitly passing a culture to any sort of formatting functions. I'm sure many people would find that useful (although it could get pretty annoying considering string interpolation & concatenation)"}}
{"actor":{"display_login":"Neme12"}}