Skip to content

Commit b2a0a98

Browse files
authored
Merge pull request #72395 from sharwell/collection-utils
Implement SegmentedCollectionsMarshal
2 parents 02069ce + 7564430 commit b2a0a98

16 files changed

+1179
-56
lines changed

src/Compilers/Core/CodeAnalysisTest/Collections/SegmentedArrayTests.cs

+5-5
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ private static void ResetToSequence(SegmentedArray<IntPtr> array)
4141
public void TestDefaultInstance()
4242
{
4343
var data = default(SegmentedArray<IntPtr>);
44-
Assert.Null(data.GetTestAccessor().Items);
44+
Assert.Null(SegmentedCollectionsMarshal.AsSegments(data));
4545

4646
Assert.True(data.IsFixedSize);
4747
Assert.True(data.IsReadOnly);
@@ -96,7 +96,7 @@ public void TestConstructor1()
9696
Assert.Throws<ArgumentOutOfRangeException>("length", () => new SegmentedArray<byte>(-1));
9797

9898
Assert.Empty(new SegmentedArray<byte>(0));
99-
Assert.Same(Array.Empty<byte[]>(), new SegmentedArray<byte>(0).GetTestAccessor().Items);
99+
Assert.Same(Array.Empty<byte[]>(), SegmentedCollectionsMarshal.AsSegments(new SegmentedArray<byte>(0)));
100100
}
101101

102102
[Theory]
@@ -106,7 +106,7 @@ public void TestConstructor2(int length)
106106
var data = new SegmentedArray<IntPtr>(length);
107107
Assert.Equal(length, data.Length);
108108

109-
var items = data.GetTestAccessor().Items;
109+
var items = SegmentedCollectionsMarshal.AsSegments(data);
110110
Assert.Equal(length, items.Sum(item => item.Length));
111111

112112
for (var i = 0; i < items.Length - 1; i++)
@@ -126,7 +126,7 @@ public void TestBasicProperties(int length)
126126
Assert.True(data.IsReadOnly);
127127
Assert.False(data.IsSynchronized);
128128
Assert.Equal(length, data.Length);
129-
Assert.Same(data.GetTestAccessor().Items, data.SyncRoot);
129+
Assert.Same(SegmentedCollectionsMarshal.AsSegments(data), data.SyncRoot);
130130

131131
Assert.Equal(length, ((ICollection)data).Count);
132132
Assert.Equal(length, ((ICollection<IntPtr>)data).Count);
@@ -192,7 +192,7 @@ public void TestIndexer(int length)
192192
public void TestIterateLargeArray()
193193
{
194194
var data = new SegmentedArray<Guid>(1000000);
195-
Assert.True(data.GetTestAccessor().Items.Length > 10);
195+
Assert.True(SegmentedCollectionsMarshal.AsSegments(data).Length > 10);
196196

197197
for (var i = 0; i < data.Length; i++)
198198
{

0 commit comments

Comments
 (0)