Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Temporarily suppress obsolete API errors to get WPF master building #3659

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ internal class PseudoWebRequest : WebRequest
/// <param name="packageUri">uri of the package</param>
/// <param name="partUri">uri of the part - may be null</param>
/// <param name="cacheEntry">cache entry to base this response on</param>
#pragma warning disable SYSLIB0014
internal PseudoWebRequest(Uri uri, Uri packageUri, Uri partUri, Package cacheEntry)
{
Debug.Assert(uri != null, "PackWebRequest uri cannot be null");
Expand All @@ -61,6 +62,7 @@ internal PseudoWebRequest(Uri uri, Uri packageUri, Uri partUri, Package cacheEnt
// set defaults
SetDefaults();
}
#pragma warning restore SYSLIB0014

//------------------------------------------------------
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ internal static WebRequest CreateRequest(Uri uri)
uri = new Uri(uri.GetLeftPart(UriPartial.Path));
}

#pragma warning disable SYSLIB0014
WebRequest request = WebRequest.Create(uri);
#pragma warning restore SYSLIB0014

// It is not clear whether WebRequest.Create() can ever return null, but v1 code make this check in
// a couple of places, so it is still done here, just in case.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ internal PackWebRequest(Uri uri, Uri packageUri, Uri partUri)
/// <param name="cachedPackageIsThreadSafe">is the cacheEntry thread-safe?</param>
/// <remarks>This should only be called by PackWebRequestFactory</remarks>
/// <exception cref="ArgumentException">Will throw an ArgumentException if the given URI is not of the correct scheme</exception>
#pragma warning disable SYSLIB0014
internal PackWebRequest(Uri uri, Uri packageUri, Uri partUri, Package cacheEntry,
bool respectCachePolicy, bool cachedPackageIsThreadSafe)
{
Expand All @@ -89,6 +90,7 @@ internal PackWebRequest(Uri uri, Uri packageUri, Uri partUri, Package cacheEntry
"PackWebRequest - working from Package Cache");
#endif
}
#pragma warning restore SYSLIB0014

//------------------------------------------------------
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,6 @@ internal static Rect GetBoundsHelper(Pen pen, Matrix worldMatrix, Point center,
{
Rect rect;

Debug.Assert(worldMatrix != null);
Debug.Assert(geometryMatrix != null);

if ( (pen == null || pen.DoesNotContainGaps) &&
worldMatrix.IsIdentity && geometryMatrix.IsIdentity)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,6 @@ internal static Rect GetBoundsHelper(Pen pen, Matrix worldMatrix, Rect rect, dou
{
Rect boundingRect;

Debug.Assert(worldMatrix != null);
Debug.Assert(geometryMatrix != null);

if (rect.IsEmpty)
{
boundingRect = Rect.Empty;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ public static void AddPackage(System.Uri uri, System.IO.Packaging.Package packag
public static System.IO.Packaging.Package GetPackage(System.Uri uri) { throw null; }
public static void RemovePackage(System.Uri uri) { }
}
#pragma warning disable SYSLIB0014
public sealed partial class PackWebRequest : System.Net.WebRequest
{
internal PackWebRequest() { }
Expand All @@ -25,6 +26,7 @@ internal PackWebRequest() { }
public override System.IO.Stream GetRequestStream() { throw null; }
public override System.Net.WebResponse GetResponse() { throw null; }
}
#pragma warning restore SYSLIB0014
public sealed partial class PackWebRequestFactory : System.Net.IWebRequestCreate
{
public PackWebRequestFactory() { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,7 @@ IntPtr unmanagedBuffer
}
catch (Exception)
{
if (unmanagedBuffer != null)
if (unmanagedBuffer != IntPtr.Zero)
{
FreeUnmanagedPrintDlgExStruct(unmanagedBuffer);
unmanagedBuffer = IntPtr.Zero;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ internal void FormatCellFinite(Size subpageSize, IntPtr breakRecordIn, bool isEm
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));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public void Dispose()
marshaler?.Dispose();
}
}
if (_array != null)
if (_array != IntPtr.Zero)
{
Marshal.FreeCoTaskMem(_array);
}
Expand Down Expand Up @@ -445,7 +445,7 @@ public void Dispose()
Marshaler<T>.DisposeMarshaler(marshaler);
}
}
if (_array != null)
if (_array != IntPtr.Zero)
{
Marshal.FreeCoTaskMem(_array);
}
Expand Down Expand Up @@ -627,7 +627,7 @@ public void Dispose()
DisposeMarshaler(marshaler);
}
}
if (_array != null)
if (_array != IntPtr.Zero)
{
Marshal.FreeCoTaskMem(_array);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,9 +349,6 @@ private bool IsValidThread()
/// <returns></returns>
private CalendarDateRange GetContainingDateRange(DateTime date)
{
if (date == null)
return null;

for (int i = 0; i < Count; i++)
{
if (DateTimeHelper.InRange(date, this[i]))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,9 @@ private string OemDriverNamespace
CultureInfo.InvariantCulture,
DeviceNamespaceFormat,
BuildInfo.WCP_VERSION_SUFFIX,
#pragma warning disable SYSLIB0013
Uri.EscapeUriString(this._driverName),
#pragma warning restore SYSLIB0013
this._driverVersion);
}

Expand Down
3 changes: 2 additions & 1 deletion src/Microsoft.DotNet.Wpf/src/Shared/MS/Win32/HwndSubclass.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,8 @@ private void Initialize(
}
}

// set metafata as required
if (contentId != null)
// set metadata as required
if (contentId != Guid.Empty)
{
hr = SafeNativeMethods.DRMSetMetaData(
_issuanceLicenseHandle,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down