Browse Source

Fix #1130: Some options on the Decompiler page seem to be more related to Display

pull/1360/head
Siegfried Pammer 6 years ago
parent
commit
4353a3a545
  1. 10
      ILSpy/DecompilationOptions.cs
  2. 2
      ILSpy/Options/DecompilerSettingsPanel.xaml
  3. 28
      ILSpy/Options/DecompilerSettingsPanel.xaml.cs
  4. 26
      ILSpy/Options/DisplaySettings.cs
  5. 2
      ILSpy/Options/DisplaySettingsPanel.xaml
  6. 15
      ILSpy/Options/DisplaySettingsPanel.xaml.cs

10
ILSpy/DecompilationOptions.cs

@ -68,23 +68,23 @@ namespace ICSharpCode.ILSpy @@ -68,23 +68,23 @@ namespace ICSharpCode.ILSpy
internal bool IsDebug = false;
public DecompilationOptions()
: this(MainWindow.Instance.CurrentLanguageVersion, DecompilerSettingsPanel.CurrentDecompilerSettings)
: this(MainWindow.Instance.CurrentLanguageVersion, DecompilerSettingsPanel.CurrentDecompilerSettings, DisplaySettingsPanel.CurrentDisplaySettings)
{
}
public DecompilationOptions(LanguageVersion version)
: this(version, DecompilerSettingsPanel.CurrentDecompilerSettings)
: this(version, DecompilerSettingsPanel.CurrentDecompilerSettings, DisplaySettingsPanel.CurrentDisplaySettings)
{
}
public DecompilationOptions(LanguageVersion version, Options.DecompilerSettings settings)
public DecompilationOptions(LanguageVersion version, Options.DecompilerSettings settings, Options.DisplaySettings displaySettings)
{
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 = settings.ExpandMemberDefinitions,
FoldBraces = settings.FoldBraces,
ExpandMemberDefinitions = displaySettings.ExpandMemberDefinitions,
FoldBraces = displaySettings.FoldBraces,
RemoveDeadCode = settings.RemoveDeadCode,
ShowDebugInfo = settings.ShowDebugInfo,
ShowXmlDocumentation = settings.ShowXmlDocumentation,

2
ILSpy/Options/DecompilerSettingsPanel.xaml

@ -11,11 +11,9 @@ @@ -11,11 +11,9 @@
<CheckBox IsChecked="{Binding UseDebugSymbols}">Use variable names from debug symbols, if available</CheckBox>
<CheckBox IsChecked="{Binding ShowDebugInfo}">Show info from debug symbols, if available</CheckBox>
<CheckBox IsChecked="{Binding ShowXmlDocumentation}">Show XML documentation in decompiled code</CheckBox>
<CheckBox IsChecked="{Binding FoldBraces}">Enable folding on all blocks in braces</CheckBox>
<CheckBox IsChecked="{Binding RemoveDeadCode}">Remove dead and side effect free code</CheckBox>
<CheckBox IsChecked="{Binding UsingDeclarations}">Insert using declarations</CheckBox>
<CheckBox IsChecked="{Binding AlwaysUseBraces}">Always use braces</CheckBox>
<CheckBox IsChecked="{Binding ExpandMemberDefinitions}">Expand member definitions after decompilation</CheckBox>
<CheckBox IsChecked="{Binding ApplyWindowsRuntimeProjections}">Apply Windows Runtime projections on loaded assemblies</CheckBox>
</StackPanel>
</UserControl>

28
ILSpy/Options/DecompilerSettingsPanel.xaml.cs

@ -53,8 +53,6 @@ namespace ICSharpCode.ILSpy.Options @@ -53,8 +53,6 @@ namespace ICSharpCode.ILSpy.Options
DecompilerSettings s = new DecompilerSettings();
s.ShowDebugInfo = (bool?)e.Attribute("showDebugInfo") ?? s.ShowDebugInfo;
s.ShowXmlDocumentation = (bool?)e.Attribute("xmlDoc") ?? s.ShowXmlDocumentation;
s.FoldBraces = (bool?)e.Attribute("foldBraces") ?? s.FoldBraces;
s.ExpandMemberDefinitions = (bool?)e.Attribute("expandMemberDefinitions") ?? s.ExpandMemberDefinitions;
s.RemoveDeadCode = (bool?)e.Attribute("removeDeadCode") ?? s.RemoveDeadCode;
s.UsingDeclarations = (bool?)e.Attribute("usingDeclarations") ?? s.UsingDeclarations;
s.AlwaysUseBraces = (bool?)e.Attribute("alwaysUseBraces") ?? s.AlwaysUseBraces;
@ -69,8 +67,6 @@ namespace ICSharpCode.ILSpy.Options @@ -69,8 +67,6 @@ namespace ICSharpCode.ILSpy.Options
section.SetAttributeValue("useDebugSymbols", s.UseDebugSymbols);
section.SetAttributeValue("showDebugInfo", s.ShowDebugInfo);
section.SetAttributeValue("xmlDoc", s.ShowXmlDocumentation);
section.SetAttributeValue("foldBraces", s.FoldBraces);
section.SetAttributeValue("expandMemberDefinitions", s.ExpandMemberDefinitions);
section.SetAttributeValue("removeDeadCode", s.RemoveDeadCode);
section.SetAttributeValue("usingDeclarations", s.UsingDeclarations);
section.SetAttributeValue("alwaysUseBraces", s.AlwaysUseBraces);
@ -103,30 +99,6 @@ namespace ICSharpCode.ILSpy.Options @@ -103,30 +99,6 @@ namespace ICSharpCode.ILSpy.Options
}
}
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>

26
ILSpy/Options/DisplaySettings.cs

@ -131,6 +131,30 @@ namespace ICSharpCode.ILSpy.Options @@ -131,6 +131,30 @@ namespace ICSharpCode.ILSpy.Options
}
}
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();
}
}
}
public void CopyValues(DisplaySettings s)
{
this.SelectedFont = s.selectedFont;
@ -140,6 +164,8 @@ namespace ICSharpCode.ILSpy.Options @@ -140,6 +164,8 @@ namespace ICSharpCode.ILSpy.Options
this.ShowMetadataTokensInBase10 = s.showMetadataTokensInBase10;
this.EnableWordWrap = s.enableWordWrap;
this.SortResults = s.sortResults;
this.FoldBraces = s.foldBraces;
this.ExpandMemberDefinitions = s.expandMemberDefinitions;
}
}
}

2
ILSpy/Options/DisplaySettingsPanel.xaml

@ -63,7 +63,9 @@ @@ -63,7 +63,9 @@
<CheckBox IsChecked="{Binding ShowMetadataTokens}">Show metadata tokens</CheckBox>
<CheckBox IsChecked="{Binding ShowMetadataTokensInBase10}">Show metadata tokens in base 10</CheckBox>
<CheckBox IsChecked="{Binding EnableWordWrap}">Enable word wrap</CheckBox>
<CheckBox IsChecked="{Binding FoldBraces}">Enable folding on all blocks in braces</CheckBox>
<CheckBox IsChecked="{Binding SortResults}">Sort results by fitness</CheckBox>
<CheckBox IsChecked="{Binding ExpandMemberDefinitions}">Expand member definitions after decompilation</CheckBox>
</StackPanel>
</GroupBox>
</Grid>

15
ILSpy/Options/DisplaySettingsPanel.xaml.cs

@ -104,6 +104,8 @@ namespace ICSharpCode.ILSpy.Options @@ -104,6 +104,8 @@ namespace ICSharpCode.ILSpy.Options
s.ShowMetadataTokensInBase10 = (bool?)e.Attribute("ShowMetadataTokensInBase10") ?? false;
s.EnableWordWrap = (bool?)e.Attribute("EnableWordWrap") ?? false;
s.SortResults = (bool?)e.Attribute("SortResults") ?? true;
s.FoldBraces = (bool?)e.Attribute("FoldBraces") ?? false;
s.ExpandMemberDefinitions = (bool?)e.Attribute("ExpandMemberDefinitions") ?? false;
return s;
}
@ -120,6 +122,8 @@ namespace ICSharpCode.ILSpy.Options @@ -120,6 +122,8 @@ namespace ICSharpCode.ILSpy.Options
section.SetAttributeValue("ShowMetadataTokensInBase10", s.ShowMetadataTokensInBase10);
section.SetAttributeValue("EnableWordWrap", s.EnableWordWrap);
section.SetAttributeValue("SortResults", s.SortResults);
section.SetAttributeValue("FoldBraces", s.FoldBraces);
section.SetAttributeValue("ExpandMemberDefinitions", s.ExpandMemberDefinitions);
XElement existingElement = root.Element("DisplaySettings");
if (existingElement != null)
@ -136,8 +140,8 @@ namespace ICSharpCode.ILSpy.Options @@ -136,8 +140,8 @@ namespace ICSharpCode.ILSpy.Options
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if (value is double) {
return Math.Round((double)value / 4 * 3);
if (value is double d) {
return Math.Round(d / 4 * 3);
}
throw new NotImplementedException();
@ -145,11 +149,10 @@ namespace ICSharpCode.ILSpy.Options @@ -145,11 +149,10 @@ namespace ICSharpCode.ILSpy.Options
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if (value is string) {
double d;
if (double.TryParse((string)value, out d))
if (value is string s) {
if (double.TryParse(s, out double d))
return d * 4 / 3;
return 11 * 4 / 3;
return 11.0 * 4 / 3;
}
throw new NotImplementedException();

Loading…
Cancel
Save