From 6c4051a419a3ae406196fa0f6fe6f848439551f3 Mon Sep 17 00:00:00 2001 From: "dotnet-maestro[bot]" <42748379+dotnet-maestro[bot]@users.noreply.github.com> Date: Wed, 14 Oct 2020 23:01:19 +0000 Subject: [PATCH] [release/5.0] Update dependencies from dotnet/arcade (#3635) [release/5.0] Update dependencies from dotnet/arcade - Replace null comparisons on non-nullable types that now cause compilation errors, due to the .NET SDK update. - PR feedback - PR feedback - Merge pull request #3649 from dotnet/nonnullablechecks Replace null comparisons on non-nullable types that now cause compilation errors, due to the .NET SDK update. --- eng/Version.Details.xml | 20 +++++++------- eng/Versions.props | 6 ++--- global.json | 8 +++--- .../System/Windows/Media/EllipseGeometry.cs | 3 --- .../Imaging/BitmapSourceSafeMILHandle.cs | 2 +- .../Windows/Media/Imaging/WriteableBitmap.cs | 9 ------- .../System/Windows/Media/LineGeometry.cs | 3 --- .../System/Windows/Media/RectangleGeometry.cs | 3 --- .../Windows/Media3D/GeneralTransform3DTo2D.cs | 16 +++++------ .../IO/Packaging/indexingfiltermarshaler.cs | 5 ++-- .../Internal/Printing/printdlgexmarshaler.cs | 2 +- .../MS/Internal/PtsHost/CellParaClient.cs | 2 +- .../Generated/WinRT/Marshalers.cs | 6 ++--- .../Peers/DateTimeAutomationPeer.cs | 4 --- .../System/Windows/Controls/Calendar.cs | 27 +++++++++---------- .../CalendarBlackoutDatesCollection.cs | 3 --- .../System/Windows/Controls/DataGridCell.cs | 2 +- .../Controls/Primitives/CalendarItem.cs | 2 -- .../Controls/SelectedDatesCollection.cs | 2 +- .../System/Windows/Data/BindingExpression.cs | 2 -- .../System/Windows/FrameworkElement.cs | 3 ++- .../System/Windows/Standard/NativeMethods.cs | 2 +- .../System/Windows/VisualStateManager.cs | 2 +- .../System/Windows/Window.cs | 2 +- .../src/Shared/MS/Win32/HwndSubclass.cs | 3 ++- .../RightsManagement/IssuanceLicense.cs | 4 +-- .../System/Windows/SplashScreen.cs | 2 +- 27 files changed, 57 insertions(+), 88 deletions(-) diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml index 69c840aa4..69d69be71 100644 --- a/eng/Version.Details.xml +++ b/eng/Version.Details.xml @@ -103,25 +103,25 @@ - + https://github.com/dotnet/arcade - ee39cd1573dbb8011f343e1037af51d4fc00a747 + 6813f5aa511a7a4498fa217a54219b5704a01f83 - + https://github.com/dotnet/arcade - ee39cd1573dbb8011f343e1037af51d4fc00a747 + 6813f5aa511a7a4498fa217a54219b5704a01f83 - + https://github.com/dotnet/arcade - ee39cd1573dbb8011f343e1037af51d4fc00a747 + 6813f5aa511a7a4498fa217a54219b5704a01f83 - + https://github.com/dotnet/arcade - ee39cd1573dbb8011f343e1037af51d4fc00a747 + 6813f5aa511a7a4498fa217a54219b5704a01f83 - + https://github.com/dotnet/arcade - ee39cd1573dbb8011f343e1037af51d4fc00a747 + 6813f5aa511a7a4498fa217a54219b5704a01f83 diff --git a/eng/Versions.props b/eng/Versions.props index a5251394a..3e2d48176 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -42,9 +42,9 @@ - 5.0.0-beta.20506.7 - 5.0.0-beta.20506.7 - 5.0.0-beta.20506.7 + 5.0.0-beta.20510.1 + 5.0.0-beta.20510.1 + 5.0.0-beta.20510.1 diff --git a/global.json b/global.json index 4898761a3..d9fb12e0a 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "tools": { - "dotnet": "5.0.100-rc.1.20452.10", + "dotnet": "5.0.100-rc.2.20479.15", "runtimes": { "dotnet": [ "2.1.7", @@ -12,11 +12,11 @@ } }, "msbuild-sdks": { - "Microsoft.DotNet.Arcade.Sdk": "5.0.0-beta.20506.7", - "Microsoft.DotNet.Helix.Sdk": "5.0.0-beta.20506.7" + "Microsoft.DotNet.Arcade.Sdk": "5.0.0-beta.20510.1", + "Microsoft.DotNet.Helix.Sdk": "5.0.0-beta.20510.1" }, "sdk": { - "version": "5.0.100-rc.1.20452.10" + "version": "5.0.100-rc.2.20479.15" }, "native-tools": { "strawberry-perl": "5.28.1.1-1", diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/EllipseGeometry.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/EllipseGeometry.cs index 8d7c07780..bc5224d64 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/EllipseGeometry.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/EllipseGeometry.cs @@ -160,9 +160,6 @@ internal override Rect GetBoundsInternal(Pen pen, Matrix matrix, double toleranc { Rect rect; - Debug.Assert(worldMatrix != null); - Debug.Assert(geometryMatrix != null); - if ( (pen == null || pen.DoesNotContainGaps) && worldMatrix.IsIdentity && geometryMatrix.IsIdentity) { diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/BitmapSourceSafeMILHandle.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/BitmapSourceSafeMILHandle.cs index 5a11194f1..0f53e6288 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/BitmapSourceSafeMILHandle.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/BitmapSourceSafeMILHandle.cs @@ -71,7 +71,7 @@ private static long ComputeEstimatedSize(IntPtr bitmapObject) { long estimatedSize = 0; - if (bitmapObject != null && bitmapObject != IntPtr.Zero) + if (bitmapObject != IntPtr.Zero) { IntPtr wicBitmap; diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/WriteableBitmap.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/WriteableBitmap.cs index d3ae38311..3bc0e4ff4 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/WriteableBitmap.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/WriteableBitmap.cs @@ -85,15 +85,6 @@ BitmapPalette palette // Sanitize inputs // - if (pixelFormat == null) - { - // Backwards Compat: - // - // The original code would null-ref, but we choose to raise a - // better exception. - throw new ArgumentNullException("pixelFormat"); - } - if (pixelFormat.Palettized && palette == null) { throw new InvalidOperationException(SR.Get(SRID.Image_IndexedPixelFormatRequiresPalette)); diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/LineGeometry.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/LineGeometry.cs index daa2c16a7..34c864211 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/LineGeometry.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/LineGeometry.cs @@ -107,9 +107,6 @@ internal override Rect GetBoundsInternal(Pen pen, Matrix worldMatrix, double tol internal static Rect GetBoundsHelper(Pen pen, Matrix worldMatrix, Point pt1, Point pt2, Matrix geometryMatrix, double tolerance, ToleranceType type) { - Debug.Assert(worldMatrix != null); - Debug.Assert(geometryMatrix != null); - if (pen == null && worldMatrix.IsIdentity && geometryMatrix.IsIdentity) { return new Rect(pt1, pt2); diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/RectangleGeometry.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/RectangleGeometry.cs index a204c8fa2..3abf8d262 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/RectangleGeometry.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/RectangleGeometry.cs @@ -190,9 +190,6 @@ internal override Rect GetBoundsInternal(Pen pen, Matrix worldMatrix, double tol { Rect boundingRect; - Debug.Assert(worldMatrix != null); - Debug.Assert(geometryMatrix != null); - if (rect.IsEmpty) { boundingRect = Rect.Empty; diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media3D/GeneralTransform3DTo2D.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media3D/GeneralTransform3DTo2D.cs index 48bb9135b..3fc145755 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media3D/GeneralTransform3DTo2D.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media3D/GeneralTransform3DTo2D.cs @@ -43,15 +43,13 @@ public bool TryTransform(Point3D inPoint, out Point result) result = new Point(); // project the point - if (_projectionTransform != null) - { Point3D projectedPoint = _projectionTransform.Transform(inPoint); - - if (_transformBetween2D != null) - { - result = _transformBetween2D.Transform(new Point(projectedPoint.X, projectedPoint.Y)); - success = true; - } - } + Point3D projectedPoint = _projectionTransform.Transform(inPoint); + + if (_transformBetween2D != null) + { + result = _transformBetween2D.Transform(new Point(projectedPoint.X, projectedPoint.Y)); + success = true; + } return success; } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/IO/Packaging/indexingfiltermarshaler.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/IO/Packaging/indexingfiltermarshaler.cs index e8e6b15f3..aaf0caaa6 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/IO/Packaging/indexingfiltermarshaler.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/IO/Packaging/indexingfiltermarshaler.cs @@ -215,8 +215,9 @@ internal static IntPtr MarshalPropVariant(Object obj) // allocate an unmanaged PROPVARIANT to return pNative = Marshal.AllocCoTaskMem(Marshal.SizeOf(typeof(PROPVARIANT))); - // Per MSDN, AllocCoTaskMem never returns null. One can't be too careful, though. - Invariant.Assert(pNative != null); + + // Per MSDN, AllocCoTaskMem never returns null: check for IntPtr.Zero instead. + Invariant.Assert(pNative != IntPtr.Zero); // marshal the managed PROPVARIANT into the unmanaged block and return it Marshal.StructureToPtr(v, pNative, false); diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/Printing/printdlgexmarshaler.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/Printing/printdlgexmarshaler.cs index 38f464a2a..d5be8f8c3 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/Printing/printdlgexmarshaler.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/Printing/printdlgexmarshaler.cs @@ -628,7 +628,7 @@ IntPtr unmanagedBuffer } catch (Exception) { - if (unmanagedBuffer != null) + if (unmanagedBuffer != IntPtr.Zero) { FreeUnmanagedPrintDlgExStruct(unmanagedBuffer); unmanagedBuffer = IntPtr.Zero; diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/PtsHost/CellParaClient.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/PtsHost/CellParaClient.cs index 14d44788f..4b643148c 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/PtsHost/CellParaClient.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/PtsHost/CellParaClient.cs @@ -157,7 +157,7 @@ internal void ValidateVisual() int dvrTopSpace; PTS.FSPAP fspap; - if(CellParagraph.StructuralCache.DtrList != null && breakRecordIn != null) + if(CellParagraph.StructuralCache.DtrList != null && breakRecordIn != IntPtr.Zero) { CellParagraph.InvalidateStructure(TextContainerHelper.GetCPFromElement(CellParagraph.StructuralCache.TextContainer, CellParagraph.Element, ElementEdge.BeforeStart)); } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/WindowsRuntime/Generated/WinRT/Marshalers.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/WindowsRuntime/Generated/WinRT/Marshalers.cs index cf159ed3b..ccbf13294 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/WindowsRuntime/Generated/WinRT/Marshalers.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/WindowsRuntime/Generated/WinRT/Marshalers.cs @@ -127,7 +127,7 @@ public void Dispose() marshaler?.Dispose(); } } - if (_array != null) + if (_array != IntPtr.Zero) { Marshal.FreeCoTaskMem(_array); } @@ -445,7 +445,7 @@ public void Dispose() Marshaler.DisposeMarshaler(marshaler); } } - if (_array != null) + if (_array != IntPtr.Zero) { Marshal.FreeCoTaskMem(_array); } @@ -627,7 +627,7 @@ public void Dispose() DisposeMarshaler(marshaler); } } - if (_array != null) + if (_array != IntPtr.Zero) { Marshal.FreeCoTaskMem(_array); } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Automation/Peers/DateTimeAutomationPeer.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Automation/Peers/DateTimeAutomationPeer.cs index 10d71f9d4..6ed7fd6a0 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Automation/Peers/DateTimeAutomationPeer.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Automation/Peers/DateTimeAutomationPeer.cs @@ -30,10 +30,6 @@ public sealed class DateTimeAutomationPeer : AutomationPeer, IGridItemProvider, internal DateTimeAutomationPeer(DateTime date, Calendar owningCalendar, CalendarMode buttonMode) : base() { - if (date == null) - { - throw new ArgumentNullException("date"); - } if (owningCalendar == null) { throw new ArgumentNullException("owningCalendar"); diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/Calendar.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/Calendar.cs index 8b4839867..e7b7e7134 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/Calendar.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/Calendar.cs @@ -1380,23 +1380,20 @@ private void ProcessEndKey(bool shift) { case CalendarMode.Month: { - if (this.DisplayDate != null) - { - DateTime? selectedDate = new DateTime(this.DisplayDateInternal.Year, this.DisplayDateInternal.Month, 1); - - if (DateTimeHelper.CompareYearMonth(DateTime.MaxValue, selectedDate.Value) > 0) - { - // since DisplayDate is not equal to DateTime.MaxValue we are sure selectedDate is not null - selectedDate = DateTimeHelper.AddMonths(selectedDate.Value, 1).Value; - selectedDate = DateTimeHelper.AddDays(selectedDate.Value, -1).Value; - } - else - { - selectedDate = DateTime.MaxValue; - } + DateTime? selectedDate = new DateTime(this.DisplayDateInternal.Year, this.DisplayDateInternal.Month, 1); - ProcessSelection(shift, selectedDate); + if (DateTimeHelper.CompareYearMonth(DateTime.MaxValue, selectedDate.Value) > 0) + { + // since DisplayDate is not equal to DateTime.MaxValue we are sure selectedDate is not null + selectedDate = DateTimeHelper.AddMonths(selectedDate.Value, 1).Value; + selectedDate = DateTimeHelper.AddDays(selectedDate.Value, -1).Value; } + else + { + selectedDate = DateTime.MaxValue; + } + + ProcessSelection(shift, selectedDate); break; } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/CalendarBlackoutDatesCollection.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/CalendarBlackoutDatesCollection.cs index 7d543ccc2..0f6c3b403 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/CalendarBlackoutDatesCollection.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/CalendarBlackoutDatesCollection.cs @@ -349,9 +349,6 @@ private bool IsValidThread() /// private CalendarDateRange GetContainingDateRange(DateTime date) { - if (date == null) - return null; - for (int i = 0; i < Count; i++) { if (DateTimeHelper.InRange(date, this[i])) diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/DataGridCell.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/DataGridCell.cs index 6f55d34c8..6358bf00e 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/DataGridCell.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/DataGridCell.cs @@ -278,7 +278,7 @@ internal void NotifyPropertyChanged(DependencyObject d, string propertyName, Dep { column.RefreshCellContent(this, propertyName); } - else if (e != null && e.Property != null) + else if (e.Property != null) { column.RefreshCellContent(this, e.Property.Name); } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/Primitives/CalendarItem.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/Primitives/CalendarItem.cs index f19015c93..29cc92bba 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/Primitives/CalendarItem.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/Primitives/CalendarItem.cs @@ -681,7 +681,6 @@ private void Cell_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) CalendarKeyboardHelper.GetMetaKeyState(out ctrl, out shift); DateTime selectedDate = (DateTime)b.DataContext; - Debug.Assert(selectedDate != null); switch (this.Owner.SelectionMode) { @@ -1303,7 +1302,6 @@ private void SetYearModeMonthButtons() if (this.Owner != null) { - Debug.Assert(this.Owner.DisplayDateInternal != null); childButton.HasSelectedDays = (DateTimeHelper.CompareYearMonth(day, this.Owner.DisplayDateInternal) == 0); if (DateTimeHelper.CompareYearMonth(day, this.Owner.DisplayDateStartInternal) < 0 || DateTimeHelper.CompareYearMonth(day, this.Owner.DisplayDateEndInternal) > 0) diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/SelectedDatesCollection.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/SelectedDatesCollection.cs index a5c960137..969b696f8 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/SelectedDatesCollection.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/SelectedDatesCollection.cs @@ -278,7 +278,7 @@ protected override void SetItem(int index, DateTime item) } else { - if (item != null && DateTime.Compare(this[index], item) != 0 && Calendar.IsValidDateSelection(this._owner, item)) + if (DateTime.Compare(this[index], item) != 0 && Calendar.IsValidDateSelection(this._owner, item)) { removedItems.Add(this[index]); base.SetItem(index, item); diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Data/BindingExpression.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Data/BindingExpression.cs index 2b25d922d..7ccbe125d 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Data/BindingExpression.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Data/BindingExpression.cs @@ -220,8 +220,6 @@ internal override void OnPropertyInvalidation(DependencyObject d, DependencyProp { if (d == null) throw new ArgumentNullException("d"); - if (args == null) - throw new ArgumentNullException("args"); DependencyProperty dp = args.Property; if (dp == null) diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/FrameworkElement.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/FrameworkElement.cs index bfd0d63d7..eb6beefb2 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/FrameworkElement.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/FrameworkElement.cs @@ -4589,7 +4589,8 @@ protected sealed override void ArrangeCore(Rect finalRect) // First, get clipped, transformed, unrounded size. if (useLayoutRounding) { - if (ltd != null && ltd.TransformedUnroundedDS != null) + // 'transformUnroundedDS' is a non-nullable value type and can never be null. + if (ltd != null) { transformedUnroundedDS = ltd.TransformedUnroundedDS; transformedUnroundedDS.Width = Math.Max(0, transformedUnroundedDS.Width - marginWidth); diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Standard/NativeMethods.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Standard/NativeMethods.cs index fc19dd6d9..1b65ea82a 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Standard/NativeMethods.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Standard/NativeMethods.cs @@ -2797,7 +2797,7 @@ public static MONITORINFO GetMonitorInfo(IntPtr hMonitor) public static IntPtr GetStockObject(StockObject fnObject) { IntPtr retPtr = _GetStockObject(fnObject); - if (retPtr == null) + if (retPtr == IntPtr.Zero) { HRESULT.ThrowLastError(); } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/VisualStateManager.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/VisualStateManager.cs index 6cfe7cd82..7824e9107 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/VisualStateManager.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/VisualStateManager.cs @@ -408,7 +408,7 @@ private static Storyboard GenerateDynamicTransitionAnimations(FrameworkElement r if (transition != null) { - if (transition.GeneratedDuration != null) + if (transition.GeneratedDuration != DurationZero) { dynamic.Duration = transition.GeneratedDuration; } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Window.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Window.cs index b5537ef5d..d15232b2f 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Window.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Window.cs @@ -6148,7 +6148,7 @@ private static object CoerceRenderTransform(DependencyObject d, object value) Transform renderTransformValue = (Transform)value; if ((value == null) || - (renderTransformValue != null && renderTransformValue.Value != null && renderTransformValue.Value.IsIdentity == true)) + (renderTransformValue != null && renderTransformValue.Value.IsIdentity == true)) { // setting this value is allowed. } diff --git a/src/Microsoft.DotNet.Wpf/src/Shared/MS/Win32/HwndSubclass.cs b/src/Microsoft.DotNet.Wpf/src/Shared/MS/Win32/HwndSubclass.cs index e9dc2e01e..3048eafdf 100644 --- a/src/Microsoft.DotNet.Wpf/src/Shared/MS/Win32/HwndSubclass.cs +++ b/src/Microsoft.DotNet.Wpf/src/Shared/MS/Win32/HwndSubclass.cs @@ -553,7 +553,8 @@ private bool UnhookWindowProc(bool force) //AvDebug.Assert(_gcHandle.IsAllocated, "External GC handle has not been allocated."); - if(null != _gcHandle) + // GCHandle is a non-nullable type. Check GCHandle.IsAllocated before calling Free(). + if(_gcHandle.IsAllocated) _gcHandle.Free(); return true; diff --git a/src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/Security/RightsManagement/IssuanceLicense.cs b/src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/Security/RightsManagement/IssuanceLicense.cs index a7b7ab949..79e579cbe 100644 --- a/src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/Security/RightsManagement/IssuanceLicense.cs +++ b/src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/Security/RightsManagement/IssuanceLicense.cs @@ -180,8 +180,8 @@ internal class IssuanceLicense : IDisposable } } - // set metafata as required - if (contentId != null) + // set metadata as required + if (contentId != Guid.Empty) { hr = SafeNativeMethods.DRMSetMetaData( _issuanceLicenseHandle, diff --git a/src/Microsoft.DotNet.Wpf/src/WindowsBase/System/Windows/SplashScreen.cs b/src/Microsoft.DotNet.Wpf/src/WindowsBase/System/Windows/SplashScreen.cs index 0b895b3de..abbf7e8fa 100644 --- a/src/Microsoft.DotNet.Wpf/src/WindowsBase/System/Windows/SplashScreen.cs +++ b/src/Microsoft.DotNet.Wpf/src/WindowsBase/System/Windows/SplashScreen.cs @@ -238,7 +238,7 @@ private object CloseInternal(Object fadeOutArg) // In the case where the developer has specified AutoClose=True and then calls // Close(non_zero_timespan) before the auto close operation is dispatched we begin // the fadeout immidiately and ignore the later call to close. - if (_dt != null || _hwnd == null) + if (_dt != null || _hwnd == IntPtr.Zero) { return BooleanBoxes.TrueBox; } -- GitLab