From 45716aff73eb4a3047def20fa6006d156a7e25bb Mon Sep 17 00:00:00 2001 From: 0xd4d Date: Wed, 11 Nov 2020 20:14:11 +0100 Subject: [PATCH] Rename files, classes, remove Core from .NET Core --- DnSpyCommon.props | 2 +- ... => DotNetAttachProgramOptionsProvider.cs} | 24 +-- .../DotNetCommonStartDebuggingOptionsPage.cs | 172 ++++++++++++++++ .../DotNetCoreStartDebuggingOptionsPage.cs | 174 ---------------- ...otNetFrameworkStartDebuggingOptionsPage.cs | 2 +- ...> DotNetGenericDebugEngineGuidProvider.cs} | 20 +- .../DotNetStartDebuggingOptionsPage.cs | 194 +++++++++--------- .../StartDebuggingOptionsPageProviderImpl.cs | 2 +- .../Impl/AppHostUtils.cs | 6 +- .../Attach/CorDebugAttachToProgramOptions.cs | 2 +- ...ons.cs => DotNetAttachToProgramOptions.cs} | 8 +- .../Impl/DbgEngineImpl.cs | 14 +- .../Impl/DbgEngineProviderImpl.cs | 8 +- ...bgEngineImpl.cs => DotNetDbgEngineImpl.cs} | 26 +-- ...sStarter.cs => DotNetDbgProcessStarter.cs} | 8 +- .../Impl/DotNetFrameworkDbgEngineImpl.cs | 2 +- .../DbgDotNetEngineObjectIdFactoryImpl.cs | 8 +- .../TheExtension.cs | 2 +- .../Themes/wpf.styles.templates.xaml | 2 +- ...{DotNetCoreHelpers.cs => DotNetHelpers.cs} | 12 +- .../dnSpy.Debugger.DotNet.CorDebug.csproj | 16 +- .../dndbg/DotNet/CorModuleDef.cs | 6 +- .../dndbg/Engine/CoreCLRHelper.cs | 4 +- .../dndbg/Engine/DnDebugger.cs | 4 +- .../DmdSigComparer.cs | 4 +- .../dnSpy.Debugger.DotNet.Metadata/DmdType.cs | 2 +- .../Impl/DmdAppDomainImpl.cs | 2 +- .../Impl/DbgEngineImpl.cs | 4 +- .../Evaluation/DbgDotNetRawValueFactory.cs | 4 +- .../DotNetGenericDebugEngineGuidProvider.cs | 4 +- .../Metadata/KnownMemberNames.cs | 6 +- README.md | 2 +- build.ps1 | 30 +-- .../Compiler/FrameworkDetector.cs | 6 +- .../ValueNodes/EnumerableDebugViewHelper.cs | 2 +- .../ResultsViewMembersValueNodeProvider.cs | 2 +- dnSpy/dnSpy-x86/Program.cs | 2 +- dnSpy/dnSpy.Console/Program.cs | 8 +- dnSpy/dnSpy.Console/dnSpy.Console.csproj | 4 +- .../CorDebugRuntimeKind.cs | 4 +- .../CorDebugRuntimeVersion.cs | 2 +- .../CorDebugStartDebuggingOptions.cs | 2 +- .../DbgCorDebugInternalRuntime.cs | 2 +- ...ions.cs => DotNetStartDebuggingOptions.cs} | 10 +- .../PredefinedDotNetDbgRuntimeTags.cs | 8 +- .../Runtimes/DbgRuntimeDotNetExtensions.cs | 2 +- ...efinedAttachProgramOptionsProviderNames.cs | 4 +- .../PredefinedDbgRuntimeGuids.cs | 8 +- .../StartDebugging/DbgProcessStarter.cs | 4 +- ...dStartDebuggingOptionsPageDisplayOrders.cs | 4 +- .../Dialog/StartDebuggingOptionsPage.cs | 6 +- .../GenericDebugEngineGuidProvider.cs | 10 +- .../PredefinedGenericDebugEngineGuids.cs | 4 +- dnSpy/dnSpy/Documents/AssemblyResolver.cs | 108 +++++----- ...ePathProvider.cs => DotNetPathProvider.cs} | 72 +++---- dnSpy/dnSpy/Documents/FrameworkPath.cs | 12 +- .../Documents/TargetFrameworkAttributeInfo.cs | 2 +- dnSpy/dnSpy/MainApp/AboutScreen.cs | 4 +- dnSpy/dnSpy/MainApp/App.xaml.cs | 12 +- dnSpy/dnSpy/MainApp/AppWindow.cs | 8 +- dnSpy/dnSpy/MainApp/BGJitUtils.cs | 4 +- dnSpy/dnSpy/MainApp/CachedMefInfo.cs | 2 +- ...emblyLoader.cs => DotNetAssemblyLoader.cs} | 6 +- .../Settings/WindowsExplorerIntegration.cs | 2 +- dnSpy/dnSpy/Search/FrameworkFileUtils.cs | 4 +- 65 files changed, 555 insertions(+), 551 deletions(-) rename Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/Dialogs/AttachToProcess/{DotNetCoreAttachProgramOptionsProvider.cs => DotNetAttachProgramOptionsProvider.cs} (74%) create mode 100644 Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/Dialogs/DebugProgram/DotNetCommonStartDebuggingOptionsPage.cs delete mode 100644 Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/Dialogs/DebugProgram/DotNetCoreStartDebuggingOptionsPage.cs rename Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/Dialogs/DebugProgram/{DotNetCoreGenericDebugEngineGuidProvider.cs => DotNetGenericDebugEngineGuidProvider.cs} (70%) rename Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/Impl/Attach/{DotNetCoreAttachToProgramOptions.cs => DotNetAttachToProgramOptions.cs} (87%) rename Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/Impl/{DotNetCoreDbgEngineImpl.cs => DotNetDbgEngineImpl.cs} (74%) rename Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/Impl/{DotNetCoreDbgProcessStarter.cs => DotNetDbgProcessStarter.cs} (87%) rename Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/Utilities/{DotNetCoreHelpers.cs => DotNetHelpers.cs} (93%) rename dnSpy/dnSpy.Contracts.Debugger.DotNet.CorDebug/{DotNetCoreStartDebuggingOptions.cs => DotNetStartDebuggingOptions.cs} (86%) rename dnSpy/dnSpy/Documents/{DotNetCorePathProvider.cs => DotNetPathProvider.cs} (81%) rename dnSpy/dnSpy/MainApp/{NetCoreAssemblyLoader.cs => DotNetAssemblyLoader.cs} (94%) diff --git a/DnSpyCommon.props b/DnSpyCommon.props index b1407ac13a..9bb1e450dd 100644 --- a/DnSpyCommon.props +++ b/DnSpyCommon.props @@ -50,7 +50,7 @@ - + false true diff --git a/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/Dialogs/AttachToProcess/DotNetCoreAttachProgramOptionsProvider.cs b/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/Dialogs/AttachToProcess/DotNetAttachProgramOptionsProvider.cs similarity index 74% rename from Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/Dialogs/AttachToProcess/DotNetCoreAttachProgramOptionsProvider.cs rename to Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/Dialogs/AttachToProcess/DotNetAttachProgramOptionsProvider.cs index c14d70bd59..ecde39b4aa 100644 --- a/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/Dialogs/AttachToProcess/DotNetCoreAttachProgramOptionsProvider.cs +++ b/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/Dialogs/AttachToProcess/DotNetAttachProgramOptionsProvider.cs @@ -28,12 +28,12 @@ You should have received a copy of the GNU General Public License using dnSpy.Debugger.DotNet.CorDebug.Utilities; namespace dnSpy.Debugger.DotNet.CorDebug.Dialogs.AttachToProcess { - [ExportAttachProgramOptionsProviderFactory(PredefinedAttachProgramOptionsProviderNames.DotNetCore)] - sealed class DotNetCoreAttachProgramOptionsProviderFactory : AttachProgramOptionsProviderFactory { - public override AttachProgramOptionsProvider? Create(bool allFactories) => new DotNetCoreAttachProgramOptionsProvider(); + [ExportAttachProgramOptionsProviderFactory(PredefinedAttachProgramOptionsProviderNames.DotNet)] + sealed class DotNetAttachProgramOptionsProviderFactory : AttachProgramOptionsProviderFactory { + public override AttachProgramOptionsProvider? Create(bool allFactories) => new DotNetAttachProgramOptionsProvider(); } - sealed class DotNetCoreAttachProgramOptionsProvider : AttachProgramOptionsProvider { + sealed class DotNetAttachProgramOptionsProvider : AttachProgramOptionsProvider { public override IEnumerable Create(AttachProgramOptionsProviderContext context) { foreach (var process in DebuggableProcesses.GetProcesses(context.ProcessIds, context.IsValidProcess, context.CancellationToken)) { foreach (var info in TryGetCoreCLRInfos(process)) { @@ -43,34 +43,34 @@ public override IEnumerable Create(AttachProgramOptionsPro } } - IEnumerable TryGetCoreCLRInfos(Process process) { + IEnumerable TryGetCoreCLRInfos(Process process) { // We can only debug processes with the same bitness int bitness = IntPtr.Size * 8; - var dbgShimFilename = DotNetCoreHelpers.GetDebugShimFilename(bitness); + var dbgShimFilename = DotNetHelpers.GetDebugShimFilename(bitness); foreach (var ccInfo in CoreCLRHelper.GetCoreCLRInfos(process.Id, null, dbgShimFilename)) - yield return new DotNetCoreAttachProgramOptions(process.Id, ccInfo.CoreCLRTypeInfo.Version, ccInfo.CoreCLRTypeInfo.CoreCLRFilename); + yield return new DotNetAttachProgramOptions(process.Id, ccInfo.CoreCLRTypeInfo.Version, ccInfo.CoreCLRTypeInfo.CoreCLRFilename); } } - sealed class DotNetCoreAttachProgramOptions : AttachProgramOptions { + sealed class DotNetAttachProgramOptions : AttachProgramOptions { public override int ProcessId { get; } public override RuntimeId RuntimeId { get; } public override string RuntimeName { get; } - public override Guid RuntimeGuid => PredefinedDbgRuntimeGuids.DotNetCore_Guid; + public override Guid RuntimeGuid => PredefinedDbgRuntimeGuids.DotNet_Guid; public override Guid RuntimeKindGuid => PredefinedDbgRuntimeKindGuids.DotNet_Guid; readonly string? clrModuleVersion; readonly string? coreCLRFilename; - public DotNetCoreAttachProgramOptions(int pid, string? clrModuleVersion, string? coreCLRFilename) { + public DotNetAttachProgramOptions(int pid, string? clrModuleVersion, string? coreCLRFilename) { ProcessId = pid; - RuntimeId = new DotNetCoreRuntimeId(clrModuleVersion); + RuntimeId = new DotNetRuntimeId(clrModuleVersion); RuntimeName = "CoreCLR " + clrModuleVersion; this.clrModuleVersion = clrModuleVersion; this.coreCLRFilename = coreCLRFilename; } - public override AttachToProgramOptions GetOptions() => new DotNetCoreAttachToProgramOptions { + public override AttachToProgramOptions GetOptions() => new DotNetAttachToProgramOptions { ProcessId = ProcessId, ClrModuleVersion = clrModuleVersion, CoreCLRFilename = coreCLRFilename, diff --git a/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/Dialogs/DebugProgram/DotNetCommonStartDebuggingOptionsPage.cs b/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/Dialogs/DebugProgram/DotNetCommonStartDebuggingOptionsPage.cs new file mode 100644 index 0000000000..5250bf3782 --- /dev/null +++ b/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/Dialogs/DebugProgram/DotNetCommonStartDebuggingOptionsPage.cs @@ -0,0 +1,172 @@ +/* + 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 System.IO; +using System.Windows.Input; +using dnSpy.Contracts.Debugger; +using dnSpy.Contracts.Debugger.DotNet.CorDebug; +using dnSpy.Contracts.Debugger.StartDebugging.Dialog; +using dnSpy.Contracts.MVVM; +using dnSpy.Debugger.DotNet.CorDebug.Properties; + +namespace dnSpy.Debugger.DotNet.CorDebug.Dialogs.DebugProgram { + abstract class DotNetCommonStartDebuggingOptionsPage : StartDebuggingOptionsPage, IDataErrorInfo { + public override object? UIObject => this; + + public string Filename { + get => filename; + set { + if (filename != value) { + filename = value; + OnPropertyChanged(nameof(Filename)); + UpdateIsValid(); + var path = GetPath(filename); + if (!(path is null)) + WorkingDirectory = path; + } + } + } + string filename = string.Empty; + + public string CommandLine { + get => commandLine; + set { + if (commandLine != value) { + commandLine = value; + OnPropertyChanged(nameof(CommandLine)); + UpdateIsValid(); + } + } + } + string commandLine = string.Empty; + + public string WorkingDirectory { + get => workingDirectory; + set { + if (workingDirectory != value) { + workingDirectory = value; + OnPropertyChanged(nameof(WorkingDirectory)); + UpdateIsValid(); + } + } + } + string workingDirectory = string.Empty; + + public ICommand PickFilenameCommand => new RelayCommand(a => PickNewFilename()); + public ICommand PickWorkingDirectoryCommand => new RelayCommand(a => PickNewWorkingDirectory()); + + public EnumListVM BreakProcessKindVM => breakProcessKindVM; + readonly EnumListVM breakProcessKindVM = new EnumListVM(BreakProcessKindsUtils.BreakProcessKindList); + + public string BreakKind { + get => (string)BreakProcessKindVM.SelectedItem!; + set => BreakProcessKindVM.SelectedItem = value; + } + + public override bool IsValid => isValid; + bool isValid; + + protected void UpdateIsValid() { + var newIsValid = CalculateIsValid(); + if (newIsValid == isValid) + return; + isValid = newIsValid; + OnPropertyChanged(nameof(IsValid)); + } + + protected abstract bool CalculateIsValid(); + + protected readonly IPickFilename pickFilename; + readonly IPickDirectory pickDirectory; + + protected DotNetCommonStartDebuggingOptionsPage(IPickFilename pickFilename, IPickDirectory pickDirectory) { + this.pickFilename = pickFilename ?? throw new ArgumentNullException(nameof(pickFilename)); + this.pickDirectory = pickDirectory ?? throw new ArgumentNullException(nameof(pickDirectory)); + } + + static string? GetPath(string file) { + try { + return Path.GetDirectoryName(file); + } + catch { + } + return null; + } + + protected static void Initialize(string filename, CorDebugStartDebuggingOptions options) { + options.Filename = filename; + options.WorkingDirectory = GetPath(options.Filename); + } + + protected abstract void PickNewFilename(); + + void PickNewWorkingDirectory() { + var newDir = pickDirectory.GetDirectory(WorkingDirectory); + if (newDir is null) + return; + + WorkingDirectory = newDir; + } + + static string FilterBreakKind(string? breakKind) { + foreach (var info in BreakProcessKindsUtils.BreakProcessKindList) { + if (StringComparer.Ordinal.Equals(breakKind, (string)info.Value)) + return breakKind!; + } + return PredefinedBreakKinds.DontBreak; + } + + protected void Initialize(CorDebugStartDebuggingOptions options) { + Filename = options.Filename ?? string.Empty; + CommandLine = options.CommandLine ?? string.Empty; + // Must be init'd after Filename since it also overwrites this property + WorkingDirectory = options.WorkingDirectory ?? string.Empty; + BreakKind = FilterBreakKind(options.BreakKind); + } + + protected T InitializeDefault(T options, string breakKind) where T : CorDebugStartDebuggingOptions { + options.BreakKind = FilterBreakKind(breakKind); + return options; + } + + protected T GetOptions(T options) where T : CorDebugStartDebuggingOptions { + options.Filename = Filename; + options.CommandLine = CommandLine; + options.WorkingDirectory = WorkingDirectory; + options.BreakKind = FilterBreakKind(BreakKind); + return options; + } + + string IDataErrorInfo.Error => throw new NotImplementedException(); + string IDataErrorInfo.this[string columnName] => Verify(columnName); + + protected static string VerifyFilename(string filename) { + if (!File.Exists(filename)) { + if (string.IsNullOrWhiteSpace(filename)) + return dnSpy_Debugger_DotNet_CorDebug_Resources.Error_MissingFilename; + return dnSpy_Debugger_DotNet_CorDebug_Resources.Error_FileDoesNotExist; + } + return string.Empty; + } + + protected abstract string Verify(string columnName); + } +} diff --git a/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/Dialogs/DebugProgram/DotNetCoreStartDebuggingOptionsPage.cs b/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/Dialogs/DebugProgram/DotNetCoreStartDebuggingOptionsPage.cs deleted file mode 100644 index 915f60eb01..0000000000 --- a/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/Dialogs/DebugProgram/DotNetCoreStartDebuggingOptionsPage.cs +++ /dev/null @@ -1,174 +0,0 @@ -/* - 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.IO; -using System.Windows.Input; -using dnSpy.Contracts.Debugger; -using dnSpy.Contracts.Debugger.DotNet.CorDebug; -using dnSpy.Contracts.Debugger.StartDebugging; -using dnSpy.Contracts.Debugger.StartDebugging.Dialog; -using dnSpy.Contracts.MVVM; -using dnSpy.Debugger.DotNet.CorDebug.Utilities; - -namespace dnSpy.Debugger.DotNet.CorDebug.Dialogs.DebugProgram { - sealed class DotNetCoreStartDebuggingOptionsPage : DotNetStartDebuggingOptionsPage { - public override Guid Guid => new Guid("6DA15E33-27DA-498B-8AF1-552399485002"); - public override double DisplayOrder => PredefinedStartDebuggingOptionsPageDisplayOrders.DotNetCore; - // Shouldn't be localized - public override string DisplayName => ".NET Core"; - - public bool UseHost { - get => useHost; - set { - if (useHost != value) { - useHost = value; - OnPropertyChanged(nameof(UseHost)); - OnPropertyChanged(nameof(HostFilename)); - UpdateIsValid(); - } - } - } - bool useHost; - - public string HostFilename { - get => hostFilename; - set { - if (hostFilename != value) { - hostFilename = value; - OnPropertyChanged(nameof(HostFilename)); - UpdateIsValid(); - } - } - } - string hostFilename = string.Empty; - - public string HostArguments { - get => hostArguments; - set { - if (hostArguments != value) { - hostArguments = value; - OnPropertyChanged(nameof(HostArguments)); - UpdateIsValid(); - } - } - } - string hostArguments = string.Empty; - - public ICommand PickHostFilenameCommand => new RelayCommand(a => PickNewHostFilename(), a => CanPickNewHostFilename); - - public DotNetCoreStartDebuggingOptionsPage(IPickFilename pickFilename, IPickDirectory pickDirectory) - : base(pickFilename, pickDirectory) { - } - - bool CanPickNewHostFilename => UseHost; - - void PickNewHostFilename() { - var newFilename = pickFilename.GetFilename(HostFilename, "exe", PickFilenameConstants.ExecutableFilter); - if (newFilename is null) - return; - - HostFilename = newFilename; - } - - protected override void PickNewFilename() { - var newFilename = pickFilename.GetFilename(Filename, "dll", PickFilenameConstants.DotNetAssemblyOrModuleFilter); - if (newFilename is null) - return; - - Filename = newFilename; - } - - public override void InitializePreviousOptions(StartDebuggingOptions options) { - var dncOptions = options as DotNetCoreStartDebuggingOptions; - if (dncOptions is null) - return; - Initialize(dncOptions); - } - - public override void InitializeDefaultOptions(string filename, string breakKind, StartDebuggingOptions? options) => - Initialize(GetDefaultOptions(filename, breakKind, options)); - - DotNetCoreStartDebuggingOptions GetDefaultOptions(string filename, string breakKind, StartDebuggingOptions? options) { - bool isExe = PortableExecutableFileHelpers.IsExecutable(filename); - if (isExe) { - var dncOptions = CreateOptions(breakKind); - Initialize(filename, dncOptions); - dncOptions.UseHost = !DotNetCoreGenericDebugEngineGuidProvider.IsDotNetCoreAppHostFilename(filename); - return dncOptions; - } - else { - // If it's a DLL, use the old EXE options if available - if (options is DotNetCoreStartDebuggingOptions dncOptions) - return dncOptions; - return CreateOptions(breakKind); - } - } - - DotNetCoreStartDebuggingOptions CreateOptions(string breakKind) => - InitializeDefault(new DotNetCoreStartDebuggingOptions { HostArguments = "exec" }, breakKind); - - void Initialize(DotNetCoreStartDebuggingOptions options) { - base.Initialize(options); - UseHost = options.UseHost; - HostFilename = options.Host ?? string.Empty; - HostArguments = options.HostArguments ?? string.Empty; - } - - public override StartDebuggingOptionsInfo GetOptions() { - var options = GetOptions(new DotNetCoreStartDebuggingOptions { - UseHost = UseHost, - Host = HostFilename, - HostArguments = HostArguments, - }); - var flags = StartDebuggingOptionsInfoFlags.None; - if (File.Exists(options.Filename)) { - var extension = Path.GetExtension(options.Filename); - if (!StringComparer.OrdinalIgnoreCase.Equals(extension, ".exe") && !StringComparer.OrdinalIgnoreCase.Equals(extension, ".dll")) - flags |= StartDebuggingOptionsInfoFlags.WrongExtension; - } - return new StartDebuggingOptionsInfo(options, options.Filename, flags); - } - - public override bool SupportsDebugEngine(Guid engineGuid, out double order) { - if (engineGuid == PredefinedGenericDebugEngineGuids.DotNetCore) { - order = PredefinedGenericDebugEngineOrders.DotNetCore; - return true; - } - - order = 0; - return false; - } - - protected override bool CalculateIsValid() => - string.IsNullOrEmpty(Verify(nameof(HostFilename))) && - string.IsNullOrEmpty(Verify(nameof(Filename))); - - protected override string Verify(string columnName) { - if (columnName == nameof(HostFilename)) { - if (UseHost && !string.IsNullOrWhiteSpace(HostFilename)) - return VerifyFilename(HostFilename); - } - else if (columnName == nameof(Filename)) - return VerifyFilename(Filename); - - return string.Empty; - } - } -} diff --git a/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/Dialogs/DebugProgram/DotNetFrameworkStartDebuggingOptionsPage.cs b/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/Dialogs/DebugProgram/DotNetFrameworkStartDebuggingOptionsPage.cs index b87cf059eb..16092228d4 100644 --- a/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/Dialogs/DebugProgram/DotNetFrameworkStartDebuggingOptionsPage.cs +++ b/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/Dialogs/DebugProgram/DotNetFrameworkStartDebuggingOptionsPage.cs @@ -27,7 +27,7 @@ You should have received a copy of the GNU General Public License using dnSpy.Debugger.DotNet.CorDebug.Utilities; namespace dnSpy.Debugger.DotNet.CorDebug.Dialogs.DebugProgram { - sealed class DotNetFrameworkStartDebuggingOptionsPage : DotNetStartDebuggingOptionsPage { + sealed class DotNetFrameworkStartDebuggingOptionsPage : DotNetCommonStartDebuggingOptionsPage { // This guid is also used by DebugProgramVM public override Guid Guid => new Guid("3FB8FCB5-AECE-443A-ABDE-601F2C23F1C1"); public override double DisplayOrder => PredefinedStartDebuggingOptionsPageDisplayOrders.DotNetFramework; diff --git a/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/Dialogs/DebugProgram/DotNetCoreGenericDebugEngineGuidProvider.cs b/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/Dialogs/DebugProgram/DotNetGenericDebugEngineGuidProvider.cs similarity index 70% rename from Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/Dialogs/DebugProgram/DotNetCoreGenericDebugEngineGuidProvider.cs rename to Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/Dialogs/DebugProgram/DotNetGenericDebugEngineGuidProvider.cs index e112cf22fc..cb48ad88a5 100644 --- a/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/Dialogs/DebugProgram/DotNetCoreGenericDebugEngineGuidProvider.cs +++ b/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/Dialogs/DebugProgram/DotNetGenericDebugEngineGuidProvider.cs @@ -24,25 +24,25 @@ You should have received a copy of the GNU General Public License using dnSpy.Debugger.DotNet.CorDebug.Impl; namespace dnSpy.Debugger.DotNet.CorDebug.Dialogs.DebugProgram { - [ExportGenericDebugEngineGuidProvider(PredefinedGenericDebugEngineGuidProviderOrders.DotNetCore)] - sealed class DotNetCoreGenericDebugEngineGuidProvider : GenericDebugEngineGuidProvider { + [ExportGenericDebugEngineGuidProvider(PredefinedGenericDebugEngineGuidProviderOrders.DotNet)] + sealed class DotNetGenericDebugEngineGuidProvider : GenericDebugEngineGuidProvider { public override Guid? GetEngineGuid(string filename) { - if (!IsDotNetCoreAppHostFilename(filename)) + if (!IsDotNetAppHostFilename(filename)) return null; - return PredefinedGenericDebugEngineGuids.DotNetCore; + return PredefinedGenericDebugEngineGuids.DotNet; } - internal static bool IsDotNetCoreAppHostFilename(string filename) { + internal static bool IsDotNetAppHostFilename(string filename) { if (!File.Exists(filename)) return false; return - AppHostUtils.IsDotNetCoreBundleV1(filename) || - AppHostUtils.IsDotNetCoreBundleV2_or_AppHost(filename) || - IsKnownDotNetCoreAppHost(filename) || - AppHostUtils.IsDotNetCoreAppHostV1(filename, out _); + AppHostUtils.IsDotNetBundleV1(filename) || + AppHostUtils.IsDotNetBundleV2_or_AppHost(filename) || + IsKnownDotNetAppHost(filename) || + AppHostUtils.IsDotNetAppHostV1(filename, out _); } - static bool IsKnownDotNetCoreAppHost(string filename) { + static bool IsKnownDotNetAppHost(string filename) { if (AppHostUtils.TryGetAppHostEmbeddedDotNetDllPath(filename, out var couldBeAppHost, out _)) return true; Debug.Assert(!couldBeAppHost, $"Looks like an unsupported apphost, update {nameof(AppHostInfoData)} table"); diff --git a/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/Dialogs/DebugProgram/DotNetStartDebuggingOptionsPage.cs b/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/Dialogs/DebugProgram/DotNetStartDebuggingOptionsPage.cs index b03927c070..85d4ac5799 100644 --- a/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/Dialogs/DebugProgram/DotNetStartDebuggingOptionsPage.cs +++ b/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/Dialogs/DebugProgram/DotNetStartDebuggingOptionsPage.cs @@ -18,155 +18,157 @@ You should have received a copy of the GNU General Public License */ using System; -using System.ComponentModel; using System.IO; using System.Windows.Input; using dnSpy.Contracts.Debugger; using dnSpy.Contracts.Debugger.DotNet.CorDebug; +using dnSpy.Contracts.Debugger.StartDebugging; using dnSpy.Contracts.Debugger.StartDebugging.Dialog; using dnSpy.Contracts.MVVM; -using dnSpy.Debugger.DotNet.CorDebug.Properties; +using dnSpy.Debugger.DotNet.CorDebug.Utilities; namespace dnSpy.Debugger.DotNet.CorDebug.Dialogs.DebugProgram { - abstract class DotNetStartDebuggingOptionsPage : StartDebuggingOptionsPage, IDataErrorInfo { - public override object? UIObject => this; - - public string Filename { - get => filename; + sealed class DotNetStartDebuggingOptionsPage : DotNetCommonStartDebuggingOptionsPage { + public override Guid Guid => new Guid("6DA15E33-27DA-498B-8AF1-552399485002"); + public override double DisplayOrder => PredefinedStartDebuggingOptionsPageDisplayOrders.DotNet; + // Shouldn't be localized + public override string DisplayName => ".NET"; + + public bool UseHost { + get => useHost; set { - if (filename != value) { - filename = value; - OnPropertyChanged(nameof(Filename)); + if (useHost != value) { + useHost = value; + OnPropertyChanged(nameof(UseHost)); + OnPropertyChanged(nameof(HostFilename)); UpdateIsValid(); - var path = GetPath(filename); - if (!(path is null)) - WorkingDirectory = path; } } } - string filename = string.Empty; + bool useHost; - public string CommandLine { - get => commandLine; + public string HostFilename { + get => hostFilename; set { - if (commandLine != value) { - commandLine = value; - OnPropertyChanged(nameof(CommandLine)); + if (hostFilename != value) { + hostFilename = value; + OnPropertyChanged(nameof(HostFilename)); UpdateIsValid(); } } } - string commandLine = string.Empty; + string hostFilename = string.Empty; - public string WorkingDirectory { - get => workingDirectory; + public string HostArguments { + get => hostArguments; set { - if (workingDirectory != value) { - workingDirectory = value; - OnPropertyChanged(nameof(WorkingDirectory)); + if (hostArguments != value) { + hostArguments = value; + OnPropertyChanged(nameof(HostArguments)); UpdateIsValid(); } } } - string workingDirectory = string.Empty; - - public ICommand PickFilenameCommand => new RelayCommand(a => PickNewFilename()); - public ICommand PickWorkingDirectoryCommand => new RelayCommand(a => PickNewWorkingDirectory()); + string hostArguments = string.Empty; - public EnumListVM BreakProcessKindVM => breakProcessKindVM; - readonly EnumListVM breakProcessKindVM = new EnumListVM(BreakProcessKindsUtils.BreakProcessKindList); + public ICommand PickHostFilenameCommand => new RelayCommand(a => PickNewHostFilename(), a => CanPickNewHostFilename); - public string BreakKind { - get => (string)BreakProcessKindVM.SelectedItem!; - set => BreakProcessKindVM.SelectedItem = value; + public DotNetStartDebuggingOptionsPage(IPickFilename pickFilename, IPickDirectory pickDirectory) + : base(pickFilename, pickDirectory) { } - public override bool IsValid => isValid; - bool isValid; + bool CanPickNewHostFilename => UseHost; - protected void UpdateIsValid() { - var newIsValid = CalculateIsValid(); - if (newIsValid == isValid) + void PickNewHostFilename() { + var newFilename = pickFilename.GetFilename(HostFilename, "exe", PickFilenameConstants.ExecutableFilter); + if (newFilename is null) return; - isValid = newIsValid; - OnPropertyChanged(nameof(IsValid)); + + HostFilename = newFilename; } - protected abstract bool CalculateIsValid(); + protected override void PickNewFilename() { + var newFilename = pickFilename.GetFilename(Filename, "dll", PickFilenameConstants.DotNetAssemblyOrModuleFilter); + if (newFilename is null) + return; - protected readonly IPickFilename pickFilename; - readonly IPickDirectory pickDirectory; + Filename = newFilename; + } - protected DotNetStartDebuggingOptionsPage(IPickFilename pickFilename, IPickDirectory pickDirectory) { - this.pickFilename = pickFilename ?? throw new ArgumentNullException(nameof(pickFilename)); - this.pickDirectory = pickDirectory ?? throw new ArgumentNullException(nameof(pickDirectory)); + public override void InitializePreviousOptions(StartDebuggingOptions options) { + var dncOptions = options as DotNetStartDebuggingOptions; + if (dncOptions is null) + return; + Initialize(dncOptions); } - static string? GetPath(string file) { - try { - return Path.GetDirectoryName(file); + public override void InitializeDefaultOptions(string filename, string breakKind, StartDebuggingOptions? options) => + Initialize(GetDefaultOptions(filename, breakKind, options)); + + DotNetStartDebuggingOptions GetDefaultOptions(string filename, string breakKind, StartDebuggingOptions? options) { + bool isExe = PortableExecutableFileHelpers.IsExecutable(filename); + if (isExe) { + var dncOptions = CreateOptions(breakKind); + Initialize(filename, dncOptions); + dncOptions.UseHost = !DotNetGenericDebugEngineGuidProvider.IsDotNetAppHostFilename(filename); + return dncOptions; } - catch { + else { + // If it's a DLL, use the old EXE options if available + if (options is DotNetStartDebuggingOptions dncOptions) + return dncOptions; + return CreateOptions(breakKind); } - return null; - } - - protected static void Initialize(string filename, CorDebugStartDebuggingOptions options) { - options.Filename = filename; - options.WorkingDirectory = GetPath(options.Filename); } - protected abstract void PickNewFilename(); + DotNetStartDebuggingOptions CreateOptions(string breakKind) => + InitializeDefault(new DotNetStartDebuggingOptions { HostArguments = "exec" }, breakKind); - void PickNewWorkingDirectory() { - var newDir = pickDirectory.GetDirectory(WorkingDirectory); - if (newDir is null) - return; - - WorkingDirectory = newDir; + void Initialize(DotNetStartDebuggingOptions options) { + base.Initialize(options); + UseHost = options.UseHost; + HostFilename = options.Host ?? string.Empty; + HostArguments = options.HostArguments ?? string.Empty; } - static string FilterBreakKind(string? breakKind) { - foreach (var info in BreakProcessKindsUtils.BreakProcessKindList) { - if (StringComparer.Ordinal.Equals(breakKind, (string)info.Value)) - return breakKind!; + public override StartDebuggingOptionsInfo GetOptions() { + var options = GetOptions(new DotNetStartDebuggingOptions { + UseHost = UseHost, + Host = HostFilename, + HostArguments = HostArguments, + }); + var flags = StartDebuggingOptionsInfoFlags.None; + if (File.Exists(options.Filename)) { + var extension = Path.GetExtension(options.Filename); + if (!StringComparer.OrdinalIgnoreCase.Equals(extension, ".exe") && !StringComparer.OrdinalIgnoreCase.Equals(extension, ".dll")) + flags |= StartDebuggingOptionsInfoFlags.WrongExtension; } - return PredefinedBreakKinds.DontBreak; - } - - protected void Initialize(CorDebugStartDebuggingOptions options) { - Filename = options.Filename ?? string.Empty; - CommandLine = options.CommandLine ?? string.Empty; - // Must be init'd after Filename since it also overwrites this property - WorkingDirectory = options.WorkingDirectory ?? string.Empty; - BreakKind = FilterBreakKind(options.BreakKind); + return new StartDebuggingOptionsInfo(options, options.Filename, flags); } - protected T InitializeDefault(T options, string breakKind) where T : CorDebugStartDebuggingOptions { - options.BreakKind = FilterBreakKind(breakKind); - return options; - } + public override bool SupportsDebugEngine(Guid engineGuid, out double order) { + if (engineGuid == PredefinedGenericDebugEngineGuids.DotNet) { + order = PredefinedGenericDebugEngineOrders.DotNet; + return true; + } - protected T GetOptions(T options) where T : CorDebugStartDebuggingOptions { - options.Filename = Filename; - options.CommandLine = CommandLine; - options.WorkingDirectory = WorkingDirectory; - options.BreakKind = FilterBreakKind(BreakKind); - return options; + order = 0; + return false; } - string IDataErrorInfo.Error => throw new NotImplementedException(); - string IDataErrorInfo.this[string columnName] => Verify(columnName); + protected override bool CalculateIsValid() => + string.IsNullOrEmpty(Verify(nameof(HostFilename))) && + string.IsNullOrEmpty(Verify(nameof(Filename))); - protected static string VerifyFilename(string filename) { - if (!File.Exists(filename)) { - if (string.IsNullOrWhiteSpace(filename)) - return dnSpy_Debugger_DotNet_CorDebug_Resources.Error_MissingFilename; - return dnSpy_Debugger_DotNet_CorDebug_Resources.Error_FileDoesNotExist; + protected override string Verify(string columnName) { + if (columnName == nameof(HostFilename)) { + if (UseHost && !string.IsNullOrWhiteSpace(HostFilename)) + return VerifyFilename(HostFilename); } + else if (columnName == nameof(Filename)) + return VerifyFilename(Filename); + return string.Empty; } - - protected abstract string Verify(string columnName); } } diff --git a/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/Dialogs/DebugProgram/StartDebuggingOptionsPageProviderImpl.cs b/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/Dialogs/DebugProgram/StartDebuggingOptionsPageProviderImpl.cs index 03960e64c8..3f9f8a7af1 100644 --- a/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/Dialogs/DebugProgram/StartDebuggingOptionsPageProviderImpl.cs +++ b/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/Dialogs/DebugProgram/StartDebuggingOptionsPageProviderImpl.cs @@ -36,7 +36,7 @@ sealed class StartDebuggingOptionsPageProviderImpl : StartDebuggingOptionsPagePr public override IEnumerable Create(StartDebuggingOptionsPageContext context) { yield return new DotNetFrameworkStartDebuggingOptionsPage(pickFilename, pickDirectory); - yield return new DotNetCoreStartDebuggingOptionsPage(pickFilename, pickDirectory); + yield return new DotNetStartDebuggingOptionsPage(pickFilename, pickDirectory); } } } diff --git a/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/Impl/AppHostUtils.cs b/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/Impl/AppHostUtils.cs index a5c421de27..c6865bab88 100644 --- a/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/Impl/AppHostUtils.cs +++ b/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/Impl/AppHostUtils.cs @@ -42,7 +42,7 @@ static int CalculateMaxAppHostExeSize() { static readonly byte[] AppHostExeSignature = Encoding.UTF8.GetBytes("c3ab8ff13720e8ad9047dd39466b3c89" + "\0"); // .NET Core 2.x, older .NET Core 3.0 previews - internal static bool IsDotNetCoreAppHostV1(string filename, [NotNullWhen(true)] out string? dllFilename) { + internal static bool IsDotNetAppHostV1(string filename, [NotNullWhen(true)] out string? dllFilename) { // We detect the apphost.exe like so: // - must have an exe extension // - must be a PE file and an EXE (DLL bit cleared) @@ -78,7 +78,7 @@ internal static bool IsDotNetCoreAppHostV1(string filename, [NotNullWhen(true)] } // Older .NET Core 3.0 previews - internal static bool IsDotNetCoreBundleV1(string filename) { + internal static bool IsDotNetBundleV1(string filename) { try { using (var stream = File.OpenRead(filename)) { if (stream.Length < bundleSig.Length) @@ -101,7 +101,7 @@ internal static bool IsDotNetCoreBundleV1(string filename) { static readonly byte[] bundleSig = new byte[] { 0x0E, 0x2E, 0x4E, 0x65, 0x74, 0x43, 0x6F, 0x72, 0x65, 0x42, 0x75, 0x6E, 0x64, 0x6C, 0x65 }; // .NET Core 3.0 - internal static bool IsDotNetCoreBundleV2_or_AppHost(string filename) { + internal static bool IsDotNetBundleV2_or_AppHost(string filename) { try { var data = ReadBytes(filename, 512 * 1024); return GetOffset(data, apphostSigV2) >= 0; diff --git a/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/Impl/Attach/CorDebugAttachToProgramOptions.cs b/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/Impl/Attach/CorDebugAttachToProgramOptions.cs index 1834949850..04e37f097e 100644 --- a/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/Impl/Attach/CorDebugAttachToProgramOptions.cs +++ b/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/Impl/Attach/CorDebugAttachToProgramOptions.cs @@ -22,7 +22,7 @@ You should have received a copy of the GNU General Public License namespace dnSpy.Debugger.DotNet.CorDebug.Impl.Attach { /// - /// Debugging options base class shared by .NET Framework code and .NET Core code + /// Debugging options base class shared by .NET Framework code and .NET code /// abstract class CorDebugAttachToProgramOptions : AttachToProgramOptions { /// diff --git a/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/Impl/Attach/DotNetCoreAttachToProgramOptions.cs b/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/Impl/Attach/DotNetAttachToProgramOptions.cs similarity index 87% rename from Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/Impl/Attach/DotNetCoreAttachToProgramOptions.cs rename to Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/Impl/Attach/DotNetAttachToProgramOptions.cs index 251f4f91f1..7e8e44158a 100644 --- a/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/Impl/Attach/DotNetCoreAttachToProgramOptions.cs +++ b/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/Impl/Attach/DotNetAttachToProgramOptions.cs @@ -22,9 +22,9 @@ You should have received a copy of the GNU General Public License namespace dnSpy.Debugger.DotNet.CorDebug.Impl.Attach { /// - /// .NET Core attach to process options + /// .NET attach to process options /// - sealed class DotNetCoreAttachToProgramOptions : CorDebugAttachToProgramOptions { + sealed class DotNetAttachToProgramOptions : CorDebugAttachToProgramOptions { /// /// A string returned by dbgshim.dll's CreateVersionStringFromModule function /// or null to use the first found CoreCLR in the process. @@ -40,14 +40,14 @@ sealed class DotNetCoreAttachToProgramOptions : CorDebugAttachToProgramOptions { /// Clones this instance /// /// - public override DebugProgramOptions Clone() => CopyTo(new DotNetCoreAttachToProgramOptions()); + public override DebugProgramOptions Clone() => CopyTo(new DotNetAttachToProgramOptions()); /// /// Copies this instance to and returns it /// /// Destination /// - public DotNetCoreAttachToProgramOptions CopyTo(DotNetCoreAttachToProgramOptions other) { + public DotNetAttachToProgramOptions CopyTo(DotNetAttachToProgramOptions other) { if (other is null) throw new ArgumentNullException(nameof(other)); base.CopyTo(other); diff --git a/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/Impl/DbgEngineImpl.cs b/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/Impl/DbgEngineImpl.cs index 87e4c970b7..6936885df0 100644 --- a/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/Impl/DbgEngineImpl.cs +++ b/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/Impl/DbgEngineImpl.cs @@ -299,7 +299,7 @@ internal DmdDynamicModuleHelperImpl GetDynamicModuleHelper(DnModule dnModule) { frame = thread.ActiveFrame; if (frame?.Function is null) { // Ignore the first frame(s) that have a null function. This rarely happens (eg. it - // happens when debugging dnSpy built for .NET Core x86) + // happens when debugging dnSpy built for .NET x86) frame = thread.AllFrames.FirstOrDefault(a => !(a.Function is null)); } } @@ -666,8 +666,8 @@ void StartCore(CorDebugStartDebuggingOptions options) { // We can only debug processes with the same bitness, so check IntPtr.Size. if (IntPtr.Size == 4 && debuggerSettings.AntiIsDebuggerPresent && options is DotNetFrameworkStartDebuggingOptions) disableMDA = true; - // .NET Core doesn't support MDAs - if (options is DotNetCoreStartDebuggingOptions) + // .NET doesn't support MDAs + if (options is DotNetStartDebuggingOptions) disableMDA = false; if (disableMDA) { // https://docs.microsoft.com/en-us/dotnet/framework/debug-trace-profile/diagnosing-errors-with-managed-debugging-assistants @@ -676,7 +676,7 @@ void StartCore(CorDebugStartDebuggingOptions options) { if (debuggerSettings.SuppressJITOptimization_SystemModules) { if (options is DotNetFrameworkStartDebuggingOptions) env.Add("COMPlus_ZapDisable", "1"); - else if (options is DotNetCoreStartDebuggingOptions) + else if (options is DotNetStartDebuggingOptions) env.Add("COMPlus_ReadyToRun", "0"); else Debug.Fail("Unreachable code"); @@ -771,8 +771,8 @@ void AttachCore(CorDebugAttachToProgramOptions options) { string errMsg; if (ex is ErrorException errEx) errMsg = errEx.Message; - else if (CorDebugRuntimeKind == CorDebugRuntimeKind.DotNetCore && ex is ArgumentException) { - // .NET Core throws ArgumentException if it can't attach to it (.NET Framework throws a COM exception with the correct error message) + else if (CorDebugRuntimeKind == CorDebugRuntimeKind.DotNet && ex is ArgumentException) { + // .NET throws ArgumentException if it can't attach to it (.NET Framework throws a COM exception with the correct error message) errMsg = string.Format(dnSpy_Debugger_DotNet_CorDebug_Resources.Error_CouldNotStartDebugger2, string.Format(dnSpy_Debugger_DotNet_CorDebug_Resources.Error_ProcessIsAlreadyBeingDebugged, options.ProcessId.ToString())); } @@ -857,7 +857,7 @@ bool HasConnected_DebugThread { get { debuggerThread.VerifyAccess(); // If it's null, we haven't connected yet (most likely due to timeout, eg. trying to debug - // a .NET Framework program with the .NET Core engine) + // a .NET Framework program with the .NET engine) return !(dnDebugger is null); } } diff --git a/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/Impl/DbgEngineProviderImpl.cs b/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/Impl/DbgEngineProviderImpl.cs index 314fcd7d23..f0af3c5e1a 100644 --- a/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/Impl/DbgEngineProviderImpl.cs +++ b/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/Impl/DbgEngineProviderImpl.cs @@ -38,14 +38,14 @@ sealed class DbgEngineProviderImpl : DbgEngineProvider { case DotNetFrameworkStartDebuggingOptions _: return new DotNetFrameworkDbgEngineImpl(dbgEngineImplDependencies.Value, dbgManager, DbgStartKind.Start); - case DotNetCoreStartDebuggingOptions _: - return new DotNetCoreDbgEngineImpl(dbgEngineImplDependencies.Value, dbgManager, DbgStartKind.Start); + case DotNetStartDebuggingOptions _: + return new DotNetDbgEngineImpl(dbgEngineImplDependencies.Value, dbgManager, DbgStartKind.Start); case DotNetFrameworkAttachToProgramOptions _: return new DotNetFrameworkDbgEngineImpl(dbgEngineImplDependencies.Value, dbgManager, DbgStartKind.Attach); - case DotNetCoreAttachToProgramOptions _: - return new DotNetCoreDbgEngineImpl(dbgEngineImplDependencies.Value, dbgManager, DbgStartKind.Attach); + case DotNetAttachToProgramOptions _: + return new DotNetDbgEngineImpl(dbgEngineImplDependencies.Value, dbgManager, DbgStartKind.Attach); } return null; diff --git a/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/Impl/DotNetCoreDbgEngineImpl.cs b/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/Impl/DotNetDbgEngineImpl.cs similarity index 74% rename from Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/Impl/DotNetCoreDbgEngineImpl.cs rename to Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/Impl/DotNetDbgEngineImpl.cs index 6dce30b671..ff5199d43d 100644 --- a/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/Impl/DotNetCoreDbgEngineImpl.cs +++ b/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/Impl/DotNetDbgEngineImpl.cs @@ -31,8 +31,8 @@ You should have received a copy of the GNU General Public License using dnSpy.Debugger.DotNet.CorDebug.Utilities; namespace dnSpy.Debugger.DotNet.CorDebug.Impl { - sealed class DotNetCoreDbgEngineImpl : DbgEngineImpl { - protected override CorDebugRuntimeKind CorDebugRuntimeKind => CorDebugRuntimeKind.DotNetCore; + sealed class DotNetDbgEngineImpl : DbgEngineImpl { + protected override CorDebugRuntimeKind CorDebugRuntimeKind => CorDebugRuntimeKind.DotNet; public override string[] Debugging => debugging; static readonly string[] debugging = new[] { "CoreCLR" }; @@ -46,26 +46,26 @@ public override DbgEngineRuntimeInfo RuntimeInfo { int Bitness => IntPtr.Size * 8; - public DotNetCoreDbgEngineImpl(DbgEngineImplDependencies deps, DbgManager dbgManager, DbgStartKind startKind) + public DotNetDbgEngineImpl(DbgEngineImplDependencies deps, DbgManager dbgManager, DbgStartKind startKind) : base(deps, dbgManager, startKind) { } string GetDbgShimAndVerify() { - var dbgShimFilename = DotNetCoreHelpers.GetDebugShimFilename(Bitness); + var dbgShimFilename = DotNetHelpers.GetDebugShimFilename(Bitness); if (!File.Exists(dbgShimFilename)) throw new Exception("Couldn't find dbgshim.dll: " + dbgShimFilename); return dbgShimFilename; } protected override CLRTypeDebugInfo CreateDebugInfo(CorDebugStartDebuggingOptions options) { - var dncOptions = (DotNetCoreStartDebuggingOptions)options; + var dncOptions = (DotNetStartDebuggingOptions)options; string? hostFilename; if (!dncOptions.UseHost) hostFilename = null; else if (string.IsNullOrWhiteSpace(dncOptions.Host)) { - hostFilename = DotNetCoreHelpers.GetPathToDotNetExeHost(Bitness); + hostFilename = DotNetHelpers.GetPathToDotNetExeHost(Bitness); if (!File.Exists(hostFilename)) - throw new Exception(string.Format(dnSpy_Debugger_DotNet_CorDebug_Resources.Error_CouldNotFindDotNetCoreHost, DotNetCoreHelpers.DotNetExeName)); + throw new Exception(string.Format(dnSpy_Debugger_DotNet_CorDebug_Resources.Error_CouldNotFindDotNetCoreHost, DotNetHelpers.DotNetExeName)); } else hostFilename = dncOptions.Host; @@ -74,22 +74,22 @@ protected override CLRTypeDebugInfo CreateDebugInfo(CorDebugStartDebuggingOption } protected override CLRTypeAttachInfo CreateAttachInfo(CorDebugAttachToProgramOptions options) { - var dncOptions = (DotNetCoreAttachToProgramOptions)options; + var dncOptions = (DotNetAttachToProgramOptions)options; return new CoreCLRTypeAttachInfo(dncOptions.ClrModuleVersion, GetDbgShimAndVerify(), dncOptions.CoreCLRFilename); } protected override void OnDebugProcess(DnDebugger dnDebugger) => - runtimeInfo = new DbgEngineRuntimeInfo(PredefinedDbgRuntimeGuids.DotNetCore_Guid, PredefinedDbgRuntimeKindGuids.DotNet_Guid, "CoreCLR", new DotNetCoreRuntimeId(dnDebugger.OtherVersion), runtimeTags); + runtimeInfo = new DbgEngineRuntimeInfo(PredefinedDbgRuntimeGuids.DotNet_Guid, PredefinedDbgRuntimeKindGuids.DotNet_Guid, "CoreCLR", new DotNetRuntimeId(dnDebugger.OtherVersion), runtimeTags); static readonly ReadOnlyCollection runtimeTags = new ReadOnlyCollection(new[] { + PredefinedDotNetDbgRuntimeTags.DotNetBase, PredefinedDotNetDbgRuntimeTags.DotNet, - PredefinedDotNetDbgRuntimeTags.DotNetCore, }); } - sealed class DotNetCoreRuntimeId : RuntimeId { + sealed class DotNetRuntimeId : RuntimeId { readonly string? version; - public DotNetCoreRuntimeId(string? version) => this.version = version; - public override bool Equals(object? obj) => obj is DotNetCoreRuntimeId other && StringComparer.Ordinal.Equals(version ?? string.Empty, other.version ?? string.Empty); + public DotNetRuntimeId(string? version) => this.version = version; + public override bool Equals(object? obj) => obj is DotNetRuntimeId other && StringComparer.Ordinal.Equals(version ?? string.Empty, other.version ?? string.Empty); public override int GetHashCode() => StringComparer.Ordinal.GetHashCode(version ?? string.Empty); } } diff --git a/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/Impl/DotNetCoreDbgProcessStarter.cs b/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/Impl/DotNetDbgProcessStarter.cs similarity index 87% rename from Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/Impl/DotNetCoreDbgProcessStarter.cs rename to Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/Impl/DotNetDbgProcessStarter.cs index a329189b06..9532c44c05 100644 --- a/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/Impl/DotNetCoreDbgProcessStarter.cs +++ b/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/Impl/DotNetDbgProcessStarter.cs @@ -25,14 +25,14 @@ You should have received a copy of the GNU General Public License using dnSpy.Debugger.DotNet.CorDebug.Utilities; namespace dnSpy.Debugger.DotNet.CorDebug.Impl { - [ExportDbgProcessStarter(PredefinedDbgProcessStarterOrders.DotNetCore)] - sealed class DotNetCoreDbgProcessStarter : DbgProcessStarter { - string? GetPathToDotNetExeHost() => DotNetCoreHelpers.GetPathToDotNetExeHost(IntPtr.Size * 8); + [ExportDbgProcessStarter(PredefinedDbgProcessStarterOrders.DotNet)] + sealed class DotNetDbgProcessStarter : DbgProcessStarter { + string? GetPathToDotNetExeHost() => DotNetHelpers.GetPathToDotNetExeHost(IntPtr.Size * 8); public override bool IsSupported(string filename, out ProcessStarterResult result) { result = ProcessStarterResult.None; - if (!DotNetCoreHelpers.IsDotNetCoreExecutable(filename) || GetPathToDotNetExeHost() is null) + if (!DotNetHelpers.IsDotNetExecutable(filename) || GetPathToDotNetExeHost() is null) return false; var extension = Path.GetExtension(filename); diff --git a/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/Impl/DotNetFrameworkDbgEngineImpl.cs b/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/Impl/DotNetFrameworkDbgEngineImpl.cs index 20b1a379b7..19048ec0e7 100644 --- a/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/Impl/DotNetFrameworkDbgEngineImpl.cs +++ b/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/Impl/DotNetFrameworkDbgEngineImpl.cs @@ -54,7 +54,7 @@ protected override CLRTypeAttachInfo CreateAttachInfo(CorDebugAttachToProgramOpt protected override void OnDebugProcess(DnDebugger dnDebugger) => runtimeInfo = new DbgEngineRuntimeInfo(PredefinedDbgRuntimeGuids.DotNetFramework_Guid, PredefinedDbgRuntimeKindGuids.DotNet_Guid, "CLR " + dnDebugger.DebuggeeVersion, new DotNetFrameworkRuntimeId(dnDebugger.DebuggeeVersion), runtimeTags); static readonly ReadOnlyCollection runtimeTags = new ReadOnlyCollection(new[] { - PredefinedDotNetDbgRuntimeTags.DotNet, + PredefinedDotNetDbgRuntimeTags.DotNetBase, PredefinedDotNetDbgRuntimeTags.DotNetFramework, }); } diff --git a/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/Impl/Evaluation/DbgDotNetEngineObjectIdFactoryImpl.cs b/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/Impl/Evaluation/DbgDotNetEngineObjectIdFactoryImpl.cs index d816ba04d7..a7371032ab 100644 --- a/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/Impl/Evaluation/DbgDotNetEngineObjectIdFactoryImpl.cs +++ b/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/Impl/Evaluation/DbgDotNetEngineObjectIdFactoryImpl.cs @@ -31,11 +31,11 @@ sealed class DbgDotNetFrameworkEngineObjectIdFactoryImpl : DbgDotNetEngineObject } } - [ExportDbgEngineObjectIdFactory(PredefinedDbgRuntimeGuids.DotNetCore)] - sealed class DbgDotNetCoreEngineObjectIdFactoryImpl : DbgDotNetEngineObjectIdFactory { + [ExportDbgEngineObjectIdFactory(PredefinedDbgRuntimeGuids.DotNet)] + sealed class DbgDotNetEngineObjectIdFactoryImpl : DbgDotNetEngineObjectIdFactory { [ImportingConstructor] - DbgDotNetCoreEngineObjectIdFactoryImpl(DbgDotNetLanguageService dbgDotNetLanguageService) - : base(PredefinedDbgRuntimeGuids.DotNetCore_Guid, dbgDotNetLanguageService) { + DbgDotNetEngineObjectIdFactoryImpl(DbgDotNetLanguageService dbgDotNetLanguageService) + : base(PredefinedDbgRuntimeGuids.DotNet_Guid, dbgDotNetLanguageService) { } } } diff --git a/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/TheExtension.cs b/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/TheExtension.cs index e33197144c..5471f3eb3f 100644 --- a/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/TheExtension.cs +++ b/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/TheExtension.cs @@ -29,7 +29,7 @@ public IEnumerable MergedResourceDictionaries { } public ExtensionInfo ExtensionInfo => new ExtensionInfo { - ShortDescription = string.Format(dnSpy_Debugger_DotNet_CorDebug_Resources.Plugin_ShortDescription, ".NET Framework, .NET Core"), + ShortDescription = string.Format(dnSpy_Debugger_DotNet_CorDebug_Resources.Plugin_ShortDescription, ".NET Framework, .NET"), }; public void OnEvent(ExtensionEvent @event, object? obj) { } diff --git a/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/Themes/wpf.styles.templates.xaml b/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/Themes/wpf.styles.templates.xaml index a8d6eb77bb..e15fda78f4 100644 --- a/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/Themes/wpf.styles.templates.xaml +++ b/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/Themes/wpf.styles.templates.xaml @@ -51,7 +51,7 @@ - + diff --git a/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/Utilities/DotNetCoreHelpers.cs b/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/Utilities/DotNetHelpers.cs similarity index 93% rename from Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/Utilities/DotNetCoreHelpers.cs rename to Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/Utilities/DotNetHelpers.cs index 24fbca9060..05d883f9a0 100644 --- a/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/Utilities/DotNetCoreHelpers.cs +++ b/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/Utilities/DotNetHelpers.cs @@ -27,7 +27,7 @@ You should have received a copy of the GNU General Public License using Microsoft.Win32; namespace dnSpy.Debugger.DotNet.CorDebug.Utilities { - static class DotNetCoreHelpers { + static class DotNetHelpers { public static readonly string DotNetExeName = FileUtilities.GetNativeExeFilename("dotnet"); public static string? GetPathToDotNetExeHost(int bitness) { @@ -36,7 +36,7 @@ static class DotNetCoreHelpers { var pathEnvVar = Environment.GetEnvironmentVariable("PATH"); if (pathEnvVar is null) return null; - foreach (var tmp in GetDotNetCoreBaseDirCandidates()) { + foreach (var tmp in GetDotNetBaseDirCandidates()) { var path = tmp.Trim(); if (!Directory.Exists(path)) continue; @@ -62,8 +62,8 @@ static class DotNetCoreHelpers { return null; } - // NOTE: This same method exists in DotNetCorePathProvider (dnSpy project). Update both methods if this one gets updated. - static IEnumerable GetDotNetCoreBaseDirCandidates() { + // NOTE: This same method exists in DotNetPathProvider (dnSpy project). Update both methods if this one gets updated. + static IEnumerable GetDotNetBaseDirCandidates() { // Microsoft tools don't check the PATH env var, only the default locations (eg. ProgramFiles) var envVars = new string[] { "PATH", @@ -115,7 +115,7 @@ public static string GetDebugShimFilename(int bitness) { case 64: return Path.Combine(basePath, "x64", filename); default: throw new ArgumentOutOfRangeException(nameof(bitness)); } -#elif NETCOREAPP +#elif NET var filename = FileUtilities.GetNativeDllFilename("dbgshim"); return Path.Combine(Path.GetDirectoryName(typeof(void).Assembly.Location)!, filename); #else @@ -123,7 +123,7 @@ public static string GetDebugShimFilename(int bitness) { #endif } - public static bool IsDotNetCoreExecutable(string filename) { + public static bool IsDotNetExecutable(string filename) { if (!File.Exists(filename)) return false; if (!PortableExecutableFileHelpers.IsExecutable(filename)) diff --git a/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/dnSpy.Debugger.DotNet.CorDebug.csproj b/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/dnSpy.Debugger.DotNet.CorDebug.csproj index 2030629fcf..50f7e8a8dd 100644 --- a/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/dnSpy.Debugger.DotNet.CorDebug.csproj +++ b/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/dnSpy.Debugger.DotNet.CorDebug.csproj @@ -47,18 +47,18 @@ - - + + - - - + + + - - - + + + diff --git a/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/dndbg/DotNet/CorModuleDef.cs b/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/dndbg/DotNet/CorModuleDef.cs index a299d08fcf..c930a7d9aa 100644 --- a/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/dndbg/DotNet/CorModuleDef.cs +++ b/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/dndbg/DotNet/CorModuleDef.cs @@ -206,7 +206,7 @@ IAssembly GetCorAssemblyRef() { continue; if ("mscorlib".Equals(asmRef.Name, StringComparison.OrdinalIgnoreCase)) { - if ((pktMscorlibDesktop.Equals(asmRef.PublicKeyOrToken) || pktMscorlibDotNetCore.Equals(asmRef.PublicKeyOrToken)) && + if ((pktMscorlibDotNetFramework.Equals(asmRef.PublicKeyOrToken) || pktMscorlibDotNet.Equals(asmRef.PublicKeyOrToken)) && asmRef.Version != mscorlibWinMDVersion) { if (bestMscorlib is null || asmRef.Version > bestMscorlib.Version) bestMscorlib = asmRef; @@ -221,8 +221,8 @@ IAssembly GetCorAssemblyRef() { return bestNonMscorlib; } static readonly Version mscorlibWinMDVersion = new Version(0xFF, 0xFF, 0xFF, 0xFF); - static readonly PublicKeyToken pktMscorlibDesktop = new PublicKeyToken("b77a5c561934e089"); - static readonly PublicKeyToken pktMscorlibDotNetCore = new PublicKeyToken("7cec85d7bea7798e"); + static readonly PublicKeyToken pktMscorlibDotNetFramework = new PublicKeyToken("b77a5c561934e089"); + static readonly PublicKeyToken pktMscorlibDotNet = new PublicKeyToken("7cec85d7bea7798e"); /// /// Should be called after caller has added it to its assembly diff --git a/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/dndbg/Engine/CoreCLRHelper.cs b/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/dndbg/Engine/CoreCLRHelper.cs index 4699d32633..d36b61700f 100644 --- a/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/dndbg/Engine/CoreCLRHelper.cs +++ b/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/dndbg/Engine/CoreCLRHelper.cs @@ -244,7 +244,7 @@ public unsafe static DnDebugger CreateDnDebugger(DebugProcessOptions options, Co if (res == NativeMethods.WAIT_TIMEOUT) { if (keepWaiting()) continue; - throw new TimeoutException("Waiting for CoreCLR timed out. Debug 32-bit .NET Core apps with 32-bit dnSpy (dnSpy-x86.exe), and 64-bit .NET Core apps with 64-bit dnSpy (dnSpy.exe)."); + throw new TimeoutException("Waiting for CoreCLR timed out. Debug 32-bit .NET apps with 32-bit dnSpy (dnSpy-x86.exe), and 64-bit .NET apps with 64-bit dnSpy (dnSpy.exe)."); } Debug.Fail($"Unknown result from WaitForMultipleObjects: 0x{res:X8}"); throw new Exception("Error waiting for startup event"); @@ -252,7 +252,7 @@ public unsafe static DnDebugger CreateDnDebugger(DebugProcessOptions options, Co hr = dbgShimState.EnumerateCLRs!(pi.dwProcessId, out pHandleArray, out pStringArray, out dwArrayLength); if (hr < 0 || dwArrayLength == 0) { - // CoreCLR doesn't give us a good error code if we try to debug a .NET Core app + // CoreCLR doesn't give us a good error code if we try to debug a .NET app // with an incompatible bitness: // x86 tries to debug x64: hr == 0x8007012B (ERROR_PARTIAL_COPY) // x64 tries to debug x86: hr == 0x00000000 && dwArrayLength == 0x00000000 diff --git a/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/dndbg/Engine/DnDebugger.cs b/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/dndbg/Engine/DnDebugger.cs index 4133bf34d1..33751694e4 100644 --- a/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/dndbg/Engine/DnDebugger.cs +++ b/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/dndbg/Engine/DnDebugger.cs @@ -168,7 +168,7 @@ public DebuggerState[] DebuggerStates { public string DebuggeeVersion { get; } /// - /// Other version, used by .NET Core + /// Other version, used by .NET /// public string OtherVersion { get; } @@ -1536,7 +1536,7 @@ public void RemoveBreakpoint(DnBreakpoint bp) { public int TryBreakProcesses() => TryBreakProcesses(true); int TryBreakProcesses(bool callProcessStopped) { - // At least with .NET Core, we'll get a DebuggerError (hr=0x80004005 (unspecified error)) + // At least with .NET, we'll get a DebuggerError (hr=0x80004005 (unspecified error)) // if we try to break the process before the CreateProcess event. if (ProcessStateInternal == DebuggerProcessState.Starting) return -1; diff --git a/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.Metadata/DmdSigComparer.cs b/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.Metadata/DmdSigComparer.cs index b87f656a43..efb2dcb0ab 100644 --- a/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.Metadata/DmdSigComparer.cs +++ b/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.Metadata/DmdSigComparer.cs @@ -360,10 +360,10 @@ public bool Equals(IDmdAssemblyName? a, IDmdAssemblyName? b) { // We do not compare the version number. The runtime can redirect an assembly // reference from a requested version to any other version. - // The public key token is also ignored. Only .NET Framwork checks it (.NET Core + // The public key token is also ignored. Only .NET Framwork checks it (.NET // and Unity ignore it). We could add a new option to ignore the PKT but it would // require too many changes to the code (they access singleton comparers) and isn't - // worth it. It's also being replaced by .NET Core. It's not common for two + // worth it. It's also being replaced by .NET. It's not common for two // assemblies loaded in the same process to have the same assembly name but a // different public key token. const DmdAssemblyNameFlags flagsMask = DmdAssemblyNameFlags.ContentType_Mask; diff --git a/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.Metadata/DmdType.cs b/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.Metadata/DmdType.cs index 533bef9e2e..6bda076e21 100644 --- a/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.Metadata/DmdType.cs +++ b/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.Metadata/DmdType.cs @@ -1368,7 +1368,7 @@ internal static HashSet GetAllInterfaces(DmdType type) { /// true if this is a by-ref like value type /// public bool IsByRefLike => - //TODO: .NET Core adds this attribute to by ref like types, but .NET Framework does not, eg. + //TODO: .NET adds this attribute to by ref like types, but .NET Framework does not, eg. // ArgIterator, RuntimeArgumentHandle, TypedReference CustomAttributesHelper.IsDefined(this, "System.Runtime.CompilerServices.IsByRefLikeAttribute", inherit: false); diff --git a/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.Metadata/Impl/DmdAppDomainImpl.cs b/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.Metadata/Impl/DmdAppDomainImpl.cs index 736282bef2..a06e3601ab 100644 --- a/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.Metadata/Impl/DmdAppDomainImpl.cs +++ b/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.Metadata/Impl/DmdAppDomainImpl.cs @@ -287,7 +287,7 @@ public override DmdAssembly[] GetAssemblies(bool includeSyntheticAssemblies) { } } else if (CanResolveToCorLib(name)) { - // .NET Core hack. We don't resolve assemblies, but some attributes used by the + // .NET hack. We don't resolve assemblies, but some attributes used by the // debugger reference types in an assembly that just forwards the type to the corlib. // This assembly isn't normally loaded at runtime. // We could resolve assemblies but then it's possible that we'll resolve the wrong diff --git a/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.Mono/Impl/DbgEngineImpl.cs b/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.Mono/Impl/DbgEngineImpl.cs index 239d255115..fb5e05f179 100644 --- a/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.Mono/Impl/DbgEngineImpl.cs +++ b/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.Mono/Impl/DbgEngineImpl.cs @@ -146,11 +146,11 @@ public DbgEngineImpl(DbgEngineImplDependencies deps, DbgManager dbgManager, Mono funcEvalFactory = new FuncEvalFactory(debuggerThread.GetDebugMessageDispatcher()); } static readonly ReadOnlyCollection monoRuntimeTags = new ReadOnlyCollection(new[] { - PredefinedDotNetDbgRuntimeTags.DotNet, + PredefinedDotNetDbgRuntimeTags.DotNetBase, PredefinedDotNetDbgRuntimeTags.DotNetMono, }); static readonly ReadOnlyCollection unityRuntimeTags = new ReadOnlyCollection(new[] { - PredefinedDotNetDbgRuntimeTags.DotNet, + PredefinedDotNetDbgRuntimeTags.DotNetBase, PredefinedDotNetDbgRuntimeTags.DotNetUnity, }); diff --git a/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.Mono/Impl/Evaluation/DbgDotNetRawValueFactory.cs b/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.Mono/Impl/Evaluation/DbgDotNetRawValueFactory.cs index 669289ad34..f98b1fb743 100644 --- a/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.Mono/Impl/Evaluation/DbgDotNetRawValueFactory.cs +++ b/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.Mono/Impl/Evaluation/DbgDotNetRawValueFactory.cs @@ -235,7 +235,7 @@ static decimal ReadDecimal(StructMirror value) { if (!(fieldValues[0] is PrimitiveValue pvFlags && fieldValues[1] is PrimitiveValue pvHi && fieldValues[2] is PrimitiveValue pvLo && fieldValues[3] is PrimitiveValue pvMid)) return default; - // Mono using .NET Core source code + // Mono using .NET source code if (pvFlags.Value is int && pvHi.Value is int && pvLo.Value is int && pvMid.Value is int) return ((int)pvFlags.Value, (int)pvHi.Value, (int)pvLo.Value, (int)pvMid.Value); // Unity and older Mono @@ -250,7 +250,7 @@ static DateTime ReadDateTime(StructMirror structMirror) { if (fields.Length != values.Length) return default; if (fields.Length == 1) { - // Newer Mono using .NET Core source code + // Newer Mono using .NET source code if (fields[0].Name != KnownMemberNames.DateTime_DateData_FieldName1 && fields[0].Name != KnownMemberNames.DateTime_DateData_FieldName2) return default; diff --git a/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet/Dialogs/DebugProgram/DotNetGenericDebugEngineGuidProvider.cs b/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet/Dialogs/DebugProgram/DotNetGenericDebugEngineGuidProvider.cs index c771c06f5e..2d55f26bf6 100644 --- a/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet/Dialogs/DebugProgram/DotNetGenericDebugEngineGuidProvider.cs +++ b/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet/Dialogs/DebugProgram/DotNetGenericDebugEngineGuidProvider.cs @@ -24,7 +24,7 @@ You should have received a copy of the GNU General Public License using dnSpy.Contracts.Debugger.StartDebugging; namespace dnSpy.Debugger.DotNet.Dialogs.DebugProgram { - [ExportGenericDebugEngineGuidProvider(PredefinedGenericDebugEngineGuidProviderOrders.DotNet)] + [ExportGenericDebugEngineGuidProvider(PredefinedGenericDebugEngineGuidProviderOrders.DotNetAny)] sealed class DotNetGenericDebugEngineGuidProvider : GenericDebugEngineGuidProvider { public override Guid? GetEngineGuid(string filename) { if (!File.Exists(filename)) @@ -59,7 +59,7 @@ sealed class DotNetGenericDebugEngineGuidProvider : GenericDebugEngineGuidProvid if (values.Length >= 2 && values.Length <= 3) { var framework = values[0].Trim(); if (framework == ".NETCoreApp") - return PredefinedGenericDebugEngineGuids.DotNetCore; + return PredefinedGenericDebugEngineGuids.DotNet; } return defaultGuid; diff --git a/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet/Metadata/KnownMemberNames.cs b/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet/Metadata/KnownMemberNames.cs index fcf81ef64b..da33d80590 100644 --- a/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet/Metadata/KnownMemberNames.cs +++ b/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet/Metadata/KnownMemberNames.cs @@ -57,9 +57,9 @@ static class KnownMemberNames { // System.Threading.Thread public const string Thread_ManagedThreadId_FieldName1 = "m_ManagedThreadId"; - public const string Thread_ManagedThreadId_FieldName2 = "_managedThreadId";// .NET Core since early 2019 + public const string Thread_ManagedThreadId_FieldName2 = "_managedThreadId";// .NET since early 2019 public const string Thread_Name_FieldName1 = "m_Name"; - public const string Thread_Name_FieldName2 = "_name";// .NET Core since early 2019 + public const string Thread_Name_FieldName2 = "_name";// .NET since early 2019 // System.Nullable public const string Nullable_HasValue_FieldName = "hasValue"; @@ -74,7 +74,7 @@ static class KnownMemberNames { // System.DateTime public const string DateTime_DateData_FieldName1 = "dateData";// .NET Framework, Mono - public const string DateTime_DateData_FieldName2 = "_dateData";// .NET Core + public const string DateTime_DateData_FieldName2 = "_dateData";// .NET public const string DateTime_Ticks_FieldName_Mono = "ticks"; public const string DateTime_Kind_FieldName_Mono = "kind"; diff --git a/README.md b/README.md index 221740502c..a5537ad925 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ To debug Unity games, you need this repo too: https://github.com/dnSpy/dnSpy-Uni # Debugger -- Debug .NET Framework, .NET Core and Unity game assemblies, no source code required +- Debug .NET Framework, .NET and Unity game assemblies, no source code required - Set breakpoints and step into any assembly - Locals, watch, autos windows - Variables windows support saving variables (eg. decrypted byte arrays) to disk or view them in the hex editor (memory window) diff --git a/build.ps1 b/build.ps1 index a6d715a9b1..4e5728e97b 100644 --- a/build.ps1 +++ b/build.ps1 @@ -1,8 +1,8 @@ param([string]$buildtfm = 'all', [switch]$NoMsbuild) $ErrorActionPreference = 'Stop' -$net_tfm = 'net48' -$netcore_tfm = 'net5.0-windows' +$netframework_tfm = 'net48' +$net_tfm = 'net5.0-windows' $configuration = 'Release' $net_baseoutput = "dnSpy\dnSpy\bin\$configuration" $apphostpatcher_dir = "Build\AppHostPatcher" @@ -14,14 +14,14 @@ $apphostpatcher_dir = "Build\AppHostPatcher" function Build-NetFramework { Write-Host 'Building .NET Framework x86 and x64 binaries' - $outdir = "$net_baseoutput\$net_tfm" + $outdir = "$net_baseoutput\$netframework_tfm" if ($NoMsbuild) { - dotnet build -v:m -c $configuration -f $net_tfm + dotnet build -v:m -c $configuration -f $netframework_tfm if ($LASTEXITCODE) { exit $LASTEXITCODE } } else { - msbuild -v:m -m -restore -t:Build -p:Configuration=$configuration -p:TargetFramework=$net_tfm + msbuild -v:m -m -restore -t:Build -p:Configuration=$configuration -p:TargetFramework=$netframework_tfm if ($LASTEXITCODE) { exit $LASTEXITCODE } } @@ -36,21 +36,21 @@ function Build-NetFramework { } } -function Build-NetCore { +function Build-Net { param([string]$arch) - Write-Host "Building .NET Core $arch binaries" + Write-Host "Building .NET $arch binaries" $rid = "win-$arch" - $outdir = "$net_baseoutput\$netcore_tfm\$rid" + $outdir = "$net_baseoutput\$net_tfm\$rid" $publishDir = "$outdir\publish" if ($NoMsbuild) { - dotnet publish -v:m -c $configuration -f $netcore_tfm -r $rid --self-contained + dotnet publish -v:m -c $configuration -f $net_tfm -r $rid --self-contained if ($LASTEXITCODE) { exit $LASTEXITCODE } } else { - msbuild -v:m -m -restore -t:Publish -p:Configuration=$configuration -p:TargetFramework=$netcore_tfm -p:RuntimeIdentifier=$rid -p:SelfContained=True + msbuild -v:m -m -restore -t:Publish -p:Configuration=$configuration -p:TargetFramework=$net_tfm -p:RuntimeIdentifier=$rid -p:SelfContained=True if ($LASTEXITCODE) { exit $LASTEXITCODE } } @@ -62,7 +62,7 @@ function Build-NetCore { Rename-Item $publishDir\$tmpbin bin foreach ($exe in 'dnSpy.exe', 'dnSpy.Console.exe') { Move-Item $publishDir\bin\$exe $publishDir - & $apphostpatcher_dir\bin\$configuration\$net_tfm\AppHostPatcher.exe $publishDir\$exe -d bin + & $apphostpatcher_dir\bin\$configuration\$netframework_tfm\AppHostPatcher.exe $publishDir\$exe -d bin if ($LASTEXITCODE) { exit $LASTEXITCODE } } } @@ -73,11 +73,11 @@ $buildCoreX64 = $buildtfm -eq 'all' -or $buildtfm -eq 'core-x64' if ($buildCoreX86 -or $buildCoreX64) { if ($NoMsbuild) { - dotnet build -v:m -c $configuration -f $net_tfm $apphostpatcher_dir\AppHostPatcher.csproj + dotnet build -v:m -c $configuration -f $netframework_tfm $apphostpatcher_dir\AppHostPatcher.csproj if ($LASTEXITCODE) { exit $LASTEXITCODE } } else { - msbuild -v:m -m -restore -t:Build -p:Configuration=$configuration -p:TargetFramework=$net_tfm $apphostpatcher_dir\AppHostPatcher.csproj + msbuild -v:m -m -restore -t:Build -p:Configuration=$configuration -p:TargetFramework=$netframework_tfm $apphostpatcher_dir\AppHostPatcher.csproj if ($LASTEXITCODE) { exit $LASTEXITCODE } } } @@ -87,9 +87,9 @@ if ($buildNet) { } if ($buildCoreX86) { - Build-NetCore x86 + Build-Net x86 } if ($buildCoreX64) { - Build-NetCore x64 + Build-Net x64 } diff --git a/dnSpy/Roslyn/dnSpy.Roslyn/Compiler/FrameworkDetector.cs b/dnSpy/Roslyn/dnSpy.Roslyn/Compiler/FrameworkDetector.cs index ad46b0eef6..135a3a8fb4 100644 --- a/dnSpy/Roslyn/dnSpy.Roslyn/Compiler/FrameworkDetector.cs +++ b/dnSpy/Roslyn/dnSpy.Roslyn/Compiler/FrameworkDetector.cs @@ -27,7 +27,7 @@ enum FrameworkKind { Unknown, DotNetFramework2, DotNetFramework4, - DotNetCore, + DotNet, Unity2, Unity4, } @@ -52,7 +52,7 @@ public static FrameworkKind GetFrameworkKind(ModuleDef module) { return FrameworkKind.Unknown; } if (info.framework == ".NETCoreApp") - return FrameworkKind.DotNetCore; + return FrameworkKind.DotNet; return FrameworkKind.Unknown; } @@ -67,7 +67,7 @@ public static FrameworkKind GetFrameworkKind(ModuleDef module) { switch (corlib.Name) { case "System.Runtime": if (corlib.Version >= new Version(4, 1, 0, 0)) - return FrameworkKind.DotNetCore; + return FrameworkKind.DotNet; break; } diff --git a/dnSpy/Roslyn/dnSpy.Roslyn/Debugger/ValueNodes/EnumerableDebugViewHelper.cs b/dnSpy/Roslyn/dnSpy.Roslyn/Debugger/ValueNodes/EnumerableDebugViewHelper.cs index e2dc07d558..877cdeaf4c 100644 --- a/dnSpy/Roslyn/dnSpy.Roslyn/Debugger/ValueNodes/EnumerableDebugViewHelper.cs +++ b/dnSpy/Roslyn/dnSpy.Roslyn/Debugger/ValueNodes/EnumerableDebugViewHelper.cs @@ -43,7 +43,7 @@ static class EnumerableDebugViewHelper { DmdWellKnownType.System_Linq_SystemCore_EnumerableDebugView_T : DmdWellKnownType.System_Linq_SystemCore_EnumerableDebugView; var debugViewType = appDomain.GetWellKnownType(wellKnownType, isOptional: true); - // If this fails, System.Core (.NET Framework) / System.Linq (.NET Core) hasn't been loaded yet + // If this fails, System.Core (.NET Framework) / System.Linq (.NET) hasn't been loaded yet // or the type doesn't exist in the assembly (Unity) if (debugViewType is null) return null; diff --git a/dnSpy/Roslyn/dnSpy.Roslyn/Debugger/ValueNodes/ResultsViewMembersValueNodeProvider.cs b/dnSpy/Roslyn/dnSpy.Roslyn/Debugger/ValueNodes/ResultsViewMembersValueNodeProvider.cs index 4504fc129a..920d9333be 100644 --- a/dnSpy/Roslyn/dnSpy.Roslyn/Debugger/ValueNodes/ResultsViewMembersValueNodeProvider.cs +++ b/dnSpy/Roslyn/dnSpy.Roslyn/Debugger/ValueNodes/ResultsViewMembersValueNodeProvider.cs @@ -145,7 +145,7 @@ enum ClrVersion { } ClrVersion GetClrVersion(DbgRuntime runtime) { - if (runtime.Guid == PredefinedDbgRuntimeGuids.DotNetCore_Guid) + if (runtime.Guid == PredefinedDbgRuntimeGuids.DotNet_Guid) return ClrVersion.CoreCLR; if (enumerableType.AppDomain.CorLib?.GetName().Version == new Version(2, 0, 0, 0)) return ClrVersion.CLR2; diff --git a/dnSpy/dnSpy-x86/Program.cs b/dnSpy/dnSpy-x86/Program.cs index 61582ad6ff..c479f84c4f 100644 --- a/dnSpy/dnSpy-x86/Program.cs +++ b/dnSpy/dnSpy-x86/Program.cs @@ -23,7 +23,7 @@ namespace dnSpy_x86 { static class Program { [STAThread] static void Main() { -#if NETCOREAPP +#if NET const string errmsg = "Wrong startup project"; System.Diagnostics.Debug.Fail(errmsg); throw new InvalidOperationException(errmsg); diff --git a/dnSpy/dnSpy.Console/Program.cs b/dnSpy/dnSpy.Console/Program.cs index 3a0a0d5052..e074a29445 100644 --- a/dnSpy/dnSpy.Console/Program.cs +++ b/dnSpy/dnSpy.Console/Program.cs @@ -190,16 +190,16 @@ sealed class DnSpyDecompiler : IMSBuildProjectWriterLogger { readonly AssemblyResolver assemblyResolver; readonly IBamlDecompiler? bamlDecompiler; readonly HashSet reservedOptions; -#if NETCOREAPP - readonly dnSpy.MainApp.NetCoreAssemblyLoader netCoreAssemblyLoader = new dnSpy.MainApp.NetCoreAssemblyLoader(System.Runtime.Loader.AssemblyLoadContext.Default); +#if NET + readonly dnSpy.MainApp.DotNetAssemblyLoader dotNetAssemblyLoader = new dnSpy.MainApp.DotNetAssemblyLoader(System.Runtime.Loader.AssemblyLoadContext.Default); #endif static readonly char PATHS_SEP = Path.PathSeparator; public DnSpyDecompiler() { -#if NETCOREAPP +#if NET // This assembly is always in the bin sub dir if one exists - netCoreAssemblyLoader.AddSearchPath(Path.GetDirectoryName(typeof(ILSpan).Assembly.Location)!); + dotNetAssemblyLoader.AddSearchPath(Path.GetDirectoryName(typeof(ILSpan).Assembly.Location)!); #endif files = new List(); asmPaths = new List(); diff --git a/dnSpy/dnSpy.Console/dnSpy.Console.csproj b/dnSpy/dnSpy.Console/dnSpy.Console.csproj index 6c8bcc5963..f013d37f5f 100644 --- a/dnSpy/dnSpy.Console/dnSpy.Console.csproj +++ b/dnSpy/dnSpy.Console/dnSpy.Console.csproj @@ -1,6 +1,6 @@