WebView2.DOM icon indicating copy to clipboard operation
WebView2.DOM copied to clipboard

When calling the method ToArray of the HTMLOptionsCollection class a stackoverflow exception is thrown

Open Jeroen3000 opened this issue 1 year ago • 0 comments

Hi, nice library. Source code is a bit complex. Anyway, when calling the ToArray method on the HTMLOptionsCollection class it is using internally the CopyTo method, but his method is overridden and is calling ToArray again recursively. etc.. which leads to a stack overflow

I think a possible solution is to implement the CopyTo as follows:

_void ICollection<HTMLOptionElement>.CopyTo(HTMLOptionElement[] array, int arrayIndex) { if (array == null) throw new ArgumentNullException(nameof(array)); if (arrayIndex < 0) throw new ArgumentOutOfRangeException(nameof(arrayIndex)); if (array.Length - arrayIndex < Count) throw new ArgumentException("Not enough elements after arrayIndex in the destination array.");

 for (int i = 0; i < Count; ++i)
     array[i + arrayIndex] = this[i];

}_

Jeroen3000 avatar Jul 09 '24 13:07 Jeroen3000