diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/Shaping/OpenTypeLayoutCache.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/Shaping/OpenTypeLayoutCache.cs index 96a9b97563e..1daae6e3e97 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/Shaping/OpenTypeLayoutCache.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/Shaping/OpenTypeLayoutCache.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // @@ -1127,6 +1127,25 @@ public bool Equals(GlyphLookupRecord value) { return !value1.Equals(value2); } + public static bool operator <(GlyphLookupRecord left, GlyphLookupRecord right) + { + return left.CompareTo(right) < 0; + } + + public static bool operator >(GlyphLookupRecord left, GlyphLookupRecord right) + { + return left.CompareTo(right) > 0; + } + + public static bool operator <=(GlyphLookupRecord left, GlyphLookupRecord right) + { + return left.CompareTo(right) <= 0; + } + + public static bool operator >=(GlyphLookupRecord left, GlyphLookupRecord right) + { + return left.CompareTo(right) >= 0; + } public override bool Equals(object value) { return Equals((GlyphLookupRecord)value); diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/TextFormatting/TextStore.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/TextFormatting/TextStore.cs index 7e818831529..6d5c4882d7e 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/TextFormatting/TextStore.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/TextFormatting/TextStore.cs @@ -590,6 +590,51 @@ public int CompareTo(TextEffectBoundary other) // Starting edge is always in front. return IsStart ? -1 : 1; } + + public bool Equals(TextEffectBoundary other) + { + return _position == other._position && _isStart == other._isStart; + } + + public override bool Equals(object obj) + { + return obj is TextEffectBoundary other && Equals(other); + } + + public override int GetHashCode() + { + return HashCode.Combine(_position, _isStart); + } + + public static bool operator ==(TextEffectBoundary left, TextEffectBoundary right) + { + return left.Equals(right); + } + + public static bool operator !=(TextEffectBoundary left, TextEffectBoundary right) + { + return !left.Equals(right); + } + + public static bool operator <(TextEffectBoundary left, TextEffectBoundary right) + { + return left.CompareTo(right) < 0; + } + + public static bool operator >(TextEffectBoundary left, TextEffectBoundary right) + { + return left.CompareTo(right) > 0; + } + + public static bool operator <=(TextEffectBoundary left, TextEffectBoundary right) + { + return left.CompareTo(right) <= 0; + } + + public static bool operator >=(TextEffectBoundary left, TextEffectBoundary right) + { + return left.CompareTo(right) >= 0; + } } diff --git a/src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/IO/Packaging/PackUriHelper.cs b/src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/IO/Packaging/PackUriHelper.cs index 3af7b7ea6ca..9e6278c58d3 100644 --- a/src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/IO/Packaging/PackUriHelper.cs +++ b/src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/IO/Packaging/PackUriHelper.cs @@ -358,9 +358,54 @@ bool IEquatable.Equals(ValidatedPartUri otherPartUri) { return Compare(otherPartUri) == 0; } - + #endregion IEqualityComparer Methods + public override bool Equals(object obj) + { + return obj is ValidatedPartUri other && Compare(other) == 0; + } + + public override int GetHashCode() + { + return NormalizedPartUriString.GetHashCode(); + } + public static bool operator ==(ValidatedPartUri left, ValidatedPartUri right) + { + if (left is null) + return right is null; + return left.Equals(right); + } + + public static bool operator !=(ValidatedPartUri left, ValidatedPartUri right) => !(left == right); + + public static bool operator <(ValidatedPartUri left, ValidatedPartUri right) + { + if (left is null) + return right is not null; + return left.Compare(right) < 0; + } + + public static bool operator >(ValidatedPartUri left, ValidatedPartUri right) + { + if (left is null) + return false; + return left.Compare(right) > 0; + } + + public static bool operator <=(ValidatedPartUri left, ValidatedPartUri right) + { + if (left is null) + return true; + return left.Compare(right) <= 0; + } + + public static bool operator >=(ValidatedPartUri left, ValidatedPartUri right) + { + if (left is null) + return right is null; + return left.Compare(right) >= 0; + } #region Internal Properties //------------------------------------------------------ diff --git a/src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/IO/Packaging/SparseMemoryStream.cs b/src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/IO/Packaging/SparseMemoryStream.cs index 967903536c9..928cf9ae005 100644 --- a/src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/IO/Packaging/SparseMemoryStream.cs +++ b/src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/IO/Packaging/SparseMemoryStream.cs @@ -872,8 +872,7 @@ internal long EndOffset } } } - - int IComparable.CompareTo(MemoryStreamBlock other) + private int Compare(MemoryStreamBlock other) { if (other == null) return 1; @@ -895,7 +894,71 @@ int IComparable.CompareTo(MemoryStreamBlock other) return -1; } } + int IComparable.CompareTo(MemoryStreamBlock other) + { + return Compare(other); + } + public bool Equals(MemoryStreamBlock other) + { + if (other == null) + return false; + + if (_offset == other.Offset) + return true; + if (_offset >= other.Offset && _offset < other.EndOffset) + return true; + if (other.Offset >= _offset && other.Offset < EndOffset) + return true; + + return false; + } + public override bool Equals(object obj) + { + return obj is MemoryStreamBlock other && Equals(other); + } + public override int GetHashCode() + { + return _offset.GetHashCode(); + } + public static bool operator ==(MemoryStreamBlock left, MemoryStreamBlock right) + { + if (left is null) + return right is null; + return left.Equals(right); + } + + public static bool operator !=(MemoryStreamBlock left, MemoryStreamBlock right) + { + return !(left == right); + } + public static bool operator <(MemoryStreamBlock left, MemoryStreamBlock right) + { + if (left is null) + return right is not null; + return left.Compare(right) < 0; + } + + public static bool operator >(MemoryStreamBlock left, MemoryStreamBlock right) + { + if (left is null) + return false; + return left.Compare(right) > 0; + } + + public static bool operator <=(MemoryStreamBlock left, MemoryStreamBlock right) + { + if (left is null) + return true; + return left.Compare(right) <= 0; + } + + public static bool operator >=(MemoryStreamBlock left, MemoryStreamBlock right) + { + if (left is null) + return right is null; + return left.Compare(right) >= 0; + } private MemoryStream _stream; private long _offset; }