{"action":"reopened","issue":{"url":"https://api.github.com/repos/FakeItEasy/FakeItEasy/issues/1366","repository_url":"https://api.github.com/repos/FakeItEasy/FakeItEasy","labels_url":"https://api.github.com/repos/FakeItEasy/FakeItEasy/issues/1366/labels{/name}","comments_url":"https://api.github.com/repos/FakeItEasy/FakeItEasy/issues/1366/comments","events_url":"https://api.github.com/repos/FakeItEasy/FakeItEasy/issues/1366/events","html_url":"https://github.com/FakeItEasy/FakeItEasy/issues/1366","id":330830606,"node_id":"MDU6SXNzdWUzMzA4MzA2MDY=","number":1366,"title":"Creating a dummy for a type with PRIVATE default constructor","user":{"login":"volak","id":1750226,"node_id":"MDQ6VXNlcjE3NTAyMjY=","avatar_url":"https://avatars3.githubusercontent.com/u/1750226?v=4","gravatar_id":"","url":"https://api.github.com/users/volak","html_url":"https://github.com/volak","followers_url":"https://api.github.com/users/volak/followers","following_url":"https://api.github.com/users/volak/following{/other_user}","gists_url":"https://api.github.com/users/volak/gists{/gist_id}","starred_url":"https://api.github.com/users/volak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/volak/subscriptions","organizations_url":"https://api.github.com/users/volak/orgs","repos_url":"https://api.github.com/users/volak/repos","events_url":"https://api.github.com/users/volak/events{/privacy}","received_events_url":"https://api.github.com/users/volak/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-06-08T23:34:52Z","updated_at":"2018-06-08T23:39:55Z","closed_at":null,"author_association":"NONE","body":"Currently when FakeItEasy goes to make a type with a private constructor we just get back `null` and no warnings / exceptions.\r\n\r\nHere's a test:\r\n\r\n```\r\n\r\n    public interface Thing { }\r\n\r\n    public interface Foo\r\n    {\r\n        Task<TThing> Bar<TThing>() where TThing : Thing;\r\n    }\r\n\r\n    public class FakeThing : Thing {\r\n        private FakeThing() { }\r\n    }\r\n\r\n        [Fact]\r\n        public async Task Test1()\r\n        {\r\n            var foo = A.Fake<Foo>();\r\n            var bar = await foo.Bar<FakeThing>();\r\n\r\n            Assert.NotNull(bar);\r\n        }\r\n    \r\n```\r\n\r\nPersonally - I'd like to see a real dummy actually be created.  Just because the constructor is private shouldn't prevent a dummy from being created.  In my app I make users define aggregate root's as private constructor so a new developer doesn't go and do `var entity = new InvoiceAggregateRoot()` so there is a real use case for creating these objects even though they're marked private.\r\n\r\nBut the bug is IMO if this behavior is not supported it should throw a \"Could not create dummy\" exception - not just return null like everything is fine."}}
{"actor":{"display_login":"volak"}}