diff --git a/src/Common/src/Interop/Windows/SChannel/SslConnectionInfo.cs b/src/Common/src/Interop/Windows/SChannel/SslConnectionInfo.cs index c2a598b8d94c..f522d8b84867 100644 --- a/src/Common/src/Interop/Windows/SChannel/SslConnectionInfo.cs +++ b/src/Common/src/Interop/Windows/SChannel/SslConnectionInfo.cs @@ -42,6 +42,7 @@ internal unsafe SslConnectionInfo(byte[] nativeBuffer) { GlobalLog.Assert("SslConnectionInfo::.ctor", "Negative size."); } + Debug.Fail("SslConnectionInfo::.ctor", "Negative size."); throw; } diff --git a/src/Common/src/Interop/Windows/sspicli/SSPIAuthType.cs b/src/Common/src/Interop/Windows/sspicli/SSPIAuthType.cs index 3eefec76898c..f836b94d27ae 100644 --- a/src/Common/src/Interop/Windows/sspicli/SSPIAuthType.cs +++ b/src/Common/src/Interop/Windows/sspicli/SSPIAuthType.cs @@ -105,13 +105,13 @@ public unsafe int DecryptMessage(SafeDeleteContext context, Interop.SspiCli.Secu context.DangerousRelease(); } - if (status == 0 && qop == Interop.SspiCli.SECQOP_WRAP_NO_ENCRYPT) { if (GlobalLog.IsEnabled) { GlobalLog.Assert("SspiCli.DecryptMessage", "Expected qop = 0, returned value = " + qop.ToString("x", CultureInfo.InvariantCulture)); } + Debug.Fail("SspiCli.DecryptMessage", "Expected qop = 0, returned value = " + qop.ToString("x", CultureInfo.InvariantCulture)); throw new InvalidOperationException(SR.net_auth_message_not_encrypted); } diff --git a/src/Common/src/Interop/Windows/sspicli/SSPIWrapper.cs b/src/Common/src/Interop/Windows/sspicli/SSPIWrapper.cs index cf9efeb94764..7d8ed059ac40 100644 --- a/src/Common/src/Interop/Windows/sspicli/SSPIWrapper.cs +++ b/src/Common/src/Interop/Windows/sspicli/SSPIWrapper.cs @@ -413,6 +413,7 @@ private unsafe static int EncryptDecryptHelper(OP op, SSPIInterface secModule, S { GlobalLog.Assert("SSPIWrapper::EncryptDecryptHelper", "Unknown OP: " + op); } + Debug.Fail("SSPIWrapper::EncryptDecryptHelper", "Unknown OP: " + op); throw NotImplemented.ByDesignWithMessage(SR.net_MethodNotImplementedException); } @@ -458,6 +459,7 @@ private unsafe static int EncryptDecryptHelper(OP op, SSPIInterface secModule, S { GlobalLog.Assert("SSPIWrapper::EncryptDecryptHelper", "Output buffer out of range."); } + Debug.Fail("SSPIWrapper::EncryptDecryptHelper", "Output buffer out of range."); iBuffer.size = 0; iBuffer.offset = 0; @@ -473,14 +475,17 @@ private unsafe static int EncryptDecryptHelper(OP op, SSPIInterface secModule, S { GlobalLog.AssertFormat("SSPIWrapper::EncryptDecryptHelper|'offset' out of range. [{0}]", iBuffer.offset); } + Debug.Fail("SSPIWrapper::EncryptDecryptHelper|'offset' out of range. [" + iBuffer.offset + "]"); } + if (iBuffer.size < 0 || iBuffer.size > (iBuffer.token == null ? 0 : iBuffer.token.Length - iBuffer.offset)) { if (GlobalLog.IsEnabled) { GlobalLog.AssertFormat("SSPIWrapper::EncryptDecryptHelper|'size' out of range. [{0}]", iBuffer.size); } + Debug.Fail("SSPIWrapper::EncryptDecryptHelper|'size' out of range. [" + iBuffer.size + "]"); } } diff --git a/src/Common/src/Interop/Windows/sspicli/SecSizes.cs b/src/Common/src/Interop/Windows/sspicli/SecSizes.cs index 0ea0e9568bc0..4d796a0ea5e8 100644 --- a/src/Common/src/Interop/Windows/sspicli/SecSizes.cs +++ b/src/Common/src/Interop/Windows/sspicli/SecSizes.cs @@ -34,6 +34,7 @@ internal unsafe SecSizes(byte[] memory) { GlobalLog.Assert("SecSizes::.ctor", "Negative size."); } + Debug.Fail("SecSizes::.ctor", "Negative size."); throw; } diff --git a/src/Common/src/Interop/Windows/sspicli/SecuritySafeHandles.cs b/src/Common/src/Interop/Windows/sspicli/SecuritySafeHandles.cs index 4b610f4ebac5..6655301f803a 100644 --- a/src/Common/src/Interop/Windows/sspicli/SecuritySafeHandles.cs +++ b/src/Common/src/Interop/Windows/sspicli/SecuritySafeHandles.cs @@ -549,6 +549,7 @@ internal unsafe static int InitializeSecurityContext( { GlobalLog.Assert("SafeDeleteContext::InitializeSecurityContext()|outSecBuffer != null"); } + Debug.Fail("SafeDeleteContext::InitializeSecurityContext()|outSecBuffer != null"); } if (inSecBuffer != null && inSecBuffers != null) @@ -557,6 +558,7 @@ internal unsafe static int InitializeSecurityContext( { GlobalLog.Assert("SafeDeleteContext::InitializeSecurityContext()|inSecBuffer == null || inSecBuffers == null"); } + Debug.Fail("SafeDeleteContext::InitializeSecurityContext()|inSecBuffer == null || inSecBuffers == null"); } @@ -859,6 +861,7 @@ internal unsafe static int AcceptSecurityContext( { GlobalLog.Assert("SafeDeleteContext::AcceptSecurityContext()|outSecBuffer != null"); } + Debug.Fail("SafeDeleteContext::AcceptSecurityContext()|outSecBuffer != null"); } if (inSecBuffer != null && inSecBuffers != null) @@ -867,6 +870,7 @@ internal unsafe static int AcceptSecurityContext( { GlobalLog.Assert("SafeDeleteContext::AcceptSecurityContext()|inSecBuffer == null || inSecBuffers == null"); } + Debug.Fail("SafeDeleteContext::AcceptSecurityContext()|outSecBuffer != null"); } @@ -1142,6 +1146,7 @@ internal unsafe static int CompleteAuthToken( { GlobalLog.Assert("SafeDeleteContext::CompleteAuthToken()|inSecBuffers == null"); } + Debug.Fail("SafeDeleteContext::CompleteAuthToken()|inSecBuffers == null"); } diff --git a/src/Common/src/Interop/Windows/sspicli/StreamSizes.cs b/src/Common/src/Interop/Windows/sspicli/StreamSizes.cs index 68db80ad31b3..fe1906d76052 100644 --- a/src/Common/src/Interop/Windows/sspicli/StreamSizes.cs +++ b/src/Common/src/Interop/Windows/sspicli/StreamSizes.cs @@ -36,6 +36,7 @@ internal unsafe StreamSizes(byte[] memory) { GlobalLog.Assert("StreamSizes::.ctor", "Negative size."); } + Debug.Fail("StreamSizes::.ctor", "Negative size."); throw; } diff --git a/src/Common/src/System/Net/ContextAwareResult.Windows.cs b/src/Common/src/System/Net/ContextAwareResult.Windows.cs index 4530d83ddf0a..ca2345e727a2 100644 --- a/src/Common/src/System/Net/ContextAwareResult.Windows.cs +++ b/src/Common/src/System/Net/ContextAwareResult.Windows.cs @@ -31,6 +31,7 @@ internal WindowsIdentity Identity { GlobalLog.AssertFormat("ContextAwareResult#{0}::Identity|Called on completed result.", LoggingHash.HashString(this)); } + Debug.Fail("ContextAwareResult#" + LoggingHash.HashString(this) + "::Identity |Called on completed result."); } @@ -49,6 +50,7 @@ internal WindowsIdentity Identity { GlobalLog.AssertFormat("ContextAwareResult#{0}::Identity|No identity captured - specify captureIdentity.", LoggingHash.HashString(this)); } + Debug.Fail("ContextAwareResult#" + LoggingHash.HashString(this) + "::Identity |No identity captured - specify captureIdentity."); } @@ -62,8 +64,10 @@ internal WindowsIdentity Identity { GlobalLog.AssertFormat("ContextAwareResult#{0}::Identity|Must lock (StartPostingAsyncOp()) { ... FinishPostingAsyncOp(); } when calling Identity (unless it's only called after FinishPostingAsyncOp).", LoggingHash.HashString(this)); } + Debug.Fail("ContextAwareResult#" + LoggingHash.HashString(this) + "::Identity |Must lock (StartPostingAsyncOp()) { ... FinishPostingAsyncOp(); } when calling Identity (unless it's only called after FinishPostingAsyncOp)."); } + lock (_lock) { } } @@ -75,6 +79,7 @@ internal WindowsIdentity Identity { GlobalLog.AssertFormat("ContextAwareResult#{0}::Identity|Result became completed during call.", LoggingHash.HashString(this)); } + Debug.Fail("ContextAwareResult#" + LoggingHash.HashString(this) + "::Identity |Result became completed during call."); } diff --git a/src/Common/src/System/Net/ContextAwareResult.cs b/src/Common/src/System/Net/ContextAwareResult.cs index e275cd288abf..8e048d5c531e 100644 --- a/src/Common/src/System/Net/ContextAwareResult.cs +++ b/src/Common/src/System/Net/ContextAwareResult.cs @@ -138,6 +138,7 @@ internal ExecutionContext ContextCopy { GlobalLog.AssertFormat("ContextAwareResult#{0}::ContextCopy|Called on completed result.", LoggingHash.HashString(this)); } + Debug.Fail("ContextAwareResult#" + LoggingHash.HashString(this) + "::ContextCopy |Called on completed result."); } @@ -157,6 +158,7 @@ internal ExecutionContext ContextCopy { GlobalLog.AssertFormat("ContextAwareResult#{0}::ContextCopy|No context captured - specify a callback or forceCaptureContext.", LoggingHash.HashString(this)); } + Debug.Fail("ContextAwareResult#" + LoggingHash.HashString(this) + "::ContextCopy |No context captured - specify a callback or forceCaptureContext."); } @@ -170,6 +172,7 @@ internal ExecutionContext ContextCopy { GlobalLog.AssertFormat("ContextAwareResult#{0}::ContextCopy|Must lock (StartPostingAsyncOp()) { ... FinishPostingAsyncOp(); } when calling ContextCopy (unless it's only called after FinishPostingAsyncOp).", LoggingHash.HashString(this)); } + Debug.Fail("ContextAwareResult#" + LoggingHash.HashString(this) +"::ContextCopy |Must lock (StartPostingAsyncOp()) { ... FinishPostingAsyncOp(); } when calling ContextCopy (unless it's only called after FinishPostingAsyncOp)."); } lock (_lock) { } @@ -183,6 +186,7 @@ internal ExecutionContext ContextCopy { GlobalLog.AssertFormat("ContextAwareResult#{0}::ContextCopy|Result became completed during call.", LoggingHash.HashString(this)); } + Debug.Fail("ContextAwareResult#" + LoggingHash.HashString(this) + "::ContextCopy |Result became completed during call."); } @@ -221,6 +225,7 @@ internal object StartPostingAsyncOp(bool lockCapture) { GlobalLog.AssertFormat("ContextAwareResult#{0}::StartPostingAsyncOp|Called on completed result.", LoggingHash.HashString(this)); } + Debug.Fail("ContextAwareResult#" + LoggingHash.HashString(this) + "::StartPostingAsyncOp |Called on completed result."); } @@ -318,6 +323,7 @@ private bool CaptureOrComplete(ref ExecutionContext cachedContext, bool returnCo { GlobalLog.AssertFormat("ContextAwareResult#{0}::CaptureOrComplete|Called without calling StartPostingAsyncOp.", LoggingHash.HashString(this)); } + Debug.Fail("ContextAwareResult#" + LoggingHash.HashString(this) + "::CaptureOrComplete |Called without calling StartPostingAsyncOp."); } @@ -384,6 +390,7 @@ private bool CaptureOrComplete(ref ExecutionContext cachedContext, bool returnCo { GlobalLog.AssertFormat("ContextAwareResult#{0}::CaptureOrComplete|Didn't capture context, but didn't complete synchronously!", LoggingHash.HashString(this)); } + Debug.Fail("ContextAwareResult#" + LoggingHash.HashString(this) + "::CaptureOrComplete |Didn't capture context, but didn't complete synchronously!"); } } diff --git a/src/Common/src/System/Net/InternalException.cs b/src/Common/src/System/Net/InternalException.cs index b009611b51a7..ce4d86aa2dd4 100644 --- a/src/Common/src/System/Net/InternalException.cs +++ b/src/Common/src/System/Net/InternalException.cs @@ -13,6 +13,7 @@ internal InternalException() { GlobalLog.Assert("InternalException thrown."); } + Debug.Fail("InternalException thrown."); } } diff --git a/src/Common/src/System/Net/LazyAsyncResult.cs b/src/Common/src/System/Net/LazyAsyncResult.cs index 84216bd8c342..80ae6c101167 100644 --- a/src/Common/src/System/Net/LazyAsyncResult.cs +++ b/src/Common/src/System/Net/LazyAsyncResult.cs @@ -79,6 +79,7 @@ internal LazyAsyncResult(object myObject, object myState, AsyncCallback myCallBa { GlobalLog.AssertFormat("LazyAsyncResult#{0}::.ctor()|Result can't be set to DBNull - it's a special internal value.", LoggingHash.HashString(this)); } + Debug.Fail("LazyAsyncResult#" + LoggingHash.HashString(this) + "::.ctor()|Result can't be set to DBNull - it's a special internal value."); } @@ -335,14 +336,17 @@ internal object Result { GlobalLog.AssertFormat("LazyAsyncResult#{0}::set_Result()|Result can't be set to DBNull - it's a special internal value.", LoggingHash.HashString(this)); } + Debug.Fail("LazyAsyncResult#" + LoggingHash.HashString(this) + "::set_Result()|Result can't be set to DBNull - it's a special internal value."); } + if (InternalPeekCompleted) { if (GlobalLog.IsEnabled) { GlobalLog.AssertFormat("LazyAsyncResult#{0}::set_Result()|Called on completed result.", LoggingHash.HashString(this)); } + Debug.Fail("LazyAsyncResult#" + LoggingHash.HashString(this) + "::set_Result()|Called on completed result."); } _result = value; diff --git a/src/System.Net.Security/src/System/Net/CertificateValidationPal.Windows.cs b/src/System.Net.Security/src/System/Net/CertificateValidationPal.Windows.cs index 941e71e080ad..b83569955be4 100644 --- a/src/System.Net.Security/src/System/Net/CertificateValidationPal.Windows.cs +++ b/src/System.Net.Security/src/System/Net/CertificateValidationPal.Windows.cs @@ -163,6 +163,7 @@ internal static string[] GetRequestCertificateAuthorities(SafeDeleteContext secu { GlobalLog.Assert("SecureChannel::GetIssuers()", "Interop.SspiCli._CERT_CHAIN_ELEMENT size is not positive: " + pIL2->cbSize.ToString()); } + Debug.Fail("SecureChannel::GetIssuers()", "Interop.SspiCli._CERT_CHAIN_ELEMENT size is not positive: " + pIL2->cbSize.ToString()); } @@ -254,6 +255,7 @@ internal static X509Store EnsureStoreOpened(bool isMachineStore) { GlobalLog.Assert("SecureChannel::EnsureStoreOpened()", "Failed to open cert store, location:" + storeLocation + " exception:" + exception); } + Debug.Fail("SecureChannel::EnsureStoreOpened()", "Failed to open cert store, location:" + storeLocation + " exception:" + exception); return null; } diff --git a/src/System.Net.Security/src/System/Net/NTAuthentication.cs b/src/System.Net.Security/src/System/Net/NTAuthentication.cs index bfe544f1d140..a92dbc7282b5 100644 --- a/src/System.Net.Security/src/System/Net/NTAuthentication.cs +++ b/src/System.Net.Security/src/System/Net/NTAuthentication.cs @@ -200,12 +200,13 @@ internal SecSizes Sizes { get { - if ((IsCompleted && IsValidContext)) + if (!(IsCompleted && IsValidContext)) { if (GlobalLog.IsEnabled) { - GlobalLog.Assert("NTAuthentication#{0}::MaxDataSize|The context is not completed or invalid.", LoggingHash.HashString(this)); + GlobalLog.AssertFormat("NTAuthentication#{0}::MaxDataSize|The context is not completed or invalid.", LoggingHash.HashString(this)); } + Debug.Fail("NTAuthentication#" + LoggingHash.HashString(this) + "::MaxDataSize |The context is not completed or invalid."); } @@ -339,21 +340,23 @@ private void Initialize(bool isServer, string package, NetworkCredential credent // This token can be used for impersonation. We use it to create a WindowsIdentity and hand it out to the server app. internal SecurityContextTokenHandle GetContextToken(out Interop.SecurityStatus status) { - if ((IsCompleted && IsValidContext)) + if (!(IsCompleted && IsValidContext)) { if (GlobalLog.IsEnabled) { GlobalLog.AssertFormat("NTAuthentication#{0}::GetContextToken|Should be called only when completed with success, currently is not!", LoggingHash.HashString(this)); } + Debug.Fail("NTAuthentication#" + LoggingHash.HashString(this) + "::GetContextToken |Should be called only when completed with success, currently is not!"); } - if (IsServer) + if (!IsServer) { if (GlobalLog.IsEnabled) { GlobalLog.AssertFormat("NTAuthentication#{0}::GetContextToken|The method must not be called by the client side!", LoggingHash.HashString(this)); } + Debug.Fail("NTAuthentication#" + LoggingHash.HashString(this) + "::GetContextToken |The method must not be called by the client side!"); } @@ -525,12 +528,13 @@ internal byte[] GetOutgoingBlob(byte[] incomingBlob, bool throwOnError, out Inte if (statusCode == Interop.SecurityStatus.OK) { // Success. - if ((statusCode == Interop.SecurityStatus.OK)) + if (statusCode != Interop.SecurityStatus.OK) { if (GlobalLog.IsEnabled) { GlobalLog.AssertFormat("NTAuthentication#{0}::GetOutgoingBlob()|statusCode:[0x{1:x8}] ({2}) m_SecurityContext#{3}::Handle:[{4}] [STATUS != OK]", LoggingHash.HashString(this), (int)statusCode, statusCode, LoggingHash.HashString(_securityContext), LoggingHash.ObjectToString(_securityContext)); } + Debug.Fail("NTAuthentication#" + LoggingHash.HashString(this) + "::GetOutgoingBlob()|statusCode:[0x" + ((int)statusCode).ToString("x8") + "] (" + statusCode + ") m_SecurityContext#" + LoggingHash.HashString(_securityContext) + "::Handle:[" + LoggingHash.ObjectToString(_securityContext) + "] [STATUS != OK]"); } @@ -571,6 +575,7 @@ internal int Encrypt(byte[] buffer, int offset, int count, ref byte[] output, ui { GlobalLog.Assert("NTAuthentication#" + LoggingHash.HashString(this) + "::Encrypt", "Arguments out of range."); } + Debug.Fail("NTAuthentication#" + LoggingHash.HashString(this) + "::Encrypt", "Arguments out of range."); } @@ -652,6 +657,7 @@ internal int Decrypt(byte[] payload, int offset, int count, out int newOffset, u { GlobalLog.Assert("NTAuthentication#" + LoggingHash.HashString(this) + "::Decrypt", "Argument 'offset' out of range."); } + Debug.Fail("NTAuthentication#" + LoggingHash.HashString(this) + "::Decrypt", "Argument 'offset' out of range."); throw new ArgumentOutOfRangeException("offset"); @@ -663,6 +669,7 @@ internal int Decrypt(byte[] payload, int offset, int count, out int newOffset, u { GlobalLog.Assert("NTAuthentication#" + LoggingHash.HashString(this) + "::Decrypt", "Argument 'count' out of range."); } + Debug.Fail("NTAuthentication#" + LoggingHash.HashString(this) + "::Decrypt", "Argument 'count' out of range."); throw new ArgumentOutOfRangeException("count"); @@ -710,12 +717,13 @@ internal int Decrypt(byte[] payload, int offset, int count, out int newOffset, u private string GetClientSpecifiedSpn() { - if ((IsValidContext && IsCompleted)) + if (!(IsValidContext && IsCompleted)) { if (GlobalLog.IsEnabled) { GlobalLog.Assert("NTAuthentication: Trying to get the client SPN before handshaking is done!"); } + Debug.Fail("NTAuthentication: Trying to get the client SPN before handshaking is done!"); } @@ -738,6 +746,7 @@ private int DecryptNtlm(byte[] payload, int offset, int count, out int newOffset { GlobalLog.Assert("NTAuthentication#" + LoggingHash.HashString(this) + "::DecryptNtlm", "Argument 'count' out of range."); } + Debug.Fail("NTAuthentication#" + LoggingHash.HashString(this) + "::DecryptNtlm", "Argument 'count' out of range."); throw new ArgumentOutOfRangeException("count"); @@ -767,6 +776,7 @@ private int DecryptNtlm(byte[] payload, int offset, int count, out int newOffset { GlobalLog.Print("NTAuthentication#" + LoggingHash.HashString(this) + "::Decrypt() throw Error = " + errorCode.ToString("x", NumberFormatInfo.InvariantInfo)); } + throw new Win32Exception(errorCode); } diff --git a/src/System.Net.Security/src/System/Net/SSPIHandleCache.cs b/src/System.Net.Security/src/System/Net/SSPIHandleCache.cs index cf28a556582b..92e0c8e0e4b9 100644 --- a/src/System.Net.Security/src/System/Net/SSPIHandleCache.cs +++ b/src/System.Net.Security/src/System/Net/SSPIHandleCache.cs @@ -46,6 +46,7 @@ internal static void CacheCredential(SafeFreeCredentials newHandle) { GlobalLog.Assert("SSPIHandlCache", "Attempted to throw: " + e.ToString()); } + Debug.Fail("SSPIHandlCache", "Attempted to throw: " + e.ToString()); } } diff --git a/src/System.Net.Security/src/System/Net/SecureChannel.cs b/src/System.Net.Security/src/System/Net/SecureChannel.cs index 7cdb5bbaf23b..d2762b2af36d 100644 --- a/src/System.Net.Security/src/System/Net/SecureChannel.cs +++ b/src/System.Net.Security/src/System/Net/SecureChannel.cs @@ -74,6 +74,7 @@ internal SecureChannel(string hostname, bool serverMode, SslProtocols sslProtoco { GlobalLog.AssertFormat("SecureChannel#{0}::.ctor()|hostname == null", LoggingHash.HashString(this)); } + Debug.Fail("SecureChannel#" + LoggingHash.HashString(this) + "::.ctor()|hostname == null"); } _hostName = hostname; @@ -623,6 +624,7 @@ private bool AcquireClientCredentials(ref byte[] thumbPrint) { GlobalLog.Assert("AcquireClientCredentials()|'selectedCert' does not match 'clientCertificate'."); } + Debug.Fail("AcquireClientCredentials()|'selectedCert' does not match 'clientCertificate'."); } @@ -749,6 +751,7 @@ private bool AcquireServerCredentials(ref byte[] thumbPrint) { GlobalLog.Assert("AcquireServerCredentials()|'selectedCert' does not match 'localCertificate'."); } + Debug.Fail("AcquireServerCredentials()|'selectedCert' does not match 'localCertificate'."); } @@ -849,6 +852,7 @@ private SecurityStatusPal GenerateToken(byte[] input, int offset, int count, ref { GlobalLog.Assert("SecureChannel#" + LoggingHash.HashString(this) + "::GenerateToken", "Argument 'offset' out of range."); } + Debug.Fail("SecureChannel#" + LoggingHash.HashString(this) + "::GenerateToken", "Argument 'offset' out of range."); throw new ArgumentOutOfRangeException("offset"); } @@ -859,6 +863,7 @@ private SecurityStatusPal GenerateToken(byte[] input, int offset, int count, ref { GlobalLog.Assert("SecureChannel#" + LoggingHash.HashString(this) + "::GenerateToken", "Argument 'count' out of range."); } + Debug.Fail("SecureChannel#" + LoggingHash.HashString(this) + "::GenerateToken", "Argument 'count' out of range."); throw new ArgumentOutOfRangeException("count"); } @@ -1001,6 +1006,7 @@ internal void ProcessHandshakeSuccess() { GlobalLog.Assert("SecureChannel#" + LoggingHash.HashString(this) + "::ProcessHandshakeSuccess", "StreamSizes out of range."); } + Debug.Fail("SecureChannel#" + LoggingHash.HashString(this) + "::ProcessHandshakeSuccess", "StreamSizes out of range."); } @@ -1073,6 +1079,7 @@ internal SecurityStatusPal Encrypt(byte[] buffer, int offset, int size, ref byte { GlobalLog.Assert("SecureChannel#" + LoggingHash.HashString(this) + "::Encrypt", "Arguments out of range."); } + Debug.Fail("SecureChannel#" + LoggingHash.HashString(this) + "::Encrypt", "Arguments out of range."); } @@ -1113,6 +1120,7 @@ internal SecurityStatusPal Decrypt(byte[] payload, ref int offset, ref int count { GlobalLog.Assert("SecureChannel#" + LoggingHash.HashString(this) + "::Encrypt", "Argument 'offset' out of range."); } + Debug.Fail("SecureChannel#" + LoggingHash.HashString(this) + "::Encrypt", "Argument 'offset' out of range."); throw new ArgumentOutOfRangeException("offset"); } @@ -1123,6 +1131,7 @@ internal SecurityStatusPal Decrypt(byte[] payload, ref int offset, ref int count { GlobalLog.Assert("SecureChannel#" + LoggingHash.HashString(this) + "::Encrypt", "Argument 'count' out of range."); } + Debug.Fail("SecureChannel#" + LoggingHash.HashString(this) + "::Encrypt", "Argument 'count' out of range."); throw new ArgumentOutOfRangeException("count"); } diff --git a/src/System.Net.Security/src/System/Net/SecureProtocols/FixedSizeReader.cs b/src/System.Net.Security/src/System/Net/SecureProtocols/FixedSizeReader.cs index 58b80042e64b..0ea9e00f2458 100644 --- a/src/System.Net.Security/src/System/Net/SecureProtocols/FixedSizeReader.cs +++ b/src/System.Net.Security/src/System/Net/SecureProtocols/FixedSizeReader.cs @@ -111,6 +111,7 @@ private bool CheckCompletionBeforeNextRead(int bytes) { GlobalLog.AssertFormat("FixedSizeReader::CheckCompletion()|State got out of range. Total:{0} Count:{1}", _totalRead + bytes, _request.Count); } + Debug.Fail("FixedSizeReader::CheckCompletion()|State got out of range. Total:" + (_totalRead + bytes) + " Count:" + _request.Count); } @@ -131,6 +132,7 @@ private static void ReadCallback(IAsyncResult transportResult) { GlobalLog.Assert("ReadCallback|State type is wrong, expected FixedSizeReader."); } + Debug.Fail("ReadCallback|State type is wrong, expected FixedSizeReader."); } diff --git a/src/System.Net.Security/src/System/Net/SecureProtocols/HelperAsyncResults.cs b/src/System.Net.Security/src/System/Net/SecureProtocols/HelperAsyncResults.cs index f5e85b8cb756..9a11f0c48e5a 100644 --- a/src/System.Net.Security/src/System/Net/SecureProtocols/HelperAsyncResults.cs +++ b/src/System.Net.Security/src/System/Net/SecureProtocols/HelperAsyncResults.cs @@ -47,6 +47,7 @@ public AsyncProtocolRequest(LazyAsyncResult userAsyncResult) { GlobalLog.Assert("AsyncProtocolRequest()|userAsyncResult == null"); } + Debug.Fail("AsyncProtocolRequest()|userAsyncResult == null"); } if (userAsyncResult.InternalPeekCompleted) @@ -55,6 +56,7 @@ public AsyncProtocolRequest(LazyAsyncResult userAsyncResult) { GlobalLog.Assert("AsyncProtocolRequest()|userAsyncResult is already completed."); } + Debug.Fail("AsyncProtocolRequest()|userAsyncResult is already completed."); } UserAsyncResult = userAsyncResult; diff --git a/src/System.Net.Security/src/System/Net/SecureProtocols/InternalNegotiateStream.cs b/src/System.Net.Security/src/System/Net/SecureProtocols/InternalNegotiateStream.cs index fc9925967d42..3f7672dc8504 100644 --- a/src/System.Net.Security/src/System/Net/SecureProtocols/InternalNegotiateStream.cs +++ b/src/System.Net.Security/src/System/Net/SecureProtocols/InternalNegotiateStream.cs @@ -301,12 +301,13 @@ private int StartFrameBody(int readBytes, byte[] buffer, int offset, int count, return 0; } - if ((readBytes == _ReadHeader.Length)) + if (!(readBytes == _ReadHeader.Length)) { if (GlobalLog.IsEnabled) { GlobalLog.AssertFormat("NegoStream::ProcessHeader()|Frame size must be 4 but received {0} bytes.", readBytes); } + Debug.Fail("NegoStream::ProcessHeader()|Frame size must be 4 but received " + readBytes + " bytes."); } @@ -398,12 +399,13 @@ private static void WriteCallback(IAsyncResult transportResult) return; } - if ((transportResult.AsyncState is AsyncProtocolRequest)) + if (!(transportResult.AsyncState is AsyncProtocolRequest)) { if (GlobalLog.IsEnabled) { GlobalLog.Assert("NegotiateSteam::WriteCallback|State type is wrong, expected AsyncProtocolRequest."); } + Debug.Fail("NegotiateSteam::WriteCallback|State type is wrong, expected AsyncProtocolRequest."); } diff --git a/src/System.Net.Security/src/System/Net/SecureProtocols/NegoState.Windows.cs b/src/System.Net.Security/src/System/Net/SecureProtocols/NegoState.Windows.cs index e07415ee00f9..69168c16ac2d 100644 --- a/src/System.Net.Security/src/System/Net/SecureProtocols/NegoState.Windows.cs +++ b/src/System.Net.Security/src/System/Net/SecureProtocols/NegoState.Windows.cs @@ -755,12 +755,13 @@ private void StartSendAuthResetSignal(LazyAsyncResult lazyResult, byte[] message private static void WriteCallback(IAsyncResult transportResult) { - if ((transportResult.AsyncState is LazyAsyncResult)) + if (!(transportResult.AsyncState is LazyAsyncResult)) { if (GlobalLog.IsEnabled) { GlobalLog.Assert("WriteCallback|State type is wrong, expected LazyAsyncResult."); } + Debug.Fail("WriteCallback|State type is wrong, expected LazyAsyncResult."); } @@ -800,12 +801,13 @@ private static void WriteCallback(IAsyncResult transportResult) private static void ReadCallback(IAsyncResult transportResult) { - if ((transportResult.AsyncState is LazyAsyncResult)) + if (!(transportResult.AsyncState is LazyAsyncResult)) { if (GlobalLog.IsEnabled) { GlobalLog.Assert("ReadCallback|State type is wrong, expected LazyAsyncResult."); } + Debug.Fail("ReadCallback|State type is wrong, expected LazyAsyncResult."); } diff --git a/src/System.Net.Security/src/System/Net/SecureProtocols/SslState.cs b/src/System.Net.Security/src/System/Net/SecureProtocols/SslState.cs index 585ff8b8128e..bcad4a3024fe 100644 --- a/src/System.Net.Security/src/System/Net/SecureProtocols/SslState.cs +++ b/src/System.Net.Security/src/System/Net/SecureProtocols/SslState.cs @@ -1057,6 +1057,7 @@ private static void WriteCallback(IAsyncResult transportResult) { GlobalLog.Assert("SslState::WriteCallback", "Exception while decoding context. type:" + exception.GetType().ToString() + " message:" + exception.Message); } + Debug.Fail("SslState::WriteCallback", "Exception while decoding context. type:" + exception.GetType().ToString() + " message:" + exception.Message); } @@ -1576,13 +1577,14 @@ private Framing DetectFraming(byte[] bytes, int length) int version = -1; - if ((bytes == null || bytes.Length == 0)) + if ((bytes == null || bytes.Length <= 0)) { if (GlobalLog.IsEnabled) { - GlobalLog.Assert("SslState::DetectFraming()|Header buffer is not allocated will boom shortly."); + GlobalLog.Assert("SslState::DetectFraming()|Header buffer is not allocated."); } - Debug.Fail("SslState::DetectFraming()|Header buffer is not allocated will boom shortly."); + + Debug.Fail("SslState::DetectFraming()|Header buffer is not allocated."); } // If the first byte is SSL3 HandShake, then check if we have a SSLv3 Type3 client hello. @@ -1807,14 +1809,17 @@ private void RehandshakeCompleteCallback(IAsyncResult result) { GlobalLog.Assert("SslState::RehandshakeCompleteCallback()|result is null!"); } + Debug.Fail("SslState::RehandshakeCompleteCallback()|result is null!"); } + if (!lazyAsyncResult.InternalPeekCompleted) { if (GlobalLog.IsEnabled) { GlobalLog.Assert("SslState::RehandshakeCompleteCallback()|result is not completed!"); } + Debug.Fail("SslState::RehandshakeCompleteCallback()|result is not completed!"); } diff --git a/src/System.Net.Security/src/System/Net/SecureProtocols/SslStreamContext.cs b/src/System.Net.Security/src/System/Net/SecureProtocols/SslStreamContext.cs index 559c0239a43c..d6358405b3ac 100644 --- a/src/System.Net.Security/src/System/Net/SecureProtocols/SslStreamContext.cs +++ b/src/System.Net.Security/src/System/Net/SecureProtocols/SslStreamContext.cs @@ -17,6 +17,7 @@ internal SslStreamContext(SslStream sslStream) { GlobalLog.Assert("SslStreamContext..ctor(): Not expecting a null sslStream!"); } + Debug.Fail("SslStreamContext..ctor(): Not expecting a null sslStream!"); } diff --git a/src/System.Net.Security/src/System/Net/SecurityBuffer.cs b/src/System.Net.Security/src/System/Net/SecurityBuffer.cs index 731cd041111f..2e84603ee539 100644 --- a/src/System.Net.Security/src/System/Net/SecurityBuffer.cs +++ b/src/System.Net.Security/src/System/Net/SecurityBuffer.cs @@ -23,14 +23,17 @@ public SecurityBuffer(byte[] data, int offset, int size, SecurityBufferType toke { GlobalLog.Assert("SecurityBuffer::.ctor", "'offset' out of range. [" + offset + "]"); } + Debug.Fail("SecurityBuffer::.ctor", "'offset' out of range. [" + offset + "]"); } + if (size < 0 || size > (data == null ? 0 : data.Length - offset)) { if (GlobalLog.IsEnabled) { GlobalLog.Assert("SecurityBuffer::.ctor", "'size' out of range. [" + size + "]"); } + Debug.Fail("SecurityBuffer::.ctor", "'size' out of range. [" + size + "]"); } @@ -55,6 +58,7 @@ public SecurityBuffer(int size, SecurityBufferType tokentype) { GlobalLog.Assert("SecurityBuffer::.ctor", "'size' out of range. [" + size + "]"); } + Debug.Fail("SecurityBuffer::.ctor", "'size' out of range. [" + size + "]"); } diff --git a/src/System.Net.Security/src/System/Net/SslSessionsCache.cs b/src/System.Net.Security/src/System/Net/SslSessionsCache.cs index 82ee197d0a24..2c2ca1c29618 100644 --- a/src/System.Net.Security/src/System/Net/SslSessionsCache.cs +++ b/src/System.Net.Security/src/System/Net/SslSessionsCache.cs @@ -169,6 +169,7 @@ internal static void CacheCredential(SafeFreeCredentials creds, byte[] thumbPrin { GlobalLog.Assert("CacheCredential|creds == null"); } + Debug.Fail("CacheCredential|creds == null"); } @@ -178,6 +179,7 @@ internal static void CacheCredential(SafeFreeCredentials creds, byte[] thumbPrin { GlobalLog.Print("CacheCredential() Refused to cache an Invalid Handle = " + creds.ToString() + ", Current Cache Count = " + s_CachedCreds.Count); } + return; } diff --git a/src/System.Net.Security/src/System/Net/StreamFramer.cs b/src/System.Net.Security/src/System/Net/StreamFramer.cs index 821301f79e71..0d8980450a01 100644 --- a/src/System.Net.Security/src/System/Net/StreamFramer.cs +++ b/src/System.Net.Security/src/System/Net/StreamFramer.cs @@ -153,12 +153,13 @@ public IAsyncResult BeginReadMessage(AsyncCallback asyncCallback, object stateOb private void ReadFrameCallback(IAsyncResult transportResult) { - if ((transportResult.AsyncState is WorkerAsyncResult)) + if (!(transportResult.AsyncState is WorkerAsyncResult)) { if (GlobalLog.IsEnabled) { GlobalLog.Assert("StreamFramer::ReadFrameCallback|The state expected to be WorkerAsyncResult, received:{0}.", transportResult.GetType().FullName); } + Debug.Fail("StreamFramer::ReadFrameCallback|The state expected to be WorkerAsyncResult, received:" + transportResult.GetType().FullName + "."); } @@ -200,12 +201,13 @@ private void ReadFrameComplete(IAsyncResult transportResult) { do { - if ((transportResult.AsyncState is WorkerAsyncResult)) + if (!(transportResult.AsyncState is WorkerAsyncResult)) { if (GlobalLog.IsEnabled) { GlobalLog.AssertFormat("StreamFramer::ReadFrameComplete|The state expected to be WorkerAsyncResult, received:{0}.", transportResult.GetType().FullName); } + Debug.Fail("StreamFramer::ReadFrameComplete|The state expected to be WorkerAsyncResult, received:" + transportResult.GetType().FullName + "."); } @@ -214,12 +216,13 @@ private void ReadFrameComplete(IAsyncResult transportResult) int bytesRead = _transportAPM.EndRead(transportResult); workerResult.Offset += bytesRead; - if ((workerResult.Offset <= workerResult.End)) + if (!(workerResult.Offset <= workerResult.End)) { if (GlobalLog.IsEnabled) { GlobalLog.AssertFormat("StreamFramer::ReadFrameCallback|WRONG: offset - end = {0}", workerResult.Offset - workerResult.End); } + Debug.Fail("StreamFramer::ReadFrameCallback|WRONG: offset - end = " + (workerResult.Offset - workerResult.End)); } @@ -390,12 +393,13 @@ public IAsyncResult BeginWriteMessage(byte[] message, AsyncCallback asyncCallbac private void BeginWriteCallback(IAsyncResult transportResult) { - if ((transportResult.AsyncState is WorkerAsyncResult)) + if (!(transportResult.AsyncState is WorkerAsyncResult)) { if (GlobalLog.IsEnabled) { GlobalLog.AssertFormat("StreamFramer::BeginWriteCallback|The state expected to be WorkerAsyncResult, received:{0}.", transportResult.AsyncState.GetType().FullName); } + Debug.Fail("StreamFramer::BeginWriteCallback|The state expected to be WorkerAsyncResult, received:" + transportResult.AsyncState.GetType().FullName + "."); } diff --git a/src/System.Net.Security/src/System/PinnableBufferCache.cs b/src/System.Net.Security/src/System/PinnableBufferCache.cs index ebe02a06e967..adee0034505d 100644 --- a/src/System.Net.Security/src/System/PinnableBufferCache.cs +++ b/src/System.Net.Security/src/System/PinnableBufferCache.cs @@ -151,7 +151,6 @@ private void Restock(out object returnBuffer) } // We have no buffers in the aged freelist, so get one from the newer list. Try to pick the best one. - // Debug.Assert(_notGen2.Count != 0); int idx = _notGen2.Count - 1; if (GC.GetGeneration(_notGen2[idx]) < GC.MaxGeneration && GC.GetGeneration(_notGen2[0]) == GC.MaxGeneration) {