@@ -99,7 +99,7 @@ private static readonly Dictionary<string, SqlColumnEncryptionKeyStoreProvider>
99
99
100
100
/// <summary>
101
101
/// Global custom provider list should be provided by the user. We shallow copy the user supplied dictionary into a ReadOnlyDictionary.
102
- /// Global custom provider list can only supplied once per application.
102
+ /// Global custom provider list can only be supplied once per application.
103
103
/// </summary>
104
104
private static IReadOnlyDictionary < string , SqlColumnEncryptionKeyStoreProvider > s_globalCustomColumnEncryptionKeyStoreProviders ;
105
105
@@ -164,7 +164,7 @@ public SqlConnection(string connectionString) : this()
164
164
/// <include file='../../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlConnection.xml' path='docs/members[@name="SqlConnection"]/ctorConnectionStringCredential/*' />
165
165
public SqlConnection ( string connectionString , SqlCredential credential ) : this ( )
166
166
{
167
- ConnectionString = connectionString ;
167
+ ConnectionString = connectionString ; // setting connection string first so that ConnectionOption is available
168
168
if ( credential != null )
169
169
{
170
170
// The following checks are necessary as setting Credential property will call CheckAndThrowOnInvalidCombinationOfConnectionStringAndSqlCredential
@@ -370,7 +370,6 @@ private static void ValidateCustomProviders(IDictionary<string, SqlColumnEncrypt
370
370
foreach ( string key in customProviders . Keys )
371
371
{
372
372
// Validate the provider name
373
- //
374
373
// Check for null or empty
375
374
if ( string . IsNullOrWhiteSpace ( key ) )
376
375
{
@@ -394,18 +393,17 @@ private static void ValidateCustomProviders(IDictionary<string, SqlColumnEncrypt
394
393
/// <summary>
395
394
/// Get enclave attestation url to be used with enclave based Always Encrypted
396
395
/// </summary>
397
- internal string EnclaveAttestationUrl => ( ( SqlConnectionString ) ConnectionOptions ) . EnclaveAttestationUrl ;
396
+ internal string EnclaveAttestationUrl
397
+ {
398
+ get => ( ( SqlConnectionString ) ConnectionOptions ) . EnclaveAttestationUrl ;
399
+ }
398
400
399
401
/// <summary>
400
402
/// Get attestation protocol
401
403
/// </summary>
402
404
internal SqlConnectionAttestationProtocol AttestationProtocol
403
405
{
404
- get
405
- {
406
- SqlConnectionString opt = ( SqlConnectionString ) ConnectionOptions ;
407
- return opt . AttestationProtocol ;
408
- }
406
+ get => ( ( SqlConnectionString ) ConnectionOptions ) . AttestationProtocol ;
409
407
}
410
408
411
409
/// <summary>
@@ -658,6 +656,7 @@ public override string ConnectionString
658
656
/// <include file='../../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlConnection.xml' path='docs/members[@name="SqlConnection"]/ConnectionTimeout/*' />
659
657
[ ResDescription ( StringsHelper . ResourceNames . SqlConnection_ConnectionTimeout ) ]
660
658
[ ResCategory ( StringsHelper . ResourceNames . SqlConnection_DataSource ) ]
659
+ [ DesignerSerializationVisibility ( DesignerSerializationVisibility . Hidden ) ]
661
660
public override int ConnectionTimeout
662
661
{
663
662
get
@@ -688,7 +687,6 @@ public string AccessToken
688
687
{
689
688
get
690
689
{
691
- string result = _accessToken ;
692
690
// When a connection is connecting or is ever opened, make AccessToken available only if "Persist Security Info" is set to true
693
691
// otherwise, return null
694
692
SqlConnectionString connectionOptions = ( SqlConnectionString ) UserConnectionOptions ;
@@ -740,6 +738,7 @@ public Func<SqlAuthenticationParameters, CancellationToken, Task<SqlAuthenticati
740
738
/// <include file='../../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlConnection.xml' path='docs/members[@name="SqlConnection"]/Database/*' />
741
739
[ ResDescription ( StringsHelper . ResourceNames . SqlConnection_Database ) ]
742
740
[ ResCategory ( StringsHelper . ResourceNames . SqlConnection_DataSource ) ]
741
+ [ DesignerSerializationVisibility ( DesignerSerializationVisibility . Hidden ) ]
743
742
public override string Database
744
743
{
745
744
// if the connection is open, we need to ask the inner connection what it's
@@ -766,6 +765,7 @@ public override string Database
766
765
///
767
766
/// To indicate the IsSupported flag sent by the server for DNS Caching. This property is for internal testing only.
768
767
///
768
+ [ DesignerSerializationVisibility ( DesignerSerializationVisibility . Hidden ) ]
769
769
internal string SQLDNSCachingSupportedState
770
770
{
771
771
get
@@ -789,6 +789,7 @@ internal string SQLDNSCachingSupportedState
789
789
///
790
790
/// To indicate the IsSupported flag sent by the server for DNS Caching before redirection. This property is for internal testing only.
791
791
///
792
+ [ DesignerSerializationVisibility ( DesignerSerializationVisibility . Hidden ) ]
792
793
internal string SQLDNSCachingSupportedStateBeforeRedirect
793
794
{
794
795
get
@@ -1079,7 +1080,7 @@ private void CheckAndThrowOnInvalidCombinationOfConnectionOptionAndAccessToken(S
1079
1080
throw ADP . InvalidMixedUsageOfCredentialAndAccessToken ( ) ;
1080
1081
}
1081
1082
1082
- if ( _accessTokenCallback != null )
1083
+ if ( _accessTokenCallback != null )
1083
1084
{
1084
1085
throw ADP . InvalidMixedUsageOfAccessTokenAndTokenCallback ( ) ;
1085
1086
}
@@ -1101,7 +1102,7 @@ private void CheckAndThrowOnInvalidCombinationOfConnectionOptionAndAccessTokenCa
1101
1102
throw ADP . InvalidMixedUsageOfAccessTokenCallbackAndAuthentication ( ) ;
1102
1103
}
1103
1104
1104
- if ( _accessToken != null )
1105
+ if ( _accessToken != null )
1105
1106
{
1106
1107
throw ADP . InvalidMixedUsageOfAccessTokenAndTokenCallback ( ) ;
1107
1108
}
@@ -1113,8 +1114,6 @@ protected override DbProviderFactory DbProviderFactory
1113
1114
get => SqlClientFactory . Instance ;
1114
1115
}
1115
1116
1116
- // SqlCredential: Pair User Id and password in SecureString which are to be used for SQL authentication
1117
-
1118
1117
//
1119
1118
// PUBLIC EVENTS
1120
1119
//
@@ -1155,11 +1154,11 @@ protected override void OnStateChange(StateChangeEventArgs stateChange)
1155
1154
new public SqlTransaction BeginTransaction ( )
1156
1155
{
1157
1156
// this is just a delegate. The actual method tracks executiontime
1158
- return BeginTransaction ( System . Data . IsolationLevel . Unspecified , null ) ;
1157
+ return BeginTransaction ( IsolationLevel . Unspecified , null ) ;
1159
1158
}
1160
1159
1161
1160
/// <include file='../../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlConnection.xml' path='docs/members[@name="SqlConnection"]/BeginTransactionIso/*' />
1162
- new public SqlTransaction BeginTransaction ( System . Data . IsolationLevel iso )
1161
+ new public SqlTransaction BeginTransaction ( IsolationLevel iso )
1163
1162
{
1164
1163
// this is just a delegate. The actual method tracks executiontime
1165
1164
return BeginTransaction ( iso , null ) ;
@@ -1172,18 +1171,18 @@ public SqlTransaction BeginTransaction(string transactionName)
1172
1171
// BEGIN...COMMIT or BEGIN...ROLLBACK statements. Transaction names
1173
1172
// are ignored for nested BEGIN's. The only way to rollback a nested
1174
1173
// transaction is to have a save point from a SAVE TRANSACTION call.
1175
- return BeginTransaction ( System . Data . IsolationLevel . Unspecified , transactionName ) ;
1174
+ return BeginTransaction ( IsolationLevel . Unspecified , transactionName ) ;
1176
1175
}
1177
1176
1178
1177
/// <include file='../../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlConnection.xml' path='docs/members[@name="SqlConnection"]/BeginDbTransaction/*' />
1179
1178
[ SuppressMessage ( "Microsoft.Reliability" , "CA2004:RemoveCallsToGCKeepAlive" ) ]
1180
- override protected DbTransaction BeginDbTransaction ( System . Data . IsolationLevel isolationLevel )
1179
+ override protected DbTransaction BeginDbTransaction ( IsolationLevel isolationLevel )
1181
1180
{
1182
1181
using ( TryEventScope . Create ( "SqlConnection.BeginDbTransaction | API | Object Id {0}, Isolation Level {1}" , ObjectID , ( int ) isolationLevel ) )
1183
1182
{
1184
1183
DbTransaction transaction = BeginTransaction ( isolationLevel ) ;
1185
1184
1186
- // InnerConnection doesn't maintain a ref on the outer connection (this) and
1185
+ // VSTFDEVDIV# 560355 - InnerConnection doesn't maintain a ref on the outer connection (this) and
1187
1186
// subsequently leaves open the possibility that the outer connection could be GC'ed before the SqlTransaction
1188
1187
// is fully hooked up (leaving a DbTransaction with a null connection property). Ensure that this is reachable
1189
1188
// until the completion of BeginTransaction with KeepAlive
@@ -1194,7 +1193,7 @@ override protected DbTransaction BeginDbTransaction(System.Data.IsolationLevel i
1194
1193
}
1195
1194
1196
1195
/// <include file='../../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlConnection.xml' path='docs/members[@name="SqlConnection"]/BeginTransactionIsoTransactionName/*' />
1197
- public SqlTransaction BeginTransaction ( System . Data . IsolationLevel iso , string transactionName )
1196
+ public SqlTransaction BeginTransaction ( IsolationLevel iso , string transactionName )
1198
1197
{
1199
1198
WaitForPendingReconnection ( ) ;
1200
1199
SqlStatistics statistics = null ;
@@ -1287,7 +1286,6 @@ public static void ClearPool(SqlConnection connection)
1287
1286
}
1288
1287
}
1289
1288
1290
-
1291
1289
private void CloseInnerConnection ( )
1292
1290
{
1293
1291
// CloseConnection() now handles the lock
@@ -1625,6 +1623,7 @@ internal Task ValidateAndReconnect(Action beforeDisconnect, int timeout)
1625
1623
_originalConnectionId = ClientConnectionId ;
1626
1624
SqlClientEventSource . Log . TryTraceEvent ( "SqlConnection.ValidateAndReconnect | Info | Connection Client Connection Id {0} is invalid, reconnecting" , _originalConnectionId ) ;
1627
1625
_recoverySessionData = cData ;
1626
+
1628
1627
if ( beforeDisconnect != null )
1629
1628
{
1630
1629
beforeDisconnect ( ) ;
@@ -1877,6 +1876,7 @@ internal void Retry(Task<DbConnectionInternal> retryTask)
1877
1876
{
1878
1877
SqlClientEventSource . Log . TryTraceEvent ( "SqlConnection.Retry | Info | Object Id {0}" , _parent ? . ObjectID ) ;
1879
1878
_registration . Dispose ( ) ;
1879
+
1880
1880
try
1881
1881
{
1882
1882
SqlStatistics statistics = null ;
@@ -2078,7 +2078,6 @@ internal bool HasLocalTransactionFromAPI
2078
2078
}
2079
2079
}
2080
2080
2081
-
2082
2081
internal bool Is2008OrNewer
2083
2082
{
2084
2083
get
@@ -2100,7 +2099,6 @@ internal TdsParser Parser
2100
2099
}
2101
2100
}
2102
2101
2103
-
2104
2102
//
2105
2103
// INTERNAL METHODS
2106
2104
//
@@ -2152,7 +2150,6 @@ internal void OnError(SqlException exception, bool breakConnection, Action<Actio
2152
2150
{
2153
2151
Debug . Assert ( exception != null && exception . Errors . Count != 0 , "SqlConnection: OnError called with null or empty exception!" ) ;
2154
2152
2155
-
2156
2153
if ( breakConnection && ( ConnectionState . Open == State ) )
2157
2154
{
2158
2155
if ( wrapCloseInAction != null )
@@ -2483,6 +2480,7 @@ private Assembly ResolveTypeAssembly(AssemblyName asmRef, bool throwOnError)
2483
2480
}
2484
2481
asmRef . Version = TypeSystemAssemblyVersion ;
2485
2482
}
2483
+
2486
2484
try
2487
2485
{
2488
2486
return Assembly . Load ( asmRef ) ;
@@ -2546,12 +2544,6 @@ internal object GetUdtValue(object value, SqlMetaDataPriv metaData, bool returnD
2546
2544
}
2547
2545
}
2548
2546
2549
- internal byte [ ] GetBytes ( object o )
2550
- {
2551
- Format format = Format . Native ;
2552
- return GetBytes ( o , out format , out int maxSize ) ;
2553
- }
2554
-
2555
2547
internal byte [ ] GetBytes ( object o , out Format format , out int maxSize )
2556
2548
{
2557
2549
SqlUdtInfo attr = GetInfoFromType ( o . GetType ( ) ) ;
@@ -2575,7 +2567,7 @@ internal byte[] GetBytes(object o, out Format format, out int maxSize)
2575
2567
2576
2568
private SqlUdtInfo GetInfoFromType ( Type t )
2577
2569
{
2578
- Debug . Assert ( t != null , "Type object cant be NULL" ) ;
2570
+ Debug . Assert ( t != null , "Type object can't be NULL" ) ;
2579
2571
Type orig = t ;
2580
2572
do
2581
2573
{
@@ -2584,10 +2576,8 @@ private SqlUdtInfo GetInfoFromType(Type t)
2584
2576
{
2585
2577
return attr ;
2586
2578
}
2587
- else
2588
- {
2589
- t = t . BaseType ;
2590
- }
2579
+
2580
+ t = t . BaseType ;
2591
2581
}
2592
2582
while ( t != null ) ;
2593
2583
0 commit comments