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 index f47cdc4633..9f6f0a7ec7 100644 --- a/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/Dialogs/DebugProgram/DotNetCommonStartDebuggingOptionsPage.cs +++ b/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/Dialogs/DebugProgram/DotNetCommonStartDebuggingOptionsPage.cs @@ -22,6 +22,7 @@ You should have received a copy of the GNU General Public License using System.IO; using System.Windows.Input; using dnSpy.Contracts.Debugger; +using dnSpy.Contracts.Debugger.Dialogs; using dnSpy.Contracts.Debugger.DotNet.CorDebug; using dnSpy.Contracts.Debugger.StartDebugging.Dialog; using dnSpy.Contracts.MVVM; @@ -70,8 +71,24 @@ public string WorkingDirectory { } string workingDirectory = string.Empty; + public string EnvironmentString { + get { + var sb = new System.Text.StringBuilder(); + foreach (var kv in Environment.Environment) { + sb.Append(kv.Key); + sb.Append('='); + sb.Append(kv.Value); + sb.Append(';'); + } + return sb.ToString(); + } + } + + public DbgEnvironment Environment { get; } = new DbgEnvironment(); + public ICommand PickFilenameCommand => new RelayCommand(a => PickNewFilename()); public ICommand PickWorkingDirectoryCommand => new RelayCommand(a => PickNewWorkingDirectory()); + public ICommand EditEnvironmentCommand => new RelayCommand(a => EditEnvironment()); public EnumListVM BreakProcessKindVM => breakProcessKindVM; readonly EnumListVM breakProcessKindVM = new EnumListVM(BreakProcessKindsUtils.BreakProcessKindList); @@ -96,10 +113,12 @@ protected void UpdateIsValid() { protected readonly IPickFilename pickFilename; readonly IPickDirectory pickDirectory; + readonly IDbgEnvironmentEditorService environmentEditorService; - protected DotNetCommonStartDebuggingOptionsPage(IPickFilename pickFilename, IPickDirectory pickDirectory) { + protected DotNetCommonStartDebuggingOptionsPage(IPickFilename pickFilename, IPickDirectory pickDirectory, IDbgEnvironmentEditorService environmentEditorService) { this.pickFilename = pickFilename ?? throw new ArgumentNullException(nameof(pickFilename)); this.pickDirectory = pickDirectory ?? throw new ArgumentNullException(nameof(pickDirectory)); + this.environmentEditorService = environmentEditorService ?? throw new ArgumentNullException(nameof(environmentEditorService)); } static string? GetPath(string file) { @@ -126,6 +145,11 @@ void PickNewWorkingDirectory() { WorkingDirectory = newDir; } + void EditEnvironment() { + if (environmentEditorService.ShowEditDialog(Environment)) + OnPropertyChanged(nameof(EnvironmentString)); + } + static string FilterBreakKind(string? breakKind) { foreach (var info in BreakProcessKindsUtils.BreakProcessKindList) { if (StringComparer.Ordinal.Equals(breakKind, (string)info.Value)) @@ -139,6 +163,8 @@ protected void Initialize(CorDebugStartDebuggingOptions options) { CommandLine = options.CommandLine ?? string.Empty; // Must be init'd after Filename since it also overwrites this property WorkingDirectory = options.WorkingDirectory ?? string.Empty; + Environment.Clear(); + Environment.AddRange(options.Environment.Environment); BreakKind = FilterBreakKind(options.BreakKind); } @@ -151,6 +177,8 @@ protected T GetOptions(T options) where T : CorDebugStartDebuggingOptions { options.Filename = Filename; options.CommandLine = CommandLine; options.WorkingDirectory = WorkingDirectory; + options.Environment.Clear(); + options.Environment.AddRange(Environment.Environment); options.BreakKind = FilterBreakKind(BreakKind); return options; } 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 e1e677b633..e104948d5a 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 @@ -21,7 +21,10 @@ You should have received a copy of the GNU General Public License using System.Collections.Generic; using System.IO; using System.Linq; +using dnSpy.Contracts.App; +using dnSpy.Contracts.Controls.ToolWindows; using dnSpy.Contracts.Debugger; +using dnSpy.Contracts.Debugger.Dialogs; using dnSpy.Contracts.Debugger.DotNet.CorDebug; using dnSpy.Contracts.Debugger.StartDebugging; using dnSpy.Contracts.Debugger.StartDebugging.Dialog; @@ -47,8 +50,8 @@ static string[] CreateRuntimeVersions() { return list.ToArray(); } - public DotNetFrameworkStartDebuggingOptionsPage(IPickFilename pickFilename, IPickDirectory pickDirectory) - : base(pickFilename, pickDirectory) { + public DotNetFrameworkStartDebuggingOptionsPage(IPickFilename pickFilename, IPickDirectory pickDirectory, IDbgEnvironmentEditorService environmentEditorService) + : base(pickFilename, pickDirectory, environmentEditorService) { } protected override void PickNewFilename() { 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 97416a989b..58468b1604 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 @@ -20,7 +20,10 @@ You should have received a copy of the GNU General Public License using System; using System.IO; using System.Windows.Input; +using dnSpy.Contracts.App; +using dnSpy.Contracts.Controls.ToolWindows; using dnSpy.Contracts.Debugger; +using dnSpy.Contracts.Debugger.Dialogs; using dnSpy.Contracts.Debugger.DotNet.CorDebug; using dnSpy.Contracts.Debugger.StartDebugging; using dnSpy.Contracts.Debugger.StartDebugging.Dialog; @@ -75,8 +78,8 @@ public string HostArguments { public ICommand PickHostFilenameCommand => new RelayCommand(a => PickNewHostFilename(), a => CanPickNewHostFilename); - public DotNetStartDebuggingOptionsPage(IPickFilename pickFilename, IPickDirectory pickDirectory) - : base(pickFilename, pickDirectory) => ConnectionTimeout = new UInt32VM(a => UpdateIsValid(), useDecimal: true); + public DotNetStartDebuggingOptionsPage(IPickFilename pickFilename, IPickDirectory pickDirectory, IDbgEnvironmentEditorService environmentEditorService) + : base(pickFilename, pickDirectory, environmentEditorService) => ConnectionTimeout = new UInt32VM(a => UpdateIsValid(), useDecimal: true); bool CanPickNewHostFilename => UseHost; 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 3f9f8a7af1..99481a09d2 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 @@ -19,24 +19,29 @@ You should have received a copy of the GNU General Public License using System.Collections.Generic; using System.ComponentModel.Composition; +using dnSpy.Contracts.App; using dnSpy.Contracts.Debugger.StartDebugging.Dialog; using dnSpy.Contracts.MVVM; +using dnSpy.Contracts.Controls.ToolWindows; +using dnSpy.Contracts.Debugger.Dialogs; namespace dnSpy.Debugger.DotNet.CorDebug.Dialogs.DebugProgram { [Export(typeof(StartDebuggingOptionsPageProvider))] sealed class StartDebuggingOptionsPageProviderImpl : StartDebuggingOptionsPageProvider { readonly IPickFilename pickFilename; readonly IPickDirectory pickDirectory; + readonly IDbgEnvironmentEditorService environmentEditorService; [ImportingConstructor] - StartDebuggingOptionsPageProviderImpl(IPickFilename pickFilename, IPickDirectory pickDirectory) { + StartDebuggingOptionsPageProviderImpl(IPickFilename pickFilename, IPickDirectory pickDirectory, IDbgEnvironmentEditorService environmentEditorService) { this.pickFilename = pickFilename; this.pickDirectory = pickDirectory; + this.environmentEditorService = environmentEditorService; } public override IEnumerable Create(StartDebuggingOptionsPageContext context) { - yield return new DotNetFrameworkStartDebuggingOptionsPage(pickFilename, pickDirectory); - yield return new DotNetStartDebuggingOptionsPage(pickFilename, pickDirectory); + yield return new DotNetFrameworkStartDebuggingOptionsPage(pickFilename, pickDirectory, environmentEditorService); + yield return new DotNetStartDebuggingOptionsPage(pickFilename, pickDirectory, environmentEditorService); } } } diff --git a/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/Properties/dnSpy.Debugger.DotNet.CorDebug.Resources.Designer.cs b/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/Properties/dnSpy.Debugger.DotNet.CorDebug.Resources.Designer.cs index ffa9d4fdc3..08265625eb 100644 --- a/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/Properties/dnSpy.Debugger.DotNet.CorDebug.Resources.Designer.cs +++ b/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/Properties/dnSpy.Debugger.DotNet.CorDebug.Resources.Designer.cs @@ -87,6 +87,15 @@ public static string DbgAsm_BreakAt { } } + /// + /// Looks up a localized string similar to Environment. + /// + public static string DbgAsm_Environment { + get { + return ResourceManager.GetString("DbgAsm_Environment", resourceCulture); + } + } + /// /// Looks up a localized string similar to E_xecutable. /// diff --git a/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/Properties/dnSpy.Debugger.DotNet.CorDebug.Resources.resx b/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/Properties/dnSpy.Debugger.DotNet.CorDebug.Resources.resx index 4edcdf81f8..7bd0f42d3a 100644 --- a/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/Properties/dnSpy.Debugger.DotNet.CorDebug.Resources.resx +++ b/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/Properties/dnSpy.Debugger.DotNet.CorDebug.Resources.resx @@ -123,6 +123,9 @@ _Break at + + Environment + _Host 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 876aa62a61..d9c6a68456 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 @@ -29,6 +29,7 @@ + @@ -47,11 +48,15 @@