Skip to content

Commit 8595644

Browse files
authored
Replace unused out arguments with discards (#2726)
* Replace unused out arguments with discards * Removing unnecessary types in discarded out arguments
1 parent 0c45198 commit 8595644

File tree

25 files changed

+100
-168
lines changed

25 files changed

+100
-168
lines changed

src/Microsoft.Data.SqlClient/netcore/src/Common/src/Interop/Windows/sspicli/SSPIWrapper.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -406,8 +406,7 @@ public static SafeFreeContextBufferChannelBinding QueryContextChannelBinding(SSP
406406

407407
public static object QueryContextAttributes(SSPIInterface secModule, SafeDeleteContext securityContext, Interop.SspiCli.ContextAttribute contextAttribute)
408408
{
409-
int errorCode;
410-
return QueryContextAttributes(secModule, securityContext, contextAttribute, out errorCode);
409+
return QueryContextAttributes(secModule, securityContext, contextAttribute, out _);
411410
}
412411

413412
public static object QueryContextAttributes(SSPIInterface secModule, SafeDeleteContext securityContext, Interop.SspiCli.ContextAttribute contextAttribute, out int errorCode)

src/Microsoft.Data.SqlClient/netcore/src/Common/src/Interop/Windows/sspicli/SecuritySafeHandles.cs

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,6 @@ public static unsafe int AcquireDefaultCredential(
214214
NetEventSource.Enter(null, package, intent);
215215

216216
int errorCode = -1;
217-
long timeStamp;
218217

219218
outCredential = new SafeFreeCredential_SECURITY();
220219

@@ -227,7 +226,7 @@ public static unsafe int AcquireDefaultCredential(
227226
null,
228227
null,
229228
ref outCredential._handle,
230-
out timeStamp);
229+
out _);
231230

232231
#if TRACE_VERBOSE
233232
if (NetEventSource.IsEnabled) NetEventSource.Info(null, $"{nameof(Interop.SspiCli.AcquireCredentialsHandleW)} returns 0x{errorCode:x}, handle = {outCredential}");
@@ -248,7 +247,6 @@ public static unsafe int AcquireCredentialsHandle(
248247
out SafeFreeCredentials outCredential)
249248
{
250249
int errorCode = -1;
251-
long timeStamp;
252250

253251
outCredential = new SafeFreeCredential_SECURITY();
254252
errorCode = Interop.SspiCli.AcquireCredentialsHandleW(
@@ -260,7 +258,7 @@ public static unsafe int AcquireCredentialsHandle(
260258
null,
261259
null,
262260
ref outCredential._handle,
263-
out timeStamp);
261+
out _);
264262

265263
if (errorCode != 0)
266264
{
@@ -280,7 +278,6 @@ public static unsafe int AcquireCredentialsHandle(
280278
NetEventSource.Enter(null, package, intent, authdata);
281279

282280
int errorCode = -1;
283-
long timeStamp;
284281

285282

286283
// If there is a certificate, wrap it into an array.
@@ -305,7 +302,7 @@ public static unsafe int AcquireCredentialsHandle(
305302
null,
306303
null,
307304
ref outCredential._handle,
308-
out timeStamp);
305+
out _);
309306
}
310307
finally
311308
{
@@ -632,8 +629,6 @@ private static unsafe int MustRunInitializeSecurityContext(
632629

633630
Interop.SspiCli.CredHandle credentialHandle = inCredentials._handle;
634631

635-
long timeStamp;
636-
637632
errorCode = Interop.SspiCli.InitializeSecurityContextW(
638633
ref credentialHandle,
639634
inContextPtr,
@@ -646,7 +641,7 @@ private static unsafe int MustRunInitializeSecurityContext(
646641
ref outContext._handle,
647642
ref outputBuffer,
648643
ref attributes,
649-
out timeStamp);
644+
out _);
650645
}
651646
finally
652647
{
@@ -919,7 +914,6 @@ private static unsafe int MustRunAcceptSecurityContext_SECURITY(
919914
outContext.DangerousAddRef(ref ignore);
920915

921916
Interop.SspiCli.CredHandle credentialHandle = inCredentials._handle;
922-
long timeStamp;
923917

924918
errorCode = Interop.SspiCli.AcceptSecurityContext(
925919
ref credentialHandle,
@@ -930,7 +924,7 @@ private static unsafe int MustRunAcceptSecurityContext_SECURITY(
930924
ref outContext._handle,
931925
ref outputBuffer,
932926
ref outFlags,
933-
out timeStamp);
927+
out _);
934928
}
935929
finally
936930
{

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ internal bool CanBePooled
6363
{
6464
get
6565
{
66-
return (!_connectionIsDoomed && !_cannotBePooled && !_owningObject.TryGetTarget(out DbConnection _));
66+
return (!_connectionIsDoomed && !_cannotBePooled && !_owningObject.TryGetTarget(out _));
6767
}
6868
}
6969

@@ -102,7 +102,7 @@ internal bool IsEmancipated
102102
// of the pool and it's owning object is no longer around to
103103
// return it.
104104

105-
return (_pooledCount < 1) && !_owningObject.TryGetTarget(out DbConnection _);
105+
return (_pooledCount < 1) && !_owningObject.TryGetTarget(out _);
106106
}
107107
}
108108

@@ -409,7 +409,7 @@ internal void PostPop(DbConnection newOwner)
409409
// IMPORTANT NOTE: You must have taken a lock on the object before
410410
// you call this method to prevent race conditions with Clear and
411411
// ReclaimEmancipatedObjects.
412-
if (_owningObject.TryGetTarget(out DbConnection _))
412+
if (_owningObject.TryGetTarget(out _))
413413
{
414414
throw ADP.InternalError(ADP.InternalErrorCode.PooledObjectHasOwner); // pooled connection already has an owner!
415415
}

src/Microsoft.Data.SqlClient/netcore/src/Interop/SNINativeMethodWrapper.Windows.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -476,14 +476,13 @@ internal static unsafe uint SNISecGenClientContext(SNIHandle pConnectionObject,
476476
fixed (byte* pin_serverUserName = &serverUserName[0])
477477
fixed (byte* pInBuff = inBuff)
478478
{
479-
bool local_fDone;
480479
return SNISecGenClientContextWrapper(
481480
pConnectionObject,
482481
pInBuff,
483482
(uint)inBuff.Length,
484483
OutBuff,
485484
ref sendLength,
486-
out local_fDone,
485+
out _,
487486
pin_serverUserName,
488487
(uint)serverUserName.Length,
489488
null,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ virtual internal void DelegatedTransactionEnded()
360360
}
361361
pool.PutObjectFromTransactedPool(this);
362362
}
363-
else if (-1 == _pooledCount && !_owningObject.TryGetTarget(out DbConnection _))
363+
else if (-1 == _pooledCount && !_owningObject.TryGetTarget(out _))
364364
{
365365
// When _pooledCount is -1 and the owning object no longer exists,
366366
// it indicates a closed (or leaked), non-pooled connection so

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

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1605,10 +1605,8 @@ private object InternalEndExecuteNonQuery(IAsyncResult asyncResult, bool isInter
16051605
{
16061606
try
16071607
{
1608-
bool dataReady;
16091608
Debug.Assert(_stateObj._syncOverAsync, "Should not attempt pends in a synchronous call");
1610-
TdsOperationStatus result = _stateObj.Parser.TryRun(RunBehavior.UntilDone, this, null, null, _stateObj,
1611-
out dataReady);
1609+
TdsOperationStatus result = _stateObj.Parser.TryRun(RunBehavior.UntilDone, this, null, null, _stateObj, out _);
16121610
if (result != TdsOperationStatus.Done)
16131611
{
16141612
throw SQL.SynchronousCallMayNotPend();
@@ -3680,9 +3678,8 @@ private Task RunExecuteNonQueryTds(string methodName, bool isAsync, int timeout,
36803678
}
36813679
else
36823680
{
3683-
bool dataReady;
36843681
Debug.Assert(_stateObj._syncOverAsync, "Should not attempt pends in a synchronous call");
3685-
TdsOperationStatus result = _stateObj.Parser.TryRun(RunBehavior.UntilDone, this, null, null, _stateObj, out dataReady);
3682+
TdsOperationStatus result = _stateObj.Parser.TryRun(RunBehavior.UntilDone, this, null, null, _stateObj, out _);
36863683
if (result != TdsOperationStatus.Done)
36873684
{
36883685
throw SQL.SynchronousCallMayNotPend();
@@ -5298,9 +5295,8 @@ private void FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, stri
52985295
{
52995296
try
53005297
{
5301-
bool dataReady;
53025298
Debug.Assert(_stateObj._syncOverAsync, "Should not attempt pends in a synchronous call");
5303-
TdsOperationStatus result = _stateObj.Parser.TryRun(RunBehavior.UntilDone, this, ds, null, _stateObj, out dataReady);
5299+
TdsOperationStatus result = _stateObj.Parser.TryRun(RunBehavior.UntilDone, this, ds, null, _stateObj, out _);
53045300
if (result != TdsOperationStatus.Done)
53055301
{
53065302
throw SQL.SynchronousCallMayNotPend();

src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlConnection.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2165,8 +2165,7 @@ internal SqlInternalConnectionTds GetOpenTdsConnection(string method)
21652165

21662166
internal void OnInfoMessage(SqlInfoMessageEventArgs imevent)
21672167
{
2168-
bool notified;
2169-
OnInfoMessage(imevent, out notified);
2168+
OnInfoMessage(imevent, out _);
21702169
}
21712170

21722171
internal void OnInfoMessage(SqlInfoMessageEventArgs imevent, out bool notified)

src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlDataReader.cs

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1001,8 +1001,7 @@ private TdsOperationStatus TryCloseInternal(bool closeReader)
10011001
#endif
10021002

10031003

1004-
bool ignored;
1005-
result = parser.TryRun(RunBehavior.Clean, _command, this, null, stateObj, out ignored);
1004+
result = parser.TryRun(RunBehavior.Clean, _command, this, null, stateObj, out _);
10061005
if (result != TdsOperationStatus.Done)
10071006
{
10081007
return result;
@@ -3208,8 +3207,7 @@ private TdsOperationStatus TryHasMoreResults(out bool moreResults)
32083207
throw ADP.ClosedConnectionError();
32093208
}
32103209

3211-
bool ignored;
3212-
result = _parser.TryRun(RunBehavior.ReturnImmediately, _command, this, null, _stateObj, out ignored);
3210+
result = _parser.TryRun(RunBehavior.ReturnImmediately, _command, this, null, _stateObj, out _);
32133211
if (result != TdsOperationStatus.Done)
32143212
{
32153213
moreResults = false;
@@ -3279,8 +3277,7 @@ private TdsOperationStatus TryHasMoreRows(out bool moreRows)
32793277
throw ADP.ClosedConnectionError();
32803278
}
32813279

3282-
bool ignored;
3283-
result = _parser.TryRun(RunBehavior.ReturnImmediately, _command, this, null, _stateObj, out ignored);
3280+
result = _parser.TryRun(RunBehavior.ReturnImmediately, _command, this, null, _stateObj, out _);
32843281
if (result != TdsOperationStatus.Done)
32853282
{
32863283
moreRows = false;
@@ -4116,8 +4113,7 @@ private TdsOperationStatus TryResetBlobState()
41164113
{
41174114
if (_stateObj._longlen != 0)
41184115
{
4119-
ulong ignored;
4120-
result = _stateObj.Parser.TrySkipPlpValue(ulong.MaxValue, _stateObj, out ignored);
4116+
result = _stateObj.Parser.TrySkipPlpValue(ulong.MaxValue, _stateObj, out _);
41214117
if (result != TdsOperationStatus.Done)
41224118
{
41234119
return result;
@@ -4212,8 +4208,7 @@ internal TdsOperationStatus TrySetAltMetaDataSet(_SqlMetaDataSet metaDataSet, bo
42124208
}
42134209
if (TdsEnums.SQLORDER == b)
42144210
{
4215-
bool ignored;
4216-
result = _parser.TryRun(RunBehavior.ReturnImmediately, _command, this, null, _stateObj, out ignored);
4211+
result = _parser.TryRun(RunBehavior.ReturnImmediately, _command, this, null, _stateObj, out _);
42174212
if (result != TdsOperationStatus.Done)
42184213
{
42194214
return result;
@@ -4229,8 +4224,7 @@ internal TdsOperationStatus TrySetAltMetaDataSet(_SqlMetaDataSet metaDataSet, bo
42294224
try
42304225
{
42314226
_stateObj._accumulateInfoEvents = true;
4232-
bool ignored;
4233-
result = _parser.TryRun(RunBehavior.ReturnImmediately, _command, null, null, _stateObj, out ignored);
4227+
result = _parser.TryRun(RunBehavior.ReturnImmediately, _command, null, null, _stateObj, out _);
42344228
if (result != TdsOperationStatus.Done)
42354229
{
42364230
return result;
@@ -4308,9 +4302,9 @@ internal TdsOperationStatus TrySetMetaData(_SqlMetaDataSet metaData, bool moreIn
43084302

43094303
// simply rip the order token off the wire
43104304
if (b == TdsEnums.SQLORDER)
4311-
{ // same logic as SetAltMetaDataSet
4312-
bool ignored;
4313-
result = _parser.TryRun(RunBehavior.ReturnImmediately, null, null, null, _stateObj, out ignored);
4305+
{
4306+
// same logic as SetAltMetaDataSet
4307+
result = _parser.TryRun(RunBehavior.ReturnImmediately, null, null, null, _stateObj, out _);
43144308
if (result != TdsOperationStatus.Done)
43154309
{
43164310
return result;
@@ -4329,8 +4323,7 @@ internal TdsOperationStatus TrySetMetaData(_SqlMetaDataSet metaData, bool moreIn
43294323
try
43304324
{
43314325
_stateObj._accumulateInfoEvents = true;
4332-
bool ignored;
4333-
result = _parser.TryRun(RunBehavior.ReturnImmediately, null, null, null, _stateObj, out ignored);
4326+
result = _parser.TryRun(RunBehavior.ReturnImmediately, null, null, null, _stateObj, out _);
43344327
if (result != TdsOperationStatus.Done)
43354328
{
43364329
return result;

0 commit comments

Comments
 (0)