/* 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; using System.ComponentModel; using dnSpy.Contracts.Debugger.Engine; namespace dnSpy.Contracts.Debugger.Breakpoints.Code { /// /// A bound breakpoint. These only exist while debugging a program. A bound breakpoint is only created /// if the breakpoint is enabled. /// public abstract class DbgBoundCodeBreakpoint : DbgObject, INotifyPropertyChanged { /// /// Raised when a property is changed /// public abstract event PropertyChangedEventHandler? PropertyChanged; /// /// Gets the breakpoint /// public abstract DbgCodeBreakpoint Breakpoint { get; } /// /// Gets the process /// public DbgProcess Process => Runtime.Process; /// /// Gets the runtime /// public abstract DbgRuntime Runtime { get; } /// /// Gets the module or null if none /// public abstract DbgModule? Module { get; } /// /// Gets the address of the breakpoint. This property is valid if is true /// public abstract ulong Address { get; } /// /// true if is a valid address /// public bool HasAddress => Address != DbgObjectFactory.BoundBreakpointNoAddress; /// /// Gets the warning/error message /// public abstract DbgBoundCodeBreakpointMessage Message { get; } } /// /// Bound breakpoint message severity /// public enum DbgBoundCodeBreakpointSeverity { /// /// No error/warning message /// None, /// /// Warning /// Warning, /// /// Error /// Error, } /// /// Bound breakpoint message /// public readonly struct DbgBoundCodeBreakpointMessage : IEquatable { /// /// No error/warning message /// public static readonly DbgBoundCodeBreakpointMessage None = new DbgBoundCodeBreakpointMessage(DbgBoundCodeBreakpointSeverity.None, string.Empty); /// /// Gets the severity /// public DbgBoundCodeBreakpointSeverity Severity { get; } /// /// Gets the message /// public string Message { get; } /// /// Constructor /// /// Severity /// Message public DbgBoundCodeBreakpointMessage(DbgBoundCodeBreakpointSeverity severity, string message) { Severity = severity; Message = message ?? throw new ArgumentNullException(nameof(message)); } #pragma warning disable CS1591 // Missing XML comment for publicly visible type or member public static bool operator ==(DbgBoundCodeBreakpointMessage left, DbgBoundCodeBreakpointMessage right) => left.Equals(right); public static bool operator !=(DbgBoundCodeBreakpointMessage left, DbgBoundCodeBreakpointMessage right) => !left.Equals(right); #pragma warning restore CS1591 // Missing XML comment for publicly visible type or member /// /// Compares this instance to /// /// Other instance /// public bool Equals(DbgBoundCodeBreakpointMessage other) => Severity == other.Severity && StringComparer.Ordinal.Equals(Message, other.Message); /// /// Compares this instance to /// /// Object /// public override bool Equals(object? obj) => obj is DbgBoundCodeBreakpointMessage other && Equals(other); /// /// Gets the hash code /// /// public override int GetHashCode() => (int)Severity ^ StringComparer.Ordinal.GetHashCode(Message ?? string.Empty); /// /// ToString() /// /// public override string ToString() => $"{Severity}: {Message}"; } }