/* 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.Debugger.DotNet.Code { /// /// Method scope /// public sealed class DbgMethodDebugScope { /// /// Gets the span of this scope /// public DbgILSpan Span { get; } /// /// Gets all child scopes /// public DbgMethodDebugScope[] Scopes { get; } /// /// Gets all new locals in the scope /// public DbgLocal[] Locals { get; } /// /// Gets all new imports in the scope /// public DbgImportInfo[] Imports { get; } /// /// Constructor /// /// Scope span /// Child scopes /// Locals /// Imports public DbgMethodDebugScope(DbgILSpan span, DbgMethodDebugScope[] scopes, DbgLocal[] locals, DbgImportInfo[] imports) { Span = span; Scopes = scopes ?? throw new ArgumentNullException(nameof(scopes)); Locals = locals ?? throw new ArgumentNullException(nameof(locals)); Imports = imports ?? throw new ArgumentNullException(nameof(imports)); } } /// /// Import kind /// public enum DbgImportInfoKind { /// /// Namespace import /// Namespace, /// /// Type import /// Type, /// /// Namespace or type import /// NamespaceOrType, /// /// C#: extern alias /// Assembly, /// /// VB: XML import /// XmlNamespace, /// /// VB: token of method with imports /// MethodToken, /// /// VB: containing namespace /// CurrentNamespace, /// /// VB: root namespace /// DefaultNamespace, } /// /// Visual Basic import scope kind /// public enum DbgVBImportScopeKind { /// /// Unspecified scope /// None, /// /// File scope /// File, /// /// Project scope /// Project, } /// /// Import info /// public readonly struct DbgImportInfo { /// /// Target kind /// public DbgImportInfoKind TargetKind { get; } /// /// Gets the VB import scope kind /// public DbgVBImportScopeKind VBImportScopeKind { get; } /// /// Target /// public string? Target { get; } /// /// Alias /// public string? Alias { get; } /// /// Extern alias /// public string? ExternAlias { get; } /// /// Constructor /// /// Target kind /// Target string /// Alias /// Extern alias /// VB import scope kind public DbgImportInfo(DbgImportInfoKind targetKind, string? target = null, string? alias = null, string? externAlias = null, DbgVBImportScopeKind importScopeKind = DbgVBImportScopeKind.None) { TargetKind = targetKind; Target = target; Alias = alias; ExternAlias = externAlias; VBImportScopeKind = importScopeKind; } #pragma warning disable CS1591 // Missing XML comment for publicly visible type or member public static DbgImportInfo CreateNamespace(string @namespace) => new DbgImportInfo(DbgImportInfoKind.Namespace, target: @namespace); public static DbgImportInfo CreateNamespace(string @namespace, string externAlias) => new DbgImportInfo(DbgImportInfoKind.Namespace, target: @namespace, externAlias: externAlias); public static DbgImportInfo CreateType(string type) => new DbgImportInfo(DbgImportInfoKind.Type, target: type); public static DbgImportInfo CreateNamespaceAlias(string @namespace, string alias) => new DbgImportInfo(DbgImportInfoKind.Namespace, target: @namespace, alias: alias); public static DbgImportInfo CreateTypeAlias(string type, string alias) => new DbgImportInfo(DbgImportInfoKind.Type, target: type, alias: alias); public static DbgImportInfo CreateNamespaceAlias(string @namespace, string alias, string externAlias) => new DbgImportInfo(DbgImportInfoKind.Namespace, target: @namespace, alias: alias, externAlias: externAlias); public static DbgImportInfo CreateAssembly(string externAlias) => new DbgImportInfo(DbgImportInfoKind.Assembly, externAlias: externAlias); public static DbgImportInfo CreateAssembly(string externAlias, string assembly) => new DbgImportInfo(DbgImportInfoKind.Assembly, externAlias: externAlias, target: assembly); public static DbgImportInfo CreateCurrentNamespace() => new DbgImportInfo(DbgImportInfoKind.CurrentNamespace, target: string.Empty); public static DbgImportInfo CreateNamespaceOrType(string namespaceOrType, string alias, DbgVBImportScopeKind importScopeKind) => new DbgImportInfo(DbgImportInfoKind.NamespaceOrType, target: namespaceOrType, alias: alias, importScopeKind: importScopeKind); public static DbgImportInfo CreateXmlNamespace(string xmlNamespace, string alias, DbgVBImportScopeKind importScopeKind) => new DbgImportInfo(DbgImportInfoKind.XmlNamespace, target: xmlNamespace, alias: alias, importScopeKind: importScopeKind); public static DbgImportInfo CreateType(string type, DbgVBImportScopeKind importScopeKind) => new DbgImportInfo(DbgImportInfoKind.Type, target: type, importScopeKind: importScopeKind); public static DbgImportInfo CreateNamespace(string @namespace, DbgVBImportScopeKind importScopeKind) => new DbgImportInfo(DbgImportInfoKind.Namespace, target: @namespace, importScopeKind: importScopeKind); public static DbgImportInfo CreateMethodToken(string token, DbgVBImportScopeKind importScopeKind) => new DbgImportInfo(DbgImportInfoKind.MethodToken, target: token, importScopeKind: importScopeKind); public static DbgImportInfo CreateDefaultNamespace(string @namespace) => new DbgImportInfo(DbgImportInfoKind.DefaultNamespace, target: @namespace); #pragma warning restore CS1591 // Missing XML comment for publicly visible type or member } }