Skip to content

Commit 0c41cf4

Browse files
committed
Align Capabilities and ServerVersion exception behaviour across derived classes
1 parent 7ef36b5 commit 0c41cf4

7 files changed

Lines changed: 16 additions & 4 deletions

File tree

src/Microsoft.Data.SqlClient/src/Microsoft/Data/ProviderBase/DbConnectionClosed.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ protected DbConnectionClosed(ConnectionState state, bool hidePassword, bool allo
2222

2323
public override string ServerVersion => throw ADP.ClosedConnectionError();
2424

25+
public override ConnectionCapabilities Capabilities => throw ADP.ClosedConnectionError();
26+
2527
protected override void Activate(System.Transactions.Transaction transaction) => throw ADP.ClosedConnectionError();
2628

2729
public override DbTransaction BeginTransaction(IsolationLevel il) => throw ADP.ClosedConnectionError();

src/Microsoft.Data.SqlClient/src/Microsoft/Data/ProviderBase/DbConnectionInternal.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,7 @@ internal bool IsInPool
167167

168168
public abstract string ServerVersion { get; }
169169

170-
public virtual ConnectionCapabilities Capabilities =>
171-
null;
170+
public virtual ConnectionCapabilities Capabilities => null;
172171

173172
// this should be abstract but until it is added to all the providers virtual will have to do RickFe
174173
public virtual string ServerVersionNormalized

src/Microsoft.Data.SqlClient/tests/UnitTests/ConnectionPool/ChannelDbConnectionPoolTest.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Licensed to the .NET Foundation under one or more agreements.
1+
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33
// See the LICENSE file in the project root for more information.
44

@@ -965,6 +965,8 @@ internal class StubDbConnectionInternal : DbConnectionInternal
965965
#region Not Implemented Members
966966
public override string ServerVersion => throw new NotImplementedException();
967967

968+
public override ConnectionCapabilities Capabilities => throw new NotImplementedException();
969+
968970
public override DbTransaction BeginTransaction(System.Data.IsolationLevel il)
969971
{
970972
throw new NotImplementedException();

src/Microsoft.Data.SqlClient/tests/UnitTests/ConnectionPool/ConnectionPoolSlotsTest.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Licensed to the .NET Foundation under one or more agreements.
1+
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33
// See the LICENSE file in the project root for more information.
44

@@ -24,6 +24,8 @@ public MockDbConnectionInternal() : base(ConnectionState.Open, true, false) { }
2424

2525
public override string ServerVersion => "Mock Server 1.0";
2626

27+
public override ConnectionCapabilities Capabilities => new();
28+
2729
public override DbTransaction BeginTransaction(System.Data.IsolationLevel il)
2830
{
2931
throw new NotImplementedException();

src/Microsoft.Data.SqlClient/tests/UnitTests/ConnectionPool/IdleConnectionChannelTest.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using System.Threading;
88
using System.Threading.Tasks;
99
using System.Transactions;
10+
using Microsoft.Data.Common;
1011
using Microsoft.Data.ProviderBase;
1112
using Microsoft.Data.SqlClient.ConnectionPool;
1213
using Xunit;
@@ -230,6 +231,8 @@ private class StubDbConnectionInternal : DbConnectionInternal
230231
{
231232
public override string ServerVersion => throw new NotImplementedException();
232233

234+
public override ConnectionCapabilities Capabilities => throw new NotImplementedException();
235+
233236
public override DbTransaction BeginTransaction(System.Data.IsolationLevel il)
234237
=> throw new NotImplementedException();
235238

src/Microsoft.Data.SqlClient/tests/UnitTests/ConnectionPool/TransactedConnectionPoolTest.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -713,6 +713,8 @@ internal class MockDbConnectionInternal : DbConnectionInternal
713713

714714
public override string ServerVersion => "Mock";
715715

716+
public override ConnectionCapabilities Capabilities => new();
717+
716718
public override DbTransaction BeginTransaction(System.Data.IsolationLevel il)
717719
{
718720
throw new NotImplementedException();

src/Microsoft.Data.SqlClient/tests/UnitTests/ConnectionPool/WaitHandleDbConnectionPoolTransactionTest.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -918,6 +918,8 @@ internal class MockDbConnectionInternal : DbConnectionInternal
918918

919919
public override string ServerVersion => "Mock";
920920

921+
public override ConnectionCapabilities Capabilities => new();
922+
921923
public override DbTransaction BeginTransaction(System.Data.IsolationLevel il)
922924
{
923925
throw new NotImplementedException();

0 commit comments

Comments
 (0)