{"action":"created","issue":{"url":"https://api.github.com/repos/xunit/xunit/issues/935","repository_url":"https://api.github.com/repos/xunit/xunit","labels_url":"https://api.github.com/repos/xunit/xunit/issues/935/labels{/name}","comments_url":"https://api.github.com/repos/xunit/xunit/issues/935/comments","events_url":"https://api.github.com/repos/xunit/xunit/issues/935/events","html_url":"https://github.com/xunit/xunit/issues/935","id":170550504,"number":935,"title":"Passing null MemberData value as Generic parameter doesn't keep original type","user":{"login":"ayb4btu","id":14414215,"avatar_url":"https://avatars.githubusercontent.com/u/14414215?v=3","gravatar_id":"","url":"https://api.github.com/users/ayb4btu","html_url":"https://github.com/ayb4btu","followers_url":"https://api.github.com/users/ayb4btu/followers","following_url":"https://api.github.com/users/ayb4btu/following{/other_user}","gists_url":"https://api.github.com/users/ayb4btu/gists{/gist_id}","starred_url":"https://api.github.com/users/ayb4btu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ayb4btu/subscriptions","organizations_url":"https://api.github.com/users/ayb4btu/orgs","repos_url":"https://api.github.com/users/ayb4btu/repos","events_url":"https://api.github.com/users/ayb4btu/events{/privacy}","received_events_url":"https://api.github.com/users/ayb4btu/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-08-11T00:44:43Z","updated_at":"2016-08-11T20:37:10Z","closed_at":"2016-08-11T20:37:10Z","body":"I'm not sure if this is by design or not, but when I call the following Theory test I was expecting `T` to be a `byte[]` but its type is a `System.Object`.\r\n\r\n```C#\r\n[Theory]\r\n[MemberData(nameof(ParseNulledTypeScenarios))]\r\npublic void ParseGenericTypeToStringTest<T>(T value, string expected, string message)\r\n{\r\n\tType byteArrayType = typeof(T); // this should be a byte[] Type, but is the base object type\r\n}\r\n\r\npublic static IEnumerable<object[]> ParseNulledTypeScenarios()\r\n{\r\n\tbyte[] nullByteArray = null;\r\n\tyield return new object[] { nullByteArray, null, \"\" };\r\n}\r\n```\r\n\r\nIf I do (essentially) the same thing with a normal method instead of passing the parameters in by a `MemberData`, I get the original type:\r\n\r\n```C#\r\n[Fact]\r\npublic void TypeTest()\r\n{\r\n\tbyte[] value = null;\r\n\tType extractedType = GetType(value);\r\n\r\n\textractedType.Should().Be(typeof(byte[]));\r\n}\r\n\r\npublic Type GetType<T>(T value)\r\n{\r\n\treturn typeof(T);\r\n}\r\n```\r\n\r\nIs it possible to get the original type (`byte[]` in this instance) of the passed in generic value using `MemberData`? Or am I stuck with the type being a `System.Object`?\r\n\r\n**Update**\r\nHaving now read this past issue: [https://github.com/xunit/xunit/issues/296]() it looks like the null's original type is forgotten, so it is instead stored as an object type. So I guess I'll need to change the way I test variables that are of a particular type, but whose value is null."},"comment":{"url":"https://api.github.com/repos/xunit/xunit/issues/comments/239284317","html_url":"https://github.com/xunit/xunit/issues/935#issuecomment-239284317","issue_url":"https://api.github.com/repos/xunit/xunit/issues/935","id":239284317,"user":{"login":"ayb4btu","id":14414215,"avatar_url":"https://avatars.githubusercontent.com/u/14414215?v=3","gravatar_id":"","url":"https://api.github.com/users/ayb4btu","html_url":"https://github.com/ayb4btu","followers_url":"https://api.github.com/users/ayb4btu/followers","following_url":"https://api.github.com/users/ayb4btu/following{/other_user}","gists_url":"https://api.github.com/users/ayb4btu/gists{/gist_id}","starred_url":"https://api.github.com/users/ayb4btu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ayb4btu/subscriptions","organizations_url":"https://api.github.com/users/ayb4btu/orgs","repos_url":"https://api.github.com/users/ayb4btu/repos","events_url":"https://api.github.com/users/ayb4btu/events{/privacy}","received_events_url":"https://api.github.com/users/ayb4btu/received_events","type":"User","site_admin":false},"created_at":"2016-08-11T20:37:10Z","updated_at":"2016-08-11T20:37:10Z","body":"Thanks for the additional info. The code being tested ended up being modified to better handle null situations, making it sufficient to test with a `System.Object` set to null."}}
{"actor":{"display_login":"ayb4btu"}}