Skip to content

Remove limitation for use of PSScriptAnalyzer on PowerShell 3.0 #317

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 12, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 7 additions & 24 deletions src/PowerShellEditorServices/Session/EditorSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
}
}

Expand Down