Skip to content

Commit

Permalink
TdsParserStateObject: Replaced var usages with explicit types.
Browse files Browse the repository at this point in the history
  • Loading branch information
panoskj committed Oct 5, 2022
1 parent 3e05aeb commit 58ae136
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 25 deletions.
Expand Up @@ -398,7 +398,7 @@ public bool TryReadByteArray(Span<byte> buff, int len, out int totalRead)
Debug.Assert(bytesToRead > 0, "0 byte read in TryReadByteArray");
if (!buff.IsEmpty)
{
var copyFrom = new ReadOnlySpan<byte>(_inBuff, _inBytesUsed, bytesToRead);
ReadOnlySpan<byte> copyFrom = new ReadOnlySpan<byte>(_inBuff, _inBytesUsed, bytesToRead);
Span<byte> copyTo = buff.Slice(totalRead, bytesToRead);
copyFrom.CopyTo(copyTo);
}
Expand Down Expand Up @@ -1292,7 +1292,7 @@ internal void OnConnectionClosed()
Interlocked.MemoryBarrier();

// then check for networkPacketTaskSource
var taskSource = _networkPacketTaskSource;
TaskCompletionSource<object> taskSource = _networkPacketTaskSource;
if (taskSource != null)
{
taskSource.TrySetException(ADP.ExceptionWithStackTrace(ADP.ClosedConnectionError()));
Expand Down Expand Up @@ -2055,7 +2055,7 @@ public void WriteAsyncCallback(IntPtr key, PacketHandle packet, uint sniError)
}
catch (Exception e)
{
var writeCompletionSource = _writeCompletionSource;
TaskCompletionSource<object> writeCompletionSource = _writeCompletionSource;
if (writeCompletionSource != null)
{
writeCompletionSource.TrySetException(e);
Expand All @@ -2071,7 +2071,7 @@ public void WriteAsyncCallback(IntPtr key, PacketHandle packet, uint sniError)
writeCompletionSource = _writeCompletionSource;
if (writeCompletionSource != null)
{
var delayedException = Interlocked.Exchange(ref _delayedWriteAsyncCallbackException, null);
Exception delayedException = Interlocked.Exchange(ref _delayedWriteAsyncCallbackException, null);
if (delayedException != null)
{
writeCompletionSource.TrySetException(delayedException);
Expand All @@ -2095,7 +2095,7 @@ public void WriteAsyncCallback(IntPtr key, PacketHandle packet, uint sniError)
new Timer(obj =>
{
Interlocked.Decrement(ref _asyncWriteCount);
var writeCompletionSource = _writeCompletionSource;
TaskCompletionSource<object> writeCompletionSource = _writeCompletionSource;
if (_asyncWriteCount == 0 && writeCompletionSource != null)
{
writeCompletionSource.TrySetResult(null);
Expand All @@ -2116,7 +2116,7 @@ public void WriteAsyncCallback(IntPtr key, PacketHandle packet, uint sniError)
return;
}
#endif
var completionSource = _writeCompletionSource;
TaskCompletionSource<object> completionSource = _writeCompletionSource;
if (_asyncWriteCount == 0 && completionSource != null)
{
completionSource.TrySetResult(null);
Expand Down Expand Up @@ -2158,7 +2158,7 @@ internal void ResetSecurePasswordsInformation()
internal Task WaitForAccumulatedWrites()
{
// Checked for stored exceptions
var delayedException = Interlocked.Exchange(ref _delayedWriteAsyncCallbackException, null);
Exception delayedException = Interlocked.Exchange(ref _delayedWriteAsyncCallbackException, null);
if (delayedException != null)
{
throw delayedException;
Expand Down Expand Up @@ -2449,7 +2449,7 @@ private void CancelWritePacket()
private Task SNIWritePacket(PacketHandle packet, out uint sniError, bool canAccumulate, bool callerHasConnectionLock, bool asyncClose = false)
{
// Check for a stored exception
var delayedException = Interlocked.Exchange(ref _delayedWriteAsyncCallbackException, null);
Exception delayedException = Interlocked.Exchange(ref _delayedWriteAsyncCallbackException, null);
if (delayedException != null)
{
throw delayedException;
Expand Down Expand Up @@ -2998,7 +2998,7 @@ internal void CheckThrowSNIException()
internal void AssertStateIsClean()
{
// If our TdsParser is closed or broken, then we don't really care about our state
var parser = _parser;
TdsParser parser = _parser;
if ((parser != null) && (parser.State != TdsParserState.Closed) && (parser.State != TdsParserState.Broken))
{
// Async reads
Expand All @@ -3020,8 +3020,8 @@ internal void AssertStateIsClean()
#if DEBUG
internal void CompletePendingReadWithSuccess(bool resetForcePendingReadsToWait)
{
var realNetworkPacketTaskSource = _realNetworkPacketTaskSource;
var networkPacketTaskSource = _networkPacketTaskSource;
TaskCompletionSource<object> realNetworkPacketTaskSource = _realNetworkPacketTaskSource;
TaskCompletionSource<object> networkPacketTaskSource = _networkPacketTaskSource;

Debug.Assert(s_forcePendingReadsToWaitForUser, "Not forcing pends to wait for user - can't force complete");
Debug.Assert(networkPacketTaskSource != null, "No pending read to complete");
Expand Down Expand Up @@ -3050,8 +3050,8 @@ internal void CompletePendingReadWithSuccess(bool resetForcePendingReadsToWait)

internal void CompletePendingReadWithFailure(int errorCode, bool resetForcePendingReadsToWait)
{
var realNetworkPacketTaskSource = _realNetworkPacketTaskSource;
var networkPacketTaskSource = _networkPacketTaskSource;
TaskCompletionSource<object> realNetworkPacketTaskSource = _realNetworkPacketTaskSource;
TaskCompletionSource<object> networkPacketTaskSource = _networkPacketTaskSource;

Debug.Assert(s_forcePendingReadsToWaitForUser, "Not forcing pends to wait for user - can't force complete");
Debug.Assert(networkPacketTaskSource != null, "No pending read to complete");
Expand Down
Expand Up @@ -1389,7 +1389,7 @@ internal void OnConnectionClosed()
Thread.MemoryBarrier();

// then check for networkPacketTaskSource
var taskSource = _networkPacketTaskSource;
TaskCompletionSource<object> taskSource = _networkPacketTaskSource;
if (taskSource != null)
{
taskSource.TrySetException(ADP.ExceptionWithStackTrace(ADP.ClosedConnectionError()));
Expand Down Expand Up @@ -2141,7 +2141,7 @@ public void WriteAsyncCallback(IntPtr key, IntPtr packet, uint sniError)
}
catch (Exception e)
{
var writeCompletionSource = _writeCompletionSource;
TaskCompletionSource<object> writeCompletionSource = _writeCompletionSource;
if (writeCompletionSource != null)
{
writeCompletionSource.TrySetException(e);
Expand All @@ -2157,7 +2157,7 @@ public void WriteAsyncCallback(IntPtr key, IntPtr packet, uint sniError)
writeCompletionSource = _writeCompletionSource;
if (writeCompletionSource != null)
{
var delayedException = Interlocked.Exchange(ref _delayedWriteAsyncCallbackException, null);
Exception delayedException = Interlocked.Exchange(ref _delayedWriteAsyncCallbackException, null);
if (delayedException != null)
{
writeCompletionSource.TrySetException(delayedException);
Expand All @@ -2181,7 +2181,7 @@ public void WriteAsyncCallback(IntPtr key, IntPtr packet, uint sniError)
new Timer(obj =>
{
Interlocked.Decrement(ref _asyncWriteCount);
var writeCompletionSource = _writeCompletionSource;
TaskCompletionSource<object> writeCompletionSource = _writeCompletionSource;
if (_asyncWriteCount == 0 && writeCompletionSource != null)
{
writeCompletionSource.TrySetResult(null);
Expand All @@ -2202,7 +2202,7 @@ public void WriteAsyncCallback(IntPtr key, IntPtr packet, uint sniError)
return;
}
#endif
var completionSource = _writeCompletionSource;
TaskCompletionSource<object> completionSource = _writeCompletionSource;
if (_asyncWriteCount == 0 && completionSource != null)
{
completionSource.TrySetResult(null);
Expand Down Expand Up @@ -2258,7 +2258,7 @@ internal Task WaitForAccumulatedWrites()
{
// Checked for stored exceptions
#pragma warning disable 420 // A reference to a volatile field will not be treated as volatile - Disabling since the Interlocked APIs are volatile aware
var delayedException = Interlocked.Exchange(ref _delayedWriteAsyncCallbackException, null);
Exception delayedException = Interlocked.Exchange(ref _delayedWriteAsyncCallbackException, null);
if (delayedException != null)
{
throw delayedException;
Expand Down Expand Up @@ -2517,7 +2517,7 @@ private void CancelWritePacket()
private Task SNIWritePacket(SNIHandle handle, SNIPacket packet, out uint sniError, bool canAccumulate, bool callerHasConnectionLock, bool asyncClose = false)
{
// Check for a stored exception
var delayedException = Interlocked.Exchange(ref _delayedWriteAsyncCallbackException, null);
Exception delayedException = Interlocked.Exchange(ref _delayedWriteAsyncCallbackException, null);
if (delayedException != null)
{
throw delayedException;
Expand Down Expand Up @@ -3163,7 +3163,7 @@ internal void CheckThrowSNIException()
internal void AssertStateIsClean()
{
// If our TdsParser is closed or broken, then we don't really care about our state
var parser = _parser;
TdsParser parser = _parser;
if ((parser != null) && (parser.State != TdsParserState.Closed) && (parser.State != TdsParserState.Broken))
{
// Async reads
Expand All @@ -3185,8 +3185,8 @@ internal void AssertStateIsClean()
#if DEBUG
internal void CompletePendingReadWithSuccess(bool resetForcePendingReadsToWait)
{
var realNetworkPacketTaskSource = _realNetworkPacketTaskSource;
var networkPacketTaskSource = _networkPacketTaskSource;
TaskCompletionSource<object> realNetworkPacketTaskSource = _realNetworkPacketTaskSource;
TaskCompletionSource<object> networkPacketTaskSource = _networkPacketTaskSource;

Debug.Assert(s_forcePendingReadsToWaitForUser, "Not forcing pends to wait for user - can't force complete");
Debug.Assert(networkPacketTaskSource != null, "No pending read to complete");
Expand Down Expand Up @@ -3215,8 +3215,8 @@ internal void CompletePendingReadWithSuccess(bool resetForcePendingReadsToWait)

internal void CompletePendingReadWithFailure(int errorCode, bool resetForcePendingReadsToWait)
{
var realNetworkPacketTaskSource = _realNetworkPacketTaskSource;
var networkPacketTaskSource = _networkPacketTaskSource;
TaskCompletionSource<object> realNetworkPacketTaskSource = _realNetworkPacketTaskSource;
TaskCompletionSource<object> networkPacketTaskSource = _networkPacketTaskSource;

Debug.Assert(s_forcePendingReadsToWaitForUser, "Not forcing pends to wait for user - can't force complete");
Debug.Assert(networkPacketTaskSource != null, "No pending read to complete");
Expand Down

0 comments on commit 58ae136

Please sign in to comment.