public void IStructuralEquatable_GetHashCode_NullComparer_ThrowsNullReferenceException() { // This was not fixed in order to be compatible with the full .NET framework and Xamarin. See #13410 IStructuralEquatable equatable = (IStructuralEquatable)Tuple; Assert.Throws <NullReferenceException>(() => equatable.GetHashCode(null)); }
/// <summary> /// Returns a hash code for the current instance. /// </summary> /// <param name="comparer">An object that computes the hash code of the current object.</param> /// <returns>The hash code for the current instance.</returns> int IStructuralEquatable.GetHashCode(IEqualityComparer comparer) { var self = this; IStructuralEquatable ours = self.array; return(ours != null?ours.GetHashCode(comparer) : self.GetHashCode()); }
public int GetHashCode(WampMessage <TMessage> obj) { IStructuralEquatable xArguments = obj.Arguments; return(obj.MessageType.GetHashCode() ^ xArguments.GetHashCode(mRawComparer)); }
public void IStructuralEquatable_GetHashCode_NullComparer_ThrowsNullReferenceException() { // This was not fixed in order to be compatible with the .NET Framework and Xamarin. // See https://github.com/dotnet/runtime/issues/19265 IStructuralEquatable equatable = (IStructuralEquatable)Tuple; Assert.Throws <NullReferenceException>(() => equatable.GetHashCode(null)); }
public static int ImmutableHash <TSrc>(this TSrc inst, ref int?hashCache, IStructuralEquatable tuple) where TSrc : IEquatable <TSrc>, IImmutable { if (hashCache is null) { hashCache = tuple.GetHashCode(); } return(hashCache.Value); }
public static int StructuralGetHashCode(IStructuralEquatable v) { if (v == null) { return(DefaultHashCode); } return(v.GetHashCode(DefaultComparer)); }
private static string GetGenericArgsSuffix(Type baseType) { if (!baseType.IsGenericType) { return(string.Empty); } IStructuralEquatable genericArguments = baseType.GetGenericArguments(); var hashCode = genericArguments.GetHashCode(EqualityComparer <Type> .Default); return($"<Generics{hashCode}>"); }
// Token: 0x060037E0 RID: 14304 RVA: 0x000D5B24 File Offset: 0x000D3D24 public int GetHashCode(object obj) { if (obj == null) { return(0); } IStructuralEquatable structuralEquatable = obj as IStructuralEquatable; if (structuralEquatable != null) { return(structuralEquatable.GetHashCode(this)); } return(obj.GetHashCode()); }
/// <inheritdoc /> public int GetHashCode(object obj) { IEqualityComparerContracts.GetHashCode(obj); // if there is a comparer registered for the type then use that IEqualityComparer comparer; if (this.comparerPerType.TryGetValue(obj.GetType(), out comparer)) { return(comparer.GetHashCode(obj)); } // check if the type is structurally equatable, and if so pass this comparer as the structural comparer IStructuralEquatable structuralEquatable = obj as IStructuralEquatable; if (structuralEquatable != null) { return(structuralEquatable.GetHashCode(this)); } // otherwise fall back on regular hashcode return(obj.GetHashCode()); }
// Structural Equality and Hashing Helpers public static int StructuralHashMethod(CodeContext /*!*/ context, IStructuralEquatable x) { return(x.GetHashCode(context.LanguageContext.EqualityComparerNonGeneric)); }
public override int GetHashCode() { IStructuralEquatable bytesEquatable = Bytes as IStructuralEquatable; return(bytesEquatable.GetHashCode(EqualityComparer <byte> .Default)); }