Skip to content

Commit 02a46f5

Browse files
committed
Removed deprecated extensions
1 parent 76a67c5 commit 02a46f5

File tree

2 files changed

+1
-306
lines changed

2 files changed

+1
-306
lines changed

Microsoft.Toolkit/Extensions/ArrayExtensions.cs

Lines changed: 1 addition & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -14,74 +14,6 @@ namespace Microsoft.Toolkit.Extensions
1414
/// </summary>
1515
public static class ArrayExtensions
1616
{
17-
/// <summary>
18-
/// Fills elements of a rectangular array at the given position and size to a specific value.
19-
/// Ranges given will fill in as many elements as possible, ignoring positions outside the bounds of the array.
20-
/// </summary>
21-
/// <typeparam name="T">The element type of the array.</typeparam>
22-
/// <param name="array">The source array.</param>
23-
/// <param name="value">Value to fill with.</param>
24-
/// <param name="row">Row to start on (inclusive, zero-index).</param>
25-
/// <param name="col">Column to start on (inclusive, zero-index).</param>
26-
/// <param name="width">Positive width of area to fill.</param>
27-
/// <param name="height">Positive height of area to fill.</param>
28-
[Obsolete("This helper will be removed in a future release, use the APIs from Microsoft.Toolkit.HighPerformance to replace it")]
29-
public static void Fill<T>(this T[,] array, T value, int row, int col, int width, int height)
30-
{
31-
for (int r = row; r < row + height; r++)
32-
{
33-
for (int c = col; c < col + width; c++)
34-
{
35-
if (r >= 0 && c >= 0 && r < array.GetLength(0) && c < array.GetLength(1))
36-
{
37-
array[r, c] = value;
38-
}
39-
}
40-
}
41-
}
42-
43-
/// <summary>
44-
/// Yields a row from a rectangular array.
45-
/// </summary>
46-
/// <typeparam name="T">The element type of the array.</typeparam>
47-
/// <param name="rectarray">The source array.</param>
48-
/// <param name="row">Row record to retrieve, 0-based index.</param>
49-
/// <returns>Yielded row.</returns>
50-
[Obsolete("This helper will be removed in a future release, use the APIs from Microsoft.Toolkit.HighPerformance to replace it")]
51-
public static IEnumerable<T> GetRow<T>(this T[,] rectarray, int row)
52-
{
53-
if (row < 0 || row >= rectarray.GetLength(0))
54-
{
55-
throw new ArgumentOutOfRangeException(nameof(row));
56-
}
57-
58-
for (int c = 0; c < rectarray.GetLength(1); c++)
59-
{
60-
yield return rectarray[row, c];
61-
}
62-
}
63-
64-
/// <summary>
65-
/// Yields a column from a rectangular array.
66-
/// </summary>
67-
/// <typeparam name="T">The element type of the array.</typeparam>
68-
/// <param name="rectarray">The source array.</param>
69-
/// <param name="column">Column record to retrieve, 0-based index.</param>
70-
/// <returns>Yielded column.</returns>
71-
[Obsolete("This helper will be removed in a future release, use the APIs from Microsoft.Toolkit.HighPerformance to replace it")]
72-
public static IEnumerable<T> GetColumn<T>(this T[,] rectarray, int column)
73-
{
74-
if (column < 0 || column >= rectarray.GetLength(1))
75-
{
76-
throw new ArgumentOutOfRangeException(nameof(column));
77-
}
78-
79-
for (int r = 0; r < rectarray.GetLength(0); r++)
80-
{
81-
yield return rectarray[r, column];
82-
}
83-
}
84-
8517
/// <summary>
8618
/// Yields a column from a jagged array.
8719
/// An exception will be thrown if the column is out of bounds, and return default in places where there are no elements from inner arrays.
@@ -102,7 +34,7 @@ public static IEnumerable<T> GetColumn<T>(this T[][] rectarray, int column)
10234
{
10335
if (column >= rectarray[r].Length)
10436
{
105-
yield return default(T);
37+
yield return default;
10638

10739
continue;
10840
}

UnitTests/UnitTests.Shared/Extensions/Test_ArrayExtensions.cs

Lines changed: 0 additions & 237 deletions
Original file line numberDiff line numberDiff line change
@@ -13,173 +13,6 @@ namespace UnitTests.Extensions
1313
[TestClass]
1414
public class Test_ArrayExtensions
1515
{
16-
[TestCategory("ArrayExtensions")]
17-
[TestMethod]
18-
public void Test_ArrayExtensions_FillArrayMid()
19-
{
20-
bool[,] test = new bool[4, 5];
21-
22-
#pragma warning disable CS0618 // Type or member is obsolete
23-
test.Fill(true, 1, 1, 3, 2);
24-
#pragma warning restore CS0618
25-
26-
var expected = new bool[,]
27-
{
28-
{ false, false, false, false, false },
29-
{ false, true, true, true, false },
30-
{ false, true, true, true, false },
31-
{ false, false, false, false, false },
32-
};
33-
34-
CollectionAssert.AreEqual(
35-
expected,
36-
test,
37-
"Fill failed. Expected:\n{0}.\nActual:\n{1}",
38-
expected.ToArrayString(),
39-
test.ToArrayString());
40-
}
41-
42-
[TestCategory("ArrayExtensions")]
43-
[TestMethod]
44-
public void Test_ArrayExtensions_FillArrayTwice()
45-
{
46-
bool[,] test = new bool[4, 5];
47-
48-
#pragma warning disable CS0618 // Type or member is obsolete
49-
test.Fill(true, 0, 0, 1, 2);
50-
test.Fill(true, 1, 3, 2, 2);
51-
#pragma warning restore CS0618
52-
53-
var expected = new bool[,]
54-
{
55-
{ true, false, false, false, false },
56-
{ true, false, false, true, true },
57-
{ false, false, false, true, true },
58-
{ false, false, false, false, false },
59-
};
60-
61-
CollectionAssert.AreEqual(
62-
expected,
63-
test,
64-
"Fill failed. Expected:\n{0}.\nActual:\n{1}",
65-
expected.ToArrayString(),
66-
test.ToArrayString());
67-
}
68-
69-
[TestCategory("ArrayExtensions")]
70-
[TestMethod]
71-
public void Test_ArrayExtensions_FillArrayNegativeSize()
72-
{
73-
bool[,] test = new bool[4, 5];
74-
75-
#pragma warning disable CS0618 // Type or member is obsolete
76-
test.Fill(true, 3, 4, -3, -2);
77-
#pragma warning restore CS0618
78-
79-
// TODO: We may want to think about this pattern in the future:
80-
/*var expected = new bool[,]
81-
{
82-
{ false, false, false, false, false },
83-
{ false, false, false, false, false },
84-
{ false, false, true, true, true },
85-
{ false, false, true, true, true },
86-
};*/
87-
88-
var expected = new bool[,]
89-
{
90-
{ false, false, false, false, false },
91-
{ false, false, false, false, false },
92-
{ false, false, false, false, false },
93-
{ false, false, false, false, false },
94-
};
95-
96-
CollectionAssert.AreEqual(
97-
expected,
98-
test,
99-
"Fill failed. Expected:\n{0}.\nActual:\n{1}",
100-
expected.ToArrayString(),
101-
test.ToArrayString());
102-
}
103-
104-
[TestCategory("ArrayExtensions")]
105-
[TestMethod]
106-
public void Test_ArrayExtensions_FillArrayBottomEdgeBoundary()
107-
{
108-
bool[,] test = new bool[4, 5];
109-
110-
#pragma warning disable CS0618 // Type or member is obsolete
111-
test.Fill(true, 1, 2, 2, 4);
112-
#pragma warning restore CS0618
113-
114-
var expected = new bool[,]
115-
{
116-
{ false, false, false, false, false },
117-
{ false, false, true, true, false },
118-
{ false, false, true, true, false },
119-
{ false, false, true, true, false },
120-
};
121-
122-
CollectionAssert.AreEqual(
123-
expected,
124-
test,
125-
"Fill failed. Expected:\n{0}.\nActual:\n{1}",
126-
expected.ToArrayString(),
127-
test.ToArrayString());
128-
}
129-
130-
[TestCategory("ArrayExtensions")]
131-
[TestMethod]
132-
public void Test_ArrayExtensions_FillArrayTopLeftCornerNegativeBoundary()
133-
{
134-
bool[,] test = new bool[4, 5];
135-
136-
#pragma warning disable CS0618 // Type or member is obsolete
137-
test.Fill(true, -1, -1, 3, 3);
138-
#pragma warning restore CS0618
139-
140-
var expected = new bool[,]
141-
{
142-
{ true, true, false, false, false },
143-
{ true, true, false, false, false },
144-
{ false, false, false, false, false },
145-
{ false, false, false, false, false },
146-
};
147-
148-
CollectionAssert.AreEqual(
149-
expected,
150-
test,
151-
"Fill failed. Expected:\n{0}.\nActual:\n{1}",
152-
expected.ToArrayString(),
153-
test.ToArrayString());
154-
}
155-
156-
[TestCategory("ArrayExtensions")]
157-
[TestMethod]
158-
public void Test_ArrayExtensions_FillArrayBottomRightCornerBoundary()
159-
{
160-
bool[,] test = new bool[5, 4];
161-
162-
#pragma warning disable CS0618 // Type or member is obsolete
163-
test.Fill(true, 3, 2, 3, 3);
164-
#pragma warning restore CS0618
165-
166-
var expected = new bool[,]
167-
{
168-
{ false, false, false, false },
169-
{ false, false, false, false },
170-
{ false, false, false, false },
171-
{ false, false, true, true },
172-
{ false, false, true, true },
173-
};
174-
175-
CollectionAssert.AreEqual(
176-
expected,
177-
test,
178-
"Fill failed. Expected:\n{0}.\nActual:\n{1}",
179-
expected.ToArrayString(),
180-
test.ToArrayString());
181-
}
182-
18316
[TestCategory("ArrayExtensions")]
18417
[TestMethod]
18518
public void Test_ArrayExtensions_Jagged_GetColumn()
@@ -218,76 +51,6 @@ public void Test_ArrayExtensions_Jagged_GetColumn_Exception()
21851
});
21952
}
22053

221-
[TestCategory("ArrayExtensions")]
222-
[TestMethod]
223-
public void Test_ArrayExtensions_Rectangular_GetColumn()
224-
{
225-
int[,] array =
226-
{
227-
{ 5, 2, 4 },
228-
{ 6, 3, 9 },
229-
{ 7, -1, 0 }
230-
};
231-
232-
#pragma warning disable CS0618 // Type or member is obsolete
233-
var col = array.GetColumn(1).ToArray();
234-
#pragma warning restore CS0618
235-
236-
CollectionAssert.AreEquivalent(new int[] { 2, 3, -1 }, col);
237-
}
238-
239-
[TestCategory("ArrayExtensions")]
240-
[TestMethod]
241-
public void Test_ArrayExtensions_Rectangular_GetColumn_Exception()
242-
{
243-
int[,] array =
244-
{
245-
{ 5, 2, 4 },
246-
{ 6, 3, 0 },
247-
{ 7, 0, 0 }
248-
};
249-
250-
#pragma warning disable CS0618 // Type or member is obsolete
251-
Assert.ThrowsException<ArgumentOutOfRangeException>(() => array.GetColumn(-1).ToArray());
252-
Assert.ThrowsException<ArgumentOutOfRangeException>(() => array.GetColumn(3).ToArray());
253-
#pragma warning restore CS0618
254-
}
255-
256-
[TestCategory("ArrayExtensions")]
257-
[TestMethod]
258-
public void Test_ArrayExtensions_Rectangular_GetRow()
259-
{
260-
int[,] array =
261-
{
262-
{ 5, 2, 4 },
263-
{ 6, 3, 9 },
264-
{ 7, -1, 0 }
265-
};
266-
267-
#pragma warning disable CS0618 // Type or member is obsolete
268-
var col = array.GetRow(1).ToArray();
269-
#pragma warning restore CS0618
270-
271-
CollectionAssert.AreEquivalent(new int[] { 6, 3, 9 }, col);
272-
}
273-
274-
[TestCategory("ArrayExtensions")]
275-
[TestMethod]
276-
public void Test_ArrayExtensions_Rectangular_GetRow_Exception()
277-
{
278-
int[,] array =
279-
{
280-
{ 5, 2, 4 },
281-
{ 6, 3, 0 },
282-
{ 7, 0, 0 }
283-
};
284-
285-
#pragma warning disable CS0618 // Type or member is obsolete
286-
Assert.ThrowsException<ArgumentOutOfRangeException>(() => array.GetRow(-1).ToArray());
287-
Assert.ThrowsException<ArgumentOutOfRangeException>(() => array.GetRow(3).ToArray());
288-
#pragma warning restore CS0618
289-
}
290-
29154
[TestCategory("ArrayExtensions")]
29255
[TestMethod]
29356
public void Test_ArrayExtensions_Rectangular_ToString()

0 commit comments

Comments
 (0)