/* 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; namespace dnSpy.Contracts.Debugger.StartDebugging.Dialog { /// /// A page shown in the 'debug an application' dialog box. It provides a UI object /// and creates a instance that is used to start /// the application. /// public abstract class StartDebuggingOptionsPage : INotifyPropertyChanged { /// /// Raised after a property is changed /// public event PropertyChangedEventHandler? PropertyChanged; /// /// Raises /// /// Name of property that got changed protected void OnPropertyChanged(string propName) => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propName)); /// /// Guid of this page /// public abstract Guid Guid { get; } /// /// Display order of the UI object compared to other instances, see /// public abstract double DisplayOrder { get; } /// /// Name of debug engine shown in the UI, eg. ".NET Framework" or ".NET" or "Mono" /// public abstract string DisplayName { get; } /// /// Gets the UI object /// public abstract object? UIObject { get; } /// /// true if all options are valid and can be called. /// gets raised when this property is changed. /// public abstract bool IsValid { get; } /// /// Initializes this instance to previous options /// /// Options public abstract void InitializePreviousOptions(StartDebuggingOptions options); /// /// Initializes this instance to default options. If is not /// an EXE file, then should be used to initialize this instance, /// else should be ignored. /// /// Filename /// Default break kind, see /// Options or null public abstract void InitializeDefaultOptions(string filename, string breakKind, StartDebuggingOptions? options); /// /// Gets all options. This method is only called if returns true /// /// public abstract StartDebuggingOptionsInfo GetOptions(); /// /// Returns true if this is a debug engine page that is compatible with a debug engine /// (see eg. ) /// /// Generic debug engine guid (see ) /// Only used if the method returns true and is the order to use if more than /// one instance returns true. (see ) /// public abstract bool SupportsDebugEngine(Guid engineGuid, out double order); /// /// Called when the dialog box gets closed /// public virtual void OnClose() { } } /// /// Contains the options and an optional filename /// public readonly struct StartDebuggingOptionsInfo { /// /// Gets the options /// public StartDebuggingOptions Options { get; } /// /// Filename or null /// public string? Filename { get; } /// /// Gets the flags /// public StartDebuggingOptionsInfoFlags Flags { get; } /// /// Constructor /// /// Options /// Filename or null /// Flags public StartDebuggingOptionsInfo(StartDebuggingOptions options, string? filename, StartDebuggingOptionsInfoFlags flags) { Options = options ?? throw new ArgumentNullException(nameof(options)); Filename = filename; Flags = flags; } } /// /// Extra start options /// [Flags] public enum StartDebuggingOptionsInfoFlags { /// /// No bit is set /// None = 0, /// /// The file extension is not the normal extension /// WrongExtension = 0x00000001, } /// /// Returned by /// public static class PredefinedGenericDebugEngineOrders { /// /// .NET Framework /// public const double DotNetFramework = 1000000; /// /// .NET /// public const double DotNet = 1000000; /// /// .NET Mono /// public const double DotNetMono = DotNetFramework + 1; /// /// .NET Unity /// public const double DotNetUnity = 1000000; } }