Skip to content

Commit 27e9f3d

Browse files
committed
Remove AreConnStringsNotAzureSynapse
Adding doc comments to DisposableArray
1 parent 55887af commit 27e9f3d

File tree

3 files changed

+44
-14
lines changed

3 files changed

+44
-14
lines changed

src/Microsoft.Data.SqlClient/tests/Common/DisposableArray.cs

Lines changed: 42 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,62 @@
66
using System.Collections;
77
using System.Collections.Generic;
88

9+
#nullable enable
10+
911
namespace Microsoft.Data.SqlClient.Tests.Common
1012
{
13+
/// <summary>
14+
/// Utility class that enables disposal of a collection of <see cref="IDisposable"/> objects
15+
/// with a single <c>using</c> statement.
16+
/// </summary>
17+
/// <typeparam name="T">Type of the elements contained within.</typeparam>
1118
public class DisposableArray<T> : IDisposable, IEnumerable<T>
12-
where T : IDisposable
19+
where T : IDisposable?
1320
{
1421
private readonly T[] _elements;
1522

16-
public T this[int i]
17-
{
18-
get => _elements[i];
19-
set => _elements[i] = value;
20-
}
21-
22-
public int Length => _elements.Length;
23-
23+
/// <summary>
24+
/// Constructs a new instance with <paramref name="size"/> elements.
25+
/// </summary>
26+
/// <remarks>
27+
/// Remember when using this constructor that the underlying array will be initialized to
28+
/// <c>default(T)</c>. If <typeparamref name="T"/> is a reference type, this will be
29+
/// <c>null</c> - even if <typeparamref name="T"/> is not nullable!
30+
/// </remarks>
31+
/// <param name="size">Number of elements the new instance will contain.</param>
2432
public DisposableArray(int size)
2533
{
2634
_elements = new T[size];
2735
}
2836

37+
/// <summary>
38+
/// Constructs a new instance from an existing array of elements.
39+
/// </summary>
40+
/// <param name="elements">Array of elements to store within the current instance.</param>
2941
public DisposableArray(T[] elements)
3042
{
3143
_elements = elements;
3244
}
3345

46+
/// <summary>
47+
/// Gets or sets the element at index <see cref="i"/>.
48+
/// </summary>
49+
/// <param name="i">The element to get/set will be at this position in the array</param>
50+
public T this[int i]
51+
{
52+
get => _elements[i];
53+
set => _elements[i] = value;
54+
}
55+
56+
/// <summary>
57+
/// Gets the number of elements in the array.
58+
/// </summary>
59+
public int Length => _elements.Length;
60+
61+
/// <summary>
62+
/// Disposes all elements in the current instance. Each element will be checked for
63+
/// <c>null</c> before disposing it.
64+
/// </summary>
3465
public void Dispose()
3566
{
3667
foreach (T element in _elements)
@@ -41,9 +72,11 @@ public void Dispose()
4172
GC.SuppressFinalize(this);
4273
}
4374

75+
/// <inheritdoc/>
4476
public IEnumerator<T> GetEnumerator() =>
4577
((IEnumerable<T>)_elements).GetEnumerator();
4678

79+
/// <inheritdoc/>
4780
IEnumerator IEnumerable.GetEnumerator() =>
4881
_elements.GetEnumerator();
4982
}

src/Microsoft.Data.SqlClient/tests/ManualTests/DataCommon/DataTestUtility.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -409,9 +409,6 @@ public static bool AreConnStringsSetup()
409409
return !string.IsNullOrEmpty(NPConnectionString) && !string.IsNullOrEmpty(TCPConnectionString);
410410
}
411411

412-
public static bool AreConnStringsNotAzureSynapse() =>
413-
AreConnStringsSetup() && IsNotAzureSynapse();
414-
415412
public static bool IsSQL2022() => string.Equals("16", SQLServerVersion.Trim());
416413

417414
public static bool IsSQL2019() => string.Equals("15", SQLServerVersion.Trim());

src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/MARSSessionPoolingTest/MarsSessionPoolingTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ private static void AssertSessionsAndRequests(
368368

369369
private static DisposableArray<SqlCommand> GetCommands(SqlConnection connection, CommandType commandType)
370370
{
371-
SqlCommand[] result = new SqlCommand[ConcurrentCommands];
371+
DisposableArray<SqlCommand> result = new(ConcurrentCommands);
372372
for (int i = 0; i < result.Length; i++)
373373
{
374374
switch (commandType)
@@ -401,7 +401,7 @@ private static DisposableArray<SqlCommand> GetCommands(SqlConnection connection,
401401
}
402402
}
403403

404-
return new DisposableArray<SqlCommand>(result);
404+
return result;
405405
}
406406

407407
private static SqlConnection GetConnection()

0 commit comments

Comments
 (0)