-
Notifications
You must be signed in to change notification settings - Fork 994
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix issue 11243 TreeNodeCollection.AddRange has been broken in .NET 8…
… and no longer results in TreeNodes being drawn at the correct location
- Loading branch information
1 parent
3365859
commit c7c7953
Showing
7 changed files
with
224 additions
and
94 deletions.
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
src/System.Windows.Forms/src/System/Windows/Forms/ArraySubsetEnumerator.cs
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System.Collections; | ||
|
||
namespace System.Windows.Forms; | ||
|
||
internal class ArraySubsetEnumerator : IEnumerator | ||
{ | ||
private readonly object[] _array; | ||
private readonly int _total; | ||
private int _current; | ||
|
||
public ArraySubsetEnumerator(object[] array, int count) | ||
{ | ||
Debug.Assert(count == 0 || array is not null, "if array is null, count should be 0"); | ||
Debug.Assert(array is null || count <= array.Length, "Trying to enumerate more than the array contains"); | ||
_array = array!; | ||
_total = count; | ||
_current = -1; | ||
} | ||
|
||
public bool MoveNext() | ||
{ | ||
if (_current < _total - 1) | ||
{ | ||
_current++; | ||
return true; | ||
} | ||
|
||
return false; | ||
} | ||
|
||
public void Reset() => _current = -1; | ||
|
||
public object? Current => _current == -1 ? null : _array[_current]; | ||
} |
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
Oops, something went wrong.