Last active
August 29, 2015 13:58
-
-
Save flagbug/9977229 to your computer and use it in GitHub Desktop.
Rx CompositeDisposable CopyTo bug
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// View constructor | |
this.WhenActivated(() => | |
{ | |
var disposable = new CompositeDisposable(); | |
// We never actually add an IDisposable to the CompositeDisposable for debugging reasons or whatever | |
return disposable; | |
}) | |
// This code will crash at https://github.com/reactiveui/ReactiveUI/blob/rxui6-master/ReactiveUI/Activation.cs#L89 | |
// with an ArgumentOutOfRangeException because of a bug in the CopyTo method of CompositeDisposable, | |
// where it doesn't accept an arrayIndex that has the same size as the array | |
// (In this case, the array is empty and arrayIndex is zero) | |
// Special gimmick: This bug occurs only under Mono, as the List<IDisposable> in the constructor of CompositeDisposable | |
// uses the CopyTo method on an empty source, but the .NET version doesn't. | |
// Even easier to reproduce under Mono: | |
new List<IDisposable>(new CompositeDisposable()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment