public Decompiler.DecompilerSettings ToDecompilerSettings() { var settings = new Decompiler.DecompilerSettings(); foreach (var item in Settings) { item.Property.SetValue(settings, item.IsEnabled); } return(settings); }
public DecompilerSettings(Decompiler.DecompilerSettings settings) { Settings = typeof(Decompiler.DecompilerSettings).GetProperties() .Where(p => p.GetCustomAttribute <BrowsableAttribute>()?.Browsable != false) .Select(p => new CSharpDecompilerSetting(p) { IsEnabled = (bool)p.GetValue(settings) }) .OrderBy(item => item.Category) .ThenBy(item => item.Description) .ToArray(); }
public static Decompiler.DecompilerSettings LoadDecompilerSettings(ILSpySettings settings) { XElement e = settings["DecompilerSettings"]; var newSettings = new Decompiler.DecompilerSettings(); var properties = typeof(Decompiler.DecompilerSettings).GetProperties() .Where(p => p.GetCustomAttribute <BrowsableAttribute>()?.Browsable != false); foreach (var p in properties) { p.SetValue(newSettings, (bool?)e.Attribute(p.Name) ?? true); } return(newSettings); }
public DecompilationOptions(LanguageVersion version, Decompiler.DecompilerSettings settings, Options.DisplaySettings displaySettings) { 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.ExpandUsingDeclarations = displaySettings.ExpandUsingDeclarations; newSettings.FoldBraces = displaySettings.FoldBraces; newSettings.ShowDebugInfo = displaySettings.ShowDebugInfo; newSettings.CSharpFormattingOptions.IndentationString = GetIndentationString(displaySettings); }
void WriteCode(ITextOutput output, Decompiler.DecompilerSettings settings, SyntaxTree syntaxTree, IDecompilerTypeSystem typeSystem) { syntaxTree.AcceptVisitor(new InsertParenthesesVisitor { InsertParenthesesForReadability = true }); TokenWriter tokenWriter = new TextTokenWriter(output, settings, typeSystem) { FoldBraces = settings.FoldBraces, ExpandMemberDefinitions = settings.ExpandMemberDefinitions }; if (output is ISmartTextOutput highlightingOutput) { tokenWriter = new CSharpHighlightingTokenWriter(tokenWriter, highlightingOutput); } syntaxTree.AcceptVisitor(new CSharpOutputVisitor(tokenWriter, settings.CSharpFormattingOptions)); }
public Decompiler.DecompilerSettings LoadDecompilerSettings(XElement e) { var newSettings = new Decompiler.DecompilerSettings(); var properties = typeof(Decompiler.DecompilerSettings).GetProperties() .Where(p => p.GetCustomAttribute <BrowsableAttribute>()?.Browsable != false); foreach (var p in properties) { var value = (bool?)e.Attribute(p.Name); if (value.HasValue) { p.SetValue(newSettings, value.Value); } } return(newSettings); }
public void Save(XElement root) { XElement section = new XElement("DecompilerSettings"); var newSettings = ((DecompilerSettings)this.DataContext).ToDecompilerSettings(); var properties = typeof(Decompiler.DecompilerSettings).GetProperties() .Where(p => p.GetCustomAttribute <BrowsableAttribute>()?.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 = newSettings; }
public void LoadDefaults() { currentDecompilerSettings = new Decompiler.DecompilerSettings(); this.DataContext = new DecompilerSettingsViewModel(currentDecompilerSettings); }
internal static void TestSetup(Decompiler.DecompilerSettings settings) { currentDecompilerSettings = settings; }