/// <summary> /// Serves as a hash function for the specified symbol. /// </summary> /// <returns>A hash code for the specified symbol.</returns> /// <param name="obj">The symbol for which to get a hash code.</param> /// <exception cref="ArgumentNullException"><paramref name="obj"/> is <c>null</c>.</exception> public override int GetHashCode(TSymbol obj) { if (obj == null) { throw new ArgumentNullException(nameof(obj)); } if (Default.Equals(obj, default(TSymbol))) { return(0); } int hashCode = Hash.Create(MetadataName.GetHashCode(obj.MetadataName)); INamedTypeSymbol t = obj.ContainingType; if (t != null) { hashCode = Combine(t); t = t.ContainingType; while (t != null) { hashCode = Hash.Combine(MetadataName.PlusHashCode, hashCode); hashCode = Combine(t); t = t.ContainingType; } } INamespaceSymbol n = obj.ContainingNamespace; if (n != null) { hashCode = Combine(n); n = n.ContainingNamespace; while (n != null) { hashCode = Hash.Combine(MetadataName.DotHashCode, hashCode); hashCode = Combine(n); n = n.ContainingNamespace; } } return(hashCode); int Combine(ISymbol symbol) { return(Hash.Combine(MetadataName.GetHashCode(symbol.MetadataName), hashCode)); } }
public MetadataNameSet(IEnumerable <string> values) : this(values.Select(f => MetadataName.Parse(f))) { }