Skip to content

Commit 1154c80

Browse files
authored
Resolve suppressed IDE0031 warnings (#10812)
Those were temporarily suppressed in 90cfb1a I used Visual Studio to fix all of them automatically.
1 parent 90cfb1a commit 1154c80

File tree

103 files changed

+276
-899
lines changed

Some content is hidden

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

103 files changed

+276
-899
lines changed

Directory.Build.props

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
<TargetFramework>net10.0</TargetFramework>
77
<TargetFrameworkVersion>10.0</TargetFrameworkVersion>
88
<BuildWithNetFrameworkHostedCompiler>true</BuildWithNetFrameworkHostedCompiler>
9-
<!-- Temporarily disable IDE0031: Null check can be simplified warnings. -->
10-
<NoWarn>$(NoWarn);IDE0031</NoWarn>
119
</PropertyGroup>
1210
<!-- Normalize $(TestWpfArcadeSdkPath) by appending a '\' to it if one is missing -->
1311
<PropertyGroup Condition="'$(TestWpfArcadeSdkPath)'!=''">

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1114,8 +1114,7 @@ protected override Geometry DefiningGeometry
11141114

11151115
//reset render transformation of the TopOwner
11161116
UIElement uie = TopOwner as UIElement;
1117-
if (uie != null)
1118-
uie.RenderTransform = Transform.Identity;
1117+
uie?.RenderTransform = Transform.Identity;
11191118

11201119
return geometry;
11211120
}

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

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -407,13 +407,10 @@ private void SetMarkerTransform(Path marker, ITextPointer anchor, ITextPointer b
407407
topTailTransform.Children.Add(tailScale);
408408
topTailTransform.Children.Add(topOffset);
409409

410-
if (geometry.Children[0] != null)
411-
geometry.Children[0].Transform = topTailTransform;
410+
geometry.Children[0]?.Transform = topTailTransform;
412411

413-
if (geometry.Children[1] != null)
414-
geometry.Children[1].Transform = bodyTransform;
415-
if (geometry.Children[2] != null)
416-
geometry.Children[2].Transform = bottomTailTransform;
412+
geometry.Children[1]?.Transform = bodyTransform;
413+
geometry.Children[2]?.Transform = bottomTailTransform;
417414

418415
//add transform to base anchor if needed
419416
if (baseAnchor != null)

src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/Controls/ActiveXContainer.cs

Lines changed: 2 additions & 3 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
//
@@ -46,8 +46,7 @@ internal ActiveXContainer(ActiveXHost host)
4646
//
4747
int UnsafeNativeMethods.IOleContainer.ParseDisplayName(Object pbc, string pszDisplayName, int[] pchEaten, Object[] ppmkOut)
4848
{
49-
if (ppmkOut != null)
50-
ppmkOut[0] = null;
49+
ppmkOut?[0] = null;
5150

5251
return NativeMethods.E_NOTIMPL;
5352
}

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1137,8 +1137,7 @@ bool IAnnotationComponent.IsDirty
11371137
}
11381138
set
11391139
{
1140-
if (_anchor != null)
1141-
_anchor.IsDirty = value;
1140+
_anchor?.IsDirty = value;
11421141
if (value)
11431142
InvalidateVisual();
11441143
}

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

Lines changed: 2 additions & 3 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
//
@@ -26,8 +26,7 @@ internal LiveShapingList List
2626
public override LiveShapingItem SetItemAt(int offset, LiveShapingItem lsi)
2727
{
2828
base.SetItemAt(offset, lsi);
29-
if (lsi != null)
30-
lsi.Block = this;
29+
lsi?.Block = this;
3130
return lsi;
3231
}
3332

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -548,8 +548,8 @@ private RBNode<T> Substitute(RBNode<T> node, RBNode<T> sub, RBNode<T> parent)
548548
sub.Parent = node.Parent;
549549
sub.IsRed = node.IsRed;
550550

551-
if (sub.LeftChild != null) sub.LeftChild.Parent = sub;
552-
if (sub.RightChild != null) sub.RightChild.Parent = sub;
551+
sub.LeftChild?.Parent = sub;
552+
sub.RightChild?.Parent = sub;
553553
return sub;
554554
}
555555

@@ -624,7 +624,7 @@ private RBNode<T> RotateLeft()
624624
node.IsRed = this.IsRed;
625625
node.Parent = this.Parent;
626626
this.RightChild = node.LeftChild;
627-
if (this.RightChild != null) this.RightChild.Parent = this;
627+
this.RightChild?.Parent = this;
628628
node.LeftChild = this;
629629
this.IsRed = true;
630630
this.Parent = node;
@@ -638,7 +638,7 @@ private RBNode<T> RotateRight()
638638
node.IsRed = this.IsRed;
639639
node.Parent = this.Parent;
640640
this.LeftChild = node.RightChild;
641-
if (this.LeftChild != null) this.LeftChild.Parent = this;
641+
this.LeftChild?.Parent = this;
642642
node.RightChild = this;
643643
this.IsRed = true;
644644
this.Parent = node;
@@ -836,8 +836,8 @@ protected RBNode<T> LoadTree(ref string s)
836836

837837
node.LeftChild = LoadTree(ref s); // read subtrees
838838
node.RightChild = LoadTree(ref s);
839-
if (node.LeftChild != null) node.LeftChild.Parent = node;
840-
if (node.RightChild != null) node.RightChild.Parent = node;
839+
node.LeftChild?.Parent = node;
840+
node.RightChild?.Parent = node;
841841

842842
s = s.Substring(1); // skip ')'
843843

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

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -424,8 +424,7 @@ internal RBNode<T> InsertNode(int index)
424424
internal void RemoveNode(int index)
425425
{
426426
LeftChild = DeleteNode(this, LeftChild, index);
427-
if (LeftChild != null)
428-
LeftChild.IsRed = false;
427+
LeftChild?.IsRed = false;
429428
}
430429

431430
internal virtual RBNode<T> NewNode()
@@ -500,8 +499,7 @@ public void RemoveAt(int index)
500499

501500
RBFinger<T> finger = FindIndex(index, true);
502501
RemoveAt(ref finger);
503-
if (LeftChild != null)
504-
LeftChild.IsRed = false;
502+
LeftChild?.IsRed = false;
505503

506504
Verify(size - 1);
507505
}
@@ -593,8 +591,7 @@ public bool Remove(T item)
593591
RBFinger<T> finger = Find(item, Comparison);
594592
if (finger.Found)
595593
RemoveAt(ref finger);
596-
if (LeftChild != null)
597-
LeftChild.IsRed = false;
594+
LeftChild?.IsRed = false;
598595
return finger.Found;
599596
}
600597

src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/Printing/PrintDlgExMarshaler.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -334,10 +334,7 @@ string printerName
334334
}
335335
}
336336
}
337-
if (printQueue != null)
338-
{
339-
printQueue.InPartialTrust = true;
340-
}
337+
printQueue?.InPartialTrust = true;
341338

342339
return printQueue;
343340
}

src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/PtsHost/ContainerParagraph.cs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1189,14 +1189,8 @@ private void BuildUpdateRecord()
11891189
}
11901190
while (paraInvalid != ur.SyncPara)
11911191
{
1192-
if (paraInvalid.Next != null)
1193-
{
1194-
paraInvalid.Next.Previous = null;
1195-
}
1196-
if (paraInvalid.Previous != null)
1197-
{
1198-
paraInvalid.Previous.Next = null;
1199-
}
1192+
paraInvalid.Next?.Previous = null;
1193+
paraInvalid.Previous?.Next = null;
12001194
paraInvalid.Dispose();
12011195
paraInvalid = paraInvalid.Next;
12021196
}

0 commit comments

Comments
 (0)