8000 Use Debug.Fail("message") over Debug.Assert(false, "message") (#10723) · dotnet/wpf@e848313 · GitHub
[go: up one dir, main page]

Skip to content

Commit e848313

Browse files
authored
Use Debug.Fail("message") over Debug.Assert(false, "message") (#10723)
1 parent 76a1d57 commit e848313

File tree

121 files changed

+229
-229
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

121 files changed

+229
-229
lines changed

src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/Ink/InkSerializedFormat/CustomAttributeSerializer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -938,7 +938,7 @@ internal static void Validate(Guid id, object value)
938938
}
939939
default:
940940
{
941-
Debug.Assert(false, "Missing case statement!");
941+
Debug.Fail("Missing case statement!");
942942
break;
943943
}
944944
}

src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/Ink/InkSerializedFormat/DrawingAttributeSerializer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ internal static uint DecodeAsISF(Stream stream, GuidList guidList, uint maximumS
279279
}
280280
catch (InvalidOperationException) // Matrix.Parse failed.
281281
{
282-
System.Diagnostics.Debug.Assert(false, "Corrupt Matrix in the ExtendedPropertyCollection!");
282+
System.Diagnostics.Debug.Fail("Corrupt Matrix in the ExtendedPropertyCollection!");
283283
}
284284
finally
285285
{

src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/Ink/InkSerializedFormat/StrokeSerializer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ private static uint DecodeISFIntoStroke(
288288

289289
byte[] out_buffer = Compressor.DecompressPropertyData(in_buffer);
290290

291-
System.Diagnostics.Debug.Assert(false, "ExtendedProperties for points are not supported");
291+
System.Diagnostics.Debug.Fail("ExtendedProperties for points are not supported");
292292

293293
// skip the bytes in both success & failure cases
294294
// Note: Point ExtendedProperties are discarded

src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/Ink/StrokeNode.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ List<Point> dcPoints
256256

257257
if (i == maxCount)
258258
{
259-
Debug.Assert(false, "StrokeNodeOperations.GetPointsAtStartOfSegment failed to find the D position");
259+
Debug.Fail("StrokeNodeOperations.GetPointsAtStartOfSegment failed to find the D position");
260260
//we didn't find the d point, return
261261
return;
262262
}
@@ -369,7 +369,7 @@ List<Point> dcPoints
369369

370370
if (i == maxCount)
371371
{
372-
Debug.Assert(false, "StrokeNodeOperations.GetPointsAtEndOfSegment failed to find the B position");
372+
Debug.Fail("StrokeNodeOperations.GetPointsAtEndOfSegment failed to find the B position");
373373
//we didn't find the d point, return
374374
return;
375375
}
@@ -636,7 +636,7 @@ out bool missingIntersection
636636

637637
if (indexA == -1 || indexB == -1 || indexC == -1 || indexD == -1)
638638
{
639-
Debug.Assert(false, "Couldn't find all 4 indexes in StrokeNodeOperations.GetPointsAtMiddleSegment");
639+
Debug.Fail("Couldn't find all 4 indexes in StrokeNodeOperations.GetPointsAtMiddleSegment");
640640
return;
641641
}
642642

src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/Shaping/OpenTypeCommon.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,7 @@ out NextGlyph
591591
break;
592592
}
593593
default:
594-
Debug.Assert(false,"Unknown OpenType layout table!");
594+
Debug.Fail("Unknown OpenType layout table!");
595595
break;
596596
}
597597
}
@@ -1072,7 +1072,7 @@ out int complexLanguageCount
10721072
break;
10731073

10741074
case 7: //Extension lookup
1075-
Debug.Assert(false,"Ext.Lookup processed earlier!");
1075+
Debug.Fail("Ext.Lookup processed earlier!");
10761076
break;
10771077

10781078
case 8: //ReverseCahiningSubst
@@ -1157,7 +1157,7 @@ out int complexLanguageCount
11571157
break;
11581158

11591159
case 9: //Extension lookup
1160-
Debug.Assert(false,"Ext.Lookup processed earlier!");
1160+
Debug.Fail("Ext.Lookup processed earlier!");
11611161
break;
11621162

11631163
default:
@@ -1170,7 +1170,7 @@ out int complexLanguageCount
11701170
}
11711171

11721172
default:
1173-
Debug.Assert(false,"Unknown OpenType layout table!");
1173+
Debug.Fail("Unknown OpenType layout table!");
11741174
break;
11751175
}
11761176
}

src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/Shaping/TypefaceMap.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ ref SpanVector<int> cachedScaledTypefaceIndexSpans
214214
typefaceIndexSpanRider.At(ichRange + ich);
215215
if((int)typefaceIndexSpanRider.CurrentValue < 0)
216216
{
217-
Debug.Assert(false, "Invalid font face spans");
217+
Debug.Fail("Invalid font face spans");
218218
return;
219219
}
220220

src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/Shaping/UshortList2.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,24 +131,24 @@ internal abstract class UshortBuffer
131131

132132
public virtual ushort[] ToArray()
133133
{
134-
Debug.Assert(false, "Not supported");
134+
Debug.Fail("Not supported");
135135
return null;
136136
}
137137

138138
public virtual ushort[] GetSubsetCopy(int index, int count)
139139
{
140-
Debug.Assert(false, "Not supported");
140+
Debug.Fail("Not supported");
141141
return null;
142142
}
143143

144144
public virtual void Insert(int index, int count, int length)
145145
{
146-
Debug.Assert(false, "Not supported");
146+
Debug.Fail("Not supported");
147147
}
148148

149149
public virtual void Remove(int index, int count, int length)
150150
{
151-
Debug.Assert(false, "Not supported");
151+
Debug.Fail("Not supported");
152152
}
153153
}
154154

src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/TextFormatting/LineServicesCallbacks.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1234,7 +1234,7 @@ private Rect DrawTextDecoration(
12341234
break;
12351235

12361236
default:
1237-
Debug.Assert(false, "Not supported TextDecorationUnit");
1237+
Debug.Fail("Not supported TextDecorationUnit");
12381238
break;
12391239
}
12401240

@@ -1261,7 +1261,7 @@ private Rect DrawTextDecoration(
12611261
break;
12621262

12631263
default:
1264-
Debug.Assert(false, "Not supported TextDecorationUnit");
1264+
Debug.Fail("Not supported TextDecorationUnit");
12651265
break;
12661266
}
12671267

@@ -2312,7 +2312,7 @@ internal unsafe LsErr GetObjectHandlerInfo(
23122312
break;
23132313

23142314
default:
2315-
Debug.Assert(false, "Unsupported installed object!");
2315+
Debug.Fail("Unsupported installed object!");
23162316
break;
23172317
}
23182318
}

src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/TextFormatting/TextMarkerSource.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ int autoNumberingIndex
124124
}
125125
else
126126
{
127-
Debug.Assert(false, "Invalid marker style");
127+
Debug.Fail("Invalid marker style");
128128
}
129129

130130
if(symbolString != null)

src/Microsoft.DotNet.Wpf/src/PresentationCore/System/IO/Packaging/PackWebResponse.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,7 @@ internal Stream GetResponseStream()
608608
// full container request?
609609
if (_parent._partName == null)
610610
{
611-
Debug.Assert(false, "Cannot return full-container stream from cached container object");
611+
Debug.Fail("Cannot return full-container stream from cached container object");
612612
}
613613
else
614614
{

src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/DragEventArgs.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,17 @@ internal DragEventArgs(IDataObject data, DragDropKeyStates dragDropKeyStates, Dr
4141
{
4242
if (!DragDrop.IsValidDragDropKeyStates(dragDropKeyStates))
4343
{
44-
Debug.Assert(false, "Invalid dragDropKeyStates");
44+
Debug.Fail("Invalid dragDropKeyStates");
4545
}
4646

4747
if (!DragDrop.IsValidDragDropEffects(allowedEffects))
4848
{
49-
Debug.Assert(false, "Invalid allowedEffects");
49+
Debug.Fail("Invalid allowedEffects");
5050
}
5151

5252
if (target == null)
5353
{
54-
Debug.Assert(false, "Invalid target");
54+
Debug.Fail("Invalid target");
5555
}
5656

5757
this._data = data;

src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/GiveFeedbackEventArgs.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ internal GiveFeedbackEventArgs(DragDropEffects effects, bool useDefaultCursors)
3737
{
3838
if (!DragDrop.IsValidDragDropEffects(effects))
3939
{
40-
Debug.Assert(false, "Invalid effects");
40+
Debug.Fail("Invalid effects");
4141
}
4242

4343
this._effects = effects;

src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Ink/IncrementalHitTester.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,15 +201,15 @@ private void OnStrokesChanged(object sender, StrokeCollectionChangedEventArgs ar
201201
//validate our cache
202202
if (_strokes.Count != _strokeInfos.Count)
203203
{
204-
Debug.Assert(false, "Benign assert. IncrementalHitTester's _strokeInfos cache is out of sync, rebuilding.");
204+
Debug.Fail("Benign assert. IncrementalHitTester's _strokeInfos cache is out of sync, rebuilding.");
205205
RebuildStrokeInfoCache();
206206
return;
207207
}
208208
for (int i = 0; i < _strokeInfos.Count; i++)
209209
{
210210
if (_strokeInfos[i].Stroke != _strokes[i])
211211
{
212-
Debug.Assert(false, "Benign assert. IncrementalHitTester's _strokeInfos cache is out of sync, rebuilding.");
212+
Debug.Fail("Benign assert. IncrementalHitTester's _strokeInfos cache is out of sync, rebuilding.");
213213
RebuildStrokeInfoCache();
214214
return;
215215
}

src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/InputMethod.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -711,7 +711,7 @@ public SpeechMode SpeechMode
711711
}
712712
else
713713
{
714-
Debug.Assert(false, "Unknown Speech Mode");
714+
Debug.Fail("Unknown Speech Mode");
715715
}
716716
}
717717
}

src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/InputMethodStateTypeInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ internal static InputMethodStateType ToType(ref Guid rguid)
8888
return im._inputmethodstatetype;
8989
}
9090

91-
Debug.Assert(false, "The guid does not match.");
91+
Debug.Fail("The guid does not match.");
9292
return InputMethodStateType.Invalid;
9393
}
9494

src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Stylus/Common/StylusLogic.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -764,7 +764,7 @@ internal bool HandleFlick(int flickData, IInputElement element)
764764
break;
765765
default:
766766
{
767-
Debug.Assert(false, "Unknown Flick Action encountered");
767+
Debug.Fail("Unknown Flick Action encountered");
768768
}
769769
break;
770770
}

src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Stylus/Wisp/PenThreadPool.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ private PenThread GetPenThreadForPenContextHelper(PenContext penContext)
140140
{
141141
StylusTraceLogger.LogReentrancyRetryLimitReached();
142142

143-
Debug.Assert(false, "Retry limit reached when acquiring PenThread");
143+
Debug.Fail("Retry limit reached when acquiring PenThread");
144144
}
145145

146146
return selectedPenThread;

src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Stylus/Wisp/WispTabletDeviceCollection.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ private void UpdateTabletsImpl()
264264
// There was an error acquiring a PenThread, do no work here.
265265
if (penThread == null)
266266
{
267-
Debug.Assert(false, "Error acquiring PenThread in UpdateTabletsImpl()");
267+
Debug.Fail("Error acquiring PenThread in UpdateTabletsImpl()");
268268
return;
269269
}
270270

@@ -412,7 +412,7 @@ internal bool HandleTabletAdded(uint wisptisIndex, ref uint tabletIndexChanged)
412412
// There was an error acquiring a PenThread, return true to force a complete tablet refresh
413413
if (penThread == null)
414414
{
415-
Debug.Assert(false, "Error acquiring PenThread in HandleTabletAdded()");
415+
Debug.Fail("Error acquiring PenThread in HandleTabletAdded()");
416416
return true;
417417
}
418418

src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Animation/TimeManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,7 @@ internal TimeSpan GetCurrentGlobalTime()
572572

573573
default:
574574

575-
Debug.Assert(false, "Unrecognized TimeState enumeration value");
575+
Debug.Fail("Unrecognized TimeState enumeration value");
576576
return TimeSpan.Zero;
577577
}
578578
}

src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Animation/TimelineClockCollection.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ internal ClockCollection(Clock owner)
423423
/// </summary>
424424
private ClockCollection()
425425
{
426-
Debug.Assert(false, "Parameterless constructor is illegal for ClockCollection.");
426+
Debug.Fail("Parameterless constructor is illegal for ClockCollection.");
427427
}
428428

429429
#endregion

src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Visual.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ internal Visual(DUCE.ResourceType resourceType)
153153
break;
154154

155155
default:
156-
Debug.Assert(false, "TYPE_VISUAL or TYPE_VIEWPORT3DVISUAL expected.");
156+
Debug.Fail("TYPE_VISUAL or TYPE_VIEWPORT3DVISUAL expected.");
157157
break;
158158
}
159159
}

src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/QueryContinueDragEventArgs.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ internal QueryContinueDragEventArgs(bool escapePressed, DragDropKeyStates dragDr
3030
{
3131
if (!DragDrop.IsValidDragDropKeyStates(dragDropKeyStates))
3232
{
33-
Debug.Assert(false, "Invalid dragDropKeyStates");
33+
Debug.Fail("Invalid dragDropKeyStates");
3434
}
3535

3636
this._escapePressed = escapePressed;

src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/Annotations/Component/AnnotationHighlightLayer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ private void GetSpannedSegments(ITextPointer start, ITextPointer end, out int st
509509
}
510510

511511
if ((startSeg < 0) || (endSeg < 0) || (startSeg > endSeg))
512-
Debug.Assert(false, "Mismatched segment data");
512+
Debug.Fail("Mismatched segment data");
513513
}
514514

515515
#endregion Private Methods

src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/Controls/StickyNote/StickyNoteAnnotations.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -718,7 +718,7 @@ private void UpdateContent(StickyNoteControl snc, bool updateAnnotation, XmlToke
718718
if ((token == XmlToken.Ink && contentControl.Type != StickyNoteType.Ink)
719719
|| (token == XmlToken.Text && contentControl.Type != StickyNoteType.Text))
720720
{
721-
Debug.Assert(false, "The annotation data does match with the current content control in StickyNote");
721+
Debug.Fail("The annotation data does match with the current content control in StickyNote");
722722
return;
723723
}
724724

src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/Data/CollectionViewGroupRoot.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,7 @@ private void MoveWithinSubgroup(object item, CollectionViewGroupInternal group,
633633
// properties that the name depends on) without notification.
634634
// We don't support this - the Move is just a no-op. But assert (in
635635
// debug builds) to help diagnose the problem if it arises.
636-
Debug.Assert(false, "Failed to find item in expected subgroup after Move");
636+
Debug.Fail("Failed to find item in expected subgroup after Move");
637637
}
638638

639639
// move the item within its group

src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/Data/CompositeCollectionView.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1649,12 +1649,12 @@ private void VerifyCurrencyIsConsistent()
16491649
{
16501650
int x, y;
16511651
if (!ItemsControl.EqualsEx(CurrentItem, GetItem(CurrentPosition, out x, out y)) && !_collection.HasRepeatedCollection())
1652-
Debug.Assert(false, "CurrentItem is not consistent with CurrentPosition");
1652+
Debug.Fail("CurrentItem is not consistent with CurrentPosition");
16531653
}
16541654
else
16551655
{
16561656
if ((CurrentItem != null) && !_collection.HasRepeatedCollection())
1657-
Debug.Assert(false, "CurrentItem is not consistent with CurrentPosition");
1657+
Debug.Fail("CurrentItem is not consistent with CurrentPosition");
16581658
}
16591659
}
16601660

src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/Data/DataExtensionMethods.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Licensed to the .NET Foundation under one or more agreements.
1+
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

44
//
@@ -30,7 +30,7 @@ internal static int Search(this IList list, int index, int count, object value,
3030
}
3131

3232
// we should never get here, but the compiler doesn't know that
33-
Debug.Assert(false, "Unsupported list passed to Search");
33+
Debug.Fail("Unsupported list passed to Search");
3434
return 0;
3535
}
3636

src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/Data/IndexedEnumerable.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ private bool EnsureCacheCurrent()
390390
}
391391
catch (InvalidOperationException)
392392
{
393-
Debug.Assert(false, "EnsureCacheCurrent: _enumerator.Current failed with InvalidOperationException");
393+
Debug.Fail("EnsureCacheCurrent: _enumerator.Current failed with InvalidOperationException");
394394
}
395395
Debug.Assert(System.Windows.Controls.ItemsControl.EqualsEx(_cachedItem, current), "EnsureCacheCurrent: _cachedItem out of sync with _enumerator.Current");
396396
}

src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/Data/StaticPropertyChangedEventManager.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,15 +80,15 @@ protected override ListenerList NewListenerList()
8080
/// </summary>
8181
protected override void StartListening(object source)
8282
{
83-
Debug.Assert(false, "Should never get here");
83+
Debug.Fail("Should never get here");
8484
}
8585

8686
/// <summary>
8787
/// Stop listening to the given source for the event.
8888
/// </summary>
8989
protected override void StopListening(object source)
9090
{
91-
Debug.Assert(false, "Should never get here");
91+
Debug.Fail("Should never get here");
9292
}
9393

9494
/// <summary>

0 commit comments

Comments
 (0)
0