{"action":"created","issue":{"url":"https://api.github.com/repos/xunit/xunit/issues/1337","repository_url":"https://api.github.com/repos/xunit/xunit","labels_url":"https://api.github.com/repos/xunit/xunit/issues/1337/labels{/name}","comments_url":"https://api.github.com/repos/xunit/xunit/issues/1337/comments","events_url":"https://api.github.com/repos/xunit/xunit/issues/1337/events","html_url":"https://github.com/xunit/xunit/issues/1337","id":239135062,"number":1337,"title":"InlineData should use InvariantCulture to convert arguments","user":{"login":"CornedBee","id":3115118,"avatar_url":"https://avatars3.githubusercontent.com/u/3115118?v=4","gravatar_id":"","url":"https://api.github.com/users/CornedBee","html_url":"https://github.com/CornedBee","followers_url":"https://api.github.com/users/CornedBee/followers","following_url":"https://api.github.com/users/CornedBee/following{/other_user}","gists_url":"https://api.github.com/users/CornedBee/gists{/gist_id}","starred_url":"https://api.github.com/users/CornedBee/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CornedBee/subscriptions","organizations_url":"https://api.github.com/users/CornedBee/orgs","repos_url":"https://api.github.com/users/CornedBee/repos","events_url":"https://api.github.com/users/CornedBee/events{/privacy}","received_events_url":"https://api.github.com/users/CornedBee/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2017-06-28T11:34:15Z","updated_at":"2017-11-11T19:50:48Z","closed_at":"2017-11-11T18:51:22Z","author_association":"NONE","body":"TL;DR: `Xunit.Sdk.Reflector.ConvertArgument` should pass `CultureInfo.InvariantCulture` to `Convert.ChangeType`.\r\n\r\nA simple test case that looks like this:\r\n\r\n```\r\n[Theory]\r\n[InlineData(false, \"1.0\")]\r\nvoid DecimalsGreaterFive(bool expected, decimal value)\r\n{\r\n  Assert.Equal(expected, value > 5);\r\n}\r\n```\r\n\r\nfails or misbehaves depending on the culture settings of the computer on which the test case runs. If the culture uses '.' as a decimal separator (e.g. 'en-US'), it succeeds. If it uses '.' as a thousands separator (e.g. 'de-DE'), it fails because it parses the number as 10. If it doesn't allow '.' at all (e.g. 'de-AT', where the comma is the decimal separator and the space is the thousands separator), it throws an exception in the test runner infrastructure.\r\n\r\nI believe test cases should not depend on the settings of the computer that is executing them. Working around this problem is tricky - for example, setting the current thread culture in the constructor doesn't work, because the method argument conversion happens before the test object is instantiated. (I think, but I am not sure, that it also happens before a BeforeAfterMethodAttribute is executed, so the UseCultureAttribute from the samples wouldn't work either.)\r\n\r\nThe working workaround (on .Net Core at least) is to create a class fixture that changes `CultureInfo.DefaultThreadCurrentCulture`. Setting `CultureInfo.CurrentCulture` doesn't work; I suspect that the culture of some other thread flows along the async test executor into the current culture of the test case after it was changed in the fixture constructor. (This may mean that the behavior is different in .Net < 4.6 where the culture doesn't flow.)\r\n\r\nThis could be easily avoided if the test runner did its conversions with a fixed culture. There is no reason to use the current culture here, and no reason why anyone would want the InlineData values to be localized. So the solution would be to just pass `CultureInfo.InvariantCulture` to `Convert.ChangeType` in `Xunit.Sdk.Reflector.ConvertArgument` (src/xunit.execution/Sdk/Reflection/Reflector.cs). This converts the arguments ahead of time to the correct types with a fixed culture."},"comment":{"url":"https://api.github.com/repos/xunit/xunit/issues/comments/343689759","html_url":"https://github.com/xunit/xunit/issues/1337#issuecomment-343689759","issue_url":"https://api.github.com/repos/xunit/xunit/issues/1337","id":343689759,"user":{"login":"nohwnd","id":5735905,"avatar_url":"https://avatars2.githubusercontent.com/u/5735905?v=4","gravatar_id":"","url":"https://api.github.com/users/nohwnd","html_url":"https://github.com/nohwnd","followers_url":"https://api.github.com/users/nohwnd/followers","following_url":"https://api.github.com/users/nohwnd/following{/other_user}","gists_url":"https://api.github.com/users/nohwnd/gists{/gist_id}","starred_url":"https://api.github.com/users/nohwnd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nohwnd/subscriptions","organizations_url":"https://api.github.com/users/nohwnd/orgs","repos_url":"https://api.github.com/users/nohwnd/repos","events_url":"https://api.github.com/users/nohwnd/events{/privacy}","received_events_url":"https://api.github.com/users/nohwnd/received_events","type":"User","site_admin":false},"created_at":"2017-11-11T19:50:48Z","updated_at":"2017-11-11T19:50:48Z","author_association":"NONE","body":"@bradwilson Thank you."}}
{"actor":{"display_login":"nohwnd"}}