{"action":"closed","issue":{"url":"https://api.github.com/repos/Reactive-Extensions/Rx.NET/issues/73","labels_url":"https://api.github.com/repos/Reactive-Extensions/Rx.NET/issues/73/labels{/name}","comments_url":"https://api.github.com/repos/Reactive-Extensions/Rx.NET/issues/73/comments","events_url":"https://api.github.com/repos/Reactive-Extensions/Rx.NET/issues/73/events","html_url":"https://github.com/Reactive-Extensions/Rx.NET/issues/73","id":52592546,"number":73,"title":"Consistent CompositeDisposable construction semantics","user":{"login":"LeeCampbell","id":981443,"avatar_url":"https://avatars.githubusercontent.com/u/981443?v=3","gravatar_id":"","url":"https://api.github.com/users/LeeCampbell","html_url":"https://github.com/LeeCampbell","followers_url":"https://api.github.com/users/LeeCampbell/followers","following_url":"https://api.github.com/users/LeeCampbell/following{/other_user}","gists_url":"https://api.github.com/users/LeeCampbell/gists{/gist_id}","starred_url":"https://api.github.com/users/LeeCampbell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LeeCampbell/subscriptions","organizations_url":"https://api.github.com/users/LeeCampbell/orgs","repos_url":"https://api.github.com/users/LeeCampbell/repos","events_url":"https://api.github.com/users/LeeCampbell/events{/privacy}","received_events_url":"https://api.github.com/users/LeeCampbell/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2014-12-21T11:07:37Z","updated_at":"2015-04-13T18:28:15Z","closed_at":"2015-04-13T18:28:15Z","body":"The `CompositeDisposable` type does not allow for null values to be added to it via the `Add` method, however this check is not performed on the constructor that takes a params array or an `IEnumerable` of `IDisposable` values.\r\n\r\ni.e. if these tests are added to the Rx.NET test suite, it would fail.\r\n\r\n        [TestMethod, ExpectedException(typeof(ArgumentNullException))]\r\n        public void CompositeDisposable_AddNull_via_params_ctor()\r\n        {\r\n            IDisposable d1 = null;\r\n            new CompositeDisposable(d1);\r\n        }\r\n        [TestMethod, ExpectedException(typeof(ArgumentNullException))]\r\n        public void CompositeDisposable_AddNull_via_IEnum_ctor()\r\n        {\r\n            IEnumerable<IDisposable> values = new IDisposable[] {null};\r\n            new CompositeDisposable(values);\r\n        }\r\n\r\nThis then has the effect that this code would run\r\n\r\n            IDisposable d1 = null;\r\n            new CompositeDisposable(d1);\r\n\r\nhowever this code would throw\r\n\r\n            IDisposable d1 = null;\r\n            new CompositeDisposable{d1};\r\n\r\nwhich seems unintuitive.\r\n\r\nMy suggestion is that `null` values not be allowed at all into the `CompositeDisposable`. It should be noted, that even with this suggested null checking in place at `ctor` and on the `Add` method, null checking will still need to be in-place in the `CompostieDisposable.Remove`, `CompostieDisposable.Dispose` & `CompostieDisposable.Clear` methods due to the manual re-sizing algorithm of the internal list."}}