Skip to content

Commit

Permalink
Search/replace Debug.Assert(false, => Debug.Fail( (dotnet#4782)
Browse files Browse the repository at this point in the history
  • Loading branch information
jkotas authored and A-And committed Oct 31, 2017
1 parent 28947a8 commit 4933d30
Show file tree
Hide file tree
Showing 65 changed files with 108 additions and 108 deletions.
2 changes: 1 addition & 1 deletion src/Common/src/Internal/Runtime/EETypeBuilderHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ private static CorElementType ComputeRhCorElementType(TypeDesc type)
break;
}

Debug.Assert(false, "Primitive type value expected.");
Debug.Fail("Primitive type value expected.");
return 0;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ public void VerifyUnifierConsistency()
if (walk2 != -1)
walk2 = _entries[walk2]._next;
if (walk1 == walk2 && walk2 != -1)
Debug.Assert(false, "Bucket " + bucket + " has a cycle in its linked list.");
Debug.Fail("Bucket " + bucket + " has a cycle in its linked list.");
}
}
// The assertion is "<=" rather than "==" because we allow an entry to "leak" until the next resize if
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ public void Add(K key, int hashCode, V value)
{
V heyYoureSupposedToBeDead;
if (_entries[idx]._weakValue.TryGetTarget(out heyYoureSupposedToBeDead))
Debug.Assert(false, "Add: You were supposed to verify inside the lock that this entry's weak reference had already expired!");
Debug.Fail("Add: You were supposed to verify inside the lock that this entry's weak reference had already expired!");
}
#endif //DEBUG
_entries[idx]._weakValue = new WeakReference<V>(value, trackResurrection: false);
Expand Down Expand Up @@ -367,7 +367,7 @@ public void VerifyUnifierConsistency()
if (walk2 != -1)
walk2 = _entries[walk2]._next;
if (walk1 == walk2 && walk2 != -1)
Debug.Assert(false, "Bucket " + bucket + " has a cycle in its linked list.");
Debug.Fail("Bucket " + bucket + " has a cycle in its linked list.");
}
}
// The assertion is "<=" rather than "==" because we allow an entry to "leak" until the next resize if
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ public void VerifyUnifierConsistency()
if (walk2 != -1)
walk2 = _entries[walk2]._next;
if (walk1 == walk2 && walk2 != -1)
Debug.Assert(false, "Bucket " + bucket + " has a cycle in its linked list.");
Debug.Fail("Bucket " + bucket + " has a cycle in its linked list.");
}
}
// The assertion is "<=" rather than "==" because we allow an entry to "leak" until the next resize if
Expand Down
2 changes: 1 addition & 1 deletion src/Common/src/System/SR.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ private static string InternalGetResourceString(string key)
{
if (key == null || key.Length == 0)
{
Debug.Assert(false, "SR::GetResourceString with null or empty key. Bug in caller, or weird recursive loading problem?");
Debug.Fail("SR::GetResourceString with null or empty key. Bug in caller, or weird recursive loading problem?");
return key;
}

Expand Down
4 changes: 2 additions & 2 deletions src/Common/src/TypeSystem/Canon/GenericParameterDesc.Canon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ public partial class GenericParameterDesc
{
public sealed override bool IsCanonicalSubtype(CanonicalFormKind policy)
{
Debug.Assert(false, "IsCanonicalSubtype of an indefinite type");
Debug.Fail("IsCanonicalSubtype of an indefinite type");
return false;
}

protected sealed override TypeDesc ConvertToCanonFormImpl(CanonicalFormKind kind)
{
Debug.Assert(false, "ConvertToCanonFormImpl for an indefinite type");
Debug.Fail("ConvertToCanonFormImpl for an indefinite type");
return this;
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/Common/src/TypeSystem/Canon/SignatureVariable.Canon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ partial class SignatureTypeVariable
{
public override bool IsCanonicalSubtype(CanonicalFormKind policy)
{
Debug.Assert(false, "IsCanonicalSubtype of an indefinite type");
Debug.Fail("IsCanonicalSubtype of an indefinite type");
return false;
}

protected override TypeDesc ConvertToCanonFormImpl(CanonicalFormKind kind)
{
Debug.Assert(false, "ConvertToCanonFormImpl for an indefinite type");
Debug.Fail("ConvertToCanonFormImpl for an indefinite type");
return this;
}
}
Expand All @@ -27,13 +27,13 @@ partial class SignatureMethodVariable
{
public override bool IsCanonicalSubtype(CanonicalFormKind policy)
{
Debug.Assert(false, "IsCanonicalSubtype of an indefinite type");
Debug.Fail("IsCanonicalSubtype of an indefinite type");
return false;
}

protected override TypeDesc ConvertToCanonFormImpl(CanonicalFormKind kind)
{
Debug.Assert(false, "ConvertToCanonFormImpl for an indefinite type");
Debug.Fail("ConvertToCanonFormImpl for an indefinite type");
return this;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,7 @@ public override DefType ComputeHomogeneousFloatAggregateElementType(DefType type
break;

default:
Debug.Assert(false, "Why is IsHfa true on this type?");
Debug.Fail("Why is IsHfa true on this type?");
return null;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Common/src/TypeSystem/Common/ThrowHelper.Common.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public static string Module(ModuleDesc module)
}
else
{
Debug.Assert(false, "Multi-module assemblies");
Debug.Fail("Multi-module assemblies");
return module.ToString();
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Common/src/TypeSystem/Common/TypeSystemHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public static MethodDesc FindMethodOnTypeWithMatchingTypicalMethod(this TypeDesc
targetOrBase = targetOrBase.BaseType;
} while (targetOrBase != null);

Debug.Assert(false, "method has no related type in the type hierarchy of type");
Debug.Fail("method has no related type in the type hierarchy of type");
return null;
}

Expand Down
4 changes: 2 additions & 2 deletions src/Common/src/TypeSystem/Ecma/EcmaType.MethodImpls.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public override MethodImplRecord[] FindMethodsImplWithMatchingDeclName(string de
break;

default:
Debug.Assert(false, "unexpected methodDeclHandleKind");
Debug.Fail("unexpected methodDeclHandleKind");
break;
}

Expand Down Expand Up @@ -113,7 +113,7 @@ protected override MethodImplRecord[] ComputeVirtualMethodImplsForType()
break;

default:
Debug.Assert(false, "unexpected methodDeclHandleKind");
Debug.Fail("unexpected methodDeclHandleKind");
break;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ private string NamePrefix
case DelegateMarshallingMethodThunkKind.ForwardNativeFunctionWrapper:
return "ForwardNativeFunctionWrapper";
default:
System.Diagnostics.Debug.Assert(false, "Unexpected DelegateMarshallingMethodThunkKind.");
System.Diagnostics.Debug.Fail("Unexpected DelegateMarshallingMethodThunkKind.");
return String.Empty;
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/Common/src/TypeSystem/IL/Stubs/ILEmitter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ public void EmitLdInd(TypeDesc type)
Emit(ILOpcode.ldobj, _emitter.NewToken(type));
break;
default:
Debug.Assert(false, "Unexpected TypeDesc category");
Debug.Fail("Unexpected TypeDesc category");
break;
}
}
Expand Down Expand Up @@ -305,7 +305,7 @@ public void EmitStInd(TypeDesc type)
Emit(ILOpcode.stobj, _emitter.NewToken(type));
break;
default:
Debug.Assert(false, "Unexpected TypeDesc category");
Debug.Fail("Unexpected TypeDesc category");
break;
}
}
Expand Down Expand Up @@ -355,7 +355,7 @@ public void EmitStElem(TypeDesc type)
Emit(ILOpcode.stelem, _emitter.NewToken(type));
break;
default:
Debug.Assert(false, "Unexpected TypeDesc category");
Debug.Fail("Unexpected TypeDesc category");
break;
}
}
Expand Down Expand Up @@ -405,7 +405,7 @@ public void EmitLdElem(TypeDesc type)
Emit(ILOpcode.ldelem, _emitter.NewToken(type));
break;
default:
Debug.Assert(false, "Unexpected TypeDesc category");
Debug.Fail("Unexpected TypeDesc category");
break;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Common/src/TypeSystem/IL/Stubs/PInvokeILEmitter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ private void EmitDelegateCall(DelegateMarshallingMethodThunk delegateMethod, PIn
}
else
{
Debug.Assert(false, "Unexpected DelegateMarshallingMethodThunkKind");
Debug.Fail("Unexpected DelegateMarshallingMethodThunkKind");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ private string NamePrefix
case StructMarshallingThunkType.Cleanup:
return "Cleanup";
default:
System.Diagnostics.Debug.Assert(false, "Unexpected Struct marshalling thunk type");
System.Diagnostics.Debug.Fail("Unexpected Struct marshalling thunk type");
return string.Empty;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Common/src/TypeSystem/Interop/IL/Marshaller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ public void StoreValue(ILCodeStream stream)
switch (_homeType)
{
case HomeType.Arg:
Debug.Assert(false, "Unexpectting setting value on non-byref arg");
Debug.Fail("Unexpectting setting value on non-byref arg");
break;
case HomeType.Local:
stream.EmitStLoc(_var);
Expand Down
2 changes: 1 addition & 1 deletion src/Common/src/TypeSystem/Interop/MethodDesc.Interop.cs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ public MethodSignatureFlags UnmanagedCallingConvention
_attributes |= PInvokeAttributes.CallingConventionThisCall;
break;
default:
System.Diagnostics.Debug.Assert(false, "Unexpected Unmanaged Calling Convention.");
System.Diagnostics.Debug.Fail("Unexpected Unmanaged Calling Convention.");
break;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ protected override MethodImplRecord[] ComputeVirtualMethodImplsForType()
break;

default:
Debug.Assert(false, "unexpected methodDeclHandleType");
Debug.Fail("unexpected methodDeclHandleType");
break;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public sealed override bool IsRuntimeDeterminedSubtype
{
get
{
Debug.Assert(false, "IsRuntimeDeterminedSubtype of an indefinite type");
Debug.Fail("IsRuntimeDeterminedSubtype of an indefinite type");
return false;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public sealed override bool IsRuntimeDeterminedSubtype
{
get
{
Debug.Assert(false, "IsRuntimeDeterminedSubtype of an indefinite type");
Debug.Fail("IsRuntimeDeterminedSubtype of an indefinite type");
return false;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public AssemblyName GetName()

public override MetadataType GetType(string nameSpace, string name, bool throwIfNotFound = true)
{
Debug.Assert(false, "Resolving a TypeRef in the compiler generated assembly?");
Debug.Fail("Resolving a TypeRef in the compiler generated assembly?");

if (throwIfNotFound)
ThrowHelper.ThrowTypeLoadException(nameSpace, name, this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ protected override bool CompareValueToValue(ModuleData value1, ModuleData value2
}
protected override ModuleData CreateValueFromKey(EcmaModule key)
{
Debug.Assert(false, "CreateValueFromKey not supported");
Debug.Fail("CreateValueFromKey not supported");
return null;
}
}
Expand Down Expand Up @@ -90,7 +90,7 @@ protected override bool CompareValueToValue(ModuleData value1, ModuleData value2
}
protected override ModuleData CreateValueFromKey(string key)
{
Debug.Assert(false, "CreateValueFromKey not supported");
Debug.Fail("CreateValueFromKey not supported");
return null;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public ISymbolNode GetTargetNode(NodeFactory factory)
return factory.RuntimeMethodHandle(TargetMethod);

case TargetKind.VTableLookup:
Debug.Assert(false, "Need to do runtime lookup");
Debug.Fail("Need to do runtime lookup");
return null;

default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ public FieldOffsetGenericLookupResult(FieldDesc field)

public override ISymbolNode GetTarget(NodeFactory factory, GenericLookupResultContext dictionary)
{
Debug.Assert(false, "GetTarget for a FieldOffsetGenericLookupResult doesn't make sense. It isn't a pointer being emitted");
Debug.Fail("GetTarget for a FieldOffsetGenericLookupResult doesn't make sense. It isn't a pointer being emitted");
return null;
}

Expand Down Expand Up @@ -435,13 +435,13 @@ public VTableOffsetGenericLookupResult(MethodDesc method)

public override ISymbolNode GetTarget(NodeFactory factory, GenericLookupResultContext dictionary)
{
Debug.Assert(false, "GetTarget for a VTableOffsetGenericLookupResult doesn't make sense. It isn't a pointer being emitted");
Debug.Fail("GetTarget for a VTableOffsetGenericLookupResult doesn't make sense. It isn't a pointer being emitted");
return null;
}

public override void EmitDictionaryEntry(ref ObjectDataBuilder builder, NodeFactory factory, GenericLookupResultContext dictionary, GenericDictionaryNode dictionaryNode)
{
Debug.Assert(false, "VTableOffset contents should only be generated into generic dictionaries at runtime");
Debug.Fail("VTableOffset contents should only be generated into generic dictionaries at runtime");
builder.EmitNaturalInt(0);
}

Expand Down Expand Up @@ -1436,13 +1436,13 @@ public CallingConventionConverterLookupResult(CallingConventionConverterKey call

public override ISymbolNode GetTarget(NodeFactory factory, GenericLookupResultContext dictionary)
{
Debug.Assert(false, "GetTarget for a CallingConventionConverterLookupResult doesn't make sense. It isn't a pointer being emitted");
Debug.Fail("GetTarget for a CallingConventionConverterLookupResult doesn't make sense. It isn't a pointer being emitted");
return null;
}

public override void EmitDictionaryEntry(ref ObjectDataBuilder builder, NodeFactory factory, GenericLookupResultContext dictionary, GenericDictionaryNode dictionaryNode)
{
Debug.Assert(false, "CallingConventionConverterLookupResult contents should only be generated into generic dictionaries at runtime");
Debug.Fail("CallingConventionConverterLookupResult contents should only be generated into generic dictionaries at runtime");
builder.EmitNaturalInt(0);
}

Expand Down Expand Up @@ -1499,7 +1499,7 @@ public TypeSizeLookupResult(TypeDesc type)
}
public override ISymbolNode GetTarget(NodeFactory factory, GenericLookupResultContext dictionary)
{
Debug.Assert(false, "GetTarget for a TypeSizeLookupResult doesn't make sense. It isn't a pointer being emitted");
Debug.Fail("GetTarget for a TypeSizeLookupResult doesn't make sense. It isn't a pointer being emitted");
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ public override Vertex WriteVertex(NodeFactory factory)
}
}

Debug.Assert(false, "UNREACHABLE");
Debug.Fail("UNREACHABLE");
return null;
}
}
Expand All @@ -467,7 +467,7 @@ public override Vertex WriteVertex(NodeFactory factory)
return GetNativeWriter(factory).GetVariableTypeSignature((uint)((SignatureMethodVariable)_type).Index, true);
}

Debug.Assert(false, "UNREACHABLE");
Debug.Fail("UNREACHABLE");
return null;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -928,7 +928,7 @@ public static void EmitObject(string objectFilePath, IEnumerable<DependencyNode>
catch (ArgumentException)
{
ISymbolNode alreadyWrittenSymbol = _previouslyWrittenNodeNames[definedSymbol.GetMangledName(factory.NameMangler)];
Debug.Assert(false, "Duplicate node name emitted to file",
Debug.Fail("Duplicate node name emitted to file",
$"Symbol {definedSymbol.GetMangledName(factory.NameMangler)} has already been written to the output object file {objectFilePath} with symbol {alreadyWrittenSymbol}");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ protected InvalidEntry() : base(StackValueKind.Unknown, null)
public override void Append(CppGenerationBuffer _builder)
{
_builder.Append("// FIXME: An invalid value was pushed onto the evaluation stack.");
Debug.Assert(false, "Invalid stack values shouldn't be appended.");
Debug.Fail("Invalid stack values shouldn't be appended.");
}

public override StackEntry Duplicate()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1723,7 +1723,7 @@ private void ImportBinaryOperation(ILOpcode opcode)
case ILOpcode.mul_ovf: op = "*"; break;
case ILOpcode.mul_ovf_un: op = "*"; unsigned = true; break;

default: Debug.Assert(false, "Unexpected opcode"); break;
default: Debug.Fail("Unexpected opcode"); break;
}

if (kind == StackValueKind.ByRef)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,7 @@ public static void EmitObject(string objectFilePath, IEnumerable<DependencyNode>
catch (ArgumentException)
{
ISymbolNode alreadyWrittenSymbol = _previouslyWrittenNodeNames[definedSymbol.GetMangledName(factory.NameMangler)];
Debug.Assert(false, "Duplicate node name emitted to file",
Debug.Fail("Duplicate node name emitted to file",
$"Symbol {definedSymbol.GetMangledName(factory.NameMangler)} has already been written to the output object file {objectFilePath} with symbol {alreadyWrittenSymbol}");
}
}
Expand Down
Loading

0 comments on commit 4933d30

Please sign in to comment.