Skip to content

Commit 24f3862

Browse files
committed
Renane Microsoft.Data.SqlClient.SqlInternalConnectionTds to Microsoft.Data.SqlClient.Connection.SqlInternalConnectionTds
1 parent 51656aa commit 24f3862

17 files changed

+161
-114
lines changed

src/Microsoft.Data.SqlClient/src/Microsoft/Data/Common/AdapterUtil.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
using Microsoft.SqlServer.Server;
2626
using System.Security.Authentication;
2727
using System.Collections.Generic;
28+
using Microsoft.Data.SqlClient.Connection;
2829

2930
#if NETFRAMEWORK
3031
using System.Reflection;
@@ -465,7 +466,11 @@ internal static ArgumentException InvalidArgumentLength(string argumentName, int
465466

466467
internal static ArgumentException MustBeReadOnly(string argumentName) => Argument(StringsHelper.GetString(Strings.ADP_MustBeReadOnly, argumentName));
467468

468-
internal static Exception CreateSqlException(MsalException msalException, SqlConnectionString connectionOptions, SqlInternalConnectionTds sender, string username)
469+
internal static Exception CreateSqlException(
470+
MsalException msalException,
471+
SqlConnectionString connectionOptions,
472+
SqlConnectionInternal sender,
473+
string username)
469474
{
470475
// Error[0]
471476
SqlErrorCollection sqlErs = new();

src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Connection/SqlConnectionInternal.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@
2222
using Microsoft.Identity.Client;
2323
using IsolationLevel = System.Data.IsolationLevel;
2424

25-
namespace Microsoft.Data.SqlClient
25+
namespace Microsoft.Data.SqlClient.Connection
2626
{
27-
internal class SqlInternalConnectionTds : DbConnectionInternal, IDisposable
27+
internal class SqlConnectionInternal : DbConnectionInternal, IDisposable
2828
{
2929
#region Constants
3030

@@ -332,7 +332,7 @@ internal class SqlInternalConnectionTds : DbConnectionInternal, IDisposable
332332
/// has been expanded (see SqlConnectionString.Expand)
333333
/// </remarks>
334334
// @TODO: We really really need simplify what we pass into this. All these optional parameters need to go!
335-
internal SqlInternalConnectionTds(
335+
internal SqlConnectionInternal(
336336
DbConnectionPoolIdentity identity,
337337
SqlConnectionString connectionOptions,
338338
SqlCredential credential,

src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlBulkCopy.cs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
using System.Threading.Tasks;
1616
using System.Xml;
1717
using Microsoft.Data.Common;
18+
using Microsoft.Data.SqlClient.Connection;
1819

1920
namespace Microsoft.Data.SqlClient
2021
{
@@ -230,7 +231,7 @@ private int RowNumber
230231
private bool _hasMoreRowToCopy = false;
231232
private bool _isAsyncBulkCopy = false;
232233
private bool _isBulkCopyingInProgress = false;
233-
private SqlInternalConnectionTds.SyncAsyncLock _parserLock = null;
234+
private SqlConnectionInternal.SyncAsyncLock _parserLock = null;
234235

235236
private SourceColumnMetadata[] _currentRowMetadata;
236237

@@ -1156,8 +1157,8 @@ private Task ReadFromRowSourceAsync(CancellationToken cts)
11561157
}
11571158
else
11581159
{ // This will call Read for DataRows, DataTable and IDataReader (this includes all IDataReader except DbDataReader)
1159-
// Release lock to prevent possible deadlocks
1160-
SqlInternalConnectionTds internalConnection = _connection.GetOpenTdsConnection();
1160+
// Release lock to prevent possible deadlocks
1161+
SqlConnectionInternal internalConnection = _connection.GetOpenTdsConnection();
11611162
bool semaphoreLock = internalConnection._parserLock.CanBeReleasedFromAnyThread;
11621163
internalConnection._parserLock.Release();
11631164

@@ -1366,7 +1367,7 @@ private void CreateOrValidateConnection(string method)
13661367
private void RunParser(BulkCopySimpleResultSet bulkCopyHandler = null)
13671368
{
13681369
// In case of error while reading, we should let the connection know that we already own the _parserLock
1369-
SqlInternalConnectionTds internalConnection = _connection.GetOpenTdsConnection();
1370+
SqlConnectionInternal internalConnection = _connection.GetOpenTdsConnection();
13701371

13711372
internalConnection.ThreadHasParserLockForClose = true;
13721373
try
@@ -1384,7 +1385,7 @@ private void RunParser(BulkCopySimpleResultSet bulkCopyHandler = null)
13841385
private void RunParserReliably(BulkCopySimpleResultSet bulkCopyHandler = null)
13851386
{
13861387
// In case of error while reading, we should let the connection know that we already own the _parserLock
1387-
SqlInternalConnectionTds internalConnection = _connection.GetOpenTdsConnection();
1388+
SqlConnectionInternal internalConnection = _connection.GetOpenTdsConnection();
13881389
internalConnection.ThreadHasParserLockForClose = true;
13891390
try
13901391
{
@@ -1401,7 +1402,7 @@ private void CommitTransaction()
14011402
{
14021403
if (_internalTransaction != null)
14031404
{
1404-
SqlInternalConnectionTds internalConnection = _connection.GetOpenTdsConnection();
1405+
SqlConnectionInternal internalConnection = _connection.GetOpenTdsConnection();
14051406
internalConnection.ThreadHasParserLockForClose = true; // In case of error, let the connection know that we have the lock
14061407
try
14071408
{
@@ -1422,7 +1423,7 @@ private void AbortTransaction()
14221423
{
14231424
if (!_internalTransaction.IsZombied)
14241425
{
1425-
SqlInternalConnectionTds internalConnection = _connection.GetOpenTdsConnection();
1426+
SqlConnectionInternal internalConnection = _connection.GetOpenTdsConnection();
14261427
internalConnection.ThreadHasParserLockForClose = true; // In case of error, let the connection know that we have the lock
14271428
try
14281429
{
@@ -2069,7 +2070,7 @@ private Task WriteRowSourceToServerAsync(int columnCount, CancellationToken ctok
20692070

20702071
CreateOrValidateConnection(nameof(WriteToServer));
20712072

2072-
SqlInternalConnectionTds internalConnection = _connection.GetOpenTdsConnection();
2073+
SqlConnectionInternal internalConnection = _connection.GetOpenTdsConnection();
20732074

20742075
Debug.Assert(_parserLock == null, "Previous parser lock not cleaned");
20752076
_parserLock = internalConnection._parserLock;
@@ -2222,7 +2223,7 @@ internal void OnConnectionClosed()
22222223
private bool FireRowsCopiedEvent(long rowsCopied)
22232224
{
22242225
// Release lock to prevent possible deadlocks
2225-
SqlInternalConnectionTds internalConnection = _connection.GetOpenTdsConnection();
2226+
SqlConnectionInternal internalConnection = _connection.GetOpenTdsConnection();
22262227
bool semaphoreLock = internalConnection._parserLock.CanBeReleasedFromAnyThread;
22272228
internalConnection._parserLock.Release();
22282229

@@ -2578,7 +2579,7 @@ private Task CopyBatchesAsync(BulkCopySimpleResultSet internalResults, string up
25782579
while (_hasMoreRowToCopy)
25792580
{
25802581
//pre->before every batch: Transaction, BulkCmd and metadata are done.
2581-
SqlInternalConnectionTds internalConnection = _connection.GetOpenTdsConnection();
2582+
SqlConnectionInternal internalConnection = _connection.GetOpenTdsConnection();
25822583

25832584
if (IsCopyOption(SqlBulkCopyOptions.UseInternalTransaction))
25842585
{ //internal transaction is started prior to each batch if the Option is set.
@@ -2965,7 +2966,7 @@ private void WriteToServerInternalRestAsync(CancellationToken cts, TaskCompletio
29652966
_hasMoreRowToCopy = true;
29662967
Task<BulkCopySimpleResultSet> internalResultsTask = null;
29672968
BulkCopySimpleResultSet internalResults = new BulkCopySimpleResultSet();
2968-
SqlInternalConnectionTds internalConnection = _connection.GetOpenTdsConnection();
2969+
SqlConnectionInternal internalConnection = _connection.GetOpenTdsConnection();
29692970
try
29702971
{
29712972
_parser = _connection.Parser;

src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlCommand.Encryption.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
using System.Threading;
1313
using System.Threading.Tasks;
1414
using Microsoft.Data.Common;
15+
using Microsoft.Data.SqlClient.Connection;
1516

1617
namespace Microsoft.Data.SqlClient
1718
{
@@ -266,8 +267,7 @@ private SqlDataReader GetParameterEncryptionDataReader(
266267
// If it is async, then TryFetchInputParameterEncryptionInfo ->
267268
// RunExecuteReaderTds would have incremented the async count. Decrement it
268269
// when we are about to complete async execute reader.
269-
SqlInternalConnectionTds internalConnectionTds =
270-
command._activeConnection.GetOpenTdsConnection();
270+
SqlConnectionInternal internalConnectionTds = command._activeConnection.GetOpenTdsConnection();
271271
if (internalConnectionTds is not null)
272272
{
273273
internalConnectionTds.DecrementAsyncCount();
@@ -345,7 +345,7 @@ private SqlDataReader GetParameterEncryptionDataReaderAsync(
345345
// If it is async, then TryFetchInputParameterEncryptionInfo ->
346346
// RunExecuteReaderTds would have incremented the async count. Decrement it
347347
// when we are about to complete async execute reader.
348-
SqlInternalConnectionTds internalConnectionTds = _activeConnection.GetOpenTdsConnection();
348+
SqlConnectionInternal internalConnectionTds = _activeConnection.GetOpenTdsConnection();
349349
if (internalConnectionTds is not null)
350350
{
351351
internalConnectionTds.DecrementAsyncCount();
@@ -769,7 +769,7 @@ private void PrepareTransparentEncryptionFinallyBlock(
769769
if (decrementAsyncCount)
770770
{
771771
// Decrement the async count
772-
SqlInternalConnectionTds internalConnection = _activeConnection.GetOpenTdsConnection();
772+
SqlConnectionInternal internalConnection = _activeConnection.GetOpenTdsConnection();
773773
internalConnection?.DecrementAsyncCount();
774774
}
775775

src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlCommand.NonQuery.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
using System.Threading.Tasks;
1111
using Microsoft.Data.Common;
1212
using Microsoft.Data.ProviderBase;
13+
using Microsoft.Data.SqlClient.Connection;
1314

1415
#if NETFRAMEWORK
1516
using System.Security.Permissions;
@@ -929,7 +930,7 @@ public void Set(
929930
protected override void AfterCleared(SqlCommand owner)
930931
{
931932
DbConnectionInternal internalConnection = owner?._activeConnection?.InnerConnection;
932-
if (internalConnection is SqlInternalConnectionTds sqlInternalConnection)
933+
if (internalConnection is SqlConnectionInternal sqlInternalConnection)
933934
{
934935
sqlInternalConnection.CachedContexts.TrySetCommandExecuteNonQueryAsyncContext(this);
935936
}

src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlCommand.Reader.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
using System.Threading.Tasks;
1212
using Microsoft.Data.Common;
1313
using Microsoft.Data.ProviderBase;
14+
using Microsoft.Data.SqlClient.Connection;
1415

1516
#if NETFRAMEWORK
1617
using System.Security.Permissions;
@@ -980,7 +981,7 @@ private Task<SqlDataReader> InternalExecuteReaderAsync(
980981
{
981982
returnedTask = RegisterForConnectionCloseNotification(returnedTask);
982983

983-
if (_activeConnection?.InnerConnection is SqlInternalConnectionTds sqlInternalConnection)
984+
if (_activeConnection?.InnerConnection is SqlConnectionInternal sqlInternalConnection)
984985
{
985986
context = sqlInternalConnection.CachedContexts.ClearCommandExecuteReaderAsyncContext();
986987
}
@@ -1576,7 +1577,7 @@ private SqlDataReader RunExecuteReaderTds(
15761577

15771578
if (decrementAsyncCountOnFailure)
15781579
{
1579-
if (_activeConnection.InnerConnection is SqlInternalConnectionTds innerConnectionTds)
1580+
if (_activeConnection.InnerConnection is SqlConnectionInternal innerConnectionTds)
15801581
{
15811582
// It may be closed
15821583
innerConnectionTds.DecrementAsyncCount();
@@ -1812,7 +1813,7 @@ public void Set(
18121813
protected override void AfterCleared(SqlCommand owner)
18131814
{
18141815
DbConnectionInternal internalConnection = owner?._activeConnection?.InnerConnection;
1815-
if (internalConnection is SqlInternalConnectionTds sqlInternalConnection)
1816+
if (internalConnection is SqlConnectionInternal sqlInternalConnection)
18161817
{
18171818
sqlInternalConnection.CachedContexts.TrySetCommandExecuteReaderAsyncContext(this);
18181819
}

src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlCommand.Xml.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
using System.Xml;
1111
using Microsoft.Data.Common;
1212
using Microsoft.Data.ProviderBase;
13+
using Microsoft.Data.SqlClient.Connection;
1314
using Microsoft.Data.SqlClient.Server;
1415

1516
#if NETFRAMEWORK
@@ -487,7 +488,7 @@ private Task<XmlReader> InternalExecuteXmlReaderAsync(CancellationToken cancella
487488

488489
// @TODO: This can be cleaned up to lines if InnerConnection is always SqlInternalConnection
489490
ExecuteXmlReaderAsyncCallContext context = null;
490-
if (_activeConnection?.InnerConnection is SqlInternalConnectionTds sqlInternalConnection)
491+
if (_activeConnection?.InnerConnection is SqlConnectionInternal sqlInternalConnection)
491492
{
492493
context = sqlInternalConnection.CachedContexts.ClearCommandExecuteXmlReaderAsyncContext();
493494
}
@@ -570,7 +571,7 @@ public void Set(
570571
protected override void AfterCleared(SqlCommand owner)
571572
{
572573
DbConnectionInternal internalConnection = owner?._activeConnection?.InnerConnection;
573-
if (internalConnection is SqlInternalConnectionTds sqlInternalConnection)
574+
if (internalConnection is SqlConnectionInternal sqlInternalConnection)
574575
{
575576
sqlInternalConnection.CachedContexts.TrySetCommandExecuteXmlReaderAsyncContext(this);
576577
}

src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlCommand.cs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
using System.Threading.Tasks;
1818
using Microsoft.Data.Common;
1919
using Microsoft.Data.Sql;
20+
using Microsoft.Data.SqlClient.Connection;
2021
using Microsoft.Data.SqlClient.Diagnostics;
2122

2223
#if NETFRAMEWORK
@@ -958,10 +959,10 @@ private int DefaultCommandTimeout
958959
}
959960

960961
// @TODO: Should be used in more than one place to justify its existence
961-
private SqlInternalConnectionTds InternalTdsConnection
962+
private SqlConnectionInternal InternalTdsConnection
962963
{
963964
// @TODO: Should check for null? Should use Connection?
964-
get => (SqlInternalConnectionTds)_activeConnection.InnerConnection;
965+
get => (SqlConnectionInternal)_activeConnection.InnerConnection;
965966
}
966967

967968
private bool IsColumnEncryptionEnabled
@@ -1084,7 +1085,7 @@ public override void Cancel()
10841085
// Note that this model is implementable because we only allow one active command
10851086
// at any one time. This code will have to change we allow multiple outstanding
10861087
// batches.
1087-
if (_activeConnection?.InnerConnection is not SqlInternalConnectionTds connection)
1088+
if (_activeConnection?.InnerConnection is not SqlConnectionInternal connection)
10881089
{
10891090
// @TODO: Really this case only applies if the connection is null.
10901091
// Fail without locking
@@ -1100,7 +1101,7 @@ public override void Cancel()
11001101
{
11011102
// Make sure the connection did not get changed getting the connection and
11021103
// taking the lock. If it has, the connection has been closed.
1103-
if (connection != _activeConnection.InnerConnection as SqlInternalConnectionTds)
1104+
if (connection != _activeConnection.InnerConnection as SqlConnectionInternal)
11041105
{
11051106
return;
11061107
}
@@ -2380,9 +2381,8 @@ private void CheckNotificationStateAndAutoEnlist()
23802381
// 3) database
23812382

23822383
// Obtain identity from connection.
2383-
// @TODO: Remove cast when possible.
2384-
SqlInternalConnectionTds internalConnection =
2385-
(SqlInternalConnectionTds)_activeConnection.InnerConnection;
2384+
SqlConnectionInternal internalConnection =
2385+
(SqlConnectionInternal)_activeConnection.InnerConnection;
23862386

23872387
SqlDependency.IdentityUserNamePair identityUserName = internalConnection.Identity is not null
23882388
? new SqlDependency.IdentityUserNamePair(
@@ -2951,8 +2951,7 @@ private void ValidateCommand(bool isAsync, [CallerMemberName] string method = ""
29512951
}
29522952

29532953
// Ensure that the connection is open and that the parser is in the correct state
2954-
// @TODO: Remove cast when possible.
2955-
SqlInternalConnectionTds tdsConnection = _activeConnection.InnerConnection as SqlInternalConnectionTds;
2954+
SqlConnectionInternal tdsConnection = _activeConnection.InnerConnection as SqlConnectionInternal;
29562955

29572956
// Ensure that if column encryption override was used then server supports it
29582957
// @TODO: This is kinda clunky

0 commit comments

Comments
 (0)