TypeDeclarationKey.cs
1 using System; 2 using System.Diagnostics.CodeAnalysis; 3 4 namespace Spv.Generator 5 { 6 internal readonly struct TypeDeclarationKey : IEquatable<TypeDeclarationKey> 7 { 8 private readonly Instruction _typeDeclaration; 9 10 public TypeDeclarationKey(Instruction typeDeclaration) 11 { 12 _typeDeclaration = typeDeclaration; 13 } 14 15 public override int GetHashCode() 16 { 17 return DeterministicHashCode.Combine(_typeDeclaration.Opcode, _typeDeclaration.GetHashCodeContent()); 18 } 19 20 public bool Equals(TypeDeclarationKey other) 21 { 22 return _typeDeclaration.Opcode == other._typeDeclaration.Opcode && _typeDeclaration.EqualsContent(other._typeDeclaration); 23 } 24 25 public override bool Equals([NotNullWhen(true)] object obj) 26 { 27 return obj is TypeDeclarationKey key && Equals(key); 28 } 29 } 30 }