Skip to content

Commit

Permalink
Move settings from custom UI to built-in options panel. (#96)
Browse files Browse the repository at this point in the history
  • Loading branch information
adamdriscoll authored Dec 10, 2024
1 parent ffd20bb commit e2c8738
Show file tree
Hide file tree
Showing 23 changed files with 1,224 additions and 808 deletions.
2 changes: 1 addition & 1 deletion PowerShellTools.2022/PowerShellTools.15.0.imagemanifest
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<ImageManifest xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.microsoft.com/VisualStudio/ImageManifestSchema/2014">
<Symbols>
<!--;v1.2.3.4;32cd18849a3a99f8-->
<String Name="Resources" Value="/PowerShellTools.2022.2024.7.0;component/Resources" />
<String Name="Resources" Value="/PowerShellTools.2022.2024.7.1;component/Resources" />
<Guid Name="ProjectGuid" Value="{072A9D46-0C24-4CFA-990A-25D7E12271F5}" />
<ID Name="ProjectIcon" Value="1" />
<ID Name="ScriptIcon" Value="2" />
Expand Down
8 changes: 0 additions & 8 deletions PowerShellTools.2022/PowerShellTools.vsct
Original file line number Diff line number Diff line change
Expand Up @@ -231,14 +231,6 @@
<ButtonText>PowerShell Modules</ButtonText>
</Strings>
</Button>

<Button guid="guidPoshToolsCmdSet" id="SettingsCommandId" priority="0x7f03" type="Button">
<Parent guid="guidPoshToolsCmdSet" id="SubMenuGroup"/>
<Icon guid="guidSettingsImage" id="1"/>
<Strings>
<ButtonText>Settings</ButtonText>
</Strings>
</Button>
</Buttons>

<Bitmaps>
Expand Down
242 changes: 242 additions & 0 deletions PowerShellTools.2022/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -1819,6 +1819,27 @@
"PowerShellStandard.Library": "[5.1.0, )"
}
},
"powershelltools.templates.data": {
"type": "Project"
},
"powershelltools.templates.formproject": {
"type": "Project"
},
"powershelltools.templates.module": {
"type": "Project"
},
"powershelltools.templates.moduleproject": {
"type": "Project"
},
"powershelltools.templates.script": {
"type": "Project"
},
"powershelltools.templates.scriptproject": {
"type": "Project"
},
"powershelltools.templates.test": {
"type": "Project"
},
"powershelltools.testadapter": {
"type": "Project",
"dependencies": {
Expand Down Expand Up @@ -1857,6 +1878,227 @@
"System.Drawing.Common": "[6.0.0, )",
"System.Text.Json": "[4.6.0, )"
}
},
"powershelltoolspro.templates.formitem": {
"type": "Project"
},
"powershelltoolspro.templates.serviceitem": {
"type": "Project"
}
},
".NETFramework,Version=v4.7.2/win": {
"Microsoft.Win32.Registry": {
"type": "Direct",
"requested": "[5.0.0, )",
"resolved": "5.0.0",
"contentHash": "dDoKi0PnDz31yAyETfRntsLArTlVAVzUzCIvvEDsDsucrl33Dl8pIJG06ePTJTI3tGpeyHS9Cq7Foc/s4EeKcg==",
"dependencies": {
"System.Security.AccessControl": "5.0.0",
"System.Security.Principal.Windows": "5.0.0"
}
},
"Microsoft.Win32.Primitives": {
"type": "Transitive",
"resolved": "4.3.0",
"contentHash": "9ZQKCWxH7Ijp9BfahvL2Zyf1cJIk8XYLF6Yjzr2yi0b2cOut/HQ31qf1ThHAgCc3WiZMdnWcfJCgN82/0UunxA==",
"dependencies": {
"runtime.win.Microsoft.Win32.Primitives": "4.3.0"
}
},
"runtime.win.Microsoft.Win32.Primitives": {
"type": "Transitive",
"resolved": "4.3.0",
"contentHash": "NU51SEt/ZaD2MF48sJ17BIqx7rjeNNLXUevfMOjqQIetdndXwYjZfZsT6jD+rSWp/FYxjesdK4xUSl4OTEI0jw=="
},
"System.IO.Compression": {
"type": "Transitive",
"resolved": "4.3.0",
"contentHash": "YHndyoiV90iu4iKG115ibkhrG+S3jBm8Ap9OwoUAzO5oPDAWcr0SFwQFm0HjM8WkEZWo0zvLTyLmbvTkW1bXgg=="
},
"System.IO.Pipes.AccessControl": {
"type": "Transitive",
"resolved": "4.5.0",
"contentHash": "uqKLJb0Cukb8vG6JVKbJXOAmMWUWOue4ZTjMn7qrfGLZHww3iV8xV1amipI238kmmoFQx6I8GP2bjDM/ss5pQQ==",
"dependencies": {
"System.Security.AccessControl": "4.5.0",
"System.Security.Principal.Windows": "4.5.0"
}
},
"System.Runtime.InteropServices.RuntimeInformation": {
"type": "Transitive",
"resolved": "4.3.0",
"contentHash": "cbz4YJMqRDR7oLeMRbdYv7mYzc++17lNhScCX0goO2XpGWdvAt60CGN+FHdePUEHCe/Jy9jUlvNAiNdM+7jsOw=="
},
"System.Security.AccessControl": {
"type": "Transitive",
"resolved": "6.0.0",
"contentHash": "AUADIc0LIEQe7MzC+I0cl0rAT8RrTAKFHl53yHjEUzNVIaUlhFY11vc2ebiVJzVBuOzun6F7FBA+8KAbGTTedQ==",
"dependencies": {
"System.Security.Principal.Windows": "5.0.0"
}
},
"System.Security.Principal.Windows": {
"type": "Transitive",
"resolved": "5.0.0",
"contentHash": "t0MGLukB5WAVU9bO3MGzvlGnyJPgUlcwerXn1kzBRjwLKixT96XV0Uza41W49gVd8zEMFu9vQEFlv0IOrytICA=="
}
},
".NETFramework,Version=v4.7.2/win-arm64": {
"Microsoft.Win32.Registry": {
"type": "Direct",
"requested": "[5.0.0, )",
"resolved": "5.0.0",
"contentHash": "dDoKi0PnDz31yAyETfRntsLArTlVAVzUzCIvvEDsDsucrl33Dl8pIJG06ePTJTI3tGpeyHS9Cq7Foc/s4EeKcg==",
"dependencies": {
"System.Security.AccessControl": "5.0.0",
"System.Security.Principal.Windows": "5.0.0"
}
},
"System.IO.Compression": {
"type": "Transitive",
"resolved": "4.3.0",
"contentHash": "YHndyoiV90iu4iKG115ibkhrG+S3jBm8Ap9OwoUAzO5oPDAWcr0SFwQFm0HjM8WkEZWo0zvLTyLmbvTkW1bXgg=="
},
"System.IO.Pipes.AccessControl": {
"type": "Transitive",
"resolved": "4.5.0",
"contentHash": "uqKLJb0Cukb8vG6JVKbJXOAmMWUWOue4ZTjMn7qrfGLZHww3iV8xV1amipI238kmmoFQx6I8GP2bjDM/ss5pQQ==",
"dependencies": {
"System.Security.AccessControl": "4.5.0",
"System.Security.Principal.Windows": "4.5.0"
}
},
"System.Runtime.InteropServices.RuntimeInformation": {
"type": "Transitive",
"resolved": "4.3.0",
"contentHash": "cbz4YJMqRDR7oLeMRbdYv7mYzc++17lNhScCX0goO2XpGWdvAt60CGN+FHdePUEHCe/Jy9jUlvNAiNdM+7jsOw=="
},
"System.Security.AccessControl": {
"type": "Transitive",
"resolved": "6.0.0",
"contentHash": "AUADIc0LIEQe7MzC+I0cl0rAT8RrTAKFHl53yHjEUzNVIaUlhFY11vc2ebiVJzVBuOzun6F7FBA+8KAbGTTedQ==",
"dependencies": {
"System.Security.Principal.Windows": "5.0.0"
}
},
"System.Security.Principal.Windows": {
"type": "Transitive",
"resolved": "5.0.0",
"contentHash": "t0MGLukB5WAVU9bO3MGzvlGnyJPgUlcwerXn1kzBRjwLKixT96XV0Uza41W49gVd8zEMFu9vQEFlv0IOrytICA=="
}
},
".NETFramework,Version=v4.7.2/win-x64": {
"Microsoft.Win32.Registry": {
"type": "Direct",
"requested": "[5.0.0, )",
"resolved": "5.0.0",
"contentHash": "dDoKi0PnDz31yAyETfRntsLArTlVAVzUzCIvvEDsDsucrl33Dl8pIJG06ePTJTI3tGpeyHS9Cq7Foc/s4EeKcg==",
"dependencies": {
"System.Security.AccessControl": "5.0.0",
"System.Security.Principal.Windows": "5.0.0"
}
},
"Microsoft.Win32.Primitives": {
"type": "Transitive",
"resolved": "4.3.0",
"contentHash": "9ZQKCWxH7Ijp9BfahvL2Zyf1cJIk8XYLF6Yjzr2yi0b2cOut/HQ31qf1ThHAgCc3WiZMdnWcfJCgN82/0UunxA==",
"dependencies": {
"runtime.win.Microsoft.Win32.Primitives": "4.3.0"
}
},
"runtime.win.Microsoft.Win32.Primitives": {
"type": "Transitive",
"resolved": "4.3.0",
"contentHash": "NU51SEt/ZaD2MF48sJ17BIqx7rjeNNLXUevfMOjqQIetdndXwYjZfZsT6jD+rSWp/FYxjesdK4xUSl4OTEI0jw=="
},
"System.IO.Compression": {
"type": "Transitive",
"resolved": "4.3.0",
"contentHash": "YHndyoiV90iu4iKG115ibkhrG+S3jBm8Ap9OwoUAzO5oPDAWcr0SFwQFm0HjM8WkEZWo0zvLTyLmbvTkW1bXgg=="
},
"System.IO.Pipes.AccessControl": {
"type": "Transitive",
"resolved": "4.5.0",
"contentHash": "uqKLJb0Cukb8vG6JVKbJXOAmMWUWOue4ZTjMn7qrfGLZHww3iV8xV1amipI238kmmoFQx6I8GP2bjDM/ss5pQQ==",
"dependencies": {
"System.Security.AccessControl": "4.5.0",
"System.Security.Principal.Windows": "4.5.0"
}
},
"System.Runtime.InteropServices.RuntimeInformation": {
"type": "Transitive",
"resolved": "4.3.0",
"contentHash": "cbz4YJMqRDR7oLeMRbdYv7mYzc++17lNhScCX0goO2XpGWdvAt60CGN+FHdePUEHCe/Jy9jUlvNAiNdM+7jsOw=="
},
"System.Security.AccessControl": {
"type": "Transitive",
"resolved": "6.0.0",
"contentHash": "AUADIc0LIEQe7MzC+I0cl0rAT8RrTAKFHl53yHjEUzNVIaUlhFY11vc2ebiVJzVBuOzun6F7FBA+8KAbGTTedQ==",
"dependencies": {
"System.Security.Principal.Windows": "5.0.0"
}
},
"System.Security.Principal.Windows": {
"type": "Transitive",
"resolved": "5.0.0",
"contentHash": "t0MGLukB5WAVU9bO3MGzvlGnyJPgUlcwerXn1kzBRjwLKixT96XV0Uza41W49gVd8zEMFu9vQEFlv0IOrytICA=="
}
},
".NETFramework,Version=v4.7.2/win-x86": {
"Microsoft.Win32.Registry": {
"type": "Direct",
"requested": "[5.0.0, )",
"resolved": "5.0.0",
"contentHash": "dDoKi0PnDz31yAyETfRntsLArTlVAVzUzCIvvEDsDsucrl33Dl8pIJG06ePTJTI3tGpeyHS9Cq7Foc/s4EeKcg==",
"dependencies": {
"System.Security.AccessControl": "5.0.0",
"System.Security.Principal.Windows": "5.0.0"
}
},
"Microsoft.Win32.Primitives": {
"type": "Transitive",
"resolved": "4.3.0",
"contentHash": "9ZQKCWxH7Ijp9BfahvL2Zyf1cJIk8XYLF6Yjzr2yi0b2cOut/HQ31qf1ThHAgCc3WiZMdnWcfJCgN82/0UunxA==",
"dependencies": {
"runtime.win.Microsoft.Win32.Primitives": "4.3.0"
}
},
"runtime.win.Microsoft.Win32.Primitives": {
"type": "Transitive",
"resolved": "4.3.0",
"contentHash": "NU51SEt/ZaD2MF48sJ17BIqx7rjeNNLXUevfMOjqQIetdndXwYjZfZsT6jD+rSWp/FYxjesdK4xUSl4OTEI0jw=="
},
"System.IO.Compression": {
"type": "Transitive",
"resolved": "4.3.0",
"contentHash": "YHndyoiV90iu4iKG115ibkhrG+S3jBm8Ap9OwoUAzO5oPDAWcr0SFwQFm0HjM8WkEZWo0zvLTyLmbvTkW1bXgg=="
},
"System.IO.Pipes.AccessControl": {
"type": "Transitive",
"resolved": "4.5.0",
"contentHash": "uqKLJb0Cukb8vG6JVKbJXOAmMWUWOue4ZTjMn7qrfGLZHww3iV8xV1amipI238kmmoFQx6I8GP2bjDM/ss5pQQ==",
"dependencies": {
"System.Security.AccessControl": "4.5.0",
"System.Security.Principal.Windows": "4.5.0"
}
},
"System.Runtime.InteropServices.RuntimeInformation": {
"type": "Transitive",
"resolved": "4.3.0",
"contentHash": "cbz4YJMqRDR7oLeMRbdYv7mYzc++17lNhScCX0goO2XpGWdvAt60CGN+FHdePUEHCe/Jy9jUlvNAiNdM+7jsOw=="
},
"System.Security.AccessControl": {
"type": "Transitive",
"resolved": "6.0.0",
"contentHash": "AUADIc0LIEQe7MzC+I0cl0rAT8RrTAKFHl53yHjEUzNVIaUlhFY11vc2ebiVJzVBuOzun6F7FBA+8KAbGTTedQ==",
"dependencies": {
"System.Security.Principal.Windows": "5.0.0"
}
},
"System.Security.Principal.Windows": {
"type": "Transitive",
"resolved": "5.0.0",
"contentHash": "t0MGLukB5WAVU9bO3MGzvlGnyJPgUlcwerXn1kzBRjwLKixT96XV0Uza41W49gVd8zEMFu9vQEFlv0IOrytICA=="
}
}
}
Expand Down
23 changes: 20 additions & 3 deletions PowerShellTools.Shared/Options/AnalysisOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,36 @@ internal class AnalysisOptions : BaseOptionModel<AnalysisOptions>
public event EventHandler<EventArgs<bool>> ScriptAnalyzerChanged;
public event EventHandler<EventArgs<bool>> SolutionWideAnalysisChanged;
public event EventHandler<EventArgs<bool>> AnalyzeOnSaveChanged;
public event EventHandler<EventArgs<string>> ConfigurationFileChanged;

public AnalysisOptions()
{
this.SolutionWideAnalysis = this.ScriptAnalyzer;
}

[DisplayName(@"Script Analyzer")]
[Description("When true, enables script analyzer support.")]
[DisplayName(@"Enable Script Analyzer")]
[Description("When true, enables PSScriptAnalyzer support.")]
public bool ScriptAnalyzer { get; set; }

[DisplayName(@"Solution Wide Analysis")]
[Description("When true, enables script analyzer support for the entire solution.")]
public bool SolutionWideAnalysis { get; set; }

[DisplayName(@"Analyze on Save")]
[Description("When true, analyzes a file when it is saved.")]
[Description("When true, analyzes a file when it is saved. When false, the script will be analyzed as you type.")]
public bool AnalyzeOnSave { get; set; }

[DisplayName(@"Configuration File")]
[Description("The path to a PSScriptAnalyzer configuration file.")]
public string ConfigurationFile { get; set; }

public override void Load()
{
var previousScriptAnalyzer = ScriptAnalyzer;
var previousSolutionWideAnalysis = SolutionWideAnalysis;
var previousAnalyzeOnSave = AnalyzeOnSave;
var previousConfigurationFile = ConfigurationFile;


base.Load();

Expand All @@ -50,6 +57,11 @@ public override void Load()
{
OnSolutionWideAnalysisChanged();
}

if (previousConfigurationFile != ConfigurationFile)
{
OnConfigurationFileChanged();
}
}

public override async Task LoadAsync()
Expand Down Expand Up @@ -90,5 +102,10 @@ public void OnSolutionWideAnalysisChanged()
{
SolutionWideAnalysisChanged?.Invoke(this, new EventArgs<bool>(SolutionWideAnalysis));
}

public void OnConfigurationFileChanged()
{
ConfigurationFileChanged?.Invoke(this, new EventArgs<string>(ConfigurationFile));
}
}
}
9 changes: 7 additions & 2 deletions PowerShellTools.Shared/Options/BaseOptionModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,11 @@ public virtual async Task SaveAsync()
/// </summary>
protected virtual string SerializeValue(object value)
{
if (value == null)
{
return null;
}

using (var stream = new MemoryStream())
{
var formatter = new BinaryFormatter();
Expand All @@ -180,10 +185,10 @@ protected virtual object DeserializeValue(string value, Type type)

private static async Task<ShellSettingsManager> GetSettingsManagerAsync()
{
#pragma warning disable VSTHRD010
#pragma warning disable VSTHRD010
// False-positive in Threading Analyzers. Bug tracked here https://github.com/Microsoft/vs-threading/issues/230
var svc = await AsyncServiceProvider.GlobalProvider.GetServiceAsync(typeof(SVsSettingsManager)) as IVsSettingsManager;
#pragma warning restore VSTHRD010
#pragma warning restore VSTHRD010

Assumes.Present(svc);

Expand Down
5 changes: 5 additions & 0 deletions PowerShellTools.Shared/Options/DialogPageProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ internal class DialogPageProvider
public class General : BaseOptionPage<GeneralOptions> {
public General() : base(x => new GeneralOptionsControl(x.Self)) { }
}

public class Analysis : BaseOptionPage<AnalysisOptions> { }

public class Diagnostics : BaseOptionPage<DiagnosticOptions> { }


}
}
3 changes: 0 additions & 3 deletions PowerShellTools.Shared/Options/GeneralOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ public GeneralOptions()
this.ShouldLoadProfiles = true;
this.TabComplete = true;
this.Sta = false;
this.DontShowLicenseInfoOnStartup = false;

var powershellLocator = new PowerShellLocator();
this.PowerShellVersion = powershellLocator.DefaultVersion;
Expand Down Expand Up @@ -73,7 +72,5 @@ public void OnPowerShellVersionChanged()

[DisplayName(@"Apartment State")]
public bool Sta { get; set; }
[DisplayName(@"Don't Show License Info On Startup")]
public bool DontShowLicenseInfoOnStartup { get; set; }
}
}
Loading

0 comments on commit e2c8738

Please sign in to comment.