/* Copyright (C) 2014-2019 de4dot@gmail.com This file is part of dnSpy dnSpy is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. dnSpy is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with dnSpy. If not, see . */ using System; namespace dnSpy.Contracts.Decompiler { /// /// An address reference /// public sealed class AddressReference : IEquatable { /// /// Filename /// public string Filename { get; } /// /// true if is an RVA, false if it's a file offset /// public bool IsRVA { get; } /// /// Address, either an RVA or a file offset () /// public ulong Address { get; } /// /// Length of range /// public ulong Length { get; } /// /// Constructor /// /// Filename or null /// true if is an RVA, false if it's a file offset /// Address /// Length public AddressReference(string? filename, bool isRva, ulong address, ulong length) { Filename = filename ?? string.Empty; IsRVA = isRva; Address = address; Length = length; } /// /// Equals() /// /// /// public bool Equals(AddressReference? other) => other is not null && IsRVA == other.IsRVA && Address == other.Address && Length == other.Length && StringComparer.OrdinalIgnoreCase.Equals(Filename, other.Filename); /// /// Equals() /// /// /// public override bool Equals(object? obj) => Equals(obj as AddressReference); /// /// GetHashCode() /// /// public override int GetHashCode() => StringComparer.OrdinalIgnoreCase.GetHashCode(Filename) ^ (IsRVA ? 0 : int.MinValue) ^ (int)Address ^ (int)(Address >> 32) ^ (int)Length ^ (int)(Length >> 32); } }