Skip to content

Commit ddb2bba

Browse files
authored
Merge pull request #317 from PowerShell/daviwil/scriptanalyzer-on-v3
Remove limitation for use of PSScriptAnalyzer on PowerShell 3.0
2 parents f04823d + 97f7018 commit ddb2bba

File tree

1 file changed

+7
-24
lines changed

1 file changed

+7
-24
lines changed

src/PowerShellEditorServices/Session/EditorSession.cs

+7-24
Original file line numberDiff line numberDiff line change
@@ -106,34 +106,17 @@ public void StartDebugSession(HostDetails hostDetails, ProfilePaths profilePaths
106106

107107
internal void InstantiateAnalysisService(string settingsPath = null)
108108
{
109-
// Only enable the AnalysisService if the machine has PowerShell
110-
// v5 installed. Script Analyzer works on earlier PowerShell
111-
// versions but our hard dependency on their binaries complicates
112-
// the deployment and assembly loading since we would have to
113-
// conditionally load the binaries for v3/v4 support. This problem
114-
// will be solved in the future by using Script Analyzer as a
115-
// module rather than an assembly dependency.
116-
if (this.PowerShellContext.PowerShellVersion.Major >= 5)
109+
// AnalysisService will throw FileNotFoundException if
110+
// Script Analyzer binaries are not included.
111+
try
117112
{
118-
// AnalysisService will throw FileNotFoundException if
119-
// Script Analyzer binaries are not included.
120-
try
121-
{
122-
this.AnalysisService = new AnalysisService(this.PowerShellContext.ConsoleHost, settingsPath);
123-
}
124-
catch (FileNotFoundException)
125-
{
126-
Logger.Write(
127-
LogLevel.Warning,
128-
"Script Analyzer binaries not found, AnalysisService will be disabled.");
129-
}
113+
this.AnalysisService = new AnalysisService(this.PowerShellContext.ConsoleHost, settingsPath);
130114
}
131-
else
115+
catch (FileNotFoundException)
132116
{
133117
Logger.Write(
134-
LogLevel.Normal,
135-
"Script Analyzer cannot be loaded due to unsupported PowerShell version " +
136-
this.PowerShellContext.PowerShellVersion.ToString());
118+
LogLevel.Warning,
119+
"Script Analyzer binaries not found, AnalysisService will be disabled.");
137120
}
138121
}
139122

0 commit comments

Comments
 (0)