{"action":"created","issue":{"url":"https://api.github.com/repos/shouldly/shouldly/issues/400","repository_url":"https://api.github.com/repos/shouldly/shouldly","labels_url":"https://api.github.com/repos/shouldly/shouldly/issues/400/labels{/name}","comments_url":"https://api.github.com/repos/shouldly/shouldly/issues/400/comments","events_url":"https://api.github.com/repos/shouldly/shouldly/issues/400/events","html_url":"https://github.com/shouldly/shouldly/issues/400","id":172990995,"number":400,"title":"ShouldBe produces a false positive on null collections using ? safe navigation","user":{"login":"SwishWez","id":21223568,"avatar_url":"https://avatars.githubusercontent.com/u/21223568?v=3","gravatar_id":"","url":"https://api.github.com/users/SwishWez","html_url":"https://github.com/SwishWez","followers_url":"https://api.github.com/users/SwishWez/followers","following_url":"https://api.github.com/users/SwishWez/following{/other_user}","gists_url":"https://api.github.com/users/SwishWez/gists{/gist_id}","starred_url":"https://api.github.com/users/SwishWez/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SwishWez/subscriptions","organizations_url":"https://api.github.com/users/SwishWez/orgs","repos_url":"https://api.github.com/users/SwishWez/repos","events_url":"https://api.github.com/users/SwishWez/events{/privacy}","received_events_url":"https://api.github.com/users/SwishWez/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/shouldly/shouldly/labels/Blocked","name":"Blocked","color":"eb6420"},{"url":"https://api.github.com/repos/shouldly/shouldly/labels/wontfix","name":"wontfix","color":"f7c6c7"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2016-08-24T15:54:15Z","updated_at":"2016-09-05T23:57:48Z","closed_at":null,"body":"This occurs when using ShouldBe to check equality of a potentially null collection for an expected value via safe navigation.\r\n\r\nE.g.\r\nvar expectedCollection = new List<string> { \"Expected\" };\r\n\r\n(Act)\r\n\r\n// Incorrectly passes when Result is null\r\nlookup.Result?.SomeCollection.ShouldBe(expectedCollection);\r\n\r\n// Adding brackets causes the test to correctly fail when Result is null\r\n(lookup.Result?.SomeCollection).ShouldBe(expectedCollection);"},"comment":{"url":"https://api.github.com/repos/shouldly/shouldly/issues/comments/244822957","html_url":"https://github.com/shouldly/shouldly/issues/400#issuecomment-244822957","issue_url":"https://api.github.com/repos/shouldly/shouldly/issues/400","id":244822957,"user":{"login":"JakeGinnivan","id":453152,"avatar_url":"https://avatars.githubusercontent.com/u/453152?v=3","gravatar_id":"","url":"https://api.github.com/users/JakeGinnivan","html_url":"https://github.com/JakeGinnivan","followers_url":"https://api.github.com/users/JakeGinnivan/followers","following_url":"https://api.github.com/users/JakeGinnivan/following{/other_user}","gists_url":"https://api.github.com/users/JakeGinnivan/gists{/gist_id}","starred_url":"https://api.github.com/users/JakeGinnivan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JakeGinnivan/subscriptions","organizations_url":"https://api.github.com/users/JakeGinnivan/orgs","repos_url":"https://api.github.com/users/JakeGinnivan/repos","events_url":"https://api.github.com/users/JakeGinnivan/events{/privacy}","received_events_url":"https://api.github.com/users/JakeGinnivan/received_events","type":"User","site_admin":false},"created_at":"2016-09-05T23:57:48Z","updated_at":"2016-09-05T23:57:48Z","body":"> My understanding of the null-conditional operator is that the ShouldBe extension method will never be called if Result is null\r\n\r\nYep, nothing we can do about this, we simply do not get called by the compiler when Result is null. I guess this is a downside of the extension method approach, afaik there is nothing we can do about this. We possibly could create a Roslyn analyser which will identity this issue and flag it as an issue?"}}
{"actor":{"display_login":"JakeGinnivan"}}