|
|
|
@ -16,11 +16,10 @@
@@ -16,11 +16,10 @@
|
|
|
|
|
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
|
|
|
// DEALINGS IN THE SOFTWARE.
|
|
|
|
|
|
|
|
|
|
using System.Windows; |
|
|
|
|
using System.ComponentModel; |
|
|
|
|
using System.Runtime.CompilerServices; |
|
|
|
|
using System.Windows.Controls; |
|
|
|
|
using System.Xml.Linq; |
|
|
|
|
using ICSharpCode.Decompiler; |
|
|
|
|
using WinForms = System.Windows.Forms; |
|
|
|
|
|
|
|
|
|
namespace ICSharpCode.ILSpy.Options |
|
|
|
|
{ |
|
|
|
@ -30,12 +29,6 @@ namespace ICSharpCode.ILSpy.Options
@@ -30,12 +29,6 @@ namespace ICSharpCode.ILSpy.Options
|
|
|
|
|
[ExportOptionPage(Title = "Decompiler", Order = 0)] |
|
|
|
|
partial class DecompilerSettingsPanel : UserControl, IOptionPage |
|
|
|
|
{ |
|
|
|
|
#if DEBUG
|
|
|
|
|
public const bool IsDebug = true; |
|
|
|
|
#else
|
|
|
|
|
public const bool IsDebug = false; |
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
public DecompilerSettingsPanel() |
|
|
|
|
{ |
|
|
|
|
InitializeComponent(); |
|
|
|
@ -58,14 +51,6 @@ namespace ICSharpCode.ILSpy.Options
@@ -58,14 +51,6 @@ namespace ICSharpCode.ILSpy.Options
|
|
|
|
|
{ |
|
|
|
|
XElement e = settings["DecompilerSettings"]; |
|
|
|
|
DecompilerSettings s = new DecompilerSettings(); |
|
|
|
|
s.AnonymousMethods = (bool?)e.Attribute("anonymousMethods") ?? s.AnonymousMethods; |
|
|
|
|
s.AnonymousTypes = (bool?)e.Attribute("anonymousTypes") ?? s.AnonymousTypes; |
|
|
|
|
s.YieldReturn = (bool?)e.Attribute("yieldReturn") ?? s.YieldReturn; |
|
|
|
|
s.AsyncAwait = (bool?)e.Attribute("asyncAwait") ?? s.AsyncAwait; |
|
|
|
|
s.AutomaticProperties = (bool?) e.Attribute("automaticProperties") ?? s.AutomaticProperties; |
|
|
|
|
s.QueryExpressions = (bool?)e.Attribute("queryExpressions") ?? s.QueryExpressions; |
|
|
|
|
s.ExpressionTrees = (bool?)e.Attribute("expressionTrees") ?? s.ExpressionTrees; |
|
|
|
|
s.UseDebugSymbols = (bool?)e.Attribute("useDebugSymbols") ?? s.UseDebugSymbols; |
|
|
|
|
s.ShowDebugInfo = (bool?)e.Attribute("showDebugInfo") ?? s.ShowDebugInfo; |
|
|
|
|
s.ShowXmlDocumentation = (bool?)e.Attribute("xmlDoc") ?? s.ShowXmlDocumentation; |
|
|
|
|
s.FoldBraces = (bool?)e.Attribute("foldBraces") ?? s.FoldBraces; |
|
|
|
@ -81,13 +66,6 @@ namespace ICSharpCode.ILSpy.Options
@@ -81,13 +66,6 @@ namespace ICSharpCode.ILSpy.Options
|
|
|
|
|
{ |
|
|
|
|
DecompilerSettings s = (DecompilerSettings)this.DataContext; |
|
|
|
|
XElement section = new XElement("DecompilerSettings"); |
|
|
|
|
section.SetAttributeValue("anonymousMethods", s.AnonymousMethods); |
|
|
|
|
section.SetAttributeValue("anonymousTypes", s.AnonymousTypes); |
|
|
|
|
section.SetAttributeValue("yieldReturn", s.YieldReturn); |
|
|
|
|
section.SetAttributeValue("asyncAwait", s.AsyncAwait); |
|
|
|
|
section.SetAttributeValue("automaticProperties", s.AutomaticProperties); |
|
|
|
|
section.SetAttributeValue("queryExpressions", s.QueryExpressions); |
|
|
|
|
section.SetAttributeValue("expressionTrees", s.ExpressionTrees); |
|
|
|
|
section.SetAttributeValue("useDebugSymbols", s.UseDebugSymbols); |
|
|
|
|
section.SetAttributeValue("showDebugInfo", s.ShowDebugInfo); |
|
|
|
|
section.SetAttributeValue("xmlDoc", s.ShowXmlDocumentation); |
|
|
|
@ -106,105 +84,149 @@ namespace ICSharpCode.ILSpy.Options
@@ -106,105 +84,149 @@ namespace ICSharpCode.ILSpy.Options
|
|
|
|
|
|
|
|
|
|
currentDecompilerSettings = s; // update cached settings
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void AdvancedOptions_Click(object sender, RoutedEventArgs e) |
|
|
|
|
{ |
|
|
|
|
#if DEBUG
|
|
|
|
|
// I know this is crazy, but WindowsFormsHost is too buggy in this scenario...
|
|
|
|
|
using (var wnd = new PropertyGridHost(((DecompilerSettings)DataContext).Clone())) { |
|
|
|
|
if (wnd.ShowDialog() == WinForms.DialogResult.OK) { |
|
|
|
|
this.DataContext = wnd.Settings; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public class DecompilerSettings : INotifyPropertyChanged |
|
|
|
|
{ |
|
|
|
|
bool showXmlDocumentation = true; |
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets/Sets whether to include XML documentation comments in the decompiled code.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public bool ShowXmlDocumentation { |
|
|
|
|
get { return showXmlDocumentation; } |
|
|
|
|
set { |
|
|
|
|
if (showXmlDocumentation != value) { |
|
|
|
|
showXmlDocumentation = value; |
|
|
|
|
OnPropertyChanged(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
#endif
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#if DEBUG
|
|
|
|
|
class PropertyGridHost : WinForms.Form |
|
|
|
|
{ |
|
|
|
|
private WinForms.PropertyGrid propertyGrid; |
|
|
|
|
private WinForms.Button cancelButton; |
|
|
|
|
private WinForms.Button okButton; |
|
|
|
|
bool foldBraces = false; |
|
|
|
|
|
|
|
|
|
public bool FoldBraces { |
|
|
|
|
get { return foldBraces; } |
|
|
|
|
set { |
|
|
|
|
if (foldBraces != value) { |
|
|
|
|
foldBraces = value; |
|
|
|
|
OnPropertyChanged(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool expandMemberDefinitions = false; |
|
|
|
|
|
|
|
|
|
public bool ExpandMemberDefinitions { |
|
|
|
|
get { return expandMemberDefinitions; } |
|
|
|
|
set { |
|
|
|
|
if (expandMemberDefinitions != value) { |
|
|
|
|
expandMemberDefinitions = value; |
|
|
|
|
OnPropertyChanged(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool decompileMemberBodies = true; |
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets/Sets whether member bodies should be decompiled.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public bool DecompileMemberBodies { |
|
|
|
|
get { return decompileMemberBodies; } |
|
|
|
|
set { |
|
|
|
|
if (decompileMemberBodies != value) { |
|
|
|
|
decompileMemberBodies = value; |
|
|
|
|
OnPropertyChanged(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public DecompilerSettings Settings { get; } |
|
|
|
|
bool fullyQualifyAmbiguousTypeNames = true; |
|
|
|
|
|
|
|
|
|
public PropertyGridHost(DecompilerSettings settings) |
|
|
|
|
{ |
|
|
|
|
InitializeComponent(); |
|
|
|
|
this.propertyGrid.SelectedObject = Settings = settings; |
|
|
|
|
public bool FullyQualifyAmbiguousTypeNames { |
|
|
|
|
get { return fullyQualifyAmbiguousTypeNames; } |
|
|
|
|
set { |
|
|
|
|
if (fullyQualifyAmbiguousTypeNames != value) { |
|
|
|
|
fullyQualifyAmbiguousTypeNames = value; |
|
|
|
|
OnPropertyChanged(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool useDebugSymbols = true; |
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets/Sets whether to use variable names from debug symbols, if available.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public bool UseDebugSymbols { |
|
|
|
|
get { return useDebugSymbols; } |
|
|
|
|
set { |
|
|
|
|
if (useDebugSymbols != value) { |
|
|
|
|
useDebugSymbols = value; |
|
|
|
|
OnPropertyChanged(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool usingDeclarations = true; |
|
|
|
|
|
|
|
|
|
public bool UsingDeclarations { |
|
|
|
|
get { return usingDeclarations; } |
|
|
|
|
set { |
|
|
|
|
if (usingDeclarations != value) { |
|
|
|
|
usingDeclarations = value; |
|
|
|
|
OnPropertyChanged(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void InitializeComponent() |
|
|
|
|
{ |
|
|
|
|
this.propertyGrid = new System.Windows.Forms.PropertyGrid(); |
|
|
|
|
this.cancelButton = new System.Windows.Forms.Button(); |
|
|
|
|
this.okButton = new System.Windows.Forms.Button(); |
|
|
|
|
this.SuspendLayout(); |
|
|
|
|
//
|
|
|
|
|
// propertyGrid
|
|
|
|
|
//
|
|
|
|
|
this.propertyGrid.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom |
|
|
|
|
| System.Windows.Forms.AnchorStyles.Left |
|
|
|
|
| System.Windows.Forms.AnchorStyles.Right; |
|
|
|
|
this.propertyGrid.Location = new System.Drawing.Point(0, 0); |
|
|
|
|
this.propertyGrid.Name = "propertyGrid"; |
|
|
|
|
this.propertyGrid.Size = new System.Drawing.Size(468, 369); |
|
|
|
|
this.propertyGrid.TabIndex = 0; |
|
|
|
|
//
|
|
|
|
|
// cancelButton
|
|
|
|
|
//
|
|
|
|
|
this.cancelButton.Anchor = System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right; |
|
|
|
|
this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel; |
|
|
|
|
this.cancelButton.Location = new System.Drawing.Point(365, 375); |
|
|
|
|
this.cancelButton.Name = "cancelButton"; |
|
|
|
|
this.cancelButton.Size = new System.Drawing.Size(91, 23); |
|
|
|
|
this.cancelButton.TabIndex = 1; |
|
|
|
|
this.cancelButton.Text = "Cancel"; |
|
|
|
|
this.cancelButton.UseVisualStyleBackColor = true; |
|
|
|
|
this.cancelButton.Click += CancelButton_Click; |
|
|
|
|
//
|
|
|
|
|
// okButton
|
|
|
|
|
//
|
|
|
|
|
this.okButton.Anchor = System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right; |
|
|
|
|
this.okButton.DialogResult = System.Windows.Forms.DialogResult.OK; |
|
|
|
|
this.okButton.Location = new System.Drawing.Point(267, 375); |
|
|
|
|
this.okButton.Name = "okButton"; |
|
|
|
|
this.okButton.Size = new System.Drawing.Size(92, 23); |
|
|
|
|
this.okButton.TabIndex = 2; |
|
|
|
|
this.okButton.Text = "OK"; |
|
|
|
|
this.okButton.UseVisualStyleBackColor = true; |
|
|
|
|
this.okButton.Click += OkButton_Click; |
|
|
|
|
//
|
|
|
|
|
// Form1
|
|
|
|
|
//
|
|
|
|
|
this.AcceptButton = this.okButton; |
|
|
|
|
this.CancelButton = this.cancelButton; |
|
|
|
|
this.ClientSize = new System.Drawing.Size(468, 410); |
|
|
|
|
this.Controls.Add(this.okButton); |
|
|
|
|
this.Controls.Add(this.cancelButton); |
|
|
|
|
this.Controls.Add(this.propertyGrid); |
|
|
|
|
this.MaximizeBox = false; |
|
|
|
|
this.MinimizeBox = false; |
|
|
|
|
this.Name = "Form1"; |
|
|
|
|
this.Text = "Advanced Decompiler Options"; |
|
|
|
|
this.ShowIcon = false; |
|
|
|
|
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; |
|
|
|
|
this.ResumeLayout(false); |
|
|
|
|
bool showDebugInfo; |
|
|
|
|
|
|
|
|
|
public bool ShowDebugInfo { |
|
|
|
|
get { return showDebugInfo; } |
|
|
|
|
set { |
|
|
|
|
if (showDebugInfo != value) { |
|
|
|
|
showDebugInfo = value; |
|
|
|
|
OnPropertyChanged(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool removeDeadCode = false; |
|
|
|
|
|
|
|
|
|
private void OkButton_Click(object sender, System.EventArgs e) |
|
|
|
|
{ |
|
|
|
|
DialogResult = WinForms.DialogResult.OK; |
|
|
|
|
Close(); |
|
|
|
|
public bool RemoveDeadCode { |
|
|
|
|
get { return removeDeadCode; } |
|
|
|
|
set { |
|
|
|
|
if (removeDeadCode != value) { |
|
|
|
|
removeDeadCode = value; |
|
|
|
|
OnPropertyChanged(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void CancelButton_Click(object sender, System.EventArgs e) |
|
|
|
|
{ |
|
|
|
|
DialogResult = WinForms.DialogResult.Cancel; |
|
|
|
|
Close(); |
|
|
|
|
bool alwaysUseBraces = true; |
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets/Sets whether to use braces for single-statement-blocks.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public bool AlwaysUseBraces { |
|
|
|
|
get { return alwaysUseBraces; } |
|
|
|
|
set { |
|
|
|
|
if (alwaysUseBraces != value) { |
|
|
|
|
alwaysUseBraces = value; |
|
|
|
|
OnPropertyChanged(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public event PropertyChangedEventHandler PropertyChanged; |
|
|
|
|
|
|
|
|
|
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null) |
|
|
|
|
{ |
|
|
|
|
if (PropertyChanged != null) { |
|
|
|
|
PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
#endif
|
|
|
|
|
} |
|
|
|
|
} |