44 changed files with 433 additions and 1538 deletions
@ -1,204 +0,0 @@ |
|||||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
|
||||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
|
||||||
using System; |
|
||||||
using System.Collections.Concurrent; |
|
||||||
using System.Collections.Generic; |
|
||||||
using System.IO; |
|
||||||
|
|
||||||
using ICSharpCode.Decompiler; |
|
||||||
using ICSharpCode.Decompiler.Ast; |
|
||||||
using ICSharpCode.Decompiler.ILAst; |
|
||||||
using ICSharpCode.ILSpyAddIn.LaunchILSpy; |
|
||||||
using ICSharpCode.SharpDevelop.Debugging; |
|
||||||
using ICSharpCode.SharpDevelop.Project; |
|
||||||
using Mono.Cecil; |
|
||||||
|
|
||||||
namespace ICSharpCode.ILSpyAddIn |
|
||||||
{ |
|
||||||
/* |
|
||||||
// Dummy class to avoid the build errors after updating the ICSharpCode.Decompiler version.
|
|
||||||
// TODO: get rid of this & fix debugging decompiled files
|
|
||||||
public class DecompileInformation { |
|
||||||
public dynamic LocalVariables; |
|
||||||
public dynamic CodeMappings; |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Stores the decompilation information.
|
|
||||||
/// </summary>
|
|
||||||
public class DebuggerDecompilerService : IDebuggerDecompilerService |
|
||||||
{ |
|
||||||
ILSpyAssemblyResolver resolver; |
|
||||||
|
|
||||||
static DebuggerDecompilerService() |
|
||||||
{ |
|
||||||
DebugInformation = new ConcurrentDictionary<int, DecompileInformation>(); |
|
||||||
ProjectService.SolutionClosed += delegate { |
|
||||||
DebugInformation.Clear(); |
|
||||||
GC.Collect(); |
|
||||||
}; |
|
||||||
} |
|
||||||
|
|
||||||
internal static IDebuggerDecompilerService Instance { get; private set; } |
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the external debug information.
|
|
||||||
/// <summary>This constains the code mappings and local variables.</summary>
|
|
||||||
/// </summary>
|
|
||||||
internal static ConcurrentDictionary<int, DecompileInformation> DebugInformation { get; private set; } |
|
||||||
|
|
||||||
public DebuggerDecompilerService() |
|
||||||
{ |
|
||||||
Instance = this; |
|
||||||
} |
|
||||||
|
|
||||||
public Tuple<int, int> DebugStepInformation { get; set; } |
|
||||||
|
|
||||||
public bool CheckMappings(int typeToken) |
|
||||||
{ |
|
||||||
DecompileInformation data = null; |
|
||||||
DebugInformation.TryGetValue(typeToken, out data); |
|
||||||
DecompileInformation information = data as DecompileInformation; |
|
||||||
|
|
||||||
if (information == null) |
|
||||||
return false; |
|
||||||
|
|
||||||
if (information.CodeMappings == null) |
|
||||||
return false; |
|
||||||
|
|
||||||
return true; |
|
||||||
} |
|
||||||
|
|
||||||
public void DecompileOnDemand(TypeDefinition type) |
|
||||||
{ |
|
||||||
if (type == null) |
|
||||||
return; |
|
||||||
|
|
||||||
if (CheckMappings(type.MetadataToken.ToInt32())) |
|
||||||
return; |
|
||||||
|
|
||||||
try { |
|
||||||
DecompilerContext context = new DecompilerContext(type.Module); |
|
||||||
AstBuilder astBuilder = new AstBuilder(context); |
|
||||||
astBuilder.AddType(type); |
|
||||||
DebuggerTextOutput output = new DebuggerTextOutput(new PlainTextOutput()); |
|
||||||
astBuilder.GenerateCode(output); |
|
||||||
|
|
||||||
// int token = type.MetadataToken.ToInt32();
|
|
||||||
// var info = new DecompileInformation {
|
|
||||||
// CodeMappings = astBuilder.CodeMappings,
|
|
||||||
// LocalVariables = astBuilder.LocalVariables,
|
|
||||||
// DecompiledMemberReferences = astBuilder.DecompiledMemberReferences
|
|
||||||
// };
|
|
||||||
//
|
|
||||||
// // save the data
|
|
||||||
// DebugInformation.AddOrUpdate(token, info, (k, v) => info);
|
|
||||||
} catch { |
|
||||||
return; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public bool GetILAndTokenByLineNumber(int typeToken, int lineNumber, out int[] ilRanges, out int memberToken) |
|
||||||
{ |
|
||||||
ilRanges = null; |
|
||||||
memberToken = -1; |
|
||||||
if (!CheckMappings(typeToken)) |
|
||||||
return false; |
|
||||||
|
|
||||||
var data = (DecompileInformation)DebugInformation[typeToken]; |
|
||||||
var mappings = data.CodeMappings; |
|
||||||
foreach (var key in mappings.Keys) { |
|
||||||
var list = mappings[key]; |
|
||||||
var instruction = list.GetInstructionByLineNumber(lineNumber, out memberToken); |
|
||||||
if (instruction == null) |
|
||||||
continue; |
|
||||||
|
|
||||||
ilRanges = new int[] { instruction.ILInstructionOffset.From, instruction.ILInstructionOffset.To }; |
|
||||||
memberToken = instruction.MemberMapping.MetadataToken; |
|
||||||
return true; |
|
||||||
} |
|
||||||
|
|
||||||
return false; |
|
||||||
} |
|
||||||
|
|
||||||
public bool GetILAndLineNumber(int typeToken, int memberToken, int ilOffset, out int[] ilRange, out int line, out bool isMatch) |
|
||||||
{ |
|
||||||
ilRange = null; |
|
||||||
line = -1; |
|
||||||
isMatch = false; |
|
||||||
|
|
||||||
if (!CheckMappings(typeToken)) |
|
||||||
return false; |
|
||||||
|
|
||||||
var data = (DecompileInformation)DebugInformation[typeToken]; |
|
||||||
var mappings = data.CodeMappings; |
|
||||||
|
|
||||||
if (!mappings.ContainsKey(memberToken)) |
|
||||||
return false; |
|
||||||
|
|
||||||
var map = mappings[memberToken].GetInstructionByTokenAndOffset(memberToken, ilOffset, out isMatch); |
|
||||||
if (map != null) { |
|
||||||
ilRange = map.ToArray(isMatch); |
|
||||||
line = map.SourceCodeLine; |
|
||||||
return true; |
|
||||||
} |
|
||||||
|
|
||||||
return false; |
|
||||||
} |
|
||||||
|
|
||||||
public IEnumerable<string> GetLocalVariables(int typeToken, int memberToken) |
|
||||||
{ |
|
||||||
if (DebugInformation == null || !DebugInformation.ContainsKey(typeToken)) |
|
||||||
yield break; |
|
||||||
|
|
||||||
var externalData = DebugInformation[typeToken]; |
|
||||||
IEnumerable<ILVariable> list; |
|
||||||
|
|
||||||
if (externalData.LocalVariables.TryGetValue(memberToken, out list)) { |
|
||||||
foreach (var local in list) { |
|
||||||
if (local.IsParameter) |
|
||||||
continue; |
|
||||||
if (string.IsNullOrEmpty(local.Name)) |
|
||||||
continue; |
|
||||||
yield return local.Name; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public object GetLocalVariableIndex(int typeToken, int memberToken, string name) |
|
||||||
{ |
|
||||||
if (DebugInformation == null || !DebugInformation.ContainsKey(typeToken)) |
|
||||||
return null; |
|
||||||
|
|
||||||
var externalData = DebugInformation[typeToken]; |
|
||||||
IEnumerable<ILVariable> list; |
|
||||||
|
|
||||||
if (externalData.LocalVariables.TryGetValue(memberToken, out list)) { |
|
||||||
foreach (var local in list) { |
|
||||||
if (local.IsParameter) |
|
||||||
continue; |
|
||||||
if (local.Name == name) |
|
||||||
return new[] { local.OriginalVariable.Index }; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
return null; |
|
||||||
} |
|
||||||
|
|
||||||
public IAssemblyResolver GetAssemblyResolver(string assemblyFile) |
|
||||||
{ |
|
||||||
if (string.IsNullOrEmpty(assemblyFile)) |
|
||||||
throw new ArgumentException("assemblyFile is null or empty"); |
|
||||||
|
|
||||||
string folderPath = Path.GetDirectoryName(assemblyFile); |
|
||||||
if (resolver == null) |
|
||||||
return (resolver = new ILSpyAssemblyResolver(folderPath)); |
|
||||||
|
|
||||||
if (string.Compare(folderPath, resolver.FolderPath, StringComparison.OrdinalIgnoreCase) != 0) |
|
||||||
return (resolver = new ILSpyAssemblyResolver(folderPath)); |
|
||||||
|
|
||||||
return resolver; |
|
||||||
} |
|
||||||
} |
|
||||||
*/ |
|
||||||
} |
|
||||||
@ -0,0 +1,118 @@ |
|||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
using System.Diagnostics; |
||||||
|
using System.Linq; |
||||||
|
using Debugger; |
||||||
|
using ICSharpCode.Core; |
||||||
|
using ICSharpCode.Decompiler; |
||||||
|
using ICSharpCode.NRefactory; |
||||||
|
using ICSharpCode.NRefactory.Documentation; |
||||||
|
using ICSharpCode.NRefactory.TypeSystem; |
||||||
|
|
||||||
|
namespace ICSharpCode.ILSpyAddIn |
||||||
|
{ |
||||||
|
public class ILSpySymbolSource : ISymbolSource |
||||||
|
{ |
||||||
|
public static MethodDebugSymbols GetSymbols(IMethod method) |
||||||
|
{ |
||||||
|
// Use the non-specialised method definition to look up decompiled symbols
|
||||||
|
var id = IdStringProvider.GetIdString(method.MemberDefinition); |
||||||
|
var content = DecompiledViewContent.Get(method); |
||||||
|
if (content != null && content.DebugSymbols.ContainsKey(id)) { |
||||||
|
return content.DebugSymbols[id]; |
||||||
|
} |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
public Debugger.SequencePoint GetSequencePoint(IMethod method, int iloffset) |
||||||
|
{ |
||||||
|
var symbols = GetSymbols(method); |
||||||
|
if (symbols == null) |
||||||
|
return null; |
||||||
|
|
||||||
|
var content = DecompiledViewContent.Get(method); |
||||||
|
var seqs = symbols.SequencePoints; |
||||||
|
var seq = seqs.FirstOrDefault(p => p.ILRanges.Any(r => r.From <= iloffset && iloffset < r.To)); |
||||||
|
if (seq == null) |
||||||
|
seq = seqs.FirstOrDefault(p => iloffset <= p.ILOffset); |
||||||
|
if (seq != null) { |
||||||
|
// Use the widest sequence point containing the IL offset
|
||||||
|
iloffset = seq.ILOffset; |
||||||
|
seq = seqs.Where(p => p.ILRanges.Any(r => r.From <= iloffset && iloffset < r.To)) |
||||||
|
.OrderByDescending(p => p.ILRanges.Last().To - p.ILRanges.First().From) |
||||||
|
.FirstOrDefault(); |
||||||
|
return seq.ToDebugger(symbols, content.VirtualFileName); |
||||||
|
} |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
public Debugger.SequencePoint GetSequencePoint(Module module, string filename, int line, int column) |
||||||
|
{ |
||||||
|
var content = DecompiledViewContent.Get(new FileName(filename)); |
||||||
|
if (content == null) |
||||||
|
return null; |
||||||
|
if (!FileUtility.IsEqualFileName(module.FullPath, content.AssemblyFile)) |
||||||
|
return null; |
||||||
|
|
||||||
|
TextLocation loc = new TextLocation(line, column); |
||||||
|
foreach(var symbols in content.DebugSymbols.Values.Where(s => s.StartLocation <= loc && loc <= s.EndLocation)) { |
||||||
|
Decompiler.SequencePoint seq = null; |
||||||
|
if (column != 0) |
||||||
|
seq = symbols.SequencePoints.FirstOrDefault(p => p.StartLocation <= loc && loc <= p.EndLocation); |
||||||
|
if (seq == null) |
||||||
|
seq = symbols.SequencePoints.FirstOrDefault(p => line <= p.StartLocation.Line); |
||||||
|
if (seq != null) |
||||||
|
return seq.ToDebugger(symbols, content.VirtualFileName); |
||||||
|
} |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
public bool HasSymbols(IMethod method) |
||||||
|
{ |
||||||
|
var symbols = GetSymbols(method); |
||||||
|
return symbols != null && symbols.SequencePoints.Any(); |
||||||
|
} |
||||||
|
|
||||||
|
public IEnumerable<ILRange> GetIgnoredILRanges(IMethod method) |
||||||
|
{ |
||||||
|
var symbols = GetSymbols(method); |
||||||
|
if (symbols == null) |
||||||
|
return new ILRange[] { }; |
||||||
|
|
||||||
|
int codesize = symbols.CecilMethod.Body.CodeSize; |
||||||
|
var inv = ICSharpCode.Decompiler.ILAst.ILRange.Invert(symbols.SequencePoints.SelectMany(s => s.ILRanges), codesize); |
||||||
|
return inv.Select(r => new ILRange(r.From, r.To)); |
||||||
|
} |
||||||
|
|
||||||
|
public IEnumerable<ILLocalVariable> GetLocalVariables(IMethod method) |
||||||
|
{ |
||||||
|
var symbols = GetSymbols(method); |
||||||
|
if (symbols == null) |
||||||
|
return null; |
||||||
|
|
||||||
|
return symbols.LocalVariables.Select(v => new Debugger.ILLocalVariable() { |
||||||
|
Index = v.OriginalVariable.Index, |
||||||
|
Type = method.Compilation.FindType(KnownTypeCode.Object), // TODO
|
||||||
|
Name = v.Name, |
||||||
|
IsCompilerGenerated = false, |
||||||
|
ILRanges = new [] { new Debugger.ILRange(0, int.MaxValue) } |
||||||
|
}); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
static class ILSpySymbolSourceExtensions |
||||||
|
{ |
||||||
|
public static Debugger.SequencePoint ToDebugger(this ICSharpCode.Decompiler.SequencePoint seq, ICSharpCode.Decompiler.MethodDebugSymbols symbols, string filename) |
||||||
|
{ |
||||||
|
return new Debugger.SequencePoint() { |
||||||
|
MethodDefToken = symbols.CecilMethod.MetadataToken.ToUInt32(), |
||||||
|
ILRanges = seq.ILRanges.Select(r => new ILRange(r.From, r.To)).ToArray(), |
||||||
|
Filename = filename, |
||||||
|
StartLine = seq.StartLocation.Line, |
||||||
|
StartColumn = seq.StartLocation.Column, |
||||||
|
EndLine = seq.EndLocation.Line, |
||||||
|
EndColumn = seq.EndLocation.Column, |
||||||
|
}; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -1,84 +0,0 @@ |
|||||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
|
||||||
// This code is distributed under MIT X11 license (for details please see \doc\license.txt)
|
|
||||||
|
|
||||||
using System; |
|
||||||
using System.ComponentModel.Design; |
|
||||||
using System.Windows.Controls; |
|
||||||
|
|
||||||
using ICSharpCode.AvalonEdit.AddIn; |
|
||||||
using ICSharpCode.AvalonEdit.Document; |
|
||||||
using ICSharpCode.AvalonEdit.Highlighting; |
|
||||||
using ICSharpCode.AvalonEdit.Search; |
|
||||||
using ICSharpCode.SharpDevelop; |
|
||||||
using ICSharpCode.SharpDevelop.Editor; |
|
||||||
using ICSharpCode.SharpDevelop.Editor.Bookmarks; |
|
||||||
using ICSharpCode.SharpDevelop.Gui; |
|
||||||
|
|
||||||
namespace ICSharpCode.ILSpyAddIn.ViewContent |
|
||||||
{ |
|
||||||
/// <summary>
|
|
||||||
/// Equivalent to AE.AddIn CodeEditor, but without editing capabilities.
|
|
||||||
/// </summary>
|
|
||||||
class CodeView : Grid, IDisposable, IPositionable |
|
||||||
{ |
|
||||||
readonly SharpDevelopTextEditor textEditor; |
|
||||||
readonly IconBarManager iconBarManager; |
|
||||||
readonly IconBarMargin iconMargin; |
|
||||||
readonly TextMarkerService textMarkerService; |
|
||||||
readonly AvalonEditTextEditorAdapter adapter; |
|
||||||
|
|
||||||
public CodeView() |
|
||||||
{ |
|
||||||
textEditor = new SharpDevelopTextEditor(); |
|
||||||
textEditor.IsReadOnly = true; |
|
||||||
this.Children.Add(textEditor); |
|
||||||
adapter = new AvalonEditTextEditorAdapter(textEditor); |
|
||||||
|
|
||||||
textEditor.SyntaxHighlighting = HighlightingManager.Instance.GetDefinition("C#"); |
|
||||||
|
|
||||||
// add margin
|
|
||||||
this.iconMargin = new IconBarMargin(iconBarManager = new IconBarManager()); |
|
||||||
textEditor.TextArea.LeftMargins.Insert(0, iconMargin); |
|
||||||
textEditor.TextArea.TextView.VisualLinesChanged += delegate { iconMargin.InvalidateVisual(); }; |
|
||||||
|
|
||||||
// add marker service
|
|
||||||
this.textMarkerService = new TextMarkerService(textEditor.Document); |
|
||||||
textEditor.TextArea.TextView.BackgroundRenderers.Add(textMarkerService); |
|
||||||
textEditor.TextArea.TextView.LineTransformers.Add(textMarkerService); |
|
||||||
var documentServiceContainer = textEditor.Document.GetRequiredService<ServiceContainer>(); |
|
||||||
documentServiceContainer.AddService(typeof(ITextMarkerService), textMarkerService); |
|
||||||
documentServiceContainer.AddService(typeof(IBookmarkMargin), iconBarManager); |
|
||||||
|
|
||||||
textEditor.TextArea.DefaultInputHandler.NestedInputHandlers.Add(new SearchInputHandler(textEditor.TextArea)); |
|
||||||
} |
|
||||||
|
|
||||||
public TextDocument Document { |
|
||||||
get { return textEditor.Document; } |
|
||||||
} |
|
||||||
|
|
||||||
public IconBarManager IconBarManager { |
|
||||||
get { return iconBarManager; } |
|
||||||
} |
|
||||||
|
|
||||||
public void Dispose() |
|
||||||
{ |
|
||||||
} |
|
||||||
|
|
||||||
public int Line { |
|
||||||
get { |
|
||||||
return textEditor.TextArea.Caret.Line; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public int Column { |
|
||||||
get { |
|
||||||
return textEditor.TextArea.Caret.Column; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public void JumpTo(int line, int column) |
|
||||||
{ |
|
||||||
adapter.JumpTo(line, column); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,121 +0,0 @@ |
|||||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
|
||||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
|
||||||
|
|
||||||
namespace ICSharpCode.SettingsEditor |
|
||||||
{ |
|
||||||
partial class SettingsView |
|
||||||
{ |
|
||||||
/// <summary>
|
|
||||||
/// Designer variable used to keep track of non-visual components.
|
|
||||||
/// </summary>
|
|
||||||
private System.ComponentModel.IContainer components = null; |
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Disposes resources used by the control.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
|
||||||
protected override void Dispose(bool disposing) |
|
||||||
{ |
|
||||||
if (disposing) { |
|
||||||
if (components != null) { |
|
||||||
components.Dispose(); |
|
||||||
} |
|
||||||
} |
|
||||||
base.Dispose(disposing); |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// This method is required for Windows Forms designer support.
|
|
||||||
/// Do not change the method contents inside the source code editor. The Forms designer might
|
|
||||||
/// not be able to load this method if it was changed manually.
|
|
||||||
/// </summary>
|
|
||||||
private void InitializeComponent() |
|
||||||
{ |
|
||||||
this.components = new System.ComponentModel.Container(); |
|
||||||
this.grid = new System.Windows.Forms.DataGridView(); |
|
||||||
this.NameColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); |
|
||||||
this.TypeColumn = new System.Windows.Forms.DataGridViewComboBoxColumn(); |
|
||||||
this.ScopeColumn = new System.Windows.Forms.DataGridViewComboBoxColumn(); |
|
||||||
this.ValueColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); |
|
||||||
this.bindingSource = new System.Windows.Forms.BindingSource(this.components); |
|
||||||
((System.ComponentModel.ISupportInitialize)(this.grid)).BeginInit(); |
|
||||||
((System.ComponentModel.ISupportInitialize)(this.bindingSource)).BeginInit(); |
|
||||||
this.SuspendLayout(); |
|
||||||
//
|
|
||||||
// grid
|
|
||||||
//
|
|
||||||
this.grid.AutoGenerateColumns = false; |
|
||||||
this.grid.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; |
|
||||||
this.grid.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { |
|
||||||
this.NameColumn, |
|
||||||
this.TypeColumn, |
|
||||||
this.ScopeColumn, |
|
||||||
this.ValueColumn}); |
|
||||||
this.grid.DataSource = this.bindingSource; |
|
||||||
this.grid.Dock = System.Windows.Forms.DockStyle.Fill; |
|
||||||
this.grid.EditMode = System.Windows.Forms.DataGridViewEditMode.EditOnKeystroke; |
|
||||||
this.grid.Location = new System.Drawing.Point(0, 0); |
|
||||||
this.grid.Name = "grid"; |
|
||||||
this.grid.Size = new System.Drawing.Size(486, 362); |
|
||||||
this.grid.TabIndex = 0; |
|
||||||
this.grid.DataError += new System.Windows.Forms.DataGridViewDataErrorEventHandler(this.GridDataError); |
|
||||||
this.grid.SelectionChanged += new System.EventHandler(this.GridSelectionChanged); |
|
||||||
this.grid.UserDeletingRow += new System.Windows.Forms.DataGridViewRowCancelEventHandler(this.GridUserDeletingRow); |
|
||||||
//
|
|
||||||
// NameColumn
|
|
||||||
//
|
|
||||||
this.NameColumn.DataPropertyName = "Name"; |
|
||||||
this.NameColumn.HeaderText = "Name"; |
|
||||||
this.NameColumn.MinimumWidth = 50; |
|
||||||
this.NameColumn.Name = "NameColumn"; |
|
||||||
//
|
|
||||||
// TypeColumn
|
|
||||||
//
|
|
||||||
this.TypeColumn.DataPropertyName = "WrappedSettingType"; |
|
||||||
this.TypeColumn.DropDownWidth = 255; |
|
||||||
this.TypeColumn.HeaderText = "Type"; |
|
||||||
this.TypeColumn.MinimumWidth = 50; |
|
||||||
this.TypeColumn.Name = "TypeColumn"; |
|
||||||
this.TypeColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic; |
|
||||||
//
|
|
||||||
// ScopeColumn
|
|
||||||
//
|
|
||||||
this.ScopeColumn.DataPropertyName = "Scope"; |
|
||||||
this.ScopeColumn.DropDownWidth = 80; |
|
||||||
this.ScopeColumn.HeaderText = "Scope"; |
|
||||||
this.ScopeColumn.MinimumWidth = 30; |
|
||||||
this.ScopeColumn.Name = "ScopeColumn"; |
|
||||||
this.ScopeColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic; |
|
||||||
//
|
|
||||||
// ValueColumn
|
|
||||||
//
|
|
||||||
this.ValueColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; |
|
||||||
this.ValueColumn.DataPropertyName = "SerializedValue"; |
|
||||||
this.ValueColumn.HeaderText = "Value"; |
|
||||||
this.ValueColumn.MinimumWidth = 50; |
|
||||||
this.ValueColumn.Name = "ValueColumn"; |
|
||||||
//
|
|
||||||
// bindingSource
|
|
||||||
//
|
|
||||||
this.bindingSource.DataSource = typeof(ICSharpCode.SettingsEditor.SettingsEntry); |
|
||||||
this.bindingSource.AddingNew += new System.ComponentModel.AddingNewEventHandler(this.BindingSourceAddingNew); |
|
||||||
//
|
|
||||||
// SettingsView
|
|
||||||
//
|
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); |
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; |
|
||||||
this.Controls.Add(this.grid); |
|
||||||
this.Name = "SettingsView"; |
|
||||||
this.Size = new System.Drawing.Size(486, 362); |
|
||||||
((System.ComponentModel.ISupportInitialize)(this.grid)).EndInit(); |
|
||||||
((System.ComponentModel.ISupportInitialize)(this.bindingSource)).EndInit(); |
|
||||||
this.ResumeLayout(false); |
|
||||||
} |
|
||||||
private System.Windows.Forms.DataGridViewComboBoxColumn TypeColumn; |
|
||||||
private System.Windows.Forms.DataGridViewComboBoxColumn ScopeColumn; |
|
||||||
private System.Windows.Forms.DataGridViewTextBoxColumn ValueColumn; |
|
||||||
private System.Windows.Forms.DataGridViewTextBoxColumn NameColumn; |
|
||||||
private System.Windows.Forms.BindingSource bindingSource; |
|
||||||
private System.Windows.Forms.DataGridView grid; |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,181 +0,0 @@ |
|||||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
|
||||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
|
||||||
|
|
||||||
using System; |
|
||||||
using System.ComponentModel; |
|
||||||
using System.Drawing; |
|
||||||
using System.Windows.Forms; |
|
||||||
using System.Collections.Generic; |
|
||||||
using ICSharpCode.NRefactory.TypeSystem; |
|
||||||
using ICSharpCode.NRefactory.TypeSystem.Implementation; |
|
||||||
using ICSharpCode.SharpDevelop.Gui; |
|
||||||
using ICSharpCode.Core; |
|
||||||
using ICSharpCode.SharpDevelop.Dom; |
|
||||||
using ICSharpCode.SharpDevelop; |
|
||||||
|
|
||||||
namespace ICSharpCode.SettingsEditor |
|
||||||
{ |
|
||||||
public partial class SettingsView : UserControl, ISettingsEntryHost |
|
||||||
{ |
|
||||||
public event EventHandler SelectionChanged; |
|
||||||
public event EventHandler SettingsChanged; |
|
||||||
|
|
||||||
static readonly Type[] defaultAvailableTypes = new Type[] { |
|
||||||
typeof(bool), |
|
||||||
typeof(byte), |
|
||||||
typeof(char), |
|
||||||
typeof(decimal), |
|
||||||
typeof(double), |
|
||||||
typeof(float), |
|
||||||
typeof(int), |
|
||||||
typeof(long), |
|
||||||
typeof(sbyte), |
|
||||||
typeof(short), |
|
||||||
typeof(string), |
|
||||||
typeof(System.Collections.Specialized.StringCollection), |
|
||||||
typeof(System.DateTime), |
|
||||||
typeof(System.Drawing.Color), |
|
||||||
typeof(System.Drawing.Font), |
|
||||||
typeof(System.Drawing.Point), |
|
||||||
typeof(System.Drawing.Size), |
|
||||||
typeof(System.Guid), |
|
||||||
typeof(System.TimeSpan), |
|
||||||
typeof(uint), |
|
||||||
typeof(ulong), |
|
||||||
typeof(ushort) |
|
||||||
}; |
|
||||||
|
|
||||||
List<string> typeNames = new List<string>(); |
|
||||||
List<Type> types = new List<Type>(); |
|
||||||
IAmbience ambience; |
|
||||||
ICompilation compilation; |
|
||||||
|
|
||||||
public SettingsView() |
|
||||||
{ |
|
||||||
InitializeComponent(); |
|
||||||
|
|
||||||
ambience = AmbienceService.GetCurrentAmbience(); |
|
||||||
compilation = MinimalCorlib.Instance.CreateCompilation(); |
|
||||||
|
|
||||||
foreach (Type type in defaultAvailableTypes) { |
|
||||||
types.Add(type); |
|
||||||
typeNames.Add(ambience.ConvertType(type.ToTypeReference().Resolve(compilation))); |
|
||||||
} |
|
||||||
foreach (SpecialTypeDescriptor d in SpecialTypeDescriptor.Descriptors) { |
|
||||||
types.Add(d.type); |
|
||||||
typeNames.Add(d.name); |
|
||||||
} |
|
||||||
|
|
||||||
ScopeColumn.DataSource = Enum.GetValues(typeof(SettingScope)); |
|
||||||
TypeColumn.DataSource = typeNames; |
|
||||||
} |
|
||||||
|
|
||||||
public void ShowEntries(IList<SettingsEntry> list) |
|
||||||
{ |
|
||||||
bindingSource.Clear(); |
|
||||||
foreach (SettingsEntry entry in list) { |
|
||||||
bindingSource.Add(entry); |
|
||||||
} |
|
||||||
bindingSource.ListChanged += delegate(object sender, ListChangedEventArgs e) { |
|
||||||
if (e.NewIndex >= 0 && e.NewIndex < bindingSource.Count) { |
|
||||||
if (((SettingsEntry)bindingSource[e.NewIndex]).Name != null) { |
|
||||||
OnSettingsChanged(e); |
|
||||||
} |
|
||||||
} |
|
||||||
}; |
|
||||||
} |
|
||||||
|
|
||||||
void GridSelectionChanged(object sender, EventArgs e) |
|
||||||
{ |
|
||||||
if (SelectionChanged != null) |
|
||||||
SelectionChanged(this, e); |
|
||||||
} |
|
||||||
|
|
||||||
public IEnumerable<SettingsEntry> GetAllEntries() |
|
||||||
{ |
|
||||||
List<SettingsEntry> l = new List<SettingsEntry>(); |
|
||||||
foreach (SettingsEntry entry in bindingSource) { |
|
||||||
if (!string.IsNullOrEmpty(entry.Name)) { |
|
||||||
l.Add(entry); |
|
||||||
} |
|
||||||
} |
|
||||||
l.Sort(delegate(SettingsEntry a, SettingsEntry b) { |
|
||||||
return a.Name.CompareTo(b.Name); |
|
||||||
}); |
|
||||||
return l; |
|
||||||
} |
|
||||||
|
|
||||||
public List<SettingsEntryPropertyGridWrapper> GetSelectedEntriesForPropertyGrid() |
|
||||||
{ |
|
||||||
List<SettingsEntryPropertyGridWrapper> l |
|
||||||
= new List<SettingsEntryPropertyGridWrapper>(); |
|
||||||
if (grid.SelectedRows.Count > 0) { |
|
||||||
foreach (DataGridViewRow row in grid.SelectedRows) { |
|
||||||
if (row.DataBoundItem != null) { |
|
||||||
l.Add(new SettingsEntryPropertyGridWrapper((SettingsEntry)row.DataBoundItem)); |
|
||||||
} |
|
||||||
} |
|
||||||
} else { |
|
||||||
bool[] rowAdded = new bool[grid.Rows.Count]; |
|
||||||
foreach (DataGridViewCell cell in grid.SelectedCells) { |
|
||||||
if (rowAdded[cell.RowIndex] == false) { |
|
||||||
rowAdded[cell.RowIndex] = true; |
|
||||||
if (cell.OwningRow.DataBoundItem != null) { |
|
||||||
l.Add(new SettingsEntryPropertyGridWrapper((SettingsEntry)cell.OwningRow.DataBoundItem)); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
return l; |
|
||||||
} |
|
||||||
|
|
||||||
void BindingSourceAddingNew(object sender, AddingNewEventArgs e) |
|
||||||
{ |
|
||||||
SettingsEntry entry = new SettingsEntry(this); |
|
||||||
entry.Type = typeof(string); |
|
||||||
e.NewObject = entry; |
|
||||||
} |
|
||||||
|
|
||||||
void GridDataError(object sender, DataGridViewDataErrorEventArgs e) |
|
||||||
{ |
|
||||||
LoggingService.Debug("Row " + e.RowIndex + ", column " + e.ColumnIndex + ", error " + e.Exception.ToString()); |
|
||||||
if (e.Exception != null) { |
|
||||||
MessageBox.Show("Error in data entry: " + e.Exception.Message); |
|
||||||
} else { |
|
||||||
MessageBox.Show("Error in data entry"); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
string ISettingsEntryHost.GetDisplayNameForType(Type type) |
|
||||||
{ |
|
||||||
foreach (SpecialTypeDescriptor d in SpecialTypeDescriptor.Descriptors) { |
|
||||||
if (type == d.type) |
|
||||||
return d.name; |
|
||||||
} |
|
||||||
return ambience.ConvertType(type.ToTypeReference().Resolve(compilation)); |
|
||||||
} |
|
||||||
|
|
||||||
Type ISettingsEntryHost.GetTypeByDisplayName(string displayName) |
|
||||||
{ |
|
||||||
for (int i = 0; i < typeNames.Count; i++) { |
|
||||||
if (typeNames[i] == displayName) |
|
||||||
return types[i]; |
|
||||||
} |
|
||||||
return null; |
|
||||||
} |
|
||||||
|
|
||||||
void GridUserDeletingRow(object sender, DataGridViewRowCancelEventArgs e) |
|
||||||
{ |
|
||||||
if (e.Row != null && !e.Cancel) { |
|
||||||
OnSettingsChanged(EventArgs.Empty); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
protected virtual void OnSettingsChanged(EventArgs e) |
|
||||||
{ |
|
||||||
if (SettingsChanged != null) { |
|
||||||
SettingsChanged(this, e); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,128 +0,0 @@ |
|||||||
<?xml version="1.0" encoding="utf-8"?> |
|
||||||
<root> |
|
||||||
<!-- |
|
||||||
Microsoft ResX Schema |
|
||||||
|
|
||||||
Version 2.0 |
|
||||||
|
|
||||||
The primary goals of this format is to allow a simple XML format |
|
||||||
that is mostly human readable. The generation and parsing of the |
|
||||||
various data types are done through the TypeConverter classes |
|
||||||
associated with the data types. |
|
||||||
|
|
||||||
Example: |
|
||||||
|
|
||||||
... ado.net/XML headers & schema ... |
|
||||||
<resheader name="resmimetype">text/microsoft-resx</resheader> |
|
||||||
<resheader name="version">2.0</resheader> |
|
||||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> |
|
||||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> |
|
||||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> |
|
||||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> |
|
||||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> |
|
||||||
<value>[base64 mime encoded serialized .NET Framework object]</value> |
|
||||||
</data> |
|
||||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> |
|
||||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> |
|
||||||
<comment>This is a comment</comment> |
|
||||||
</data> |
|
||||||
|
|
||||||
There are any number of "resheader" rows that contain simple |
|
||||||
name/value pairs. |
|
||||||
|
|
||||||
Each data row contains a name, and value. The row also contains a |
|
||||||
type or mimetype. Type corresponds to a .NET class that support |
|
||||||
text/value conversion through the TypeConverter architecture. |
|
||||||
Classes that don't support this are serialized and stored with the |
|
||||||
mimetype set. |
|
||||||
|
|
||||||
The mimetype is used for serialized objects, and tells the |
|
||||||
ResXResourceReader how to depersist the object. This is currently not |
|
||||||
extensible. For a given mimetype the value must be set accordingly: |
|
||||||
|
|
||||||
Note - application/x-microsoft.net.object.binary.base64 is the format |
|
||||||
that the ResXResourceWriter will generate, however the reader can |
|
||||||
read any of the formats listed below. |
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.binary.base64 |
|
||||||
value : The object must be serialized with |
|
||||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter |
|
||||||
: and then encoded with base64 encoding. |
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.soap.base64 |
|
||||||
value : The object must be serialized with |
|
||||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter |
|
||||||
: and then encoded with base64 encoding. |
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.bytearray.base64 |
|
||||||
value : The object must be serialized into a byte array |
|
||||||
: using a System.ComponentModel.TypeConverter |
|
||||||
: and then encoded with base64 encoding. |
|
||||||
--> |
|
||||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> |
|
||||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> |
|
||||||
<xsd:element name="root" msdata:IsDataSet="true"> |
|
||||||
<xsd:complexType> |
|
||||||
<xsd:choice maxOccurs="unbounded"> |
|
||||||
<xsd:element name="metadata"> |
|
||||||
<xsd:complexType> |
|
||||||
<xsd:sequence> |
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" /> |
|
||||||
</xsd:sequence> |
|
||||||
<xsd:attribute name="name" use="required" type="xsd:string" /> |
|
||||||
<xsd:attribute name="type" type="xsd:string" /> |
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" /> |
|
||||||
<xsd:attribute ref="xml:space" /> |
|
||||||
</xsd:complexType> |
|
||||||
</xsd:element> |
|
||||||
<xsd:element name="assembly"> |
|
||||||
<xsd:complexType> |
|
||||||
<xsd:attribute name="alias" type="xsd:string" /> |
|
||||||
<xsd:attribute name="name" type="xsd:string" /> |
|
||||||
</xsd:complexType> |
|
||||||
</xsd:element> |
|
||||||
<xsd:element name="data"> |
|
||||||
<xsd:complexType> |
|
||||||
<xsd:sequence> |
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> |
|
||||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> |
|
||||||
</xsd:sequence> |
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" /> |
|
||||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> |
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> |
|
||||||
<xsd:attribute ref="xml:space" /> |
|
||||||
</xsd:complexType> |
|
||||||
</xsd:element> |
|
||||||
<xsd:element name="resheader"> |
|
||||||
<xsd:complexType> |
|
||||||
<xsd:sequence> |
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> |
|
||||||
</xsd:sequence> |
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" /> |
|
||||||
</xsd:complexType> |
|
||||||
</xsd:element> |
|
||||||
</xsd:choice> |
|
||||||
</xsd:complexType> |
|
||||||
</xsd:element> |
|
||||||
</xsd:schema> |
|
||||||
<resheader name="resmimetype"> |
|
||||||
<value>text/microsoft-resx</value> |
|
||||||
</resheader> |
|
||||||
<resheader name="version"> |
|
||||||
<value>2.0</value> |
|
||||||
</resheader> |
|
||||||
<resheader name="reader"> |
|
||||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> |
|
||||||
</resheader> |
|
||||||
<resheader name="writer"> |
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> |
|
||||||
</resheader> |
|
||||||
<assembly alias="mscorlib" name="mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> |
|
||||||
<data name="TypeColumn.UserAddedColumn" type="System.Boolean, mscorlib"> |
|
||||||
<value>True</value> |
|
||||||
</data> |
|
||||||
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> |
|
||||||
<data name="bindingSource.TrayLocation" type="System.Drawing.Point, System.Drawing"> |
|
||||||
<value>28, 18</value> |
|
||||||
</data> |
|
||||||
</root> |
|
||||||
@ -1,6 +1,6 @@ |
|||||||
<?xml version="1.0" encoding="utf-8"?> |
<?xml version="1.0" encoding="utf-8"?> |
||||||
<UserControl |
<UserControl |
||||||
x:Class="ICSharpCode.SettingsEditor.SettingsViewXaml" |
x:Class="ICSharpCode.SettingsEditor.SettingsView" |
||||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
||||||
xmlns:sd="clr-namespace:ICSharpCode.SharpDevelop;assembly=ICSharpCode.SharpDevelop" |
xmlns:sd="clr-namespace:ICSharpCode.SharpDevelop;assembly=ICSharpCode.SharpDevelop" |
||||||
@ -1,73 +0,0 @@ |
|||||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
|
||||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
|
||||||
using System; |
|
||||||
using ICSharpCode.Core; |
|
||||||
using ICSharpCode.NRefactory; |
|
||||||
using ICSharpCode.SharpDevelop.Debugging; |
|
||||||
|
|
||||||
namespace ICSharpCode.SharpDevelop.Editor.Bookmarks |
|
||||||
{ |
|
||||||
/* |
|
||||||
public class DecompiledBreakpointBookmark : BreakpointBookmark |
|
||||||
{ |
|
||||||
public const string SEPARATOR = ","; // don't use '.'
|
|
||||||
|
|
||||||
MemberReference memberReference; |
|
||||||
string assemblyFile; |
|
||||||
|
|
||||||
public DecompiledBreakpointBookmark(FileName fileName, TextLocation location) |
|
||||||
: base(fileName, location) |
|
||||||
{ |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
public MemberReference MemberReference { |
|
||||||
get { return memberReference; } |
|
||||||
} |
|
||||||
|
|
||||||
public MemberReference GetMemberReference(IAssemblyResolver resolver) |
|
||||||
{ |
|
||||||
if (resolver == null) |
|
||||||
throw new ArgumentNullException("resolver"); |
|
||||||
|
|
||||||
if (memberReference != null) |
|
||||||
return memberReference; |
|
||||||
|
|
||||||
// reload from filename
|
|
||||||
ReaderParameters readerParameters = new ReaderParameters(); |
|
||||||
// Use new assembly resolver instance so that the AssemblyDefinitions can be garbage-collected
|
|
||||||
// once the code is decompiled.
|
|
||||||
readerParameters.AssemblyResolver = resolver; |
|
||||||
|
|
||||||
string typeName; |
|
||||||
if (GetAssemblyAndType(FileName.ToString(), out assemblyFile, out typeName)) { |
|
||||||
ModuleDefinition module = ModuleDefinition.ReadModule(assemblyFile, readerParameters); |
|
||||||
TypeDefinition typeDefinition = module.GetType(typeName); |
|
||||||
if (typeDefinition == null) |
|
||||||
throw new InvalidOperationException("Could not find type"); |
|
||||||
memberReference = typeDefinition; |
|
||||||
} |
|
||||||
|
|
||||||
return memberReference; |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the assembly file and the type from the file name.
|
|
||||||
/// </summary>
|
|
||||||
/// <returns><c>true</c>, if the operation succeded; <c>false</c>, otherwise.</returns>
|
|
||||||
public static bool GetAssemblyAndType(string fileName, out string assemblyFile, out string typeName) |
|
||||||
{ |
|
||||||
if (string.IsNullOrEmpty(fileName) || !fileName.Contains(",")) { |
|
||||||
assemblyFile = null; |
|
||||||
typeName = null; |
|
||||||
return false; |
|
||||||
} |
|
||||||
|
|
||||||
int index = fileName.IndexOf(SEPARATOR); |
|
||||||
assemblyFile = fileName.Substring(0, index); |
|
||||||
typeName = fileName.Substring(index + 1, fileName.Length - index - 4); |
|
||||||
return true; |
|
||||||
} |
|
||||||
} |
|
||||||
*/ |
|
||||||
} |
|
||||||
Loading…
Reference in new issue