/// <summary> /// Determine a hash value for the TypeMetadata object according to /// the general <see cref="object.GetHashCode"/> contract. /// </summary> /// <returns> /// An integer hash value for this TypeMetadata instance. /// </returns> public override int GetHashCode() { ITypeKey key = Key; int hash = HashHelper.Hash(key.TypeId, 31); hash = HashHelper.Hash(key.VersionId, hash); hash = HashHelper.Hash(m_attributes, hash); return(hash); }
private void AddNameToChain(IVTableSlot slot) { var method = slot.MethodDef; var type = method.DeclaringType; var name = method.Name; var otherType = slot.Parent?.MethodDef.DeclaringType; Dictionary <string, VChain> chains, otherChains = null; VChain chain, otherChain = null; ITypeKey key = type.CreateKey(), otherKey = null; if (!_chains.TryGetValue(key, out chains)) { _chains.Add(key, chains = new Dictionary <string, VChain>()); } if (otherType != null) { otherKey = otherType.CreateKey(); if (!_chains.TryGetValue(otherKey, out otherChains)) { _chains.Add(otherKey, otherChains = new Dictionary <string, VChain>()); } } chains.TryGetValue(name, out chain); otherChains?.TryGetValue(name, out otherChain); if (otherChain == null) { if (chain == null) { chains.Add(name, chain = new VChain(name)); } otherChain = chain; otherChains?.Add(name, otherChain); } else { if (chain == null) { chains.Add(name, chain = otherChain); } else if (chain != otherChain) { CombineChains(chain, otherChain); } } chain.Types.Add(key); if (otherType != null) { chain.Types.Add(otherKey); } if (!chain.DontRename && DontRename != null) { chain.DontRename = DontRename(method) || (slot.Parent != null && DontRename(slot.Parent?.MethodDef)); } }
/// <summary> /// Compare this TypeKey with another object to determine /// equality. /// </summary> /// <remarks> /// Two TypeKey objects are considered equal iff their /// <see cref="TypeId"/> and <see cref="VersionId"/> are equal. /// </remarks> /// <param name="that"> /// ITypeKey instance to compare this instance to. /// </param> /// <returns> /// <c>true</c> iff this TypeKey and the passed object are /// equivalent. /// </returns> public virtual bool Equals(ITypeKey that) { return(TypeId == that.TypeId && VersionId == that.VersionId); }