Skip to content

Commit d285c82

Browse files
authored
Remove now-redundant Debug.Assert messages (#105167)
1 parent 18b2ef1 commit d285c82

File tree

35 files changed

+77
-79
lines changed

35 files changed

+77
-79
lines changed

src/coreclr/System.Private.CoreLib/src/System/Reflection/Emit/RuntimeILGenerator.cs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1369,9 +1369,9 @@ internal void MarkFinallyAddr(int finallyAddr, int endCatchAddr)
13691369

13701370
internal void Done(int endAddr)
13711371
{
1372-
Debug.Assert(m_currentCatch > 0, "m_currentCatch > 0");
1373-
Debug.Assert(m_catchAddr[m_currentCatch - 1] > 0, "m_catchAddr[m_currentCatch-1] > 0");
1374-
Debug.Assert(m_catchEndAddr[m_currentCatch - 1] == -1, "m_catchEndAddr[m_currentCatch-1] == -1");
1372+
Debug.Assert(m_currentCatch > 0);
1373+
Debug.Assert(m_catchAddr[m_currentCatch - 1] > 0);
1374+
Debug.Assert(m_catchEndAddr[m_currentCatch - 1] == -1);
13751375
m_catchEndAddr[m_currentCatch - 1] = endAddr;
13761376
m_currentState = State_Done;
13771377
}
@@ -1447,8 +1447,8 @@ internal Label GetFinallyEndLabel()
14471447
internal bool IsInner(__ExceptionInfo exc)
14481448
{
14491449
Debug.Assert(exc != null);
1450-
Debug.Assert(m_currentCatch > 0, "m_currentCatch > 0");
1451-
Debug.Assert(exc.m_currentCatch > 0, "exc.m_currentCatch > 0");
1450+
Debug.Assert(m_currentCatch > 0);
1451+
Debug.Assert(exc.m_currentCatch > 0);
14521452

14531453
int exclast = exc.m_currentCatch - 1;
14541454
int last = m_currentCatch - 1;
@@ -1458,8 +1458,7 @@ internal bool IsInner(__ExceptionInfo exc)
14581458

14591459
if (exc.m_catchEndAddr[exclast] != m_catchEndAddr[last])
14601460
return false;
1461-
Debug.Assert(exc.GetEndAddress() != GetEndAddress(),
1462-
"exc.GetEndAddress() != GetEndAddress()");
1461+
Debug.Assert(exc.GetEndAddress() != GetEndAddress());
14631462

14641463
return exc.GetEndAddress() > GetEndAddress();
14651464
}

src/coreclr/System.Private.CoreLib/src/System/Variant.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,14 +257,14 @@ public Variant(object? obj)
257257
{
258258
vt = VarEnum.VT_ERROR;
259259
obj = (object)(((ErrorWrapper)obj).ErrorCode);
260-
Debug.Assert(obj != null, "obj != null");
260+
Debug.Assert(obj != null);
261261
}
262262
#pragma warning disable 0618 // CurrencyWrapper is obsolete
263263
else if (obj is CurrencyWrapper)
264264
{
265265
vt = VarEnum.VT_CY;
266266
obj = (object)(((CurrencyWrapper)obj).WrappedObject);
267-
Debug.Assert(obj != null, "obj != null");
267+
Debug.Assert(obj != null);
268268
}
269269
#pragma warning restore 0618
270270
else if (obj is BStrWrapper)

src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.OpenSsl.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ internal static SafeSslHandle AllocateSslHandle(SslAuthenticationOptions sslAuth
458458
SslCertificateTrust trust = sslAuthenticationOptions.CertificateContext!.Trust!;
459459
X509Certificate2Collection certList = (trust._trustList ?? trust._store!.Certificates);
460460

461-
Debug.Assert(certList != null, "certList != null");
461+
Debug.Assert(certList != null);
462462
Span<IntPtr> handles = certList.Count <= 256 ?
463463
stackalloc IntPtr[256] :
464464
new IntPtr[certList.Count];
@@ -884,8 +884,8 @@ private static void BioWrite(SafeBioHandle bio, ReadOnlySpan<byte> buffer)
884884

885885
private static void SetSslCertificate(SafeSslContextHandle contextPtr, SafeX509Handle certPtr, SafeEvpPKeyHandle keyPtr)
886886
{
887-
Debug.Assert(certPtr != null && !certPtr.IsInvalid, "certPtr != null && !certPtr.IsInvalid");
888-
Debug.Assert(keyPtr != null && !keyPtr.IsInvalid, "keyPtr != null && !keyPtr.IsInvalid");
887+
Debug.Assert(certPtr != null && !certPtr.IsInvalid);
888+
Debug.Assert(keyPtr != null && !keyPtr.IsInvalid);
889889

890890
int retVal = Ssl.SslCtxUseCertificate(contextPtr, certPtr);
891891

src/libraries/Common/src/Interop/Windows/Advapi32/Interop.LsaLookupSids.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public static unsafe void InitializeReferencedDomainsList(this SafeLsaMemoryHand
4444
pTrustInformation += domainList.Entries;
4545

4646
long bufferSize = (byte*)pTrustInformation - pRdl;
47-
System.Diagnostics.Debug.Assert(bufferSize > 0, "bufferSize > 0");
47+
System.Diagnostics.Debug.Assert(bufferSize > 0);
4848
referencedDomains.Initialize((ulong)bufferSize);
4949
}
5050
}

src/libraries/Common/src/System/Security/Cryptography/ECAndroid.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ public void Dispose()
4646

4747
internal void SetKey(SafeEcKeyHandle key)
4848
{
49-
Debug.Assert(key != null, "key != null");
50-
Debug.Assert(!key.IsInvalid, "!key.IsInvalid");
51-
Debug.Assert(!key.IsClosed, "!key.IsClosed");
49+
Debug.Assert(key != null);
50+
Debug.Assert(!key.IsInvalid);
51+
Debug.Assert(!key.IsClosed);
5252

5353
FreeKey();
5454
_key = new Lazy<SafeEcKeyHandle>(key);

src/libraries/Common/src/System/Security/Cryptography/ECCng.ImportExport.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ internal static byte[] GetNamedCurveBlob(ref ECParameters parameters, bool ecdh)
5959
}
6060

6161
// We better have computed the right allocation size above!
62-
Debug.Assert(offset == blobSize, "offset == blobSize");
62+
Debug.Assert(offset == blobSize);
6363
}
6464
}
6565
return blob;
@@ -143,7 +143,7 @@ internal static byte[] GetPrimeCurveBlob(ref ECParameters parameters, bool ecdh)
143143
}
144144

145145
// We better have computed the right allocation size above!
146-
Debug.Assert(offset == blobSize, "offset == blobSize");
146+
Debug.Assert(offset == blobSize);
147147
}
148148

149149
return blob;
@@ -311,7 +311,7 @@ internal static unsafe byte[] GetPrimeCurveParameterBlob(ref ECCurve curve)
311311
}
312312

313313
// We better have computed the right allocation size above!
314-
Debug.Assert(offset == blobSize, "offset == blobSize");
314+
Debug.Assert(offset == blobSize);
315315
}
316316

317317
return blob;

src/libraries/Common/src/System/Security/Cryptography/ECOpenSsl.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ internal SafeEvpPKeyHandle CreateEvpPKeyHandle()
5050

5151
private void SetKey(SafeEcKeyHandle key)
5252
{
53-
Debug.Assert(key != null, "key != null");
54-
Debug.Assert(!key.IsInvalid, "!key.IsInvalid");
55-
Debug.Assert(!key.IsClosed, "!key.IsClosed");
53+
Debug.Assert(key != null);
54+
Debug.Assert(!key.IsInvalid);
55+
Debug.Assert(!key.IsClosed);
5656

5757
FreeKey();
5858
_key = new Lazy<SafeEcKeyHandle>(key);

src/libraries/Common/tests/System/Net/ManualChunkingStream.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ public ManualChunkingStream(Stream stream, bool chunkWrite)
2626

2727
public async ValueTask CommitWriteAsync(int length)
2828
{
29-
Debug.Assert(length <= PendingWriteLength && length > 0, "length <= PendingWriteLength && length > 0");
29+
Debug.Assert(length <= PendingWriteLength && length > 0);
3030
byte[] buffer = ArrayPool<byte>.Shared.Rent(length);
3131

3232
int read = await _writeBuffer.ReadAsync(buffer.AsMemory(0, length));
33-
Debug.Assert(read == length, "read == length");
33+
Debug.Assert(read == length);
3434
await _innerStream.WriteAsync(buffer, 0, read);
3535
await _innerStream.FlushAsync();
3636

@@ -46,7 +46,7 @@ public void SetWriteChunking(bool chunking)
4646
byte[] buffer = ArrayPool<byte>.Shared.Rent(PendingWriteLength);
4747

4848
int read = _writeBuffer.Read(buffer.AsSpan(0, PendingWriteLength));
49-
Debug.Assert(PendingWriteLength == 0, "PendingWriteLength == 0");
49+
Debug.Assert(PendingWriteLength == 0);
5050
_innerStream.Write(buffer, 0, read);
5151
_innerStream.Flush();
5252

src/libraries/System.Net.Security/src/System/Net/Security/Pal.OSX/SafeDeleteSslContext.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ public SafeDeleteSslContext(SslAuthenticationOptions sslAuthenticationOptions)
121121
SslCertificateTrust trust = sslAuthenticationOptions.CertificateContext!.Trust!;
122122
X509Certificate2Collection certList = (trust._trustList ?? trust._store!.Certificates);
123123

124-
Debug.Assert(certList != null, "certList != null");
124+
Debug.Assert(certList != null);
125125
Span<IntPtr> handles = certList.Count <= 256
126126
? stackalloc IntPtr[256]
127127
: new IntPtr[certList.Count];
@@ -368,7 +368,7 @@ private static void SetProtocols(SafeSslHandle sslContext, SslProtocols protocol
368368

369369
internal static void SetCertificate(SafeSslHandle sslContext, SslStreamCertificateContext context)
370370
{
371-
Debug.Assert(sslContext != null, "sslContext != null");
371+
Debug.Assert(sslContext != null);
372372

373373
IntPtr[] ptrs = new IntPtr[context!.IntermediateCertificates.Count + 1];
374374

src/libraries/System.Net.Security/src/System/Net/Security/SslStream.Protocol.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ internal void CloseContext()
277277

278278
private static X509Certificate2? MakeEx(X509Certificate certificate)
279279
{
280-
Debug.Assert(certificate != null, "certificate != null");
280+
Debug.Assert(certificate != null);
281281

282282
if (certificate.GetType() == typeof(X509Certificate2))
283283
{
@@ -985,7 +985,7 @@ internal void ProcessHandshakeSuccess()
985985
_headerSize = streamSizes.Header;
986986
_trailerSize = streamSizes.Trailer;
987987
_maxDataSize = streamSizes.MaximumMessage;
988-
Debug.Assert(_maxDataSize > 0, "_maxDataSize > 0");
988+
Debug.Assert(_maxDataSize > 0);
989989

990990
SslStreamPal.QueryContextConnectionInfo(_securityContext!, ref _connectionInfo);
991991
#if DEBUG

0 commit comments

Comments
 (0)