Update ReferenceEqualityComparer.cs (#24728)
We don't support running on mono 4.x anymore
This commit is contained in:
parent
369b8a17cb
commit
24f35bc76f
|
|
@ -9,8 +9,6 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding
|
||||||
{
|
{
|
||||||
internal class ReferenceEqualityComparer : IEqualityComparer<object>
|
internal class ReferenceEqualityComparer : IEqualityComparer<object>
|
||||||
{
|
{
|
||||||
private static readonly bool IsMono = Type.GetType("Mono.Runtime") != null;
|
|
||||||
|
|
||||||
public static ReferenceEqualityComparer Instance { get; } = new ReferenceEqualityComparer();
|
public static ReferenceEqualityComparer Instance { get; } = new ReferenceEqualityComparer();
|
||||||
|
|
||||||
public new bool Equals(object x, object y)
|
public new bool Equals(object x, object y)
|
||||||
|
|
@ -20,14 +18,6 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding
|
||||||
|
|
||||||
public int GetHashCode(object obj)
|
public int GetHashCode(object obj)
|
||||||
{
|
{
|
||||||
// RuntimeHelpers.GetHashCode sometimes crashes the runtime on Mono 4.0.4
|
|
||||||
// See: https://github.com/aspnet/External/issues/45
|
|
||||||
// The workaround here is to just not hash anything, and fall back to an equality check.
|
|
||||||
if (IsMono)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return RuntimeHelpers.GetHashCode(obj);
|
return RuntimeHelpers.GetHashCode(obj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue