Browse Source

Display a warning message when attaching to a running process.

Remove the Attach button from toolbar.
Add Debugger options panel + move all options panels in Options folder.
pull/191/merge
Eusebiu Marcu 14 years ago
parent
commit
203799c744
  1. 35
      Debugger/ILSpy.Debugger/DebuggerSettings.cs
  2. 2
      Debugger/ILSpy.Debugger/ILSpy.Debugger.csproj
  3. BIN
      Debugger/ILSpy.Debugger/Images/bug.png
  4. 8
      ILSpy.sln
  5. 105
      ILSpy/Commands/DebuggerCommands.cs
  6. 23
      ILSpy/ILSpy.csproj
  7. 10
      ILSpy/Options/DebuggerSettingsPanel.xaml
  8. 63
      ILSpy/Options/DebuggerSettingsPanel.xaml.cs
  9. 0
      ILSpy/Options/DecompilerSettingsPanel.xaml
  10. 2
      ILSpy/Options/DecompilerSettingsPanel.xaml.cs
  11. 0
      ILSpy/Options/OptionsDialog.xaml
  12. 15
      ILSpy/Options/OptionsDialog.xaml.cs

35
Debugger/ILSpy.Debugger/DebuggerSettings.cs

@ -0,0 +1,35 @@ @@ -0,0 +1,35 @@
// Copyright (c) 2011 AlphaSierraPapa for the SharpDevelop Team
// This code is distributed under MIT X11 license (for details please see \doc\license.txt)
using System;
using System.ComponentModel;
namespace ILSpy.Debugger
{
public class DebuggerSettings : INotifyPropertyChanged
{
bool showWarnings = true;
/// <summary>
/// Show warnings messages.
/// </summary>
public bool ShowWarnings {
get { return showWarnings; }
set {
if (showWarnings != value) {
showWarnings = value;
OnPropertyChanged("ShowWarnings");
}
}
}
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnPropertyChanged(string propertyName)
{
if (PropertyChanged != null) {
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
}
}

2
Debugger/ILSpy.Debugger/ILSpy.Debugger.csproj

@ -69,6 +69,7 @@ @@ -69,6 +69,7 @@
<Compile Include="Bookmarks\IBookmark.cs" />
<Compile Include="Bookmarks\MarkerBookmark.cs" />
<Compile Include="DebuggedData.cs" />
<Compile Include="DebuggerSettings.cs" />
<Compile Include="Models\TreeModel\ArrayRangeNode.cs" />
<Compile Include="Models\TreeModel\ChildNodesOfObject.cs" />
<Compile Include="Models\TreeModel\ExpressionNode.cs" />
@ -200,7 +201,6 @@ @@ -200,7 +201,6 @@
<Resource Include="Images\DeleteAllBreakpoints.PNG" />
</ItemGroup>
<ItemGroup>
<Resource Include="Images\bug.png" />
<Resource Include="Images\ContinueDebugging.png" />
</ItemGroup>
<ItemGroup>

BIN
Debugger/ILSpy.Debugger/Images/bug.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 827 B

8
ILSpy.sln

@ -1,15 +1,15 @@ @@ -1,15 +1,15 @@

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
# SharpDevelop 4.1.0.7312-alpha
# SharpDevelop 4.1.0.7371-alpha
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Debugger", "Debugger", "{1DEB3B4E-03AC-437C-821D-B09FBFCC3E5B}"
ProjectSection(SolutionItems) = postProject
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ILSpy.Debugger", "Debugger\ILSpy.Debugger\ILSpy.Debugger.csproj", "{6D3D0F0D-348D-456A-A6ED-E9BD5EFABB6A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Debugger.Core", "Debugger\Debugger.Core\Debugger.Core.csproj", "{1D18D788-F7EE-4585-A23B-34DC8EC63CB8}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ILSpy.Debugger", "Debugger\ILSpy.Debugger\ILSpy.Debugger.csproj", "{6D3D0F0D-348D-456A-A6ED-E9BD5EFABB6A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ILSpy", "ILSpy\ILSpy.csproj", "{1E85EFF9-E370-4683-83E4-8A3D063FF791}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.TreeView", "SharpTreeView\ICSharpCode.TreeView.csproj", "{DDE2A481-8271-4EAC-A330-8FA6A38D13D1}"
@ -109,7 +109,7 @@ Global @@ -109,7 +109,7 @@ Global
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{1D18D788-F7EE-4585-A23B-34DC8EC63CB8} = {1DEB3B4E-03AC-437C-821D-B09FBFCC3E5B}
{6D3D0F0D-348D-456A-A6ED-E9BD5EFABB6A} = {1DEB3B4E-03AC-437C-821D-B09FBFCC3E5B}
{1D18D788-F7EE-4585-A23B-34DC8EC63CB8} = {1DEB3B4E-03AC-437C-821D-B09FBFCC3E5B}
EndGlobalSection
EndGlobal

105
ILSpy/Commands/DebuggerCommands.cs

@ -9,6 +9,7 @@ using System.Windows.Controls; @@ -9,6 +9,7 @@ using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Interop;
using System.Windows.Media;
using System.Xml.Linq;
using ILSpy.Debugger;
using ILSpy.Debugger.Bookmarks;
@ -172,21 +173,57 @@ namespace ICSharpCode.ILSpy.Commands @@ -172,21 +173,57 @@ namespace ICSharpCode.ILSpy.Commands
}
}
[ExportToolbarCommand(ToolTip = "Attach to running application",
ToolbarIcon = "ILSpy.Debugger;component/Images/bug.png",
[ExportToolbarCommand(ToolTip = "Debug an executable",
ToolbarIcon = "ILSpy.Debugger;component/Images/application-x-executable.png",
ToolbarCategory = "Debugger",
Tag = "Debugger",
ToolbarOrder = 0)]
[ExportMainMenuCommand(Menu = "_Debugger",
MenuIcon = "ILSpy.Debugger;component/Images/bug.png",
MenuCategory = "Debugger1",
Header = "Attach to _running application",
MenuIcon = "ILSpy.Debugger;component/Images/application-x-executable.png",
MenuCategory = "Start",
Header = "Debug an _executable",
MenuOrder = 0)]
internal sealed class DebugExecutableCommand : DebuggerCommand
{
public override void Execute(object parameter)
{
OpenFileDialog dialog = new OpenFileDialog() {
Filter = ".NET Executable (*.exe) | *.exe",
RestoreDirectory = true,
DefaultExt = "exe"
};
if (dialog.ShowDialog() == true) {
string fileName = dialog.FileName;
// add it to references
MainWindow.Instance.OpenFiles(new [] { fileName }, false);
if (!CurrentDebugger.IsDebugging) {
// execute the process
this.StartExecutable(fileName);
}
}
}
}
[ExportMainMenuCommand(Menu = "_Debugger",
MenuCategory = "Start",
Header = "Attach to _running application",
MenuOrder = 1)]
internal sealed class AttachCommand : DebuggerCommand
{
public override void Execute(object parameter)
{
if (!CurrentDebugger.IsDebugging) {
var settings = ILSpySettings.Load();
XElement e = settings["DebuggerSettings"];
var showWarnings = (bool?)e.Attribute("showWarnings");
if (showWarnings.HasValue && showWarnings.Value)
MessageBox.Show("Warning: When attaching to an application, some local variables might not be available. If possible, use the \"Start Executable\" command.",
"Attach to a process", MessageBoxButton.OK, MessageBoxImage.Warning);
var window = new AttachToProcessWindow { Owner = MainWindow.Instance };
if (window.ShowDialog() == true) {
StartAttaching(window.SelectedProcess);
@ -197,11 +234,11 @@ namespace ICSharpCode.ILSpy.Commands @@ -197,11 +234,11 @@ namespace ICSharpCode.ILSpy.Commands
[ExportMainMenuCommand(Menu = "_Debugger",
MenuIcon = "ILSpy.Debugger;component/Images/ContinueDebugging.png",
MenuCategory = "Debugger1",
MenuCategory = "SteppingArea",
Header = "Continue debugging",
InputGestureText = "F5",
IsEnabled = false,
MenuOrder = 1)]
MenuOrder = 2)]
internal sealed class ContinueDebuggingCommand : DebuggerCommand
{
public override void Execute(object parameter)
@ -215,11 +252,11 @@ namespace ICSharpCode.ILSpy.Commands @@ -215,11 +252,11 @@ namespace ICSharpCode.ILSpy.Commands
[ExportMainMenuCommand(Menu = "_Debugger",
MenuIcon = "ILSpy.Debugger;component/Images/StepInto.png",
MenuCategory = "Debugger1",
MenuCategory = "SteppingArea",
Header = "Step into",
InputGestureText = "F11",
IsEnabled = false,
MenuOrder = 2)]
MenuOrder = 3)]
internal sealed class StepIntoCommand : DebuggerCommand
{
public override void Execute(object parameter)
@ -233,11 +270,11 @@ namespace ICSharpCode.ILSpy.Commands @@ -233,11 +270,11 @@ namespace ICSharpCode.ILSpy.Commands
[ExportMainMenuCommand(Menu = "_Debugger",
MenuIcon = "ILSpy.Debugger;component/Images/StepOver.png",
MenuCategory = "Debugger1",
MenuCategory = "SteppingArea",
Header = "Step over",
InputGestureText = "F10",
IsEnabled = false,
MenuOrder = 3)]
MenuOrder = 4)]
internal sealed class StepOverCommand : DebuggerCommand
{
public override void Execute(object parameter)
@ -251,10 +288,10 @@ namespace ICSharpCode.ILSpy.Commands @@ -251,10 +288,10 @@ namespace ICSharpCode.ILSpy.Commands
[ExportMainMenuCommand(Menu = "_Debugger",
MenuIcon = "ILSpy.Debugger;component/Images/StepOut.png",
MenuCategory = "Debugger1",
MenuCategory = "SteppingArea",
Header = "Step out",
IsEnabled = false,
MenuOrder = 4)]
MenuOrder = 5)]
internal sealed class StepOutCommand : DebuggerCommand
{
public override void Execute(object parameter)
@ -267,10 +304,10 @@ namespace ICSharpCode.ILSpy.Commands @@ -267,10 +304,10 @@ namespace ICSharpCode.ILSpy.Commands
}
[ExportMainMenuCommand(Menu = "_Debugger",
MenuCategory = "Debugger1",
MenuCategory = "SteppingArea",
Header = "_Detach from running application",
IsEnabled = false,
MenuOrder = 5)]
MenuOrder = 6)]
internal sealed class DetachCommand : DebuggerCommand
{
public override void Execute(object parameter)
@ -286,9 +323,9 @@ namespace ICSharpCode.ILSpy.Commands @@ -286,9 +323,9 @@ namespace ICSharpCode.ILSpy.Commands
[ExportMainMenuCommand(Menu = "_Debugger",
MenuIcon = "ILSpy.Debugger;component/Images/DeleteAllBreakpoints.png",
MenuCategory = "Debugger2",
MenuCategory = "Others",
Header = "Remove all _breakpoints",
MenuOrder = 6)]
MenuOrder = 7)]
internal sealed class RemoveBreakpointsCommand : DebuggerCommand
{
public override void Execute(object parameter)
@ -301,38 +338,4 @@ namespace ICSharpCode.ILSpy.Commands @@ -301,38 +338,4 @@ namespace ICSharpCode.ILSpy.Commands
}
}
}
[ExportToolbarCommand(ToolTip = "Debug an executable",
ToolbarIcon = "ILSpy.Debugger;component/Images/application-x-executable.png",
ToolbarCategory = "Debugger",
Tag = "Debugger",
ToolbarOrder = 0)]
[ExportMainMenuCommand(Menu = "_Debugger",
MenuIcon = "ILSpy.Debugger;component/Images/application-x-executable.png",
MenuCategory = "Debugger3",
Header = "Debug an _executable",
MenuOrder = 7)]
internal sealed class DebugExecutableCommand : DebuggerCommand
{
public override void Execute(object parameter)
{
OpenFileDialog dialog = new OpenFileDialog() {
Filter = ".NET Executable (*.exe) | *.exe",
RestoreDirectory = true,
DefaultExt = "exe"
};
if (dialog.ShowDialog() == true) {
string fileName = dialog.FileName;
// add it to references
MainWindow.Instance.OpenFiles(new [] { fileName }, false);
if (!CurrentDebugger.IsDebugging) {
// execute the process
this.StartExecutable(fileName);
}
}
}
}
}

23
ILSpy/ILSpy.csproj

@ -91,10 +91,6 @@ @@ -91,10 +91,6 @@
<Compile Include="BamlDecompiler.cs" />
<Compile Include="Commands.cs" />
<Compile Include="Commands\DebuggerCommands.cs" />
<Compile Include="DecompilerSettingsPanel.xaml.cs">
<DependentUpon>DecompilerSettingsPanel.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="Controls\SearchBox.cs" />
<Compile Include="Controls\SortableGridViewColumn.cs" />
<Compile Include="CSharpLanguage.cs" />
@ -117,7 +113,15 @@ @@ -117,7 +113,15 @@
<DependentUpon>OpenFromGacDialog.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="OptionsDialog.xaml.cs">
<Compile Include="Options\DebuggerSettingsPanel.xaml.cs">
<DependentUpon>DebuggerSettingsPanel.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="Options\DecompilerSettingsPanel.xaml.cs">
<DependentUpon>DecompilerSettingsPanel.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="Options\OptionsDialog.xaml.cs">
<DependentUpon>OptionsDialog.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
@ -181,10 +185,11 @@ @@ -181,10 +185,11 @@
<Page Include="Controls\SearchBoxStyle.xaml">
<DependentUpon>SearchBox.cs</DependentUpon>
</Page>
<Page Include="DecompilerSettingsPanel.xaml" />
<Page Include="MainWindow.xaml" />
<Page Include="OpenFromGacDialog.xaml" />
<Page Include="OptionsDialog.xaml" />
<Page Include="Options\DebuggerSettingsPanel.xaml" />
<Page Include="Options\DecompilerSettingsPanel.xaml" />
<Page Include="Options\OptionsDialog.xaml" />
<Page Include="TextView\DecompilerTextView.xaml">
<DependentUpon>DecompilerTextView.cs</DependentUpon>
</Page>
@ -260,6 +265,8 @@ @@ -260,6 +265,8 @@
<Name>ICSharpCode.TreeView</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup />
<ItemGroup>
<Folder Include="Options" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
</Project>

10
ILSpy/Options/DebuggerSettingsPanel.xaml

@ -0,0 +1,10 @@ @@ -0,0 +1,10 @@
<UserControl x:Class="ICSharpCode.ILSpy.Options.DebuggerSettingsPanel"
x:ClassModifier="internal"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Grid>
<StackPanel Margin="10">
<CheckBox IsChecked="{Binding ShowWarnings}">Show warning messages</CheckBox>
</StackPanel>
</Grid>
</UserControl>

63
ILSpy/Options/DebuggerSettingsPanel.xaml.cs

@ -0,0 +1,63 @@ @@ -0,0 +1,63 @@
// Copyright (c) 2011 AlphaSierraPapa for the SharpDevelop Team
// This code is distributed under MIT X11 license (for details please see \doc\license.txt)
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Xml.Linq;
using ILSpy.Debugger;
namespace ICSharpCode.ILSpy.Options
{
[ExportOptionPage(Title = "Debugger", Order = 1)]
partial class DebuggerSettingsPanel : UserControl, IOptionPage
{
public DebuggerSettingsPanel()
{
InitializeComponent();
}
public void Load(ILSpySettings settings)
{
this.DataContext = LoadDebuggerSettings(settings);
}
static DebuggerSettings currentDebuggerSettings;
public static DebuggerSettings CurrentDebuggerSettings {
get {
return currentDebuggerSettings ?? (currentDebuggerSettings = LoadDebuggerSettings(ILSpySettings.Load()));
}
}
public static DebuggerSettings LoadDebuggerSettings(ILSpySettings settings)
{
XElement e = settings["DebuggerSettings"];
DebuggerSettings s = new DebuggerSettings();
s.ShowWarnings = (bool?)e.Attribute("showWarnings") ?? s.ShowWarnings;
return s;
}
public void Save(XElement root)
{
var s = (DebuggerSettings)this.DataContext;
XElement section = new XElement("DebuggerSettings");
section.SetAttributeValue("showWarnings", s.ShowWarnings);
XElement existingElement = root.Element("DebuggerSettings");
if (existingElement != null)
existingElement.ReplaceWith(section);
else
root.Add(section);
currentDebuggerSettings = null; // invalidate cached settings
}
}
}

0
ILSpy/DecompilerSettingsPanel.xaml → ILSpy/Options/DecompilerSettingsPanel.xaml

2
ILSpy/DecompilerSettingsPanel.xaml.cs → ILSpy/Options/DecompilerSettingsPanel.xaml.cs

@ -18,7 +18,7 @@ namespace ICSharpCode.ILSpy @@ -18,7 +18,7 @@ namespace ICSharpCode.ILSpy
/// <summary>
/// Interaction logic for DecompilerSettingsPanel.xaml
/// </summary>
[ExportOptionPage("Decompiler")]
[ExportOptionPage(Title = "Decompiler", Order = 0)]
partial class DecompilerSettingsPanel : UserControl, IOptionPage
{
public DecompilerSettingsPanel()

0
ILSpy/OptionsDialog.xaml → ILSpy/Options/OptionsDialog.xaml

15
ILSpy/OptionsDialog.xaml.cs → ILSpy/Options/OptionsDialog.xaml.cs

@ -4,6 +4,7 @@ @@ -4,6 +4,7 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
@ -28,7 +29,7 @@ namespace ICSharpCode.ILSpy @@ -28,7 +29,7 @@ namespace ICSharpCode.ILSpy
InitializeComponent();
App.CompositionContainer.ComposeParts(this);
ILSpySettings settings = ILSpySettings.Load();
foreach (var optionPage in optionPages) {
foreach (var optionPage in optionPages.OrderBy(p => p.Metadata.Order)) {
TabItem tabItem = new TabItem();
tabItem.Header = optionPage.Metadata.Title;
tabItem.Content = optionPage.Value;
@ -58,6 +59,7 @@ namespace ICSharpCode.ILSpy @@ -58,6 +59,7 @@ namespace ICSharpCode.ILSpy
public interface IOptionsMetadata
{
string Title { get; }
int Order { get; }
}
public interface IOptionPage
@ -70,13 +72,12 @@ namespace ICSharpCode.ILSpy @@ -70,13 +72,12 @@ namespace ICSharpCode.ILSpy
[AttributeUsage(AttributeTargets.Class, AllowMultiple=false)]
public class ExportOptionPageAttribute : ExportAttribute
{
public ExportOptionPageAttribute(string title)
: base("OptionPages", typeof(UIElement))
{
this.Title = title;
}
public ExportOptionPageAttribute() : base("OptionPages", typeof(UIElement))
{ }
public string Title { get; set; }
public string Title { get; private set; }
public int Order { get; set; }
}
[ExportMainMenuCommand(Menu = "_View", Header = "_Options", MenuCategory = "Options", MenuOrder = 999)]
Loading…
Cancel
Save