Skip to content

Commit db191d2

Browse files
committed
Use ReferenceEqualityComparer instead of TypeEqualityComparer
1 parent f6c4b67 commit db191d2

File tree

3 files changed

+24
-31
lines changed

3 files changed

+24
-31
lines changed

src/Avalonia.Base/AvaloniaProperty.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ public abstract class AvaloniaProperty : IEquatable<AvaloniaProperty>, IProperty
3232
private Type? _singleHostType;
3333
private AvaloniaPropertyMetadata? _singleMetadata;
3434

35-
private readonly Dictionary<Type, AvaloniaPropertyMetadata> _metadata = new(TypeEqualityComparer.Instance);
36-
private readonly Dictionary<Type, AvaloniaPropertyMetadata> _metadataCache = new(TypeEqualityComparer.Instance);
35+
private readonly Dictionary<Type, AvaloniaPropertyMetadata> _metadata = new(ReferenceEqualityComparer.Instance);
36+
private readonly Dictionary<Type, AvaloniaPropertyMetadata> _metadataCache = new(ReferenceEqualityComparer.Instance);
3737

3838
/// <summary>
3939
/// Initializes a new instance of the <see cref="AvaloniaProperty"/> class.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#if NETSTANDARD2_0
2+
3+
using System.Runtime.CompilerServices;
4+
5+
namespace System.Collections.Generic;
6+
7+
internal sealed class ReferenceEqualityComparer : IEqualityComparer<object?>, IEqualityComparer
8+
{
9+
public static ReferenceEqualityComparer Instance { get; } = new();
10+
11+
private ReferenceEqualityComparer()
12+
{
13+
}
14+
15+
public new bool Equals(object? x, object? y)
16+
=> ReferenceEquals(x, y);
17+
18+
public int GetHashCode(object? obj)
19+
=> RuntimeHelpers.GetHashCode(obj);
20+
}
21+
22+
#endif

src/Avalonia.Base/Utilities/TypeEqualityComparer.cs

Lines changed: 0 additions & 29 deletions
This file was deleted.

0 commit comments

Comments
 (0)