diff --git a/EditorExtensions/BrowserLink/Menu/MenuBrowserLink.cs b/EditorExtensions/BrowserLink/Menu/MenuBrowserLink.cs index 3bd07c54b..16d3642f8 100644 --- a/EditorExtensions/BrowserLink/Menu/MenuBrowserLink.cs +++ b/EditorExtensions/BrowserLink/Menu/MenuBrowserLink.cs @@ -10,7 +10,7 @@ public class MenuBrowserLinkFactory : IBrowserLinkExtensionFactory { public BrowserLinkExtension CreateExtensionInstance(BrowserLinkConnection connection) { - if (!WESettings.GetBoolean(WESettings.Keys.EnableBrowserLinkMenu)) + if (!WESettings.Instance.BrowserLink.EnableMenu) return null; return new MenuBrowserLink(); @@ -18,7 +18,7 @@ public BrowserLinkExtension CreateExtensionInstance(BrowserLinkConnection connec public string GetScript() { - if (!WESettings.GetBoolean(WESettings.Keys.EnableBrowserLinkMenu)) + if (!WESettings.Instance.BrowserLink.EnableMenu) return null; using (Stream stream = GetType().Assembly.GetManifestResourceStream("MadsKristensen.EditorExtensions.BrowserLink.Menu.MenuBrowserLink.js")) @@ -33,15 +33,15 @@ public class MenuBrowserLink : BrowserLinkExtension { public override void OnConnected(BrowserLinkConnection connection) { - Browsers.Client(connection).Invoke("setVisibility", WESettings.GetBoolean(WESettings.Keys.BrowserLink_ShowMenu)); + Browsers.Client(connection).Invoke("setVisibility", WESettings.Instance.BrowserLink.ShowMenu); } [SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic")] [BrowserLinkCallback] // This method can be called from JavaScript public void ToggleVisibility(bool visible) { - Settings.SetValue(WESettings.Keys.BrowserLink_ShowMenu, visible); - Settings.Save(); + WESettings.Instance.BrowserLink.ShowMenu = visible; + SettingsStore.Save(); } } } \ No newline at end of file diff --git a/EditorExtensions/BrowserLink/PixelPushing/PixelPushingMode.cs b/EditorExtensions/BrowserLink/PixelPushing/PixelPushingMode.cs index a31458a40..ee0b57af4 100644 --- a/EditorExtensions/BrowserLink/PixelPushing/PixelPushingMode.cs +++ b/EditorExtensions/BrowserLink/PixelPushing/PixelPushingMode.cs @@ -45,9 +45,10 @@ public static IEnumerable IgnoreList { get { - var ignorePatterns = WESettings.GetString(WESettings.Keys.UnusedCss_IgnorePatterns) ?? ""; + var ignorePatterns = WESettings.Instance.BrowserLink.CssIgnorePatterns ?? ""; - return _ignoreList ?? (_ignoreList = ignorePatterns.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries).Select(x => new Regex(UnusedCssExtension.FilePatternToRegex(x.Trim()))).ToList()); + return _ignoreList ?? (_ignoreList = ignorePatterns.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries) + .Select(x => new Regex(UnusedCssExtension.FilePatternToRegex(x.Trim()))).ToList()); } } diff --git a/EditorExtensions/Commands/Css/CssSaveListener.cs b/EditorExtensions/Commands/Css/CssSaveListener.cs index f6f2b064b..285070f6e 100644 --- a/EditorExtensions/Commands/Css/CssSaveListener.cs +++ b/EditorExtensions/Commands/Css/CssSaveListener.cs @@ -15,6 +15,7 @@ namespace MadsKristensen.EditorExtensions [TextViewRole(PredefinedTextViewRoles.Document)] public class CssSaveListener : IWpfTextViewCreationListener { + //TODO: Move to common base class [Import] public ITextDocumentFactoryService TextDocumentFactoryService { get; set; } @@ -30,7 +31,7 @@ public void TextViewCreated(IWpfTextView textView) void document_FileActionOccurred(object sender, TextDocumentFileActionEventArgs e) { - if (!WESettings.GetBoolean(WESettings.Keys.EnableCssMinification)) + if (!WESettings.Instance.Css.MinifyOnSave) return; if (e.FileActionType == FileActionTypes.ContentSavedToDisk && e.FilePath.EndsWith(".css", StringComparison.OrdinalIgnoreCase)) @@ -62,7 +63,7 @@ public static void Minify(string file, string minFile) writer.Write(content); } - if (WESettings.GetBoolean(WESettings.Keys.CssEnableGzipping)) + if (WESettings.Instance.Css.GzipMinifiedFiles) GzipFile(file, minFile, content); } catch diff --git a/EditorExtensions/Commands/HTML/EnterFormatCommandTarget.cs b/EditorExtensions/Commands/HTML/EnterFormatCommandTarget.cs index f3f130a22..af58d0b49 100644 --- a/EditorExtensions/Commands/HTML/EnterFormatCommandTarget.cs +++ b/EditorExtensions/Commands/HTML/EnterFormatCommandTarget.cs @@ -31,7 +31,7 @@ public EnterFormat(IVsTextView adapter, IWpfTextView textView, IEditorFormatterP protected override bool Execute(CommandId commandId, uint nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut) { - if (_broker.IsCompletionActive(TextView) || !IsValidTextBuffer() || !WESettings.GetBoolean(WESettings.Keys.EnableEnterFormat)) + if (_broker.IsCompletionActive(TextView) || !IsValidTextBuffer() || !WESettings.Instance.Html.EnableEnterFormat) return false; int position = TextView.Caret.Position.BufferPosition.Position; diff --git a/EditorExtensions/Commands/HTML/HtmlSaveListener.cs b/EditorExtensions/Commands/HTML/HtmlSaveListener.cs index c7b9560b7..b7dce7979 100644 --- a/EditorExtensions/Commands/HTML/HtmlSaveListener.cs +++ b/EditorExtensions/Commands/HTML/HtmlSaveListener.cs @@ -29,7 +29,7 @@ public void TextViewCreated(IWpfTextView textView) void document_FileActionOccurred(object sender, TextDocumentFileActionEventArgs e) { - if (!WESettings.GetBoolean(WESettings.Keys.EnableHtmlMinification)) + if (!WESettings.Instance.Html.MinifyOnSave) return; if (e.FileActionType == FileActionTypes.ContentSavedToDisk && e.FilePath.EndsWith(".html", StringComparison.OrdinalIgnoreCase)) diff --git a/EditorExtensions/Commands/JavaScript/CommentCompletionCommandTarget.cs b/EditorExtensions/Commands/JavaScript/CommentCompletionCommandTarget.cs index b2ec3bf9f..50083216b 100644 --- a/EditorExtensions/Commands/JavaScript/CommentCompletionCommandTarget.cs +++ b/EditorExtensions/Commands/JavaScript/CommentCompletionCommandTarget.cs @@ -20,7 +20,7 @@ public CommentCompletionCommandTarget(IVsTextView adapter, IWpfTextView textView protected override bool Execute(CommandId commandId, uint nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut) { - if (!WESettings.GetBoolean(WESettings.Keys.JavaScriptCommentCompletion)) + if (!WESettings.Instance.JavaScript.BlockCommentCompletion) return false; char typedChar = (char)(ushort)Marshal.GetObjectForNativeVariant(pvaIn); diff --git a/EditorExtensions/Commands/JavaScript/CommentIndentationCommandTarget.cs b/EditorExtensions/Commands/JavaScript/CommentIndentationCommandTarget.cs index 80e96f7f7..a9511b039 100644 --- a/EditorExtensions/Commands/JavaScript/CommentIndentationCommandTarget.cs +++ b/EditorExtensions/Commands/JavaScript/CommentIndentationCommandTarget.cs @@ -23,7 +23,7 @@ public CommentIndentationCommandTarget(IVsTextView adapter, IWpfTextView textVie protected override bool Execute(CommandId commandId, uint nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut) { - if (!WESettings.GetBoolean(WESettings.Keys.JavaScriptCommentCompletion) || _broker.IsCompletionActive(TextView)) + if (!WESettings.Instance.JavaScript.BlockCommentCompletion || _broker.IsCompletionActive(TextView)) return false; int position = TextView.Caret.Position.BufferPosition.Position; diff --git a/EditorExtensions/Commands/JavaScript/JsHintRunner.cs b/EditorExtensions/Commands/JavaScript/JsHintRunner.cs index 9d1ad92ed..0ac79161f 100644 --- a/EditorExtensions/Commands/JavaScript/JsHintRunner.cs +++ b/EditorExtensions/Commands/JavaScript/JsHintRunner.cs @@ -194,22 +194,23 @@ private ErrorTask CreateTask(CompilerError error) private static TaskErrorCategory GetOutputLocation() { - var location = (WESettings.Keys.FullErrorLocation)WESettings.GetInt(WESettings.Keys.JsHintErrorLocation); - - if (location == WESettings.Keys.FullErrorLocation.Errors) - return TaskErrorCategory.Error; - - if (location == WESettings.Keys.FullErrorLocation.Warnings) - return TaskErrorCategory.Warning; - - return TaskErrorCategory.Message; + switch (WESettings.Instance.JavaScript.LintResultLocation) + { + case ErrorLocation.Errors: + return TaskErrorCategory.Error; + case ErrorLocation.Warnings: + return TaskErrorCategory.Warning; + case ErrorLocation.Messages: + default: + return TaskErrorCategory.Message; + } } private void task_Navigate(object sender, EventArgs e) { Task task = sender as Task; - _provider.Navigate(task, new Guid(EnvDTE.Constants.vsViewKindPrimary)); + _provider.Navigate(task, new Guid(Constants.vsViewKindPrimary)); if (task.Column > 0) { diff --git a/EditorExtensions/Commands/TypeScript/TsLintProjectRunner.cs b/EditorExtensions/Commands/TypeScript/TsLintProjectRunner.cs index 949304a9b..ed14874f3 100644 --- a/EditorExtensions/Commands/TypeScript/TsLintProjectRunner.cs +++ b/EditorExtensions/Commands/TypeScript/TsLintProjectRunner.cs @@ -18,7 +18,7 @@ public TsLintProjectRunner(ITextDocument document) _document.FileActionOccurred += DocumentSavedHandler; _runner = new TsLintRunner(_document.FilePath); - if (WESettings.GetBoolean(WESettings.Keys.EnableTsLint)) + if (WESettings.Instance.TypeScript.LintOnSave) { Dispatcher.CurrentDispatcher.BeginInvoke(new Action(_runner.RunCompiler), DispatcherPriority.ApplicationIdle, null); } @@ -26,7 +26,7 @@ public TsLintProjectRunner(ITextDocument document) private void DocumentSavedHandler(object sender, TextDocumentFileActionEventArgs e) { - if (!WESettings.GetBoolean(WESettings.Keys.EnableTsLint)) + if (!WESettings.Instance.TypeScript.LintOnSave) return; ITextDocument document = (ITextDocument)sender; diff --git a/EditorExtensions/Commands/TypeScript/TypeScriptTypeThroughControllerProvider.cs b/EditorExtensions/Commands/TypeScript/TypeScriptTypeThroughControllerProvider.cs index 602ebc251..abab6f4ec 100644 --- a/EditorExtensions/Commands/TypeScript/TypeScriptTypeThroughControllerProvider.cs +++ b/EditorExtensions/Commands/TypeScript/TypeScriptTypeThroughControllerProvider.cs @@ -40,7 +40,7 @@ public TypeScriptTypeThroughController(ITextView textView, IList su protected override bool CanComplete(ITextBuffer textBuffer, int position) { - bool result = WESettings.GetBoolean(WESettings.Keys.TypeScriptBraceCompletion); + bool result = WESettings.Instance.TypeScript.BraceCompletion; if (result) { diff --git a/EditorExtensions/Commands/TypeScript/TypeThroughController.cs b/EditorExtensions/Commands/TypeScript/TypeThroughController.cs index 0df7a8c74..4f483a24c 100644 --- a/EditorExtensions/Commands/TypeScript/TypeThroughController.cs +++ b/EditorExtensions/Commands/TypeScript/TypeThroughController.cs @@ -126,7 +126,7 @@ private void OnPostTypeChar(char typedCharacter) // current caret position may be beyond projection boundary like when // typing at the end of onclick="return foo(". - if (WESettings.GetBoolean(WESettings.Keys.TypeScriptBraceCompletion)) + if (WESettings.Instance.TypeScript.BraceCompletion) { char completionCharacter = GetCompletionCharacter(typedCharacter); if (completionCharacter != '\0') diff --git a/EditorExtensions/Compilers/CoffeeScript/CoffeeScriptCompiler.cs b/EditorExtensions/Compilers/CoffeeScript/CoffeeScriptCompiler.cs index 13774c762..902986323 100644 --- a/EditorExtensions/Compilers/CoffeeScript/CoffeeScriptCompiler.cs +++ b/EditorExtensions/Compilers/CoffeeScript/CoffeeScriptCompiler.cs @@ -30,10 +30,10 @@ protected override string GetArguments(string sourceFileName, string targetFileN { var args = new StringBuilder(); - if (!WESettings.GetBoolean(WESettings.Keys.WrapCoffeeScriptClosure)) + if (!WESettings.Instance.CoffeeScript.WrapClosure) args.Append("--bare "); - if (WESettings.GetBoolean(WESettings.Keys.CoffeeScriptSourceMaps) && !InUnitTests) + if (WESettings.Instance.CoffeeScript.GenerateSourceMaps && !InUnitTests) args.Append("--map "); args.AppendFormat(CultureInfo.CurrentCulture, "--output \"{0}\" --compile \"{1}\"", Path.GetDirectoryName(targetFileName), sourceFileName); @@ -65,10 +65,9 @@ private static void ProcessMapFile(string jsFileName) File.Delete(oldSourceMapFile); // end-Hack - if (WESettings.GetBoolean(WESettings.Keys.CoffeeScriptSourceMaps)) + if (WESettings.Instance.CoffeeScript.GenerateSourceMaps) { - Dispatcher.CurrentDispatcher.BeginInvoke(new Action(() => - { + Dispatcher.CurrentDispatcher.BeginInvoke(new Action(() => { ProjectHelpers.AddFileToProject(jsFileName, sourceMapFile); }), DispatcherPriority.ApplicationIdle, null); } @@ -76,7 +75,7 @@ private static void ProcessMapFile(string jsFileName) private static string UpdateSourceMapUrls(string content, string compiledFileName) { - if (!WESettings.GetBoolean(WESettings.Keys.LessSourceMaps) || !File.Exists(compiledFileName)) + if (!WESettings.Instance.CoffeeScript.GenerateSourceMaps || !File.Exists(compiledFileName)) return content; string sourceMapFilename = compiledFileName + ".map"; diff --git a/EditorExtensions/Compilers/LESS/LessCompiler.cs b/EditorExtensions/Compilers/LESS/LessCompiler.cs index 732a24a2a..51b460db2 100644 --- a/EditorExtensions/Compilers/LESS/LessCompiler.cs +++ b/EditorExtensions/Compilers/LESS/LessCompiler.cs @@ -33,7 +33,7 @@ protected override string GetArguments(string sourceFileName, string targetFileN { var args = new StringBuilder("--no-color --relative-urls "); - if (WESettings.GetBoolean(WESettings.Keys.LessSourceMaps)) + if (WESettings.Instance.Less.GenerateSourceMaps) { string baseFolder = null; if (!InUnitTests) @@ -57,7 +57,8 @@ protected override string PostProcessResult(string resultSource, string sourceFi var message = "LESS: " + Path.GetFileName(sourceFileName) + " compiled."; // If the caller wants us to renormalize URLs to a different filename, do so. - if (!string.IsNullOrWhiteSpace(WESettings.GetString(WESettings.Keys.LessCompileToLocation)) && targetFileName != null && resultSource.IndexOf("url(", StringComparison.OrdinalIgnoreCase) > 0) + if (targetFileName != null && Path.GetDirectoryName(targetFileName) != Path.GetDirectoryName(sourceFileName) + && resultSource.IndexOf("url(", StringComparison.OrdinalIgnoreCase) > 0) { try { @@ -80,7 +81,7 @@ protected override string PostProcessResult(string resultSource, string sourceFi private static string UpdateSourceMapUrls(string content, string compiledFileName) { - if (!WESettings.GetBoolean(WESettings.Keys.LessSourceMaps) || !File.Exists(compiledFileName)) + if (!WESettings.Instance.Less.GenerateSourceMaps || !File.Exists(compiledFileName)) return content; string sourceMapFilename = compiledFileName + ".map"; diff --git a/EditorExtensions/Compilers/SASS/SassCompiler.cs b/EditorExtensions/Compilers/SASS/SassCompiler.cs index 5d7afc55d..9264ca059 100644 --- a/EditorExtensions/Compilers/SASS/SassCompiler.cs +++ b/EditorExtensions/Compilers/SASS/SassCompiler.cs @@ -33,7 +33,7 @@ protected override string GetArguments(string sourceFileName, string targetFileN { var args = new StringBuilder(); - if (WESettings.GetBoolean(WESettings.Keys.SassSourceMaps) && !InUnitTests) + if (WESettings.Instance.Sass.GenerateSourceMaps && !InUnitTests) { args.Append("--source-map "); } @@ -73,7 +73,7 @@ protected override string PostProcessResult(string resultSource, string sourceFi private static string UpdateSourceMapUrls(string content, string compiledFileName) { - if (!WESettings.GetBoolean(WESettings.Keys.SassSourceMaps) || !File.Exists(compiledFileName)) + if (WESettings.Instance.Sass.GenerateSourceMaps || !File.Exists(compiledFileName)) return content; string sourceMapFilename = compiledFileName + ".map"; diff --git a/EditorExtensions/EditorExtensionsPackage.cs b/EditorExtensions/EditorExtensionsPackage.cs index a2ca2c347..ab9a0d142 100644 --- a/EditorExtensions/EditorExtensionsPackage.cs +++ b/EditorExtensions/EditorExtensionsPackage.cs @@ -121,36 +121,29 @@ protected override void Initialize() private async void BuildEvents_OnBuildDone(vsBuildScope Scope, vsBuildAction Action) { if (Action != vsBuildAction.vsBuildActionClean) + { await ThreadingTask.Task.Run(async () => { - if (WESettings.GetBoolean(WESettings.Keys.LessCompileOnBuild)) + if (WESettings.Instance.Less.CompileOnBuild) await BuildMenu.BuildLess(); - if (WESettings.GetBoolean(WESettings.Keys.SassCompileOnBuild)) + if (WESettings.Instance.Sass.CompileOnBuild) await BuildMenu.BuildSass(); - if (WESettings.GetBoolean(WESettings.Keys.CoffeeScriptCompileOnBuild)) + if (WESettings.Instance.CoffeeScript.CompileOnBuild) await BuildMenu.BuildCoffeeScript(); BuildMenu.UpdateBundleFiles(); - - if (WESettings.GetBoolean(WESettings.Keys.RunJsHintOnBuild)) - { - await Dispatcher.CurrentDispatcher.BeginInvoke( - new Action(() => JsHintProjectRunner.RunOnAllFilesInProject()), - DispatcherPriority.ApplicationIdle, null); - } - - if (WESettings.GetBoolean(WESettings.Keys.RunTsLintOnBuild)) - { - await Dispatcher.CurrentDispatcher.BeginInvoke( - new Action(() => TsLintProjectRunner.RunOnAllFilesInProject()), - DispatcherPriority.ApplicationIdle, null); - } }); + + if (WESettings.Instance.JavaScript.LintOnBuild) + JsHintProjectRunner.RunOnAllFilesInProject(); + if (WESettings.Instance.TypeScript.LintOnBuild) + TsLintProjectRunner.RunOnAllFilesInProject(); + } else if (Action == vsBuildAction.vsBuildActionClean) { - await ThreadingTask.Task.Run(() => JsHintRunner.Reset()); - await ThreadingTask.Task.Run(() => TsLintRunner.Reset()); + JsHintRunner.Reset(); + TsLintRunner.Reset(); } } diff --git a/EditorExtensions/MenuItems/BundleFiles.cs b/EditorExtensions/MenuItems/BundleFiles.cs index 3e88124b8..0daca89af 100644 --- a/EditorExtensions/MenuItems/BundleFiles.cs +++ b/EditorExtensions/MenuItems/BundleFiles.cs @@ -61,8 +61,7 @@ private void document_FileActionOccurred(object sender, TextDocumentFileActionEv { string file = e.FilePath.EndsWith(_ext, StringComparison.OrdinalIgnoreCase) ? e.FilePath : null; - System.Threading.Tasks.Task.Run(() => - { + System.Threading.Tasks.Task.Run(() => { UpdateBundles(file, true); }); } @@ -323,7 +322,7 @@ private static void WriteBundleFile(string filePath, XmlDocument doc) //{ // sb.AppendLine("/*#source " + files[file] + " */"); //} - if (extension.Equals(".js", StringComparison.OrdinalIgnoreCase) && WESettings.GetBoolean(WESettings.Keys.GenerateJavaScriptSourceMaps)) + if (extension.Equals(".js", StringComparison.OrdinalIgnoreCase) && WESettings.Instance.JavaScript.GenerateSourceMaps) { sb.AppendLine("///#source 1 1 " + files[file]); } @@ -338,7 +337,7 @@ private static void WriteBundleFile(string filePath, XmlDocument doc) // or if does not have URLs, no need to normalize. if (Path.GetDirectoryName(file) != Path.GetDirectoryName(bundlePath) && source.IndexOf("url(", StringComparison.OrdinalIgnoreCase) > 0 - && !WESettings.GetBoolean(WESettings.Keys.CssPreserveRelativePathsOnMinify)) + && WESettings.Instance.Css.AdjustRelativePaths) source = CssUrlNormalizer.NormalizeUrls( tree: new CssParser().Parse(source, true), targetFile: bundlePath, @@ -371,15 +370,14 @@ private static void WriteMinFile(string filePath, string bundlePath, string cont if (!bundleChanged && File.Exists(minPath)) return; + // TODO: Refactor to common class that takes settings interface & minifier if (extension.Equals(".js", StringComparison.OrdinalIgnoreCase)) { JavaScriptSaveListener.Minify(bundlePath, minPath, true); ProjectHelpers.AddFileToProject(filePath, minPath); - if (WESettings.GetBoolean(WESettings.Keys.GenerateJavaScriptSourceMaps)) - { + if (WESettings.Instance.JavaScript.GenerateSourceMaps) ProjectHelpers.AddFileToProject(filePath, minPath + ".map"); - } ProjectHelpers.AddFileToProject(filePath, minPath + ".gzip"); } @@ -391,7 +389,7 @@ private static void WriteMinFile(string filePath, string bundlePath, string cont File.WriteAllText(minPath, minContent, new UTF8Encoding(true)); ProjectHelpers.AddFileToProject(filePath, minPath); - if (WESettings.GetBoolean(WESettings.Keys.CssEnableGzipping)) + if (WESettings.Instance.Css.GzipMinifiedFiles) CssSaveListener.GzipFile(filePath, minPath, minContent); } else if (extension.Equals(".html", StringComparison.OrdinalIgnoreCase)) diff --git a/EditorExtensions/MenuItems/MinifyFile.cs b/EditorExtensions/MenuItems/MinifyFile.cs index 1cde8275d..16c4aad10 100644 --- a/EditorExtensions/MenuItems/MinifyFile.cs +++ b/EditorExtensions/MenuItems/MinifyFile.cs @@ -97,31 +97,32 @@ private static void EnableSync(string extension) { string message = "Do you also want to enable automatic minification when the source file changes?"; - if (extension.Equals(".css", StringComparison.OrdinalIgnoreCase) && !WESettings.GetBoolean(WESettings.Keys.EnableCssMinification)) + // TODO: Move to common code with map of extension to settings interface + if (extension.Equals(".css", StringComparison.OrdinalIgnoreCase) && !WESettings.Instance.Css.MinifyOnSave) { var result = MessageBox.Show(message, "Web Essentials", MessageBoxButton.YesNo, MessageBoxImage.Question); if (result == MessageBoxResult.Yes) { - Settings.SetValue(WESettings.Keys.EnableCssMinification, true); - Settings.Save(); + WESettings.Instance.Css.MinifyOnSave = true; + SettingsStore.Save(); } } - else if (extension.Equals(".js", StringComparison.OrdinalIgnoreCase) && !WESettings.GetBoolean(WESettings.Keys.EnableJsMinification)) + else if (extension.Equals(".js", StringComparison.OrdinalIgnoreCase) && !WESettings.Instance.JavaScript.MinifyOnSave) { var result = MessageBox.Show(message, "Web Essentials", MessageBoxButton.YesNo, MessageBoxImage.Question); if (result == MessageBoxResult.Yes) { - Settings.SetValue(WESettings.Keys.EnableJsMinification, true); - Settings.Save(); + WESettings.Instance.JavaScript.MinifyOnSave = true; + SettingsStore.Save(); } } - else if (extension.Equals(".html", StringComparison.OrdinalIgnoreCase) && !WESettings.GetBoolean(WESettings.Keys.EnableHtmlMinification)) + else if (extension.Equals(".html", StringComparison.OrdinalIgnoreCase) && !WESettings.Instance.Html.MinifyOnSave) { var result = MessageBox.Show(message, "Web Essentials", MessageBoxButton.YesNo, MessageBoxImage.Question); if (result == MessageBoxResult.Yes) { - Settings.SetValue(WESettings.Keys.EnableHtmlMinification, true); - Settings.Save(); + WESettings.Instance.Html.MinifyOnSave = true; + SettingsStore.Save(); } } } @@ -136,10 +137,10 @@ public static string MinifyString(string extension, string content) if (extension == ".css") { Minifier minifier = new Minifier(); - CssSettings settings = new CssSettings(); + var settings = new Microsoft.Ajax.Utilities.CssSettings(); settings.CommentMode = CssComment.None; - if (WESettings.GetBoolean(WESettings.Keys.KeepImportantComments)) + if (WESettings.Instance.General.KeepImportantComments) { settings.CommentMode = CssComment.Important; } @@ -149,18 +150,16 @@ public static string MinifyString(string extension, string content) else if (extension == ".js") { Minifier minifier = new Minifier(); - CodeSettings settings = new CodeSettings() - { + CodeSettings settings = new CodeSettings() { EvalTreatment = EvalTreatment.MakeImmediateSafe, - PreserveImportantComments = WESettings.GetBoolean(WESettings.Keys.KeepImportantComments) + PreserveImportantComments = WESettings.Instance.General.KeepImportantComments }; return minifier.MinifyJavaScript(content, settings); } else if (_htmlExt.Contains(extension.ToLowerInvariant())) { - var settings = new HtmlMinificationSettings - { + var settings = new HtmlMinificationSettings { RemoveOptionalEndTags = false, AttributeQuotesRemovalMode = HtmlAttributeQuotesRemovalMode.KeepQuotes, RemoveRedundantAttributes = false, diff --git a/EditorExtensions/Settings/LegacySettings.cs b/EditorExtensions/Settings/LegacySettings.cs index ceb8434cf..7193de899 100644 --- a/EditorExtensions/Settings/LegacySettings.cs +++ b/EditorExtensions/Settings/LegacySettings.cs @@ -104,13 +104,13 @@ public void ApplyTo(WESettings target) target.TypeScript.LintResultLocation = (ErrorLocation)GetInt("TsLintErrorLocation"); // Browser Link - target.BrowserLink.IgnorePatterns = GetString("UnusedCss_IgnorePatterns"); - target.BrowserLink.EnableBrowserLinkMenu = GetBoolean("EnableBrowserLinkMenu"); + target.BrowserLink.CssIgnorePatterns = GetString("UnusedCss_IgnorePatterns"); + target.BrowserLink.EnableMenu = GetBoolean("EnableBrowserLinkMenu"); //Pixel Pushing mode target.BrowserLink.EnablePixelPushing = GetBoolean("PixelPushing_OnByDefault"); - //target. = GetBoolean("BrowserLink_ShowMenu"); + target.BrowserLink.ShowMenu = GetBoolean("BrowserLink_ShowMenu"); } diff --git a/EditorExtensions/Settings/WESettings.cs b/EditorExtensions/Settings/WESettings.cs index aae8e4492..28f5d5ef7 100644 --- a/EditorExtensions/Settings/WESettings.cs +++ b/EditorExtensions/Settings/WESettings.cs @@ -54,18 +54,22 @@ public sealed class BrowserLinkSettings : SettingsBase [DisplayName("Enable Browser Link menu")] [Description("Enable the menu that shows up in the browser. Requires restart.")] [DefaultValue(true)] - public bool EnableBrowserLinkMenu { get; set; } + public bool EnableMenu { get; set; } [Category("CSS")] [DisplayName("CSS usage files to ignore")] [Description("A semicolon-separated list of file patterns to ignore.")] [DefaultValue("bootstrap*; reset.css; normalize.css; jquery*; toastr*; foundation*; animate*; inuit*; elements*; ratchet*; hint*; flat-ui*; 960*; skeleton*")] - public string IgnorePatterns { get; set; } // TODO: Switch to List & check property designer support + public string CssIgnorePatterns { get; set; } // TODO: Switch to List & check property designer support [Category("CSS")] [DisplayName("Enable f12 auto-sync")] [Description("Automatically synchronize changes made in the browser dev tools with CSS files in Visual Studio. If this is turned off, you can synchronize changes explicitly in the Browser Link menu.")] [DefaultValue(true)] public bool EnablePixelPushing { get; set; } + + [Browsable(false)] + [DefaultValue(true)] + public bool ShowMenu { get; set; } } public sealed class CodeGenSettings : SettingsBase { @@ -170,7 +174,7 @@ public sealed class JavaScriptSettings : LinterSettings [Category("Minification")] [DisplayName("Create source map files")] - [Description("Generate source map files when minifying. This option has no effect when Minify on save is disabled.")] + [Description("Generate source map files when minifying or bundling.")] [DefaultValue(true)] public bool GenerateSourceMaps { get; set; } #endregion @@ -192,7 +196,7 @@ public sealed class CssSettings : SettingsBase [Category("Minification")] [DisplayName("Create gzipped files")] - [Description("Also save separate gzipped files when minifying. This option has no effect when Minify on save is disabled.")] + [Description("Also save separate gzipped files when minifying or bundling.")] [DefaultValue(false)] public bool GzipMinifiedFiles { get; set; } @@ -316,7 +320,7 @@ public sealed class CoffeeScriptSettings : CompilationSettings