diff --git a/src/coreclr/System.Private.CoreLib/src/System/Reflection/Emit/RuntimeILGenerator.cs b/src/coreclr/System.Private.CoreLib/src/System/Reflection/Emit/RuntimeILGenerator.cs index b8992dbe5d29b..c2d08f7e85af8 100644 --- a/src/coreclr/System.Private.CoreLib/src/System/Reflection/Emit/RuntimeILGenerator.cs +++ b/src/coreclr/System.Private.CoreLib/src/System/Reflection/Emit/RuntimeILGenerator.cs @@ -1369,9 +1369,9 @@ internal void MarkFinallyAddr(int finallyAddr, int endCatchAddr) internal void Done(int endAddr) { - Debug.Assert(m_currentCatch > 0, "m_currentCatch > 0"); - Debug.Assert(m_catchAddr[m_currentCatch - 1] > 0, "m_catchAddr[m_currentCatch-1] > 0"); - Debug.Assert(m_catchEndAddr[m_currentCatch - 1] == -1, "m_catchEndAddr[m_currentCatch-1] == -1"); + Debug.Assert(m_currentCatch > 0); + Debug.Assert(m_catchAddr[m_currentCatch - 1] > 0); + Debug.Assert(m_catchEndAddr[m_currentCatch - 1] == -1); m_catchEndAddr[m_currentCatch - 1] = endAddr; m_currentState = State_Done; } @@ -1447,8 +1447,8 @@ internal Label GetFinallyEndLabel() internal bool IsInner(__ExceptionInfo exc) { Debug.Assert(exc != null); - Debug.Assert(m_currentCatch > 0, "m_currentCatch > 0"); - Debug.Assert(exc.m_currentCatch > 0, "exc.m_currentCatch > 0"); + Debug.Assert(m_currentCatch > 0); + Debug.Assert(exc.m_currentCatch > 0); int exclast = exc.m_currentCatch - 1; int last = m_currentCatch - 1; @@ -1458,8 +1458,7 @@ internal bool IsInner(__ExceptionInfo exc) if (exc.m_catchEndAddr[exclast] != m_catchEndAddr[last]) return false; - Debug.Assert(exc.GetEndAddress() != GetEndAddress(), - "exc.GetEndAddress() != GetEndAddress()"); + Debug.Assert(exc.GetEndAddress() != GetEndAddress()); return exc.GetEndAddress() > GetEndAddress(); } diff --git a/src/coreclr/System.Private.CoreLib/src/System/Variant.cs b/src/coreclr/System.Private.CoreLib/src/System/Variant.cs index f32f2b99e788a..fe6e216881d6d 100644 --- a/src/coreclr/System.Private.CoreLib/src/System/Variant.cs +++ b/src/coreclr/System.Private.CoreLib/src/System/Variant.cs @@ -257,14 +257,14 @@ public Variant(object? obj) { vt = VarEnum.VT_ERROR; obj = (object)(((ErrorWrapper)obj).ErrorCode); - Debug.Assert(obj != null, "obj != null"); + Debug.Assert(obj != null); } #pragma warning disable 0618 // CurrencyWrapper is obsolete else if (obj is CurrencyWrapper) { vt = VarEnum.VT_CY; obj = (object)(((CurrencyWrapper)obj).WrappedObject); - Debug.Assert(obj != null, "obj != null"); + Debug.Assert(obj != null); } #pragma warning restore 0618 else if (obj is BStrWrapper) diff --git a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.OpenSsl.cs b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.OpenSsl.cs index 88c93310bb1c9..f8fa8b7d736c0 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.OpenSsl.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.OpenSsl.cs @@ -458,7 +458,7 @@ internal static SafeSslHandle AllocateSslHandle(SslAuthenticationOptions sslAuth SslCertificateTrust trust = sslAuthenticationOptions.CertificateContext!.Trust!; X509Certificate2Collection certList = (trust._trustList ?? trust._store!.Certificates); - Debug.Assert(certList != null, "certList != null"); + Debug.Assert(certList != null); Span handles = certList.Count <= 256 ? stackalloc IntPtr[256] : new IntPtr[certList.Count]; @@ -884,8 +884,8 @@ private static void BioWrite(SafeBioHandle bio, ReadOnlySpan buffer) private static void SetSslCertificate(SafeSslContextHandle contextPtr, SafeX509Handle certPtr, SafeEvpPKeyHandle keyPtr) { - Debug.Assert(certPtr != null && !certPtr.IsInvalid, "certPtr != null && !certPtr.IsInvalid"); - Debug.Assert(keyPtr != null && !keyPtr.IsInvalid, "keyPtr != null && !keyPtr.IsInvalid"); + Debug.Assert(certPtr != null && !certPtr.IsInvalid); + Debug.Assert(keyPtr != null && !keyPtr.IsInvalid); int retVal = Ssl.SslCtxUseCertificate(contextPtr, certPtr); diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.LsaLookupSids.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.LsaLookupSids.cs index 24abe5323e5bd..9b7a72001fc28 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.LsaLookupSids.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.LsaLookupSids.cs @@ -44,7 +44,7 @@ public static unsafe void InitializeReferencedDomainsList(this SafeLsaMemoryHand pTrustInformation += domainList.Entries; long bufferSize = (byte*)pTrustInformation - pRdl; - System.Diagnostics.Debug.Assert(bufferSize > 0, "bufferSize > 0"); + System.Diagnostics.Debug.Assert(bufferSize > 0); referencedDomains.Initialize((ulong)bufferSize); } } diff --git a/src/libraries/Common/src/System/Security/Cryptography/ECAndroid.cs b/src/libraries/Common/src/System/Security/Cryptography/ECAndroid.cs index 671b6b63643fc..60ed529ecb26c 100644 --- a/src/libraries/Common/src/System/Security/Cryptography/ECAndroid.cs +++ b/src/libraries/Common/src/System/Security/Cryptography/ECAndroid.cs @@ -46,9 +46,9 @@ public void Dispose() internal void SetKey(SafeEcKeyHandle key) { - Debug.Assert(key != null, "key != null"); - Debug.Assert(!key.IsInvalid, "!key.IsInvalid"); - Debug.Assert(!key.IsClosed, "!key.IsClosed"); + Debug.Assert(key != null); + Debug.Assert(!key.IsInvalid); + Debug.Assert(!key.IsClosed); FreeKey(); _key = new Lazy(key); diff --git a/src/libraries/Common/src/System/Security/Cryptography/ECCng.ImportExport.cs b/src/libraries/Common/src/System/Security/Cryptography/ECCng.ImportExport.cs index b80904aef0c52..d7c9c8a1a56a1 100644 --- a/src/libraries/Common/src/System/Security/Cryptography/ECCng.ImportExport.cs +++ b/src/libraries/Common/src/System/Security/Cryptography/ECCng.ImportExport.cs @@ -59,7 +59,7 @@ internal static byte[] GetNamedCurveBlob(ref ECParameters parameters, bool ecdh) } // We better have computed the right allocation size above! - Debug.Assert(offset == blobSize, "offset == blobSize"); + Debug.Assert(offset == blobSize); } } return blob; @@ -143,7 +143,7 @@ internal static byte[] GetPrimeCurveBlob(ref ECParameters parameters, bool ecdh) } // We better have computed the right allocation size above! - Debug.Assert(offset == blobSize, "offset == blobSize"); + Debug.Assert(offset == blobSize); } return blob; @@ -311,7 +311,7 @@ internal static unsafe byte[] GetPrimeCurveParameterBlob(ref ECCurve curve) } // We better have computed the right allocation size above! - Debug.Assert(offset == blobSize, "offset == blobSize"); + Debug.Assert(offset == blobSize); } return blob; diff --git a/src/libraries/Common/src/System/Security/Cryptography/ECOpenSsl.cs b/src/libraries/Common/src/System/Security/Cryptography/ECOpenSsl.cs index 29c5d8c944a24..21218957a5362 100644 --- a/src/libraries/Common/src/System/Security/Cryptography/ECOpenSsl.cs +++ b/src/libraries/Common/src/System/Security/Cryptography/ECOpenSsl.cs @@ -70,9 +70,9 @@ internal SafeEvpPKeyHandle UpRefKeyHandle() internal void SetKey(SafeEcKeyHandle key) { - Debug.Assert(key != null, "key != null"); - Debug.Assert(!key.IsInvalid, "!key.IsInvalid"); - Debug.Assert(!key.IsClosed, "!key.IsClosed"); + Debug.Assert(key != null); + Debug.Assert(!key.IsInvalid); + Debug.Assert(!key.IsClosed); FreeKey(); _key = new Lazy(key); diff --git a/src/libraries/Common/tests/System/Net/ManualChunkingStream.cs b/src/libraries/Common/tests/System/Net/ManualChunkingStream.cs index a37fb304bb9a1..b355546765614 100644 --- a/src/libraries/Common/tests/System/Net/ManualChunkingStream.cs +++ b/src/libraries/Common/tests/System/Net/ManualChunkingStream.cs @@ -26,11 +26,11 @@ public ManualChunkingStream(Stream stream, bool chunkWrite) public async ValueTask CommitWriteAsync(int length) { - Debug.Assert(length <= PendingWriteLength && length > 0, "length <= PendingWriteLength && length > 0"); + Debug.Assert(length <= PendingWriteLength && length > 0); byte[] buffer = ArrayPool.Shared.Rent(length); int read = await _writeBuffer.ReadAsync(buffer.AsMemory(0, length)); - Debug.Assert(read == length, "read == length"); + Debug.Assert(read == length); await _innerStream.WriteAsync(buffer, 0, read); await _innerStream.FlushAsync(); @@ -46,7 +46,7 @@ public void SetWriteChunking(bool chunking) byte[] buffer = ArrayPool.Shared.Rent(PendingWriteLength); int read = _writeBuffer.Read(buffer.AsSpan(0, PendingWriteLength)); - Debug.Assert(PendingWriteLength == 0, "PendingWriteLength == 0"); + Debug.Assert(PendingWriteLength == 0); _innerStream.Write(buffer, 0, read); _innerStream.Flush(); diff --git a/src/libraries/System.Net.Security/src/System/Net/Security/Pal.OSX/SafeDeleteSslContext.cs b/src/libraries/System.Net.Security/src/System/Net/Security/Pal.OSX/SafeDeleteSslContext.cs index d2c81f51a25a1..7ff7b26e7a5e6 100644 --- a/src/libraries/System.Net.Security/src/System/Net/Security/Pal.OSX/SafeDeleteSslContext.cs +++ b/src/libraries/System.Net.Security/src/System/Net/Security/Pal.OSX/SafeDeleteSslContext.cs @@ -121,7 +121,7 @@ public SafeDeleteSslContext(SslAuthenticationOptions sslAuthenticationOptions) SslCertificateTrust trust = sslAuthenticationOptions.CertificateContext!.Trust!; X509Certificate2Collection certList = (trust._trustList ?? trust._store!.Certificates); - Debug.Assert(certList != null, "certList != null"); + Debug.Assert(certList != null); Span handles = certList.Count <= 256 ? stackalloc IntPtr[256] : new IntPtr[certList.Count]; @@ -368,7 +368,7 @@ private static void SetProtocols(SafeSslHandle sslContext, SslProtocols protocol internal static void SetCertificate(SafeSslHandle sslContext, SslStreamCertificateContext context) { - Debug.Assert(sslContext != null, "sslContext != null"); + Debug.Assert(sslContext != null); IntPtr[] ptrs = new IntPtr[context!.IntermediateCertificates.Count + 1]; diff --git a/src/libraries/System.Net.Security/src/System/Net/Security/SslStream.Protocol.cs b/src/libraries/System.Net.Security/src/System/Net/Security/SslStream.Protocol.cs index 0d9a0e0ef7842..db0a4a6c84bf1 100644 --- a/src/libraries/System.Net.Security/src/System/Net/Security/SslStream.Protocol.cs +++ b/src/libraries/System.Net.Security/src/System/Net/Security/SslStream.Protocol.cs @@ -277,7 +277,7 @@ internal void CloseContext() private static X509Certificate2? MakeEx(X509Certificate certificate) { - Debug.Assert(certificate != null, "certificate != null"); + Debug.Assert(certificate != null); if (certificate.GetType() == typeof(X509Certificate2)) { @@ -985,7 +985,7 @@ internal void ProcessHandshakeSuccess() _headerSize = streamSizes.Header; _trailerSize = streamSizes.Trailer; _maxDataSize = streamSizes.MaximumMessage; - Debug.Assert(_maxDataSize > 0, "_maxDataSize > 0"); + Debug.Assert(_maxDataSize > 0); SslStreamPal.QueryContextConnectionInfo(_securityContext!, ref _connectionInfo); #if DEBUG diff --git a/src/libraries/System.Net.Security/src/System/Net/Security/SslStream.cs b/src/libraries/System.Net.Security/src/System/Net/Security/SslStream.cs index 47ee34664a4ee..4b3893156be3e 100644 --- a/src/libraries/System.Net.Security/src/System/Net/Security/SslStream.cs +++ b/src/libraries/System.Net.Security/src/System/Net/Security/SslStream.cs @@ -85,7 +85,7 @@ public SslBuffer() public ReadOnlySpan DecryptedReadOnlySpanSliced(int length) { - Debug.Assert(length <= DecryptedLength, "length <= DecryptedLength"); + Debug.Assert(length <= DecryptedLength); return _buffer.ActiveSpan.Slice(0, length); } diff --git a/src/libraries/System.Private.CoreLib/src/System/Collections/Hashtable.cs b/src/libraries/System.Private.CoreLib/src/System/Collections/Hashtable.cs index def27e549d8d2..1c69b34d4fd41 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Collections/Hashtable.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Collections/Hashtable.cs @@ -937,7 +937,7 @@ private void Insert(object key, object? nvalue, bool add) private void putEntry(Bucket[] newBuckets, object key, object? nvalue, int hashcode) { - Debug.Assert(hashcode >= 0, "hashcode >= 0"); // make sure collision bit (sign bit) wasn't set. + Debug.Assert(hashcode >= 0); // make sure collision bit (sign bit) wasn't set. uint seed = (uint)hashcode; uint incr = unchecked((uint)(1 + ((seed * HashHelpers.HashPrime) % ((uint)newBuckets.Length - 1)))); diff --git a/src/libraries/System.Private.CoreLib/src/System/Decimal.cs b/src/libraries/System.Private.CoreLib/src/System/Decimal.cs index 240bcc7e5d632..b0426ac109f86 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Decimal.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Decimal.cs @@ -627,7 +627,7 @@ public static bool TryGetBits(decimal d, Span destination, out int valuesWr internal static void GetBytes(in decimal d, Span buffer) { - Debug.Assert(buffer.Length >= 16, "buffer.Length >= 16"); + Debug.Assert(buffer.Length >= 16); BinaryPrimitives.WriteInt32LittleEndian(buffer, (int)d.Low); BinaryPrimitives.WriteInt32LittleEndian(buffer.Slice(4), (int)d.Mid); @@ -637,7 +637,7 @@ internal static void GetBytes(in decimal d, Span buffer) internal static decimal ToDecimal(ReadOnlySpan span) { - Debug.Assert(span.Length >= 16, "span.Length >= 16"); + Debug.Assert(span.Length >= 16); int lo = BinaryPrimitives.ReadInt32LittleEndian(span); int mid = BinaryPrimitives.ReadInt32LittleEndian(span.Slice(4)); int hi = BinaryPrimitives.ReadInt32LittleEndian(span.Slice(8)); diff --git a/src/libraries/System.Private.CoreLib/src/System/Globalization/CharUnicodeInfo.cs b/src/libraries/System.Private.CoreLib/src/System/Globalization/CharUnicodeInfo.cs index d98008b8c3a24..66d0f4f06ff75 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Globalization/CharUnicodeInfo.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Globalization/CharUnicodeInfo.cs @@ -53,7 +53,7 @@ internal static StrongBidiCategory GetBidiCategory(string s, int index) internal static StrongBidiCategory GetBidiCategory(StringBuilder s, int index) { - Debug.Assert(s != null, "s != null"); + Debug.Assert(s != null); Debug.Assert(index >= 0 && index < s.Length, "index < s.Length"); // The logic below follows Table 3-5 in the Unicode Standard, Sec. 3.9. @@ -363,7 +363,7 @@ public static UnicodeCategory GetUnicodeCategory(string s, int index) internal static UnicodeCategory GetUnicodeCategoryInternal(string value, int index) { Debug.Assert(value != null, "value can not be null"); - Debug.Assert(index < value.Length, "index < value.Length"); + Debug.Assert(index < value.Length); return GetUnicodeCategoryNoBoundsChecks((uint)GetCodePointFromString(value, index)); } @@ -375,8 +375,8 @@ internal static UnicodeCategory GetUnicodeCategoryInternal(string value, int ind internal static UnicodeCategory GetUnicodeCategoryInternal(string str, int index, out int charLength) { Debug.Assert(str != null, "str can not be null"); - Debug.Assert(str.Length > 0, "str.Length > 0"); - Debug.Assert(index >= 0 && index < str.Length, "index >= 0 && index < str.Length"); + Debug.Assert(str.Length > 0); + Debug.Assert(index >= 0 && index < str.Length); uint codePoint = (uint)GetCodePointFromString(str, index); UnicodeDebug.AssertIsValidCodePoint(codePoint); @@ -408,7 +408,7 @@ private static UnicodeCategory GetUnicodeCategoryNoBoundsChecks(uint codePoint) /// private static int GetCodePointFromString(string s, int index) { - Debug.Assert(s != null, "s != null"); + Debug.Assert(s != null); Debug.Assert((uint)index < (uint)s.Length, "index < s.Length"); int codePoint = 0; diff --git a/src/libraries/System.Private.CoreLib/src/System/Globalization/DateTimeFormat.cs b/src/libraries/System.Private.CoreLib/src/System/Globalization/DateTimeFormat.cs index 1879f22b62da7..a7ca7828e6e49 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Globalization/DateTimeFormat.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Globalization/DateTimeFormat.cs @@ -206,7 +206,7 @@ internal static int ParseRepeatPattern(ReadOnlySpan format, int pos, char private static string FormatDayOfWeek(int dayOfWeek, int repeat, DateTimeFormatInfo dtfi) { - Debug.Assert(dayOfWeek >= 0 && dayOfWeek <= 6, "dayOfWeek >= 0 && dayOfWeek <= 6"); + Debug.Assert(dayOfWeek >= 0 && dayOfWeek <= 6); if (repeat == 3) { return dtfi.GetAbbreviatedDayName((DayOfWeek)dayOfWeek); diff --git a/src/libraries/System.Private.CoreLib/src/System/Globalization/DateTimeParse.cs b/src/libraries/System.Private.CoreLib/src/System/Globalization/DateTimeParse.cs index 5e55b3b1a1aef..302b5ff3dd3fe 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Globalization/DateTimeParse.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Globalization/DateTimeParse.cs @@ -550,8 +550,8 @@ private static bool ParseTimeZone(ref __DTString str, scoped ref TimeSpan result // Wrong number of digits return false; } - Debug.Assert(hourOffset >= 0 && hourOffset <= 99, "hourOffset >= 0 && hourOffset <= 99"); - Debug.Assert(minuteOffset >= 0 && minuteOffset <= 99, "minuteOffset >= 0 && minuteOffset <= 99"); + Debug.Assert(hourOffset >= 0 && hourOffset <= 99); + Debug.Assert(minuteOffset >= 0 && minuteOffset <= 99); if (minuteOffset < 0 || minuteOffset >= 60) { return false; @@ -2066,7 +2066,7 @@ private static bool GetTimeOfN(ref DateTimeResult result, scoped ref DateTimeRaw private static bool GetTimeOfNN(ref DateTimeResult result, scoped ref DateTimeRawInfo raw) { - Debug.Assert(raw.numCount >= 2, "raw.numCount >= 2"); + Debug.Assert(raw.numCount >= 2); if ((result.flags & ParseFlags.HaveTime) != 0) { // Multiple times in the input string @@ -2088,7 +2088,7 @@ private static bool GetTimeOfNNN(ref DateTimeResult result, scoped ref DateTimeR result.SetBadDateTimeFailure(); return false; } - Debug.Assert(raw.numCount >= 3, "raw.numCount >= 3"); + Debug.Assert(raw.numCount >= 3); result.Hour = raw.GetNumber(0); result.Minute = raw.GetNumber(1); result.Second = raw.GetNumber(2); @@ -2806,7 +2806,7 @@ private static bool DetermineTimeZoneAdjustments(ref DateTimeResult result, Date else { // No time zone and no Assume flags, so DateTimeKind.Unspecified is fine - Debug.Assert(result.parsedDate.Kind == DateTimeKind.Unspecified, "result.parsedDate.Kind == DateTimeKind.Unspecified"); + Debug.Assert(result.parsedDate.Kind == DateTimeKind.Unspecified); return true; } } @@ -3142,9 +3142,9 @@ internal static bool ParseDigits(ref __DTString str, int digitLen, out int resul internal static bool ParseDigits(ref __DTString str, int minDigitLen, int maxDigitLen, out int result) { - Debug.Assert(minDigitLen > 0, "minDigitLen > 0"); - Debug.Assert(maxDigitLen < 9, "maxDigitLen < 9"); - Debug.Assert(minDigitLen <= maxDigitLen, "minDigitLen <= maxDigitLen"); + Debug.Assert(minDigitLen > 0); + Debug.Assert(maxDigitLen < 9); + Debug.Assert(minDigitLen <= maxDigitLen); int localResult = 0; int startingIndex = str.Index; int tokenLength = 0; @@ -5915,7 +5915,7 @@ internal DTSubString GetSubString() return sub; } int number = ch - '0'; - Debug.Assert(number >= 0 && number <= 9, "number >= 0 && number <= 9"); + Debug.Assert(number >= 0 && number <= 9); sub.value = sub.value * 10 + number; } else @@ -5937,7 +5937,7 @@ internal DTSubString GetSubString() internal void ConsumeSubString(DTSubString sub) { - Debug.Assert(sub.index == Index, "sub.index == Index"); + Debug.Assert(sub.index == Index); Debug.Assert(sub.index + sub.length <= Length, "sub.index + sub.length <= len"); Index = sub.index + sub.length; if (Index < Length) diff --git a/src/libraries/System.Private.CoreLib/src/System/Globalization/SortKey.cs b/src/libraries/System.Private.CoreLib/src/System/Globalization/SortKey.cs index a8c54f662d842..5c1fbb158d7e9 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Globalization/SortKey.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Globalization/SortKey.cs @@ -51,8 +51,8 @@ public static int Compare(SortKey sortkey1, SortKey sortkey2) byte[] key1Data = sortkey1._keyData; byte[] key2Data = sortkey2._keyData; - Debug.Assert(key1Data != null, "key1Data != null"); - Debug.Assert(key2Data != null, "key2Data != null"); + Debug.Assert(key1Data != null); + Debug.Assert(key2Data != null); // SortKey comparisons are done as an ordinal comparison by the raw sort key bytes. diff --git a/src/libraries/System.Private.CoreLib/src/System/IO/MemoryStream.cs b/src/libraries/System.Private.CoreLib/src/System/IO/MemoryStream.cs index d95ba477a4bb3..ee537382ff828 100644 --- a/src/libraries/System.Private.CoreLib/src/System/IO/MemoryStream.cs +++ b/src/libraries/System.Private.CoreLib/src/System/IO/MemoryStream.cs @@ -240,7 +240,7 @@ internal int InternalEmulateRead(int count) if (n < 0) n = 0; - Debug.Assert(_position + n >= 0, "_position + n >= 0"); // len is less than 2^31 -1. + Debug.Assert(_position + n >= 0); // len is less than 2^31 -1. _position += n; return n; } @@ -327,7 +327,7 @@ public override int Read(byte[] buffer, int offset, int count) if (n <= 0) return 0; - Debug.Assert(_position + n >= 0, "_position + n >= 0"); // len is less than 2^31 -1. + Debug.Assert(_position + n >= 0); // len is less than 2^31 -1. if (n <= 8) { @@ -530,7 +530,7 @@ private long SeekCore(long offset, int loc) throw new IOException(SR.IO_SeekBeforeBegin); _position = tempPosition; - Debug.Assert(_position >= _origin, "_position >= _origin"); + Debug.Assert(_position >= _origin); return _position - _origin; } diff --git a/src/libraries/System.Private.CoreLib/src/System/IO/Strategies/FileStreamHelpers.Windows.cs b/src/libraries/System.Private.CoreLib/src/System/IO/Strategies/FileStreamHelpers.Windows.cs index ce1dedaa8889d..4bd6eca24924d 100644 --- a/src/libraries/System.Private.CoreLib/src/System/IO/Strategies/FileStreamHelpers.Windows.cs +++ b/src/libraries/System.Private.CoreLib/src/System/IO/Strategies/FileStreamHelpers.Windows.cs @@ -55,7 +55,7 @@ internal static void FlushToDisk(SafeFileHandle handle) internal static long Seek(SafeFileHandle handle, long offset, SeekOrigin origin, bool closeInvalidHandle = false) { - Debug.Assert(origin >= SeekOrigin.Begin && origin <= SeekOrigin.End, "origin >= SeekOrigin.Begin && origin <= SeekOrigin.End"); + Debug.Assert(origin >= SeekOrigin.Begin && origin <= SeekOrigin.End); if (!Interop.Kernel32.SetFilePointerEx(handle, offset, out long ret, (uint)origin)) { @@ -132,7 +132,7 @@ internal static void Unlock(SafeFileHandle handle, long position, long length) internal static unsafe int ReadFileNative(SafeFileHandle handle, Span bytes, NativeOverlapped* overlapped, out int errorCode) { - Debug.Assert(handle != null, "handle != null"); + Debug.Assert(handle != null); int r; int numBytesRead = 0; diff --git a/src/libraries/System.Private.CoreLib/src/System/IO/Strategies/OSFileStreamStrategy.cs b/src/libraries/System.Private.CoreLib/src/System/IO/Strategies/OSFileStreamStrategy.cs index febe3d1fce79b..4e5753655d6b0 100644 --- a/src/libraries/System.Private.CoreLib/src/System/IO/Strategies/OSFileStreamStrategy.cs +++ b/src/libraries/System.Private.CoreLib/src/System/IO/Strategies/OSFileStreamStrategy.cs @@ -186,7 +186,7 @@ public sealed override void SetLength(long value) protected unsafe void SetLengthCore(long value) { - Debug.Assert(value >= 0, "value >= 0"); + Debug.Assert(value >= 0); RandomAccess.SetFileLength(_fileHandle, value); Debug.Assert(!_fileHandle.TryGetCachedLength(out _), "If length can be cached (file opened for reading, not shared for writing), it should be impossible to modify file length"); diff --git a/src/libraries/System.Private.CoreLib/src/System/Resources/ResourceManager.cs b/src/libraries/System.Private.CoreLib/src/System/Resources/ResourceManager.cs index 5727c717405c3..dfa6081f49fb1 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Resources/ResourceManager.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Resources/ResourceManager.cs @@ -427,7 +427,7 @@ protected virtual string GetResourceFileName(CultureInfo culture) // This will take a minimal number of locks. protected virtual ResourceSet? InternalGetResourceSet(CultureInfo culture, bool createIfNotExists, bool tryParents) { - Debug.Assert(culture != null, "culture != null"); + Debug.Assert(culture != null); Debug.Assert(_resourceSets != null); Dictionary localResourceSets = _resourceSets; diff --git a/src/libraries/System.Private.CoreLib/src/System/String.cs b/src/libraries/System.Private.CoreLib/src/System/String.cs index 4ea9b5b37b67f..45f4ac3e8f380 100644 --- a/src/libraries/System.Private.CoreLib/src/System/String.cs +++ b/src/libraries/System.Private.CoreLib/src/System/String.cs @@ -534,7 +534,7 @@ internal static unsafe string CreateStringFromEncoding( // Get our string length int stringLength = encoding.GetCharCount(bytes, byteLength); - Debug.Assert(stringLength >= 0, "stringLength >= 0"); + Debug.Assert(stringLength >= 0); // They gave us an empty string if they needed one // 0 bytelength might be possible if there's something in an encoder diff --git a/src/libraries/System.Private.Xml/src/System/Xml/XPath/Internal/QueryBuilder.cs b/src/libraries/System.Private.Xml/src/System/Xml/XPath/Internal/QueryBuilder.cs index f98014d00e61c..79972ea74fedc 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/XPath/Internal/QueryBuilder.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/XPath/Internal/QueryBuilder.cs @@ -461,7 +461,7 @@ private Query ProcessNode(AstNode root, Flags flags, out Props props) throw XPathException.Create(SR.Xp_QueryTooComplex); } - Debug.Assert(root != null, "root != null"); + Debug.Assert(root != null); Query? result = null; props = Props.None; switch (root.Type) diff --git a/src/libraries/System.Private.Xml/src/System/Xml/XPath/XPathNavigator.cs b/src/libraries/System.Private.Xml/src/System/Xml/XPath/XPathNavigator.cs index ce2afa27c433d..38264d13da2b7 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/XPath/XPathNavigator.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/XPath/XPathNavigator.cs @@ -1064,7 +1064,7 @@ private static XmlReader GetValidatingReader(XmlReader reader, XmlSchemaSet sche { return schemaType.Validate(reader, null, schemas, validationEvent); } - Debug.Assert(schemas != null, "schemas != null"); + Debug.Assert(schemas != null); XmlReaderSettings readerSettings = new XmlReaderSettings(); readerSettings.ConformanceLevel = ConformanceLevel.Auto; readerSettings.ValidationType = ValidationType.Schema; diff --git a/src/libraries/System.Runtime.Serialization.Formatters/src/System/Runtime/Serialization/ObjectManager.cs b/src/libraries/System.Runtime.Serialization.Formatters/src/System/Runtime/Serialization/ObjectManager.cs index 89b91be09a3cb..6fac98c14aea1 100644 --- a/src/libraries/System.Runtime.Serialization.Formatters/src/System/Runtime/Serialization/ObjectManager.cs +++ b/src/libraries/System.Runtime.Serialization.Formatters/src/System/Runtime/Serialization/ObjectManager.cs @@ -221,7 +221,7 @@ private void FixupSpecialObject(ObjectHolder holder) private bool ResolveObjectReference(ObjectHolder holder) { object? tempObject; - Debug.Assert(holder.IsIncompleteObjectReference, "holder.IsIncompleteObjectReference"); + Debug.Assert(holder.IsIncompleteObjectReference); //In the pathological case, an Object implementing IObjectReference could return a reference //to a different object which implements IObjectReference. This makes us vulnerable to a @@ -496,7 +496,7 @@ internal void CompleteObject(ObjectHolder holder, bool bObjectFullyComplete) switch (currentFixup._fixupType) { case FixupHolder.ArrayFixup: - Debug.Assert(holder.ObjectValue is Array, "holder.ObjectValue is Array"); + Debug.Assert(holder.ObjectValue is Array); if (holder.RequiresValueTypeFixup) { throw new SerializationException(SR.Serialization_ValueTypeFixup); @@ -507,7 +507,7 @@ internal void CompleteObject(ObjectHolder holder, bool bObjectFullyComplete) } break; case FixupHolder.MemberFixup: - Debug.Assert(fixupInfo is MemberInfo, "fixupInfo is MemberInfo"); + Debug.Assert(fixupInfo is MemberInfo); //Fixup the member directly. MemberInfo tempMember = (MemberInfo)fixupInfo; if (tempMember is FieldInfo) diff --git a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/CngHelpers.cs b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/CngHelpers.cs index 1b0ec56d99122..926432b2f01f4 100644 --- a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/CngHelpers.cs +++ b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/CngHelpers.cs @@ -345,7 +345,7 @@ internal static unsafe ArraySegment ToBCryptBlob(this in RSAParameters par } // We better have computed the right allocation size above! - Debug.Assert(offset == blobSize, "offset == blobSize"); + Debug.Assert(offset == blobSize); } return new ArraySegment(rsaBlob, 0, blobSize); diff --git a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/DSACng.Key.cs b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/DSACng.Key.cs index 919338a899839..90fba5a0d5e16 100644 --- a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/DSACng.Key.cs +++ b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/DSACng.Key.cs @@ -28,7 +28,7 @@ public CngKey Key private set { CngKey key = value; - Debug.Assert(key != null, "key != null"); + Debug.Assert(key != null); if (key.AlgorithmGroup != CngAlgorithmGroup.Dsa) throw new ArgumentException(SR.Cryptography_ArgDSARequiresDSAKey, nameof(value)); _core.SetKey(key); diff --git a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/Helpers.cs b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/Helpers.cs index a232dfa5f4983..88861c3926d59 100644 --- a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/Helpers.cs +++ b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/Helpers.cs @@ -119,7 +119,7 @@ internal static byte[] LaxDecodeHexString(this string hexString) // so add it to the buffer. if (!byteInProgress) { - Debug.Assert(index < cbHex, "index < cbHex"); + Debug.Assert(index < cbHex); hex[index] = accum; index++; @@ -130,7 +130,7 @@ internal static byte[] LaxDecodeHexString(this string hexString) // The .NET Framework algorithm removed all whitespace before the loop, then went up to length/2 // of what was left. This means that in the event of odd-length input the last char is // ignored, no exception should be raised. - Debug.Assert(index == cbHex, "index == cbHex"); + Debug.Assert(index == cbHex); return hex; } diff --git a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/OidLookup.OpenSsl.cs b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/OidLookup.OpenSsl.cs index 50b4612ee57f8..f871933c1a35c 100644 --- a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/OidLookup.OpenSsl.cs +++ b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/OidLookup.OpenSsl.cs @@ -23,7 +23,7 @@ private static bool ShouldUseCache(OidGroup oidGroup) switch (result) { case 1: /* Success */ - Debug.Assert(friendlyNamePtr != IntPtr.Zero, "friendlyNamePtr != IntPtr.Zero"); + Debug.Assert(friendlyNamePtr != IntPtr.Zero); // The pointer is to a shared string, so marshalling it out is all that's required. return Marshal.PtrToStringUTF8(friendlyNamePtr); diff --git a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/RSACng.Key.cs b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/RSACng.Key.cs index 7d4f326846ad5..320b346742539 100644 --- a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/RSACng.Key.cs +++ b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/RSACng.Key.cs @@ -28,7 +28,7 @@ public CngKey Key private set { CngKey key = value; - Debug.Assert(key != null, "key != null"); + Debug.Assert(key != null); if (key.AlgorithmGroup != CngAlgorithmGroup.Rsa) throw new ArgumentException(SR.Cryptography_ArgRSARequiresRSAKey, nameof(value)); _core.SetKey(key); diff --git a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/UniversalCryptoDecryptor.cs b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/UniversalCryptoDecryptor.cs index 933d834814654..070f4cfdc440f 100644 --- a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/UniversalCryptoDecryptor.cs +++ b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/UniversalCryptoDecryptor.cs @@ -51,7 +51,7 @@ protected override int UncheckedTransformBlock(ReadOnlySpan inputBuffer, S } // Postpone the last block to the next round. - Debug.Assert(inputBuffer.Length >= _heldoverCipher.Length, "inputBuffer.Length >= _heldoverCipher.Length"); + Debug.Assert(inputBuffer.Length >= _heldoverCipher.Length); inputBuffer.Slice(inputBuffer.Length - _heldoverCipher.Length).CopyTo(_heldoverCipher); inputBuffer = inputBuffer.Slice(0, inputBuffer.Length - _heldoverCipher.Length); Debug.Assert(inputBuffer.Length % InputBlockSize == 0, "Did not remove whole blocks for depadding"); diff --git a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/X509Certificates/CertificatePal.Windows.PrivateKey.cs b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/X509Certificates/CertificatePal.Windows.PrivateKey.cs index 947d7bbee5e9f..dc3458ad1bedc 100644 --- a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/X509Certificates/CertificatePal.Windows.PrivateKey.cs +++ b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/X509Certificates/CertificatePal.Windows.PrivateKey.cs @@ -258,9 +258,8 @@ public ICertificatePal CopyWithPrivateKey(RSA rsa) SafeCertContextHandle certificateContext, out CngKeyHandleOpenOptions handleOptions) { - Debug.Assert(certificateContext != null, "certificateContext != null"); - Debug.Assert(!certificateContext.IsClosed && !certificateContext.IsInvalid, - "!certificateContext.IsClosed && !certificateContext.IsInvalid"); + Debug.Assert(certificateContext != null); + Debug.Assert(!certificateContext.IsClosed && !certificateContext.IsInvalid); IntPtr privateKeyPtr; diff --git a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/X509Certificates/ChainPal.OpenSsl.cs b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/X509Certificates/ChainPal.OpenSsl.cs index e3a40e86f345a..2c034f6d1b4b2 100644 --- a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/X509Certificates/ChainPal.OpenSsl.cs +++ b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/X509Certificates/ChainPal.OpenSsl.cs @@ -193,8 +193,8 @@ public static void FlushStores() if (chainPal.ChainElements!.Length > 0) { X509Certificate2 reportedLeaf = chainPal.ChainElements[0].Certificate; - Debug.Assert(reportedLeaf != null, "reportedLeaf != null"); - Debug.Assert(!ReferenceEquals(cert, reportedLeaf.Pal), "!ReferenceEquals(cert, reportedLeaf.Pal)"); + Debug.Assert(reportedLeaf != null); + Debug.Assert(!ReferenceEquals(cert, reportedLeaf.Pal)); } #endif return chainPal; diff --git a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/X509Certificates/X509ChainElementCollection.cs b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/X509Certificates/X509ChainElementCollection.cs index b368a3579aabb..e996ee3e0f7d2 100644 --- a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/X509Certificates/X509ChainElementCollection.cs +++ b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/X509Certificates/X509ChainElementCollection.cs @@ -18,7 +18,7 @@ internal X509ChainElementCollection() internal X509ChainElementCollection(X509ChainElement[] chainElements) { - Debug.Assert(chainElements != null, "chainElements != null"); + Debug.Assert(chainElements != null); _elements = chainElements; } diff --git a/src/libraries/System.Transactions.Local/src/System/Transactions/Enlistment.cs b/src/libraries/System.Transactions.Local/src/System/Transactions/Enlistment.cs index 7d23de2aad39d..e136b969dc5ac 100644 --- a/src/libraries/System.Transactions.Local/src/System/Transactions/Enlistment.cs +++ b/src/libraries/System.Transactions.Local/src/System/Transactions/Enlistment.cs @@ -90,7 +90,7 @@ internal Guid DistributedTxId // For Recovering Enlistments protected InternalEnlistment(Enlistment enlistment, IEnlistmentNotification twoPhaseNotifications) { - Debug.Assert(this is RecoveringInternalEnlistment, "this is RecoveringInternalEnlistment"); + Debug.Assert(this is RecoveringInternalEnlistment); _enlistment = enlistment; _twoPhaseNotifications = twoPhaseNotifications; _enlistmentId = 1; @@ -100,7 +100,7 @@ protected InternalEnlistment(Enlistment enlistment, IEnlistmentNotification twoP // For Promotable Enlistments protected InternalEnlistment(Enlistment enlistment, InternalTransaction transaction, Transaction atomicTransaction) { - Debug.Assert(this is PromotableInternalEnlistment, "this is PromotableInternalEnlistment"); + Debug.Assert(this is PromotableInternalEnlistment); _enlistment = enlistment; _transaction = transaction; _atomicTransaction = atomicTransaction;