From c7b34c8633e783a01739aec77c9889cc39f3aa77 Mon Sep 17 00:00:00 2001 From: Stephen Toub Date: Sun, 21 Jul 2024 21:04:08 -0400 Subject: [PATCH] Replace `Debug.Assert(false,` with `Debug.Fail(` --- .../src/Internal/Runtime/MethodTable.cs | 2 +- .../src/System/Diagnostics/Debug.cs | 7 ++ .../src/System/Runtime/ExceptionHandling.cs | 10 +-- .../src/System/Runtime/RuntimeExports.cs | 2 +- .../src/System/Runtime/TypeCast.cs | 2 +- .../StackTraceMetadata/MethodNameFormatter.cs | 2 +- .../src/System/Diagnostics/Debug.cs | 7 ++ .../src/System/RuntimeExceptionHelpers.cs | 2 +- .../SystemVStructClassificator.cs | 2 +- .../Common/FieldLayoutIntervalCalculator.cs | 2 +- .../Dataflow/CompilerGeneratedState.cs | 2 +- .../Metadata/Transform.TypeForwarders.cs | 2 +- .../ReadyToRun/AttributePresenceFilterNode.cs | 2 +- .../ReadyToRunCompilationModuleGroupBase.cs | 2 +- .../ObjectWriter/R2RPEBuilder.cs | 2 +- src/coreclr/tools/r2rdump/TextDumper.cs | 6 +- .../ComHost/ClsidMap.cs | 2 +- .../System/Collections/TestBase.Generic.cs | 2 +- .../tests/System/Xml/XmlDiff/XmlDiff.cs | 2 +- .../System/Xml/XmlDiff/XmlDiffDocument.cs | 14 ++-- .../ComInterop/VariantBuilder.cs | 2 +- .../src/ServiceDescriptor.cs | 2 +- .../src/Metrics/ListenerSubscription.cs | 2 +- .../gen/LoggerMessageGenerator.Parser.cs | 2 +- .../System.Data.OleDb/src/ColumnBinding.cs | 30 ++++----- .../src/DbConnectionOptions.cs | 4 +- .../System.Data.OleDb/src/OleDbCommand.cs | 2 +- .../System.Data.OleDb/src/OleDbConnection.cs | 2 +- .../src/OleDbConnectionStringBuilder.cs | 6 +- .../System.Data.OleDb/src/OleDbDataReader.cs | 8 +-- .../src/OleDbReferenceCollection.cs | 2 +- .../System.Data.OleDb/src/OleDb_Util.cs | 10 +-- .../System.Data.OleDb/src/RowBinding.cs | 8 +-- .../src/System/Data/Common/AdapterUtil.cs | 10 +-- .../Data/ProviderBase/DbConnectionHelper.cs | 2 +- .../Metrics/ObservableInstrument.cs | 2 +- .../EventSourceTestParser.cs | 64 +++++++++---------- .../src/System/Formats/Tar/TarEntry.cs | 2 +- .../System/Globalization/CultureData.Icu.cs | 2 +- .../src/System/Reflection/FieldAccessor.cs | 2 +- .../src/System/WeakReference.T.cs | 2 +- .../Xml/Core/XsdValidatingReaderAsync.cs | 2 +- .../Metadata/TypeSystem/AssemblyReference.cs | 2 +- .../Metadata/TypeSystem/CustomAttribute.cs | 2 +- .../Metadata/TypeSystem/TypeReference.cs | 4 +- .../src/System/Security/AccessControl/ACL.cs | 10 +-- .../src/System/Security/Cryptography/HKDF.cs | 2 +- .../tests/Utils/XmlDiff.cs | 2 +- .../tests/Utils/XmlDiffDocument.cs | 14 ++-- .../Internal/SrgsCompiler/CfgSemanticTag.cs | 2 +- .../src/Internal/SrgsCompiler/RuleRef.cs | 2 +- .../Internal/SrgsParser/SrgsDocumentParser.cs | 2 +- .../src/Internal/Synthesis/AudioDeviceOut.cs | 2 +- .../src/Internal/Synthesis/VoiceSynthesis.cs | 2 +- .../Recognition/SrgsGrammar/SrgsGrammar.cs | 2 +- .../src/Base/DataflowBlock.cs | 8 +-- .../src/Blocks/BroadcastBlock.cs | 2 +- .../src/Blocks/TransformManyBlock.cs | 2 +- .../src/Internal/SourceCore.cs | 2 +- .../Oletx/OletxVolatileEnlistment.cs | 6 +- .../JIT/Directed/StructABI/structreturn.cs | 4 +- .../JitBlue/GitHub_39823/GitHub_39823.cs | 2 +- 62 files changed, 165 insertions(+), 151 deletions(-) diff --git a/src/coreclr/nativeaot/Common/src/Internal/Runtime/MethodTable.cs b/src/coreclr/nativeaot/Common/src/Internal/Runtime/MethodTable.cs index 91ef0a286e356c..98d5f338899a6e 100644 --- a/src/coreclr/nativeaot/Common/src/Internal/Runtime/MethodTable.cs +++ b/src/coreclr/nativeaot/Common/src/Internal/Runtime/MethodTable.cs @@ -1362,7 +1362,7 @@ public uint GetFieldOffset(EETypeField eField) return cbOffset; } - Debug.Assert(false, "Unknown MethodTable field type"); + Debug.Fail("Unknown MethodTable field type"); return 0; } diff --git a/src/coreclr/nativeaot/Runtime.Base/src/System/Diagnostics/Debug.cs b/src/coreclr/nativeaot/Runtime.Base/src/System/Diagnostics/Debug.cs index 0221b8e7c98951..ea85cc5389bf68 100644 --- a/src/coreclr/nativeaot/Runtime.Base/src/System/Diagnostics/Debug.cs +++ b/src/coreclr/nativeaot/Runtime.Base/src/System/Diagnostics/Debug.cs @@ -27,5 +27,12 @@ internal static void Assert(bool condition) EH.FallbackFailFast(RhFailFastReason.InternalError, null); } } + + [System.Diagnostics.Conditional("DEBUG")] + [MethodImpl(MethodImplOptions.NoInlining)] + internal static void Fail(string message) + { + Assert(false, message); + } } } diff --git a/src/coreclr/nativeaot/Runtime.Base/src/System/Runtime/ExceptionHandling.cs b/src/coreclr/nativeaot/Runtime.Base/src/System/Runtime/ExceptionHandling.cs index f74e394df855da..3443e1bcb711a9 100644 --- a/src/coreclr/nativeaot/Runtime.Base/src/System/Runtime/ExceptionHandling.cs +++ b/src/coreclr/nativeaot/Runtime.Base/src/System/Runtime/ExceptionHandling.cs @@ -200,7 +200,7 @@ private static void OnUnhandledExceptionViaClassLib(object exception) // disallow all exceptions leaking out of callbacks } #else - Debug.Assert(false, "Unhandled exceptions should be processed by the native runtime only"); + Debug.Fail("Unhandled exceptions should be processed by the native runtime only"); #endif } @@ -429,7 +429,7 @@ public static Exception GetRuntimeException(ExceptionIDs id) return new InvalidCastException(); default: - Debug.Assert(false, "unexpected ExceptionID"); + Debug.Fail("unexpected ExceptionID"); FallbackFailFast(RhFailFastReason.InternalError, null); return null; } @@ -696,7 +696,7 @@ public static void RhUnwindAndIntercept(ref ExInfo exInfo, UIntPtr interceptStac InternalCalls.ResumeAtInterceptionLocation(exInfo._frameIter.RegisterSet); } - Debug.Assert(false, "unreachable"); + Debug.Fail("unreachable"); FallbackFailFast(RhFailFastReason.InternalError, null); } #endif // !NATIVEAOT @@ -903,7 +903,7 @@ private static void DispatchEx(scoped ref StackFrameIterator frameIter, ref ExIn pReversePInvokePropagationContext, pReversePInvokePropagationCallback, frameIter.RegisterSet, ref exInfo, frameIter.PreviousTransitionFrame); // the helper should jump to propagation handler and not return #endif - Debug.Assert(false, "unreachable"); + Debug.Fail("unreachable"); FallbackFailFast(RhFailFastReason.InternalError, null); } #endif // FEATURE_OBJCMARSHAL @@ -926,7 +926,7 @@ private static void DispatchEx(scoped ref StackFrameIterator frameIter, ref ExIn } #endif // NATIVEAOT // currently, RhpCallCatchFunclet will resume after the catch - Debug.Assert(false, "unreachable"); + Debug.Fail("unreachable"); FallbackFailFast(RhFailFastReason.InternalError, null); } diff --git a/src/coreclr/nativeaot/Runtime.Base/src/System/Runtime/RuntimeExports.cs b/src/coreclr/nativeaot/Runtime.Base/src/System/Runtime/RuntimeExports.cs index 8a552a86cd48dd..a1e7ab60f30da6 100644 --- a/src/coreclr/nativeaot/Runtime.Base/src/System/Runtime/RuntimeExports.cs +++ b/src/coreclr/nativeaot/Runtime.Base/src/System/Runtime/RuntimeExports.cs @@ -388,7 +388,7 @@ internal static unsafe IntPtr RhGetRuntimeHelperForType(MethodTable* pEEType, Ru return (IntPtr)(delegate*)&InternalCalls.RhpNewArray; default: - Debug.Assert(false, "Unknown RuntimeHelperKind"); + Debug.Fail("Unknown RuntimeHelperKind"); return IntPtr.Zero; } } diff --git a/src/coreclr/nativeaot/Runtime.Base/src/System/Runtime/TypeCast.cs b/src/coreclr/nativeaot/Runtime.Base/src/System/Runtime/TypeCast.cs index 0161e8c47c1508..742c5092674b6c 100644 --- a/src/coreclr/nativeaot/Runtime.Base/src/System/Runtime/TypeCast.cs +++ b/src/coreclr/nativeaot/Runtime.Base/src/System/Runtime/TypeCast.cs @@ -711,7 +711,7 @@ internal static unsafe bool TypeParametersAreCompatible(int arity, break; default: - Debug.Assert(false, "unknown generic variance type"); + Debug.Fail("unknown generic variance type"); break; } } diff --git a/src/coreclr/nativeaot/System.Private.StackTraceMetadata/src/Internal/StackTraceMetadata/MethodNameFormatter.cs b/src/coreclr/nativeaot/System.Private.StackTraceMetadata/src/Internal/StackTraceMetadata/MethodNameFormatter.cs index 464479f5395e03..fc1bb1428ee74a 100644 --- a/src/coreclr/nativeaot/System.Private.StackTraceMetadata/src/Internal/StackTraceMetadata/MethodNameFormatter.cs +++ b/src/coreclr/nativeaot/System.Private.StackTraceMetadata/src/Internal/StackTraceMetadata/MethodNameFormatter.cs @@ -263,7 +263,7 @@ private void EmitTypeName(Handle typeHandle, Flags flags) break; default: - Debug.Assert(false, $"Type handle {typeHandle.HandleType} was not handled"); + Debug.Fail($"Type handle {typeHandle.HandleType} was not handled"); _outputBuilder.Append("???"); break; } diff --git a/src/coreclr/nativeaot/Test.CoreLib/src/System/Diagnostics/Debug.cs b/src/coreclr/nativeaot/Test.CoreLib/src/System/Diagnostics/Debug.cs index 0a5cb92cc30f40..e3318b4d06cf10 100644 --- a/src/coreclr/nativeaot/Test.CoreLib/src/System/Diagnostics/Debug.cs +++ b/src/coreclr/nativeaot/Test.CoreLib/src/System/Diagnostics/Debug.cs @@ -27,5 +27,12 @@ internal static void Assert(bool condition) RuntimeImports.RhpFallbackFailFast(); } } + + [System.Diagnostics.Conditional("DEBUG")] + [MethodImpl(MethodImplOptions.NoInlining)] + internal static void Fail(string message) + { + Assert(false, message); + } } } diff --git a/src/coreclr/nativeaot/Test.CoreLib/src/System/RuntimeExceptionHelpers.cs b/src/coreclr/nativeaot/Test.CoreLib/src/System/RuntimeExceptionHelpers.cs index 8100d936e66b07..c4758c8cb10fca 100644 --- a/src/coreclr/nativeaot/Test.CoreLib/src/System/RuntimeExceptionHelpers.cs +++ b/src/coreclr/nativeaot/Test.CoreLib/src/System/RuntimeExceptionHelpers.cs @@ -69,7 +69,7 @@ public static Exception GetRuntimeException(ExceptionIDs id) return new PlatformNotSupportedException(); default: - Debug.Assert(false, "unexpected ExceptionID"); + Debug.Fail("unexpected ExceptionID"); RuntimeImports.RhpFallbackFailFast(); return null; } diff --git a/src/coreclr/tools/Common/JitInterface/SystemVStructClassificator.cs b/src/coreclr/tools/Common/JitInterface/SystemVStructClassificator.cs index 5aa1265a56bdcb..943f23ce102a4a 100644 --- a/src/coreclr/tools/Common/JitInterface/SystemVStructClassificator.cs +++ b/src/coreclr/tools/Common/JitInterface/SystemVStructClassificator.cs @@ -260,7 +260,7 @@ private static bool ClassifyEightBytes(TypeDesc typeDesc, // The field can't span past the end of the struct. if ((normalizedFieldOffset + fieldSize) > helper.StructSize) { - Debug.Assert(false, "Invalid struct size. The size of fields and overall size don't agree"); + Debug.Fail("Invalid struct size. The size of fields and overall size don't agree"); return false; } diff --git a/src/coreclr/tools/Common/TypeSystem/Common/FieldLayoutIntervalCalculator.cs b/src/coreclr/tools/Common/TypeSystem/Common/FieldLayoutIntervalCalculator.cs index 9f909eccc35809..73fa31073598a0 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/FieldLayoutIntervalCalculator.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/FieldLayoutIntervalCalculator.cs @@ -73,7 +73,7 @@ private int GetFieldSize(TypeDesc fieldType) } else { - Debug.Assert(false, fieldType.ToString()); + Debug.Fail(fieldType.ToString()); return fieldType.GetElementSize().AsInt; } } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/CompilerGeneratedState.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/CompilerGeneratedState.cs index 3ef0bbf02a573f..def7db6138c99c 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/CompilerGeneratedState.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/CompilerGeneratedState.cs @@ -378,7 +378,7 @@ void MapGeneratedTypeTypeParameters( } else { - Debug.Assert(false, "This should be impossible in valid code"); + Debug.Fail("This should be impossible in valid code"); } } } diff --git a/src/coreclr/tools/aot/ILCompiler.MetadataTransform/ILCompiler/Metadata/Transform.TypeForwarders.cs b/src/coreclr/tools/aot/ILCompiler.MetadataTransform/ILCompiler/Metadata/Transform.TypeForwarders.cs index d95dba55b1e937..028198d07f84b2 100644 --- a/src/coreclr/tools/aot/ILCompiler.MetadataTransform/ILCompiler/Metadata/Transform.TypeForwarders.cs +++ b/src/coreclr/tools/aot/ILCompiler.MetadataTransform/ILCompiler/Metadata/Transform.TypeForwarders.cs @@ -39,7 +39,7 @@ private void HandleTypeForwarders(Cts.Ecma.EcmaModule module) } else { - Debug.Assert(false, "Multi-module assemblies"); + Debug.Fail("Multi-module assemblies"); } } } diff --git a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/AttributePresenceFilterNode.cs b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/AttributePresenceFilterNode.cs index b9e9c8316e5af8..2629c3960594b4 100644 --- a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/AttributePresenceFilterNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/AttributePresenceFilterNode.cs @@ -383,7 +383,7 @@ public override ObjectData GetData(NodeFactory factory, bool relocsOnly = false) return; } } - Debug.Assert(false, "Not possible to reach here"); + Debug.Fail("Not possible to reach here"); }; // Scan for pre-existing fingerprint entry in buckets if (hasEntryInBucket(bucketAIndex, fingerprint) || hasEntryInBucket(bucketBIndex, fingerprint)) diff --git a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/ReadyToRunCompilationModuleGroupBase.cs b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/ReadyToRunCompilationModuleGroupBase.cs index a3b8d6e93b04cd..09c12867e50b16 100644 --- a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/ReadyToRunCompilationModuleGroupBase.cs +++ b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/ReadyToRunCompilationModuleGroupBase.cs @@ -860,7 +860,7 @@ private bool ComputeTypeReferenceVersionsWithCode(TypeDesc type) return true; } - Debug.Assert(false, "Unhandled form of type in VersionsWithTypeReference"); + Debug.Fail("Unhandled form of type in VersionsWithTypeReference"); return false; } diff --git a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/ObjectWriter/R2RPEBuilder.cs b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/ObjectWriter/R2RPEBuilder.cs index 41e656e5014d37..46d7bba69b43cf 100644 --- a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/ObjectWriter/R2RPEBuilder.cs +++ b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/ObjectWriter/R2RPEBuilder.cs @@ -545,7 +545,7 @@ private int RelocateRVA(int rva) return rva + sectionRvaDelta.DeltaRVA; } } - Debug.Assert(false, "RVA is not within any of the input sections - output PE may be inconsistent"); + Debug.Fail("RVA is not within any of the input sections - output PE may be inconsistent"); return rva; } diff --git a/src/coreclr/tools/r2rdump/TextDumper.cs b/src/coreclr/tools/r2rdump/TextDumper.cs index e9c658d935fa6d..9f2c462ddaa347 100644 --- a/src/coreclr/tools/r2rdump/TextDumper.cs +++ b/src/coreclr/tools/r2rdump/TextDumper.cs @@ -549,7 +549,7 @@ public override void DumpSectionContents(ReadyToRunSection section) if (curMethod != (countMethods + 1)) { Program.WriteWarning("MethodIsGenericMap malformed"); - System.Diagnostics.Debug.Assert(false, "MethodIsGenericMap malformed"); + System.Diagnostics.Debug.Fail("MethodIsGenericMap malformed"); } break; } @@ -561,7 +561,7 @@ public override void DumpSectionContents(ReadyToRunSection section) if (countTypes != NativeReader.ReadUInt16(_r2r.Image, ref mapOffset)) { Program.WriteWarning("EnclosingTypeMap malformed"); - System.Diagnostics.Debug.Assert(false, "EnclosingTypeMap malformed"); + System.Diagnostics.Debug.Fail("EnclosingTypeMap malformed"); } int curType = 1; while (curType <= (countTypes + 1)) @@ -594,7 +594,7 @@ public override void DumpSectionContents(ReadyToRunSection section) if (curType != (countTypes + 1)) { Program.WriteWarning("TypeGenericInfoMap malformed"); - System.Diagnostics.Debug.Assert(false, "TypeGenericInfoMap malformed"); + System.Diagnostics.Debug.Fail("TypeGenericInfoMap malformed"); } break; } diff --git a/src/installer/managed/Microsoft.NET.HostModel/ComHost/ClsidMap.cs b/src/installer/managed/Microsoft.NET.HostModel/ComHost/ClsidMap.cs index 4d7dcd09a00a63..45d25a57ef8d2d 100644 --- a/src/installer/managed/Microsoft.NET.HostModel/ComHost/ClsidMap.cs +++ b/src/installer/managed/Microsoft.NET.HostModel/ComHost/ClsidMap.cs @@ -236,7 +236,7 @@ private static bool IsTargetAttribute(MetadataReader reader, CustomAttribute att break; default: - Debug.Assert(false, "Unknown attribute constructor kind"); + Debug.Fail("Unknown attribute constructor kind"); return false; } diff --git a/src/libraries/Common/tests/System/Collections/TestBase.Generic.cs b/src/libraries/Common/tests/System/Collections/TestBase.Generic.cs index 0a22540b6588b9..f90b2d34628d1b 100644 --- a/src/libraries/Common/tests/System/Collections/TestBase.Generic.cs +++ b/src/libraries/Common/tests/System/Collections/TestBase.Generic.cs @@ -110,7 +110,7 @@ protected IEnumerable CreateEnumerable(EnumerableType type, IEnumerable en case EnumerableType.Lazy: return CreateLazyEnumerable(enumerableToMatchTo, count, numberOfMatchingElements, numberOfDuplicateElements); default: - Debug.Assert(false, "Check that the 'EnumerableType' Enum returns only types that are special-cased in the CreateEnumerable function within the Iset_Generic_Tests class"); + Debug.Fail("Check that the 'EnumerableType' Enum returns only types that are special-cased in the CreateEnumerable function within the Iset_Generic_Tests class"); return null; } } diff --git a/src/libraries/Common/tests/System/Xml/XmlDiff/XmlDiff.cs b/src/libraries/Common/tests/System/Xml/XmlDiff/XmlDiff.cs index 4101d1bbe73f90..8498a7899b6704 100644 --- a/src/libraries/Common/tests/System/Xml/XmlDiff/XmlDiff.cs +++ b/src/libraries/Common/tests/System/Xml/XmlDiff/XmlDiff.cs @@ -354,7 +354,7 @@ private bool CompareChildren(XmlDiffNode sourceNode, XmlDiffNode targetNode) else { //Both SourceRead and TargetRead is NULL - Debug.Assert(false, "Impossible Situation for comparison"); + Debug.Fail("Impossible Situation for comparison"); } } return flag; diff --git a/src/libraries/Common/tests/System/Xml/XmlDiff/XmlDiffDocument.cs b/src/libraries/Common/tests/System/Xml/XmlDiff/XmlDiffDocument.cs index 569103b5f4e41d..d3b76384aa9937 100644 --- a/src/libraries/Common/tests/System/Xml/XmlDiff/XmlDiffDocument.cs +++ b/src/libraries/Common/tests/System/Xml/XmlDiff/XmlDiffDocument.cs @@ -201,7 +201,7 @@ internal NodePosition ComparePosition(XmlDiffNode node1, XmlDiffNode node2) else { //something really wrong here, what should we do??? - Debug.Assert(false, "ComparePosition meets an indecision situation."); + Debug.Fail("ComparePosition meets an indecision situation."); return NodePosition.Unknown; } } @@ -747,7 +747,7 @@ public string GetAttribute(string localName, string namespaceURI) public string GetNamespace(string name) { - Debug.Assert(false, "GetNamespace is NYI"); + Debug.Fail("GetNamespace is NYI"); return ""; } @@ -835,12 +835,12 @@ public bool MoveToFirstChild() } public bool MoveToId(string id) { - Debug.Assert(false, "MoveToId is NYI"); + Debug.Fail("MoveToId is NYI"); return false; } public bool MoveToNamespace(string name) { - Debug.Assert(false, "MoveToNamespace is NYI"); + Debug.Fail("MoveToNamespace is NYI"); return false; } public bool MoveToNext() @@ -1000,7 +1000,7 @@ public string BaseURI { get { - Debug.Assert(false, "BaseURI is NYI"); + Debug.Fail("BaseURI is NYI"); return ""; } } @@ -1008,7 +1008,7 @@ public string XmlLang { get { - Debug.Assert(false, "XmlLang not supported"); + Debug.Fail("XmlLang not supported"); return ""; } } @@ -1594,7 +1594,7 @@ public override void WriteTo(XmlWriter w) w.WriteString(Value); break; default: - Debug.Assert(false, $"Wrong type for text-like node : {this._nodetype}"); + Debug.Fail($"Wrong type for text-like node : {this._nodetype}"); break; } } diff --git a/src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/ComInterop/VariantBuilder.cs b/src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/ComInterop/VariantBuilder.cs index 39bdcc24d96478..3f42323caee72a 100644 --- a/src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/ComInterop/VariantBuilder.cs +++ b/src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/ComInterop/VariantBuilder.cs @@ -95,7 +95,7 @@ internal Expression InitializeArgumentVariant(MemberExpression variant, Expressi return Expression.Assign(variant, Expression.Property(null, typeof(ComVariant).GetProperty(nameof(ComVariant.Null), BindingFlags.Public | BindingFlags.Static))); default: - Debug.Assert(false, "Unexpected VarEnum"); + Debug.Fail("Unexpected VarEnum"); return null; } } diff --git a/src/libraries/Microsoft.Extensions.DependencyInjection.Abstractions/src/ServiceDescriptor.cs b/src/libraries/Microsoft.Extensions.DependencyInjection.Abstractions/src/ServiceDescriptor.cs index 040b844c434c99..26c1f1007e1f25 100644 --- a/src/libraries/Microsoft.Extensions.DependencyInjection.Abstractions/src/ServiceDescriptor.cs +++ b/src/libraries/Microsoft.Extensions.DependencyInjection.Abstractions/src/ServiceDescriptor.cs @@ -330,7 +330,7 @@ internal Type GetImplementationType() } } - Debug.Assert(false, "ImplementationType, ImplementationInstance, ImplementationFactory or KeyedImplementationFactory must be non null"); + Debug.Fail("ImplementationType, ImplementationInstance, ImplementationFactory or KeyedImplementationFactory must be non null"); return null; } diff --git a/src/libraries/Microsoft.Extensions.Diagnostics/src/Metrics/ListenerSubscription.cs b/src/libraries/Microsoft.Extensions.Diagnostics/src/Metrics/ListenerSubscription.cs index 816a07c0e34dd2..533ccc15c9bf15 100644 --- a/src/libraries/Microsoft.Extensions.Diagnostics/src/Metrics/ListenerSubscription.cs +++ b/src/libraries/Microsoft.Extensions.Diagnostics/src/Metrics/ListenerSubscription.cs @@ -52,7 +52,7 @@ private void InstrumentPublished(Instrument instrument, MeterListener _) if (_instruments.ContainsKey(instrument)) { - Debug.Assert(false, "InstrumentPublished called for an instrument we're already listening to."); + Debug.Fail("InstrumentPublished called for an instrument we're already listening to."); return; } diff --git a/src/libraries/Microsoft.Extensions.Logging.Abstractions/gen/LoggerMessageGenerator.Parser.cs b/src/libraries/Microsoft.Extensions.Logging.Abstractions/gen/LoggerMessageGenerator.Parser.cs index 73e347d067112e..d245209c818693 100644 --- a/src/libraries/Microsoft.Extensions.Logging.Abstractions/gen/LoggerMessageGenerator.Parser.cs +++ b/src/libraries/Microsoft.Extensions.Logging.Abstractions/gen/LoggerMessageGenerator.Parser.cs @@ -181,7 +181,7 @@ public IReadOnlyList GetLogClasses(IEnumerable System.Data.OleDb.OleDbDataReader: 2000 IMultipleResult.GetResult(NULL, DBRESULTFLAG_DEFAULT, IID_NULL, NULL, NULL) iterations with 0 records affected. Stopping suspect infinite loop. To work-around try using ExecuteReader() and iterating through results with NextResult().\n"); + Debug.Fail(" System.Data.OleDb.OleDbDataReader: 2000 IMultipleResult.GetResult(NULL, DBRESULTFLAG_DEFAULT, IID_NULL, NULL, NULL) iterations with 0 records affected. Stopping suspect infinite loop. To work-around try using ExecuteReader() and iterating through results with NextResult().\n"); } public override bool NextResult() diff --git a/src/libraries/System.Data.OleDb/src/OleDbReferenceCollection.cs b/src/libraries/System.Data.OleDb/src/OleDbReferenceCollection.cs index 4ff89fa0c648ff..7410eb61659cd5 100644 --- a/src/libraries/System.Data.OleDb/src/OleDbReferenceCollection.cs +++ b/src/libraries/System.Data.OleDb/src/OleDbReferenceCollection.cs @@ -32,7 +32,7 @@ protected override void NotifyItem(int message, int tag, object value) } else { - Debug.Assert(false, "shouldn't be here"); + Debug.Fail("shouldn't be here"); } } diff --git a/src/libraries/System.Data.OleDb/src/OleDb_Util.cs b/src/libraries/System.Data.OleDb/src/OleDb_Util.cs index b35087409aebe4..961e0c050f0f26 100644 --- a/src/libraries/System.Data.OleDb/src/OleDb_Util.cs +++ b/src/libraries/System.Data.OleDb/src/OleDb_Util.cs @@ -43,7 +43,7 @@ internal static void CommandParameterStatus(StringBuilder builder, int index, DB break; case DBStatus.E_CANTCREATE: - Debug.Assert(false, "CommandParameterStatus: unexpected E_CANTCREATE"); + Debug.Fail("CommandParameterStatus: unexpected E_CANTCREATE"); goto default; case DBStatus.E_UNAVAILABLE: @@ -52,19 +52,19 @@ internal static void CommandParameterStatus(StringBuilder builder, int index, DB break; case DBStatus.E_PERMISSIONDENIED: - Debug.Assert(false, "CommandParameterStatus: unexpected E_PERMISSIONDENIED"); + Debug.Fail("CommandParameterStatus: unexpected E_PERMISSIONDENIED"); goto default; case DBStatus.E_INTEGRITYVIOLATION: - Debug.Assert(false, "CommandParameterStatus: unexpected E_INTEGRITYVIOLATION"); + Debug.Fail("CommandParameterStatus: unexpected E_INTEGRITYVIOLATION"); goto default; case DBStatus.E_SCHEMAVIOLATION: - Debug.Assert(false, "CommandParameterStatus: unexpected E_SCHEMAVIOLATION"); + Debug.Fail("CommandParameterStatus: unexpected E_SCHEMAVIOLATION"); goto default; case DBStatus.E_BADSTATUS: - Debug.Assert(false, "CommandParameterStatus: unexpected E_BADSTATUS"); + Debug.Fail("CommandParameterStatus: unexpected E_BADSTATUS"); goto default; case DBStatus.S_DEFAULT: diff --git a/src/libraries/System.Data.OleDb/src/RowBinding.cs b/src/libraries/System.Data.OleDb/src/RowBinding.cs index 0a9ea89cb075d9..a7f722a85e1727 100644 --- a/src/libraries/System.Data.OleDb/src/RowBinding.cs +++ b/src/libraries/System.Data.OleDb/src/RowBinding.cs @@ -54,7 +54,7 @@ internal void StartDataBlock() { if (_haveData) { - Debug.Assert(false, "previous row not yet cleared"); + Debug.Fail("previous row not yet cleared"); ResetValues(); } _haveData = true; @@ -110,7 +110,7 @@ internal OleDbHResult CreateAccessor(UnsafeNativeMethods.IAccessor iaccessor, in throw ODB.BadStatusRowAccessor(bindings[k].ColumnBindingOrdinal, (DBBindStatus)rowBindStatus[k]); } else - Debug.Assert(false, "unknown accessor buffer"); + Debug.Fail("unknown accessor buffer"); } } return hr; @@ -382,7 +382,7 @@ internal void ResetValues() case NativeDBType.VARIANT: case NativeDBType.BSTR: case NativeDBType.HCHAPTER: - Debug.Assert(false, "expected _needToReset"); + Debug.Fail("expected _needToReset"); break; } } @@ -458,7 +458,7 @@ private unsafe void ResetValues(IntPtr buffer, object? iaccessor) case NativeDBType.IUNKNOWN: break; // known, releasing RowHandle will handle lifetimes correctly default: - Debug.Assert(false, "investigate"); + Debug.Fail("investigate"); break; #endif } diff --git a/src/libraries/System.Data.OleDb/src/System/Data/Common/AdapterUtil.cs b/src/libraries/System.Data.OleDb/src/System/Data/Common/AdapterUtil.cs index 6f8526a62222dc..eafc1913bf2806 100644 --- a/src/libraries/System.Data.OleDb/src/System/Data/Common/AdapterUtil.cs +++ b/src/libraries/System.Data.OleDb/src/System/Data/Common/AdapterUtil.cs @@ -266,7 +266,7 @@ internal static ArgumentOutOfRangeException InvalidCommandType(CommandType value case CommandType.Text: case CommandType.StoredProcedure: case CommandType.TableDirect: - Debug.Assert(false, $"valid CommandType {value}"); + Debug.Fail($"valid CommandType {value}"); break; } #endif @@ -283,7 +283,7 @@ internal static ArgumentOutOfRangeException InvalidDataRowVersion(DataRowVersion case DataRowVersion.Current: case DataRowVersion.Original: case DataRowVersion.Proposed: - Debug.Assert(false, $"valid DataRowVersion {value}"); + Debug.Fail($"valid DataRowVersion {value}"); break; } #endif @@ -303,7 +303,7 @@ internal static ArgumentOutOfRangeException InvalidIsolationLevel(IsolationLevel case IsolationLevel.RepeatableRead: case IsolationLevel.Serializable: case IsolationLevel.Snapshot: - Debug.Assert(false, $"valid IsolationLevel {value}"); + Debug.Fail($"valid IsolationLevel {value}"); break; } #endif @@ -320,7 +320,7 @@ internal static ArgumentOutOfRangeException InvalidParameterDirection(ParameterD case ParameterDirection.Output: case ParameterDirection.InputOutput: case ParameterDirection.ReturnValue: - Debug.Assert(false, $"valid ParameterDirection {value}"); + Debug.Fail($"valid ParameterDirection {value}"); break; } #endif @@ -337,7 +337,7 @@ internal static ArgumentOutOfRangeException InvalidUpdateRowSource(UpdateRowSour case UpdateRowSource.OutputParameters: case UpdateRowSource.FirstReturnedRecord: case UpdateRowSource.Both: - Debug.Assert(false, $"valid UpdateRowSource {value}"); + Debug.Fail($"valid UpdateRowSource {value}"); break; } #endif diff --git a/src/libraries/System.Data.OleDb/src/System/Data/ProviderBase/DbConnectionHelper.cs b/src/libraries/System.Data.OleDb/src/System/Data/ProviderBase/DbConnectionHelper.cs index abdb2c91a9a2f1..13eee27ff776e8 100644 --- a/src/libraries/System.Data.OleDb/src/System/Data/ProviderBase/DbConnectionHelper.cs +++ b/src/libraries/System.Data.OleDb/src/System/Data/ProviderBase/DbConnectionHelper.cs @@ -294,7 +294,7 @@ internal void SetInnerConnectionEvent(DbConnectionInternal to) } else { - Debug.Assert(false, "unexpected state switch"); + Debug.Fail("unexpected state switch"); if (originalState != currentState) { OnStateChange(new StateChangeEventArgs(originalState, currentState)); diff --git a/src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/Metrics/ObservableInstrument.cs b/src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/Metrics/ObservableInstrument.cs index d718dd9867155f..10a0f188ee67cf 100644 --- a/src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/Metrics/ObservableInstrument.cs +++ b/src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/Metrics/ObservableInstrument.cs @@ -86,7 +86,7 @@ internal static IEnumerable> Observe(object callback) return listOfMeasurementsFunc(); } - Debug.Assert(false, "Execution shouldn't reach this point"); + Debug.Fail("Execution shouldn't reach this point"); return null; } diff --git a/src/libraries/System.Diagnostics.Tracing/tests/BasicEventSourceTest/EventSourceTestParser.cs b/src/libraries/System.Diagnostics.Tracing/tests/BasicEventSourceTest/EventSourceTestParser.cs index bcd204bf2f10dd..4229ebf40d0ff0 100644 --- a/src/libraries/System.Diagnostics.Tracing/tests/BasicEventSourceTest/EventSourceTestParser.cs +++ b/src/libraries/System.Diagnostics.Tracing/tests/BasicEventSourceTest/EventSourceTestParser.cs @@ -658,7 +658,7 @@ // case 0: // return x; // default: -// Debug.Assert(false, "Bad field index"); +// Debug.Fail("Bad field index"); // return null; // } // } @@ -715,7 +715,7 @@ // case 0: // return x; // default: -// Debug.Assert(false, "Bad field index"); +// Debug.Fail("Bad field index"); // return null; // } // } @@ -772,7 +772,7 @@ // case 0: // return x; // default: -// Debug.Assert(false, "Bad field index"); +// Debug.Fail("Bad field index"); // return null; // } // } @@ -829,7 +829,7 @@ // case 0: // return x; // default: -// Debug.Assert(false, "Bad field index"); +// Debug.Fail("Bad field index"); // return null; // } // } @@ -886,7 +886,7 @@ // case 0: // return arg1; // default: -// Debug.Assert(false, "Bad field index"); +// Debug.Fail("Bad field index"); // return null; // } // } @@ -947,7 +947,7 @@ // case 1: // return arg2; // default: -// Debug.Assert(false, "Bad field index"); +// Debug.Fail("Bad field index"); // return null; // } // } @@ -1012,7 +1012,7 @@ // case 2: // return arg3; // default: -// Debug.Assert(false, "Bad field index"); +// Debug.Fail("Bad field index"); // return null; // } // } @@ -1069,7 +1069,7 @@ // case 0: // return arg1; // default: -// Debug.Assert(false, "Bad field index"); +// Debug.Fail("Bad field index"); // return null; // } // } @@ -1130,7 +1130,7 @@ // case 1: // return arg2; // default: -// Debug.Assert(false, "Bad field index"); +// Debug.Fail("Bad field index"); // return null; // } // } @@ -1195,7 +1195,7 @@ // case 2: // return arg3; // default: -// Debug.Assert(false, "Bad field index"); +// Debug.Fail("Bad field index"); // return null; // } // } @@ -1252,7 +1252,7 @@ // case 0: // return s; // default: -// Debug.Assert(false, "Bad field index"); +// Debug.Fail("Bad field index"); // return null; // } // } @@ -1309,7 +1309,7 @@ // case 0: // return arg1; // default: -// Debug.Assert(false, "Bad field index"); +// Debug.Fail("Bad field index"); // return null; // } // } @@ -1370,7 +1370,7 @@ // case 1: // return arg2; // default: -// Debug.Assert(false, "Bad field index"); +// Debug.Fail("Bad field index"); // return null; // } // } @@ -1435,7 +1435,7 @@ // case 2: // return arg3; // default: -// Debug.Assert(false, "Bad field index"); +// Debug.Fail("Bad field index"); // return null; // } // } @@ -1496,7 +1496,7 @@ // case 1: // return arg2; // default: -// Debug.Assert(false, "Bad field index"); +// Debug.Fail("Bad field index"); // return null; // } // } @@ -1557,7 +1557,7 @@ // case 1: // return arg2; // default: -// Debug.Assert(false, "Bad field index"); +// Debug.Fail("Bad field index"); // return null; // } // } @@ -1622,7 +1622,7 @@ // case 2: // return arg3; // default: -// Debug.Assert(false, "Bad field index"); +// Debug.Fail("Bad field index"); // return null; // } // } @@ -1703,7 +1703,7 @@ // case 6: // return s6; // default: -// Debug.Assert(false, "Bad field index"); +// Debug.Fail("Bad field index"); // return null; // } // } @@ -1792,7 +1792,7 @@ // case 8: // return s8; // default: -// Debug.Assert(false, "Bad field index"); +// Debug.Fail("Bad field index"); // return null; // } // } @@ -1855,7 +1855,7 @@ // case 1: // return n; // default: -// Debug.Assert(false, "Bad field index"); +// Debug.Fail("Bad field index"); // return null; // } // } @@ -1918,7 +1918,7 @@ // case 1: // return n; // default: -// Debug.Assert(false, "Bad field index"); +// Debug.Fail("Bad field index"); // return null; // } // } @@ -1979,7 +1979,7 @@ // case 1: // return n; // default: -// Debug.Assert(false, "Bad field index"); +// Debug.Fail("Bad field index"); // return null; // } // } @@ -2080,7 +2080,7 @@ // case 11: // return guid; // default: -// Debug.Assert(false, "Bad field index"); +// Debug.Fail("Bad field index"); // return null; // } // } @@ -2141,7 +2141,7 @@ // case 1: // return percentage; // default: -// Debug.Assert(false, "Bad field index"); +// Debug.Fail("Bad field index"); // return null; // } // } @@ -2206,7 +2206,7 @@ // case 2: // return le; // default: -// Debug.Assert(false, "Bad field index"); +// Debug.Fail("Bad field index"); // return null; // } // } @@ -2263,7 +2263,7 @@ // case 0: // return arg1; // default: -// Debug.Assert(false, "Bad field index"); +// Debug.Fail("Bad field index"); // return null; // } // } @@ -2324,7 +2324,7 @@ // case 1: // return arg2; // default: -// Debug.Assert(false, "Bad field index"); +// Debug.Fail("Bad field index"); // return null; // } // } @@ -2381,7 +2381,7 @@ // case 0: // return dt; // default: -// Debug.Assert(false, "Bad field index"); +// Debug.Fail("Bad field index"); // return null; // } // } @@ -2438,7 +2438,7 @@ // case 0: // return message; // default: -// Debug.Assert(false, "Bad field index"); +// Debug.Fail("Bad field index"); // return null; // } // } @@ -2495,7 +2495,7 @@ // case 0: // return message; // default: -// Debug.Assert(false, "Bad field index"); +// Debug.Fail("Bad field index"); // return null; // } // } @@ -2592,7 +2592,7 @@ // case 10: // return guid; // default: -// Debug.Assert(false, "Bad field index"); +// Debug.Fail("Bad field index"); // return null; // } // } @@ -2657,7 +2657,7 @@ // case 2: // return le; // default: -// Debug.Assert(false, "Bad field index"); +// Debug.Fail("Bad field index"); // return null; // } // } diff --git a/src/libraries/System.Formats.Tar/src/System/Formats/Tar/TarEntry.cs b/src/libraries/System.Formats.Tar/src/System/Formats/Tar/TarEntry.cs index 73b158b10957bf..d59f348666b429 100644 --- a/src/libraries/System.Formats.Tar/src/System/Formats/Tar/TarEntry.cs +++ b/src/libraries/System.Formats.Tar/src/System/Formats/Tar/TarEntry.cs @@ -478,7 +478,7 @@ private void CreateNonRegularFile(string filePath, string? linkTargetPath) case TarEntryType.GlobalExtendedAttributes: case TarEntryType.LongPath: case TarEntryType.LongLink: - Debug.Assert(false, $"Metadata entry type should not be visible: '{EntryType}'"); + Debug.Fail($"Metadata entry type should not be visible: '{EntryType}'"); break; case TarEntryType.MultiVolume: diff --git a/src/libraries/System.Private.CoreLib/src/System/Globalization/CultureData.Icu.cs b/src/libraries/System.Private.CoreLib/src/System/Globalization/CultureData.Icu.cs index 2d6f5f687fa9eb..a95226e089686e 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Globalization/CultureData.Icu.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Globalization/CultureData.Icu.cs @@ -490,7 +490,7 @@ private static string IcuGetListSeparator(string? cultureName) return ",,"; default: - Debug.Assert(false, "[CultureData.IcuGetListSeparator] Unexpected ListSeparator value."); + Debug.Fail("[CultureData.IcuGetListSeparator] Unexpected ListSeparator value."); break; } } diff --git a/src/libraries/System.Private.CoreLib/src/System/Reflection/FieldAccessor.cs b/src/libraries/System.Private.CoreLib/src/System/Reflection/FieldAccessor.cs index 82e485fab51ff8..e4c17f18934b7f 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Reflection/FieldAccessor.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Reflection/FieldAccessor.cs @@ -202,7 +202,7 @@ private void Initialize() throw new FieldAccessException(); default: - Debug.Assert(false, "Unknown enum value"); + Debug.Fail("Unknown enum value"); return null; } } diff --git a/src/libraries/System.Private.CoreLib/src/System/WeakReference.T.cs b/src/libraries/System.Private.CoreLib/src/System/WeakReference.T.cs index 07e854c4c7aa8e..eb29066c1cb54c 100644 --- a/src/libraries/System.Private.CoreLib/src/System/WeakReference.T.cs +++ b/src/libraries/System.Private.CoreLib/src/System/WeakReference.T.cs @@ -166,7 +166,7 @@ private T? Target #pragma warning disable CA1821 // Remove empty Finalizers ~WeakReference() { - Debug.Assert(false, " WeakReference finalizer should never run"); + Debug.Fail(" WeakReference finalizer should never run"); } #pragma warning restore CA1821 // Remove empty Finalizers diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Core/XsdValidatingReaderAsync.cs b/src/libraries/System.Private.Xml/src/System/Xml/Core/XsdValidatingReaderAsync.cs index 1900d484a133e9..b63d06714b02d3 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Core/XsdValidatingReaderAsync.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Core/XsdValidatingReaderAsync.cs @@ -153,7 +153,7 @@ public override async Task ReadElementContentAsStringAsync() } else { - Debug.Assert(false, $"{nameof(typedValue)} should never be null"); + Debug.Fail($"{nameof(typedValue)} should never be null"); return typedValue as string; } } diff --git a/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/TypeSystem/AssemblyReference.cs b/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/TypeSystem/AssemblyReference.cs index b3b9a5bd5f68f5..bae3361ba7c9ae 100644 --- a/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/TypeSystem/AssemblyReference.cs +++ b/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/TypeSystem/AssemblyReference.cs @@ -172,7 +172,7 @@ private static StringHandle.VirtualIndex GetVirtualNameIndex(AssemblyReferenceHa return StringHandle.VirtualIndex.System_Numerics_Vectors; } - Debug.Assert(false, "Unexpected virtual index value"); + Debug.Fail("Unexpected virtual index value"); return 0; } diff --git a/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/TypeSystem/CustomAttribute.cs b/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/TypeSystem/CustomAttribute.cs index dfd9428d067d38..4de5dd3e1f0a01 100644 --- a/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/TypeSystem/CustomAttribute.cs +++ b/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/TypeSystem/CustomAttribute.cs @@ -138,7 +138,7 @@ private BlobHandle GetProjectedValue(CustomAttributeValueTreatment treatment) break; default: - Debug.Assert(false, $"Unexpected treatment {treatment}"); + Debug.Fail($"Unexpected treatment {treatment}"); return default(BlobHandle); } diff --git a/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/TypeSystem/TypeReference.cs b/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/TypeSystem/TypeReference.cs index 7c19d7d73e19f3..6646ec21d28c87 100644 --- a/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/TypeSystem/TypeReference.cs +++ b/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/TypeSystem/TypeReference.cs @@ -109,7 +109,7 @@ private EntityHandle GetProjectedResolutionScope() return MetadataReader.GetProjectedAssemblyRef(RowId); } - Debug.Assert(false, "Unknown TypeRef treatment"); + Debug.Fail("Unknown TypeRef treatment"); return default(AssemblyReferenceHandle); } @@ -137,7 +137,7 @@ private StringHandle GetProjectedNamespace() return MetadataReader.GetProjectedNamespace(RowId); } - Debug.Assert(false, "Unknown TypeRef treatment"); + Debug.Fail("Unknown TypeRef treatment"); return default(StringHandle); } diff --git a/src/libraries/System.Security.AccessControl/src/System/Security/AccessControl/ACL.cs b/src/libraries/System.Security.AccessControl/src/System/Security/AccessControl/ACL.cs index 13d19509d57822..0cbf3e6a8ec4a7 100644 --- a/src/libraries/System.Security.AccessControl/src/System/Security/AccessControl/ACL.cs +++ b/src/libraries/System.Security.AccessControl/src/System/Security/AccessControl/ACL.cs @@ -337,7 +337,7 @@ internal void SetBinaryForm(byte[] binaryForm, int offset) // Binary length of an ace must ALWAYS be divisible by 4. // - Debug.Assert(false, "aceLength % 4 != 0"); + Debug.Fail("aceLength % 4 != 0"); // Replacing SystemException with InvalidOperationException. This code path // indicates a bad ACE, but I don't know of a great exception to represent that. // InvalidOperation seems to be the closest, though it's definitely not exactly @@ -480,7 +480,7 @@ public override void GetBinaryForm(byte[] binaryForm, int offset) // Binary length of an ace must ALWAYS be divisible by 4. // - Debug.Assert(false, "aceLength % 4 != 0"); + Debug.Fail("aceLength % 4 != 0"); // Replacing SystemException with InvalidOperationException. This code path // indicates a bad ACE, but I don't know of a great exception to represent that. // InvalidOperation seems to be the closest, though it's definitely not exactly @@ -516,7 +516,7 @@ public override GenericAce this[int index] // Binary length of an ace must ALWAYS be divisible by 4. // - Debug.Assert(false, "aceLength % 4 != 0"); + Debug.Fail("aceLength % 4 != 0"); // Replacing SystemException with InvalidOperationException. This code path // indicates a bad ACE, but I don't know of a great exception to represent that. // InvalidOperation seems to be the closest, though it's definitely not exactly @@ -1684,7 +1684,7 @@ private bool CanonicalCheck(bool isDacl) // Only allow and deny ACEs are allowed here // - Debug.Assert(false, "Audit and alarm ACEs must have been stripped by remove-meaningless logic"); + Debug.Fail("Audit and alarm ACEs must have been stripped by remove-meaningless logic"); return false; } } @@ -1762,7 +1762,7 @@ private bool CanonicalCheck(bool isDacl) // Only audit and alarm ACEs are allowed here // - Debug.Assert(false, "Allow and deny ACEs must have been stripped by remove-meaningless logic"); + Debug.Fail("Allow and deny ACEs must have been stripped by remove-meaningless logic"); return false; } } diff --git a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/HKDF.cs b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/HKDF.cs index 051db760e204fb..9b33aea297a77c 100644 --- a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/HKDF.cs +++ b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/HKDF.cs @@ -261,7 +261,7 @@ private static void GetHashAndReset(IncrementalHash hmac, Span output) { if (!hmac.TryGetHashAndReset(output, out int bytesWritten)) { - Debug.Assert(false, "HMAC operation failed unexpectedly"); + Debug.Fail("HMAC operation failed unexpectedly"); throw new CryptographicException(SR.Arg_CryptographyException); } diff --git a/src/libraries/System.ServiceModel.Syndication/tests/Utils/XmlDiff.cs b/src/libraries/System.ServiceModel.Syndication/tests/Utils/XmlDiff.cs index fdbc744a1ba5cf..ae95c6b55baea4 100644 --- a/src/libraries/System.ServiceModel.Syndication/tests/Utils/XmlDiff.cs +++ b/src/libraries/System.ServiceModel.Syndication/tests/Utils/XmlDiff.cs @@ -365,7 +365,7 @@ private bool CompareChildren(XmlDiffNode sourceNode, XmlDiffNode targetNode) else { //Both SourceRead and TargetRead is NULL - Debug.Assert(false, "Impossible Situation for comparison"); + Debug.Fail("Impossible Situation for comparison"); } } return flag; diff --git a/src/libraries/System.ServiceModel.Syndication/tests/Utils/XmlDiffDocument.cs b/src/libraries/System.ServiceModel.Syndication/tests/Utils/XmlDiffDocument.cs index a3ca18c21d35fa..8a2086e6c5af24 100644 --- a/src/libraries/System.ServiceModel.Syndication/tests/Utils/XmlDiffDocument.cs +++ b/src/libraries/System.ServiceModel.Syndication/tests/Utils/XmlDiffDocument.cs @@ -164,7 +164,7 @@ internal NodePosition ComparePosition(XmlDiffNode node1, XmlDiffNode node2) else { //something really wrong here, what should we do??? - Debug.Assert(false, "ComparePosition meets an undecision situation."); + Debug.Fail("ComparePosition meets an undecision situation."); return NodePosition.Unknown; } } @@ -753,7 +753,7 @@ public override string GetAttribute(string localName, string namespaceURI) public override string GetNamespace(string name) { - Debug.Assert(false, "GetNamespace is NYI"); + Debug.Fail("GetNamespace is NYI"); return ""; } @@ -871,13 +871,13 @@ public override bool MoveToFirstNamespace(XPathNamespaceScope namespaceScope) public override bool MoveToId(string id) { - Debug.Assert(false, "MoveToId is NYI"); + Debug.Fail("MoveToId is NYI"); return false; } public override bool MoveToNamespace(string name) { - Debug.Assert(false, "MoveToNamespace is NYI"); + Debug.Fail("MoveToNamespace is NYI"); return false; } @@ -1094,7 +1094,7 @@ public override string BaseURI { get { - Debug.Assert(false, "BaseURI is NYI"); + Debug.Fail("BaseURI is NYI"); return ""; } } @@ -1103,7 +1103,7 @@ public override string XmlLang { get { - Debug.Assert(false, "XmlLang not supported"); + Debug.Fail("XmlLang not supported"); return ""; } } @@ -1612,7 +1612,7 @@ public override void WriteTo(XmlWriter w) w.WriteString(Value); break; default: - Debug.Assert(false, $"Wrong type for text-like node : {_nodetype}"); + Debug.Fail($"Wrong type for text-like node : {_nodetype}"); break; } } diff --git a/src/libraries/System.Speech/src/Internal/SrgsCompiler/CfgSemanticTag.cs b/src/libraries/System.Speech/src/Internal/SrgsCompiler/CfgSemanticTag.cs index 1d1568755f5ac0..b56fd883c307f2 100644 --- a/src/libraries/System.Speech/src/Internal/SrgsCompiler/CfgSemanticTag.cs +++ b/src/libraries/System.Speech/src/Internal/SrgsCompiler/CfgSemanticTag.cs @@ -72,7 +72,7 @@ internal CfgSemanticTag(StringBlob symbols, CfgGrammar.CfgProperty property) break; default: - System.Diagnostics.Debug.Assert(false, "Unknown Semantic Tag type"); + System.Diagnostics.Debug.Fail("Unknown Semantic Tag type"); break; } #pragma warning restore 0618 diff --git a/src/libraries/System.Speech/src/Internal/SrgsCompiler/RuleRef.cs b/src/libraries/System.Speech/src/Internal/SrgsCompiler/RuleRef.cs index 4538990bbb3d62..379ccebe981759 100644 --- a/src/libraries/System.Speech/src/Internal/SrgsCompiler/RuleRef.cs +++ b/src/libraries/System.Speech/src/Internal/SrgsCompiler/RuleRef.cs @@ -125,7 +125,7 @@ internal void InitSpecialRuleRef(Backend backend, ParseElementCollection parent) break; default: - System.Diagnostics.Debug.Assert(false, "Unknown special ruleref type"); + System.Diagnostics.Debug.Fail("Unknown special ruleref type"); break; } } diff --git a/src/libraries/System.Speech/src/Internal/SrgsParser/SrgsDocumentParser.cs b/src/libraries/System.Speech/src/Internal/SrgsParser/SrgsDocumentParser.cs index febe5109132eef..ba10c0fd0795c2 100644 --- a/src/libraries/System.Speech/src/Internal/SrgsParser/SrgsDocumentParser.cs +++ b/src/libraries/System.Speech/src/Internal/SrgsParser/SrgsDocumentParser.cs @@ -344,7 +344,7 @@ private void ProcessChildNodes(SrgsElement srgsElement, IElement parent, IRule r } else { - System.Diagnostics.Debug.Assert(false, "Unsupported Srgs element"); + System.Diagnostics.Debug.Fail("Unsupported Srgs element"); XmlParser.ThrowSrgsException(SRID.InvalidElement); } diff --git a/src/libraries/System.Speech/src/Internal/Synthesis/AudioDeviceOut.cs b/src/libraries/System.Speech/src/Internal/Synthesis/AudioDeviceOut.cs index 216e3149ac651a..c077b808ef1944 100644 --- a/src/libraries/System.Speech/src/Internal/Synthesis/AudioDeviceOut.cs +++ b/src/libraries/System.Speech/src/Internal/Synthesis/AudioDeviceOut.cs @@ -194,7 +194,7 @@ internal override void Pause() Interop.WinMM.MMSYSERR result = Interop.WinMM.waveOutPause(_hwo); if (result != Interop.WinMM.MMSYSERR.NOERROR) { - System.Diagnostics.Debug.Assert(false, ((int)result).ToString(System.Globalization.CultureInfo.InvariantCulture)); + System.Diagnostics.Debug.Fail(((int)result).ToString(System.Globalization.CultureInfo.InvariantCulture)); } } _fPaused = true; diff --git a/src/libraries/System.Speech/src/Internal/Synthesis/VoiceSynthesis.cs b/src/libraries/System.Speech/src/Internal/Synthesis/VoiceSynthesis.cs index f22f70c484751d..0016455f76f357 100644 --- a/src/libraries/System.Speech/src/Internal/Synthesis/VoiceSynthesis.cs +++ b/src/libraries/System.Speech/src/Internal/Synthesis/VoiceSynthesis.cs @@ -804,7 +804,7 @@ private void ThreadProc() #pragma warning restore 6500 default: - System.Diagnostics.Debug.Assert(false, "Unknown Action!"); + System.Diagnostics.Debug.Fail("Unknown Action!"); break; } } diff --git a/src/libraries/System.Speech/src/Recognition/SrgsGrammar/SrgsGrammar.cs b/src/libraries/System.Speech/src/Recognition/SrgsGrammar/SrgsGrammar.cs index 0183a01dfe3c4c..469ce61d829b03 100644 --- a/src/libraries/System.Speech/src/Recognition/SrgsGrammar/SrgsGrammar.cs +++ b/src/libraries/System.Speech/src/Recognition/SrgsGrammar/SrgsGrammar.cs @@ -88,7 +88,7 @@ internal void WriteSrgs(XmlWriter writer) break; default: - System.Diagnostics.Debug.Assert(false, "Unknown Tag Format!!!"); + System.Diagnostics.Debug.Fail("Unknown Tag Format!!!"); break; } diff --git a/src/libraries/System.Threading.Tasks.Dataflow/src/Base/DataflowBlock.cs b/src/libraries/System.Threading.Tasks.Dataflow/src/Base/DataflowBlock.cs index 7b7064f948f160..6568f2b267d0d0 100644 --- a/src/libraries/System.Threading.Tasks.Dataflow/src/Base/DataflowBlock.cs +++ b/src/libraries/System.Threading.Tasks.Dataflow/src/Base/DataflowBlock.cs @@ -333,11 +333,11 @@ public static Task SendAsync(this ITargetBlock target, TIn #if DEBUG case DataflowMessageStatus.Postponed: - Debug.Assert(false, "A message should never be postponed when no source has been provided"); + Debug.Fail("A message should never be postponed when no source has been provided"); break; case DataflowMessageStatus.NotAvailable: - Debug.Assert(false, "The message should never be missed, as it's offered to only this one target"); + Debug.Fail("The message should never be missed, as it's offered to only this one target"); break; #endif } @@ -617,7 +617,7 @@ internal void OfferToTarget() break; #if DEBUG case DataflowMessageStatus.NotAvailable: - Debug.Assert(false, "The message should never be missed, as it's offered to only this one target"); + Debug.Fail("The message should never be missed, as it's offered to only this one target"); break; // If the message was postponed, the source may or may not be complete yet. Nothing to validate. // Treat an improper DataflowMessageStatus as postponed and do nothing. @@ -1340,7 +1340,7 @@ private void CleanupAndComplete(ReceiveCoreByLinkingCleanupReason reason) }, this, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default); break; default: - Debug.Assert(false, "Invalid linking cleanup reason specified."); + Debug.Fail("Invalid linking cleanup reason specified."); goto case ReceiveCoreByLinkingCleanupReason.Cancellation; // Task final state: Faulted diff --git a/src/libraries/System.Threading.Tasks.Dataflow/src/Blocks/BroadcastBlock.cs b/src/libraries/System.Threading.Tasks.Dataflow/src/Blocks/BroadcastBlock.cs index a6f4c4f0b06827..79c951a79e3d01 100644 --- a/src/libraries/System.Threading.Tasks.Dataflow/src/Blocks/BroadcastBlock.cs +++ b/src/libraries/System.Threading.Tasks.Dataflow/src/Blocks/BroadcastBlock.cs @@ -813,7 +813,7 @@ private void OfferMessageToTarget(DataflowMessageHeader header, TOutput message, break; case DataflowMessageStatus.NotAvailable: - Debug.Assert(false, "Messages from a Broadcast should never be missed."); + Debug.Fail("Messages from a Broadcast should never be missed."); break; // No action required for Postponed or Declined } diff --git a/src/libraries/System.Threading.Tasks.Dataflow/src/Blocks/TransformManyBlock.cs b/src/libraries/System.Threading.Tasks.Dataflow/src/Blocks/TransformManyBlock.cs index 4acb1ce404b12f..13f762163f3c02 100644 --- a/src/libraries/System.Threading.Tasks.Dataflow/src/Blocks/TransformManyBlock.cs +++ b/src/libraries/System.Threading.Tasks.Dataflow/src/Blocks/TransformManyBlock.cs @@ -292,7 +292,7 @@ private void AsyncCompleteProcessMessageWithTask( break; default: - Debug.Assert(false, "The task should have been in a final state."); + Debug.Fail("The task should have been in a final state."); break; } diff --git a/src/libraries/System.Threading.Tasks.Dataflow/src/Internal/SourceCore.cs b/src/libraries/System.Threading.Tasks.Dataflow/src/Internal/SourceCore.cs index 6ba06b86a8424c..05506218c3a0a2 100644 --- a/src/libraries/System.Threading.Tasks.Dataflow/src/Internal/SourceCore.cs +++ b/src/libraries/System.Threading.Tasks.Dataflow/src/Internal/SourceCore.cs @@ -625,7 +625,7 @@ private bool OfferToTargets(ITargetBlock? linkToTarget = null) if (_nextMessageId.Value != header.Id || !_messages.TryDequeue(out dropped)) // remove the next message { - Debug.Assert(false, "The target did not follow the protocol."); + Debug.Fail("The target did not follow the protocol."); } _nextMessageId.Value++; diff --git a/src/libraries/System.Transactions.Local/src/System/Transactions/Oletx/OletxVolatileEnlistment.cs b/src/libraries/System.Transactions.Local/src/System/Transactions/Oletx/OletxVolatileEnlistment.cs index 8074d51ac5aa94..dee045aba08c03 100644 --- a/src/libraries/System.Transactions.Local/src/System/Transactions/Oletx/OletxVolatileEnlistment.cs +++ b/src/libraries/System.Transactions.Local/src/System/Transactions/Oletx/OletxVolatileEnlistment.cs @@ -308,7 +308,7 @@ internal override void OutcomeFromTransaction(TransactionStatus outcome) InDoubt(); break; default: - Debug.Assert(false, "OletxPhase0VolatileEnlistmentContainer.OutcomeFromTransaction, outcome is not Commited or Aborted or InDoubt"); + Debug.Fail("OletxPhase0VolatileEnlistmentContainer.OutcomeFromTransaction, outcome is not Commited or Aborted or InDoubt"); break; } } @@ -336,7 +336,7 @@ internal override void Committed() etwLog.InternalError(); } - Debug.Assert(false, "OletxPhase1VolatileEnlistmentContainer.Committed, enlistmentList element is not an OletxVolatileEnlistment."); + Debug.Fail("OletxPhase1VolatileEnlistmentContainer.Committed, enlistmentList element is not an OletxVolatileEnlistment."); throw new InvalidOperationException(SR.InternalError); } @@ -368,7 +368,7 @@ internal override void Aborted() etwLog.InternalError(); } - Debug.Assert(false, "OletxPhase1VolatileEnlistmentContainer.Aborted, enlistmentList element is not an OletxVolatileEnlistment."); + Debug.Fail("OletxPhase1VolatileEnlistmentContainer.Aborted, enlistmentList element is not an OletxVolatileEnlistment."); throw new InvalidOperationException(SR.InternalError); } diff --git a/src/tests/JIT/Directed/StructABI/structreturn.cs b/src/tests/JIT/Directed/StructABI/structreturn.cs index a9d09afa835c5e..4f9108f5e29224 100644 --- a/src/tests/JIT/Directed/StructABI/structreturn.cs +++ b/src/tests/JIT/Directed/StructABI/structreturn.cs @@ -1373,7 +1373,7 @@ static void TestReturnVectorT() try { var a = ReturnVectorT2(new Vector4(1)); - Debug.Assert(false, "unreachable"); + Debug.Fail("unreachable"); } catch (System.NotSupportedException) { @@ -1381,7 +1381,7 @@ static void TestReturnVectorT() try { var a = ReturnVectorT2>(new VectorTWrapperWrapper()); - Debug.Assert(false, "unreachable"); + Debug.Fail("unreachable"); } catch (System.NotSupportedException) { diff --git a/src/tests/JIT/Regression/JitBlue/GitHub_39823/GitHub_39823.cs b/src/tests/JIT/Regression/JitBlue/GitHub_39823/GitHub_39823.cs index 488a79557d4a04..5ffdbee2a2a906 100644 --- a/src/tests/JIT/Regression/JitBlue/GitHub_39823/GitHub_39823.cs +++ b/src/tests/JIT/Regression/JitBlue/GitHub_39823/GitHub_39823.cs @@ -30,7 +30,7 @@ public static unsafe int TestEntryPoint() try { TestUnusedObjCopy((IntsWrapped*)0); - Debug.Assert(false, "unreachable"); + Debug.Fail("unreachable"); } catch {