diff --git a/ICSharpCode.Decompiler/DecompilerSettings.cs b/ICSharpCode.Decompiler/DecompilerSettings.cs
index a8d30e0e8..6e3f0da9b 100644
--- a/ICSharpCode.Decompiler/DecompilerSettings.cs
+++ b/ICSharpCode.Decompiler/DecompilerSettings.cs
@@ -40,9 +40,18 @@ namespace ICSharpCode.Decompiler
/// appropriate for the specified language version.
///
///
- /// This does not imply that the resulting
+ /// This does not imply that the resulting code strictly uses only language features from that version.
+ /// Language constructs like generics or ref locals cannot be removed from the compiled code.
///
public DecompilerSettings(CSharp.LanguageVersion languageVersion)
+ {
+ SetLanguageVersion(languageVersion);
+ }
+
+ ///
+ /// Deactivates all language features from versions newer than .
+ ///
+ public void SetLanguageVersion(CSharp.LanguageVersion languageVersion)
{
// By default, all decompiler features are enabled.
// Disable some of them based on language version:
@@ -198,7 +207,7 @@ namespace ICSharpCode.Decompiler
/// Decompile enumerators.
///
[Category("C# 2.0 / VS 2005")]
- [Description("Decompile enumerators")]
+ [Description("Decompile enumerators (yield return)")]
public bool YieldReturn {
get { return yieldReturn; }
set {
@@ -266,6 +275,7 @@ namespace ICSharpCode.Decompiler
///
/// Decompile [DecimalConstant(...)] as simple literal values.
///
+ [Category("C# 1.0 / VS .NET")]
[Description("Decompile [DecimalConstant(...)] as simple literal values")]
public bool DecimalConstants {
get { return decimalConstants; }
@@ -384,9 +394,8 @@ namespace ICSharpCode.Decompiler
///
/// Gets/Sets whether to use braces for single-statement-blocks.
///
- [Category("Formatting")]
+ [Category("Other")]
[Description("Always use braces")]
- [Browsable(false)]
public bool AlwaysUseBraces {
get { return alwaysUseBraces; }
set {
@@ -448,7 +457,7 @@ namespace ICSharpCode.Decompiler
bool usingDeclarations = true;
[Category("C# 1.0 / VS .NET")]
- [Browsable(false)]
+ [Description("Insert using declarations")]
public bool UsingDeclarations {
get { return usingDeclarations; }
set {
@@ -533,7 +542,6 @@ namespace ICSharpCode.Decompiler
///
[Category("Other")]
[Description("Use variable names from debug symbols, if available")]
- [Browsable(false)]
public bool UseDebugSymbols {
get { return useDebugSymbols; }
set {
@@ -640,7 +648,8 @@ namespace ICSharpCode.Decompiler
///
/// Gets/Sets whether to include XML documentation comments in the decompiled code.
///
- [Browsable(false)]
+ [Category("Other")]
+ [Description("Include XML documentation comments in the decompiled code")]
public bool ShowXmlDocumentation {
get { return showXmlDocumentation; }
set {
@@ -1030,7 +1039,7 @@ namespace ICSharpCode.Decompiler
bool removeDeadCode = false;
[Category("F#-specific options")]
- [Browsable(false)]
+ [Description("Remove dead and side effect free code (use with caution!)")]
public bool RemoveDeadCode {
get { return removeDeadCode; }
set {
@@ -1074,7 +1083,6 @@ namespace ICSharpCode.Decompiler
[Category("Other")]
[Description("Apply Windows Runtime projections on loaded assemblies")]
- [Browsable(false)]
public bool ApplyWindowsRuntimeProjections {
get { return applyWindowsRuntimeProjections; }
set {
diff --git a/ILSpy/DecompilationOptions.cs b/ILSpy/DecompilationOptions.cs
index efb268c97..ebb97187a 100644
--- a/ILSpy/DecompilationOptions.cs
+++ b/ILSpy/DecompilationOptions.cs
@@ -18,7 +18,6 @@
using System;
using System.Threading;
-using ICSharpCode.Decompiler;
using ICSharpCode.ILSpy.Options;
namespace ICSharpCode.ILSpy
@@ -68,43 +67,24 @@ namespace ICSharpCode.ILSpy
internal bool IsDebug = false;
public DecompilationOptions()
- : this(MainWindow.Instance.CurrentLanguageVersion, DecompilerSettingsPanel.CurrentDecompilerSettings, DisplaySettingsPanel.CurrentDisplaySettings, CSharpDecompilerSettingsPanel.CurrentCSharpSettings)
+ : this(MainWindow.Instance.CurrentLanguageVersion, DecompilerSettingsPanel.CurrentDecompilerSettings, DisplaySettingsPanel.CurrentDisplaySettings)
{
}
public DecompilationOptions(LanguageVersion version)
- : this(version, DecompilerSettingsPanel.CurrentDecompilerSettings, DisplaySettingsPanel.CurrentDisplaySettings, CSharpDecompilerSettingsPanel.CurrentCSharpSettings)
+ : this(version, DecompilerSettingsPanel.CurrentDecompilerSettings, DisplaySettingsPanel.CurrentDisplaySettings)
{
}
- public DecompilationOptions(LanguageVersion version, Options.DecompilerSettings settings, Options.DisplaySettings displaySettings, Decompiler.DecompilerSettings csharpSettings)
+ public DecompilationOptions(LanguageVersion version, Decompiler.DecompilerSettings settings, Options.DisplaySettings displaySettings)
{
- if (version.Version == "Custom") {
- var newSettings = this.DecompilerSettings = csharpSettings.Clone();
- newSettings.AlwaysUseBraces = settings.AlwaysUseBraces;
- newSettings.ExpandMemberDefinitions = displaySettings.ExpandMemberDefinitions;
- newSettings.FoldBraces = displaySettings.FoldBraces;
- newSettings.RemoveDeadCode = settings.RemoveDeadCode;
- newSettings.ShowDebugInfo = settings.ShowDebugInfo;
- newSettings.ShowXmlDocumentation = settings.ShowXmlDocumentation;
- newSettings.UseDebugSymbols = settings.UseDebugSymbols;
- newSettings.UsingDeclarations = settings.UsingDeclarations;
- newSettings.ApplyWindowsRuntimeProjections = settings.ApplyWindowsRuntimeProjections;
- } else {
- if (!Enum.TryParse(version.Version, out Decompiler.CSharp.LanguageVersion languageVersion))
- languageVersion = Decompiler.CSharp.LanguageVersion.Latest;
- this.DecompilerSettings = new Decompiler.DecompilerSettings(languageVersion) {
- AlwaysUseBraces = settings.AlwaysUseBraces,
- ExpandMemberDefinitions = displaySettings.ExpandMemberDefinitions,
- FoldBraces = displaySettings.FoldBraces,
- RemoveDeadCode = settings.RemoveDeadCode,
- ShowDebugInfo = settings.ShowDebugInfo,
- ShowXmlDocumentation = settings.ShowXmlDocumentation,
- UseDebugSymbols = settings.UseDebugSymbols,
- UsingDeclarations = settings.UsingDeclarations,
- ApplyWindowsRuntimeProjections = settings.ApplyWindowsRuntimeProjections,
- };
- }
+ if (!Enum.TryParse(version.Version, out Decompiler.CSharp.LanguageVersion languageVersion))
+ languageVersion = Decompiler.CSharp.LanguageVersion.Latest;
+ var newSettings = this.DecompilerSettings = settings.Clone();
+ newSettings.SetLanguageVersion(languageVersion);
+ newSettings.ExpandMemberDefinitions = displaySettings.ExpandMemberDefinitions;
+ newSettings.FoldBraces = displaySettings.FoldBraces;
+ newSettings.ShowDebugInfo = displaySettings.ShowDebugInfo;
}
}
}
diff --git a/ILSpy/ILSpy.csproj b/ILSpy/ILSpy.csproj
index 6ee5b6bf7..6b0df4c8a 100644
--- a/ILSpy/ILSpy.csproj
+++ b/ILSpy/ILSpy.csproj
@@ -158,7 +158,7 @@
-
+
@@ -185,10 +185,6 @@
OpenListDialog.xaml
-
- DecompilerSettingsPanel.xaml
- Code
-
DisplaySettingsPanel.xaml
@@ -317,7 +313,6 @@
-
@@ -391,7 +386,7 @@
-
+
MSBuild:Compile
diff --git a/ILSpy/Languages/CSharpLanguage.cs b/ILSpy/Languages/CSharpLanguage.cs
index ae402a718..88239f9d1 100644
--- a/ILSpy/Languages/CSharpLanguage.cs
+++ b/ILSpy/Languages/CSharpLanguage.cs
@@ -102,7 +102,6 @@ namespace ICSharpCode.ILSpy
new LanguageVersion(Decompiler.CSharp.LanguageVersion.CSharp7_2.ToString(), "C# 7.2 / VS 2017.4"),
new LanguageVersion(Decompiler.CSharp.LanguageVersion.CSharp7_3.ToString(), "C# 7.3 / VS 2017.7"),
new LanguageVersion(Decompiler.CSharp.LanguageVersion.CSharp8_0.ToString(), "C# 8.0 / VS 2019"),
- new LanguageVersion("Custom", "Custom"),
};
}
return versions;
diff --git a/ILSpy/Options/CSharpDecompilerSettingsPanel.xaml b/ILSpy/Options/CSharpDecompilerSettingsPanel.xaml
deleted file mode 100644
index 083800360..000000000
--- a/ILSpy/Options/CSharpDecompilerSettingsPanel.xaml
+++ /dev/null
@@ -1,58 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/ILSpy/Options/CSharpDecompilerSettingsPanel.xaml.cs b/ILSpy/Options/CSharpDecompilerSettingsPanel.xaml.cs
deleted file mode 100644
index 8a7974ca2..000000000
--- a/ILSpy/Options/CSharpDecompilerSettingsPanel.xaml.cs
+++ /dev/null
@@ -1,195 +0,0 @@
-// Copyright (c) 2011 AlphaSierraPapa for the SharpDevelop Team
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy of this
-// software and associated documentation files (the "Software"), to deal in the Software
-// without restriction, including without limitation the rights to use, copy, modify, merge,
-// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
-// to whom the Software is furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in all copies or
-// substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
-// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
-// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
-// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
-// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-// DEALINGS IN THE SOFTWARE.
-
-using System.ComponentModel;
-using System.Linq;
-using System.Reflection;
-using System.Runtime.CompilerServices;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Data;
-using System.Xml.Linq;
-
-namespace ICSharpCode.ILSpy.Options
-{
- ///
- /// Interaction logic for CSharpDecompilerSettingsPanel.xaml
- ///
- [ExportOptionPage(Title = "C# Decompiler", Order = 10)]
- internal partial class CSharpDecompilerSettingsPanel : UserControl, IOptionPage
- {
- public CSharpDecompilerSettingsPanel()
- {
- InitializeComponent();
- }
-
- static Decompiler.DecompilerSettings currentCSharpSettings;
-
- public static Decompiler.DecompilerSettings CurrentCSharpSettings {
- get {
- return currentCSharpSettings ?? (currentCSharpSettings = LoadDecompilerSettings(ILSpySettings.Load()));
- }
- }
-
- public static Decompiler.DecompilerSettings LoadDecompilerSettings(ILSpySettings settings)
- {
- XElement e = settings["CustomCSharpDecompilerSettings"];
- var newSettings = new Decompiler.DecompilerSettings();
- var properties = typeof(Decompiler.DecompilerSettings).GetProperties()
- .Where(p => p.GetCustomAttribute()?.Browsable != false);
- foreach (var p in properties) {
- p.SetValue(newSettings, (bool?)e.Attribute(p.Name) ?? true);
- }
- return newSettings;
- }
-
- public void Load(ILSpySettings settings)
- {
- this.DataContext = new CSharpDecompilerSettings(LoadDecompilerSettings(settings));
- }
-
- public void Save(XElement root)
- {
- XElement section = new XElement("CustomCSharpDecompilerSettings");
- var newSettings = ((CSharpDecompilerSettings)this.DataContext).ToDecompilerSettings();
- var properties = typeof(Decompiler.DecompilerSettings).GetProperties()
- .Where(p => p.GetCustomAttribute()?.Browsable != false);
- foreach (var p in properties) {
- section.SetAttributeValue(p.Name, p.GetValue(newSettings));
- }
- XElement existingElement = root.Element("CustomCSharpDecompilerSettings");
- if (existingElement != null)
- existingElement.ReplaceWith(section);
- else
- root.Add(section);
-
- currentCSharpSettings = newSettings;
- }
-
- private void OnGroupChecked(object sender, RoutedEventArgs e)
- {
- CheckGroup((CollectionViewGroup)((CheckBox)sender).DataContext, true);
- }
- private void OnGroupUnchecked(object sender, RoutedEventArgs e)
- {
- CheckGroup((CollectionViewGroup)((CheckBox)sender).DataContext, false);
- }
-
- void CheckGroup(CollectionViewGroup group, bool value)
- {
- foreach (var item in group.Items) {
- switch (item) {
- case CollectionViewGroup subGroup:
- CheckGroup(subGroup, value);
- break;
- case CSharpDecompilerSetting setting:
- setting.IsEnabled = value;
- break;
- }
- }
- }
-
- bool IsGroupChecked(CollectionViewGroup group)
- {
- bool value = true;
- foreach (var item in group.Items) {
- switch (item) {
- case CollectionViewGroup subGroup:
- value = value && IsGroupChecked(subGroup);
- break;
- case CSharpDecompilerSetting setting:
- value = value && setting.IsEnabled;
- break;
- }
- }
- return value;
- }
-
- private void OnGroupLoaded(object sender, RoutedEventArgs e)
- {
- CheckBox checkBox = (CheckBox)sender;
- checkBox.IsChecked = IsGroupChecked((CollectionViewGroup)checkBox.DataContext);
- }
- }
-
- public class CSharpDecompilerSettings : INotifyPropertyChanged
- {
- public CSharpDecompilerSetting[] Settings { get; set; }
-
- public CSharpDecompilerSettings(Decompiler.DecompilerSettings settings)
- {
- Settings = typeof(Decompiler.DecompilerSettings).GetProperties()
- .Where(p => p.GetCustomAttribute()?.Browsable != false)
- .Select(p => new CSharpDecompilerSetting(p) { IsEnabled = (bool)p.GetValue(settings) })
- .OrderBy(item => item.Category)
- .ThenBy(item => item.Description)
- .ToArray();
- }
-
- public event PropertyChangedEventHandler PropertyChanged;
-
- protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
- {
- PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
- }
-
- public Decompiler.DecompilerSettings ToDecompilerSettings()
- {
- var settings = new Decompiler.DecompilerSettings();
- foreach (var item in Settings) {
- item.Property.SetValue(settings, item.IsEnabled);
- }
- return settings;
- }
- }
-
- public class CSharpDecompilerSetting : INotifyPropertyChanged
- {
- bool isEnabled;
-
- public CSharpDecompilerSetting(PropertyInfo p)
- {
- this.Property = p;
- this.Category = p.GetCustomAttribute()?.Category ?? "Other";
- this.Description = p.GetCustomAttribute()?.Description ?? p.Name;
- }
-
- public PropertyInfo Property { get; }
-
- public bool IsEnabled {
- get => isEnabled;
- set {
- if (value != isEnabled) {
- isEnabled = value;
- OnPropertyChanged();
- }
- }
- }
-
- public string Description { get; set; }
-
- public string Category { get; set; }
-
- public event PropertyChangedEventHandler PropertyChanged;
-
- protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
- {
- PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
- }
- }
-}
diff --git a/ILSpy/Options/DecompilerSettingsPanel.xaml b/ILSpy/Options/DecompilerSettingsPanel.xaml
index c4f599dbb..5be544466 100644
--- a/ILSpy/Options/DecompilerSettingsPanel.xaml
+++ b/ILSpy/Options/DecompilerSettingsPanel.xaml
@@ -2,18 +2,61 @@
x:ClassModifier="internal"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- xmlns:options="clr-namespace:ICSharpCode.ILSpy.Options"
- xmlns:controls="clr-namespace:ICSharpCode.ILSpy.Controls">
+ xmlns:options="clr-namespace:ICSharpCode.ILSpy.Options">
-
+
+
+
+
+
-
- Use variable names from debug symbols, if available
- Show info from debug symbols, if available
- Show XML documentation in decompiled code
- Remove dead and side effect free code (use with caution!)
- Insert using declarations
- Always use braces
- Apply Windows Runtime projections on loaded assemblies
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/ILSpy/Options/DecompilerSettingsPanel.xaml.cs b/ILSpy/Options/DecompilerSettingsPanel.xaml.cs
index c3c613ffd..36ed83784 100644
--- a/ILSpy/Options/DecompilerSettingsPanel.xaml.cs
+++ b/ILSpy/Options/DecompilerSettingsPanel.xaml.cs
@@ -17,8 +17,12 @@
// DEALINGS IN THE SOFTWARE.
using System.ComponentModel;
+using System.Linq;
+using System.Reflection;
using System.Runtime.CompilerServices;
+using System.Windows;
using System.Windows.Controls;
+using System.Windows.Data;
using System.Xml.Linq;
namespace ICSharpCode.ILSpy.Options
@@ -26,182 +30,166 @@ namespace ICSharpCode.ILSpy.Options
///
/// Interaction logic for DecompilerSettingsPanel.xaml
///
- [ExportOptionPage(Title = "Decompiler", Order = 0)]
- partial class DecompilerSettingsPanel : UserControl, IOptionPage
+ [ExportOptionPage(Title = "Decompiler", Order = 10)]
+ internal partial class DecompilerSettingsPanel : UserControl, IOptionPage
{
public DecompilerSettingsPanel()
{
InitializeComponent();
}
-
- public void Load(ILSpySettings settings)
- {
- this.DataContext = currentDecompilerSettings ?? LoadDecompilerSettings(settings);
- }
-
- static DecompilerSettings currentDecompilerSettings;
-
- public static DecompilerSettings CurrentDecompilerSettings {
+
+ static Decompiler.DecompilerSettings currentDecompilerSettings;
+
+ public static Decompiler.DecompilerSettings CurrentDecompilerSettings {
get {
return currentDecompilerSettings ?? (currentDecompilerSettings = LoadDecompilerSettings(ILSpySettings.Load()));
}
}
-
- public static DecompilerSettings LoadDecompilerSettings(ILSpySettings settings)
+
+ public static Decompiler.DecompilerSettings LoadDecompilerSettings(ILSpySettings settings)
{
XElement e = settings["DecompilerSettings"];
- DecompilerSettings s = new DecompilerSettings();
- s.ShowDebugInfo = (bool?)e.Attribute("showDebugInfo") ?? s.ShowDebugInfo;
- s.ShowXmlDocumentation = (bool?)e.Attribute("xmlDoc") ?? s.ShowXmlDocumentation;
- s.RemoveDeadCode = (bool?)e.Attribute("removeDeadCode") ?? s.RemoveDeadCode;
- s.UsingDeclarations = (bool?)e.Attribute("usingDeclarations") ?? s.UsingDeclarations;
- s.AlwaysUseBraces = (bool?)e.Attribute("alwaysUseBraces") ?? s.AlwaysUseBraces;
- s.ApplyWindowsRuntimeProjections = (bool?)e.Attribute("applyWindowsRuntimeProjections") ?? s.ApplyWindowsRuntimeProjections;
- return s;
- }
-
+ var newSettings = new Decompiler.DecompilerSettings();
+ var properties = typeof(Decompiler.DecompilerSettings).GetProperties()
+ .Where(p => p.GetCustomAttribute()?.Browsable != false);
+ foreach (var p in properties) {
+ p.SetValue(newSettings, (bool?)e.Attribute(p.Name) ?? true);
+ }
+ return newSettings;
+ }
+
+ public void Load(ILSpySettings settings)
+ {
+ this.DataContext = new DecompilerSettings(LoadDecompilerSettings(settings));
+ }
+
public void Save(XElement root)
{
- DecompilerSettings s = (DecompilerSettings)this.DataContext;
XElement section = new XElement("DecompilerSettings");
- section.SetAttributeValue("useDebugSymbols", s.UseDebugSymbols);
- section.SetAttributeValue("showDebugInfo", s.ShowDebugInfo);
- section.SetAttributeValue("xmlDoc", s.ShowXmlDocumentation);
- section.SetAttributeValue("removeDeadCode", s.RemoveDeadCode);
- section.SetAttributeValue("usingDeclarations", s.UsingDeclarations);
- section.SetAttributeValue("alwaysUseBraces", s.AlwaysUseBraces);
- section.SetAttributeValue("applyWindowsRuntimeProjections", s.ApplyWindowsRuntimeProjections);
-
+ var newSettings = ((DecompilerSettings)this.DataContext).ToDecompilerSettings();
+ var properties = typeof(Decompiler.DecompilerSettings).GetProperties()
+ .Where(p => p.GetCustomAttribute()?.Browsable != false);
+ foreach (var p in properties) {
+ section.SetAttributeValue(p.Name, p.GetValue(newSettings));
+ }
XElement existingElement = root.Element("DecompilerSettings");
if (existingElement != null)
existingElement.ReplaceWith(section);
else
root.Add(section);
-
- currentDecompilerSettings = s; // update cached settings
+
+ currentDecompilerSettings = newSettings;
}
- }
- public class DecompilerSettings : INotifyPropertyChanged
- {
- bool showXmlDocumentation = true;
+ private void OnGroupChecked(object sender, RoutedEventArgs e)
+ {
+ CheckGroup((CollectionViewGroup)((CheckBox)sender).DataContext, true);
+ }
+ private void OnGroupUnchecked(object sender, RoutedEventArgs e)
+ {
+ CheckGroup((CollectionViewGroup)((CheckBox)sender).DataContext, false);
+ }
- ///
- /// Gets/Sets whether to include XML documentation comments in the decompiled code.
- ///
- public bool ShowXmlDocumentation {
- get { return showXmlDocumentation; }
- set {
- if (showXmlDocumentation != value) {
- showXmlDocumentation = value;
- OnPropertyChanged();
+ void CheckGroup(CollectionViewGroup group, bool value)
+ {
+ foreach (var item in group.Items) {
+ switch (item) {
+ case CollectionViewGroup subGroup:
+ CheckGroup(subGroup, value);
+ break;
+ case CSharpDecompilerSetting setting:
+ setting.IsEnabled = value;
+ break;
}
}
}
- bool decompileMemberBodies = true;
-
- ///
- /// Gets/Sets whether member bodies should be decompiled.
- ///
- public bool DecompileMemberBodies {
- get { return decompileMemberBodies; }
- set {
- if (decompileMemberBodies != value) {
- decompileMemberBodies = value;
- OnPropertyChanged();
+ bool IsGroupChecked(CollectionViewGroup group)
+ {
+ bool value = true;
+ foreach (var item in group.Items) {
+ switch (item) {
+ case CollectionViewGroup subGroup:
+ value = value && IsGroupChecked(subGroup);
+ break;
+ case CSharpDecompilerSetting setting:
+ value = value && setting.IsEnabled;
+ break;
}
}
+ return value;
}
- bool useDebugSymbols = true;
-
- ///
- /// Gets/Sets whether to use variable names from debug symbols, if available.
- ///
- public bool UseDebugSymbols {
- get { return useDebugSymbols; }
- set {
- if (useDebugSymbols != value) {
- useDebugSymbols = value;
- OnPropertyChanged();
- }
- }
+ private void OnGroupLoaded(object sender, RoutedEventArgs e)
+ {
+ CheckBox checkBox = (CheckBox)sender;
+ checkBox.IsChecked = IsGroupChecked((CollectionViewGroup)checkBox.DataContext);
}
+ }
- bool usingDeclarations = true;
+ public class DecompilerSettings : INotifyPropertyChanged
+ {
+ public CSharpDecompilerSetting[] Settings { get; set; }
- public bool UsingDeclarations {
- get { return usingDeclarations; }
- set {
- if (usingDeclarations != value) {
- usingDeclarations = value;
- OnPropertyChanged();
- }
- }
+ public DecompilerSettings(Decompiler.DecompilerSettings settings)
+ {
+ Settings = typeof(Decompiler.DecompilerSettings).GetProperties()
+ .Where(p => p.GetCustomAttribute()?.Browsable != false)
+ .Select(p => new CSharpDecompilerSetting(p) { IsEnabled = (bool)p.GetValue(settings) })
+ .OrderBy(item => item.Category)
+ .ThenBy(item => item.Description)
+ .ToArray();
}
- bool showDebugInfo;
+ public event PropertyChangedEventHandler PropertyChanged;
- public bool ShowDebugInfo {
- get { return showDebugInfo; }
- set {
- if (showDebugInfo != value) {
- showDebugInfo = value;
- OnPropertyChanged();
- }
- }
+ protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
+ {
+ PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
- bool removeDeadCode = false;
-
- public bool RemoveDeadCode {
- get { return removeDeadCode; }
- set {
- if (removeDeadCode != value) {
- removeDeadCode = value;
- OnPropertyChanged();
- }
+ public Decompiler.DecompilerSettings ToDecompilerSettings()
+ {
+ var settings = new Decompiler.DecompilerSettings();
+ foreach (var item in Settings) {
+ item.Property.SetValue(settings, item.IsEnabled);
}
+ return settings;
}
+ }
- bool alwaysUseBraces = true;
+ public class CSharpDecompilerSetting : INotifyPropertyChanged
+ {
+ bool isEnabled;
- ///
- /// Gets/Sets whether to use braces for single-statement-blocks.
- ///
- public bool AlwaysUseBraces {
- get { return alwaysUseBraces; }
- set {
- if (alwaysUseBraces != value) {
- alwaysUseBraces = value;
- OnPropertyChanged();
- }
- }
+ public CSharpDecompilerSetting(PropertyInfo p)
+ {
+ this.Property = p;
+ this.Category = p.GetCustomAttribute()?.Category ?? "Other";
+ this.Description = p.GetCustomAttribute()?.Description ?? p.Name;
}
- bool applyWindowsRuntimeProjections = true;
+ public PropertyInfo Property { get; }
- ///
- /// Gets/Sets whether to Windows Runtime projections to all loaded assemblies.
- ///
- public bool ApplyWindowsRuntimeProjections {
- get { return applyWindowsRuntimeProjections; }
+ public bool IsEnabled {
+ get => isEnabled;
set {
- if (applyWindowsRuntimeProjections != value) {
- applyWindowsRuntimeProjections = value;
+ if (value != isEnabled) {
+ isEnabled = value;
OnPropertyChanged();
}
}
}
+ public string Description { get; set; }
+
+ public string Category { get; set; }
+
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
- if (PropertyChanged != null) {
- PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
- }
+ PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
-}
\ No newline at end of file
+}
diff --git a/ILSpy/Options/DisplaySettings.cs b/ILSpy/Options/DisplaySettings.cs
index 31f378457..caa02d470 100644
--- a/ILSpy/Options/DisplaySettings.cs
+++ b/ILSpy/Options/DisplaySettings.cs
@@ -155,6 +155,18 @@ namespace ICSharpCode.ILSpy.Options
}
}
+ bool showDebugInfo;
+
+ public bool ShowDebugInfo {
+ get { return showDebugInfo; }
+ set {
+ if (showDebugInfo != value) {
+ showDebugInfo = value;
+ OnPropertyChanged();
+ }
+ }
+ }
+
public void CopyValues(DisplaySettings s)
{
this.SelectedFont = s.selectedFont;
@@ -162,6 +174,7 @@ namespace ICSharpCode.ILSpy.Options
this.ShowLineNumbers = s.showLineNumbers;
this.ShowMetadataTokens = s.showMetadataTokens;
this.ShowMetadataTokensInBase10 = s.showMetadataTokensInBase10;
+ this.ShowDebugInfo = s.showDebugInfo;
this.EnableWordWrap = s.enableWordWrap;
this.SortResults = s.sortResults;
this.FoldBraces = s.foldBraces;
diff --git a/ILSpy/Options/DisplaySettingsPanel.xaml b/ILSpy/Options/DisplaySettingsPanel.xaml
index ec6fb197d..334d17aaf 100644
--- a/ILSpy/Options/DisplaySettingsPanel.xaml
+++ b/ILSpy/Options/DisplaySettingsPanel.xaml
@@ -62,6 +62,7 @@
Show line numbers
Show metadata tokens
Show metadata tokens in base 10
+ Show info from debug symbols, if available
Enable word wrap
Enable folding on all blocks in braces
Sort results by fitness
diff --git a/ILSpy/Options/DisplaySettingsPanel.xaml.cs b/ILSpy/Options/DisplaySettingsPanel.xaml.cs
index ab46d4b2c..4435287f6 100644
--- a/ILSpy/Options/DisplaySettingsPanel.xaml.cs
+++ b/ILSpy/Options/DisplaySettingsPanel.xaml.cs
@@ -102,6 +102,7 @@ namespace ICSharpCode.ILSpy.Options
s.ShowLineNumbers = (bool?)e.Attribute("ShowLineNumbers") ?? false;
s.ShowMetadataTokens = (bool?)e.Attribute("ShowMetadataTokens") ?? false;
s.ShowMetadataTokensInBase10 = (bool?)e.Attribute("ShowMetadataTokensInBase10") ?? false;
+ s.ShowDebugInfo = (bool?)e.Attribute("ShowDebugInfo") ?? false;
s.EnableWordWrap = (bool?)e.Attribute("EnableWordWrap") ?? false;
s.SortResults = (bool?)e.Attribute("SortResults") ?? true;
s.FoldBraces = (bool?)e.Attribute("FoldBraces") ?? false;
@@ -120,6 +121,7 @@ namespace ICSharpCode.ILSpy.Options
section.SetAttributeValue("ShowLineNumbers", s.ShowLineNumbers);
section.SetAttributeValue("ShowMetadataTokens", s.ShowMetadataTokens);
section.SetAttributeValue("ShowMetadataTokensInBase10", s.ShowMetadataTokensInBase10);
+ section.SetAttributeValue("ShowDebugInfo", s.ShowDebugInfo);
section.SetAttributeValue("EnableWordWrap", s.EnableWordWrap);
section.SetAttributeValue("SortResults", s.SortResults);
section.SetAttributeValue("FoldBraces", s.FoldBraces);