From 97f701882d6c336d4aa00d2d2f58145e819096d3 Mon Sep 17 00:00:00 2001 From: David Wilson Date: Mon, 12 Dec 2016 14:41:07 -0800 Subject: [PATCH] Remove limitation for use of PSScriptAnalyzer on PowerShell 3.0 --- .../Session/EditorSession.cs | 31 +++++-------------- 1 file changed, 7 insertions(+), 24 deletions(-) diff --git a/src/PowerShellEditorServices/Session/EditorSession.cs b/src/PowerShellEditorServices/Session/EditorSession.cs index 4bc539959..80081d6aa 100644 --- a/src/PowerShellEditorServices/Session/EditorSession.cs +++ b/src/PowerShellEditorServices/Session/EditorSession.cs @@ -106,34 +106,17 @@ public void StartDebugSession(HostDetails hostDetails, ProfilePaths profilePaths internal void InstantiateAnalysisService(string settingsPath = null) { - // Only enable the AnalysisService if the machine has PowerShell - // v5 installed. Script Analyzer works on earlier PowerShell - // versions but our hard dependency on their binaries complicates - // the deployment and assembly loading since we would have to - // conditionally load the binaries for v3/v4 support. This problem - // will be solved in the future by using Script Analyzer as a - // module rather than an assembly dependency. - if (this.PowerShellContext.PowerShellVersion.Major >= 5) + // AnalysisService will throw FileNotFoundException if + // Script Analyzer binaries are not included. + try { - // AnalysisService will throw FileNotFoundException if - // Script Analyzer binaries are not included. - try - { - this.AnalysisService = new AnalysisService(this.PowerShellContext.ConsoleHost, settingsPath); - } - catch (FileNotFoundException) - { - Logger.Write( - LogLevel.Warning, - "Script Analyzer binaries not found, AnalysisService will be disabled."); - } + this.AnalysisService = new AnalysisService(this.PowerShellContext.ConsoleHost, settingsPath); } - else + catch (FileNotFoundException) { Logger.Write( - LogLevel.Normal, - "Script Analyzer cannot be loaded due to unsupported PowerShell version " + - this.PowerShellContext.PowerShellVersion.ToString()); + LogLevel.Warning, + "Script Analyzer binaries not found, AnalysisService will be disabled."); } }