Skip to content

Commit 30f246b

Browse files
authored
Merge pull request #277 from PowerShell/release/0.7.1
Release 0.7.1
2 parents 5940ad1 + db267b5 commit 30f246b

File tree

11 files changed

+136
-97
lines changed

11 files changed

+136
-97
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# PowerShell Editor Services Release History
22

3+
## 0.7.1
4+
### Tuesday, August 23, 2016
5+
6+
- Fixed PowerShell/vscode-powerShell#246: Restore default PSScriptAnalyzer ruleset
7+
- Fixed PowerShell/vscode-powershell#248: Extension fails to load on Windows 7 with PowerShell v3
8+
39
## 0.7.0
410
### Thursday, August 18, 2016
511

appveyor.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ clone_depth: 10
55
skip_tags: true
66

77
environment:
8-
core_version: '0.7.0'
8+
core_version: '0.7.1'
99
prerelease_name: '-beta'
1010

1111
branches:

module/PowerShellEditorServices/PowerShellEditorServices.psd1

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
RootModule = 'PowerShellEditorServices.psm1'
1313

1414
# Version number of this module.
15-
ModuleVersion = '0.7.0'
15+
ModuleVersion = '0.7.1'
1616

1717
# ID used to uniquely identify this module
1818
GUID = '9ca15887-53a2-479a-9cda-48d26bcb6c47'
@@ -33,7 +33,7 @@ Copyright = '(c) 2016 Microsoft. All rights reserved.'
3333
# PowerShellVersion = ''
3434

3535
# Name of the Windows PowerShell host required by this module
36-
#PowerShellHostName = ''
36+
# PowerShellHostName = ''
3737

3838
# Minimum version of the Windows PowerShell host required by this module
3939
# PowerShellHostVersion = ''
@@ -72,7 +72,7 @@ FunctionsToExport = @('Start-EditorServicesHost')
7272
CmdletsToExport = @()
7373

7474
# Variables to export from this module
75-
VariablesToExport = '*'
75+
VariablesToExport = @()
7676

7777
# Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export.
7878
AliasesToExport = @()

module/PowerShellEditorServices/PowerShellEditorServices.psm1

+4-4
Original file line numberDiff line numberDiff line change
@@ -50,17 +50,17 @@ function Start-EditorServicesHost {
5050
)
5151

5252
$editorServicesHost = $null
53-
$hostDetails = [Microsoft.PowerShell.EditorServices.Session.HostDetails]::new($HostName, $HostProfileId, [System.Version]::new($HostVersion))
53+
$hostDetails = New-Object Microsoft.PowerShell.EditorServices.Session.HostDetails @($HostName, $HostProfileId, (New-Object System.Version @($HostVersion)))
5454

5555
try {
5656
$editorServicesHost =
57-
[Microsoft.PowerShell.EditorServices.Host.EditorServicesHost]::new(
57+
New-Object Microsoft.PowerShell.EditorServices.Host.EditorServicesHost @(
5858
$hostDetails,
5959
$BundledModulesPath,
60-
$WaitForDebugger.IsPresent);
60+
$WaitForDebugger.IsPresent)
6161

6262
# Build the profile paths using the root paths of the current $profile variable
63-
$profilePaths = [Microsoft.PowerShell.EditorServices.Session.ProfilePaths]::new(
63+
$profilePaths = New-Object Microsoft.PowerShell.EditorServices.Session.ProfilePaths @(
6464
$hostDetails.ProfileId,
6565
[System.IO.Path]::GetDirectoryName($profile.AllUsersAllHosts),
6666
[System.IO.Path]::GetDirectoryName($profile.CurrentUserAllHosts));

src/PowerShellEditorServices.Host/EditorServicesHost.cs

+17-6
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,20 @@ public void StartLogging(string logFilePath, LogLevel logLevel)
9696
{
9797
Logger.Initialize(logFilePath, logLevel);
9898

99-
FileVersionInfo fileVersionInfo =
10099
#if NanoServer
100+
FileVersionInfo fileVersionInfo =
101101
FileVersionInfo.GetVersionInfo(this.GetType().GetTypeInfo().Assembly.Location);
102+
103+
// TODO #278: Need the correct dependency package for this to work correctly
104+
//string osVersionString = RuntimeInformation.OSDescription;
105+
//string processArchitecture = RuntimeInformation.ProcessArchitecture == Architecture.X64 ? "64-bit" : "32-bit";
106+
//string osArchitecture = RuntimeInformation.OSArchitecture == Architecture.X64 ? "64-bit" : "32-bit";
102107
#else
108+
FileVersionInfo fileVersionInfo =
103109
FileVersionInfo.GetVersionInfo(this.GetType().Assembly.Location);
110+
string osVersionString = Environment.OSVersion.VersionString;
111+
string processArchitecture = Environment.Is64BitProcess ? "64-bit" : "32-bit";
112+
string osArchitecture = Environment.Is64BitOperatingSystem ? "64-bit" : "32-bit";
104113
#endif
105114

106115
string newLine = Environment.NewLine;
@@ -113,12 +122,14 @@ public void StartLogging(string logFilePath, LogLevel logLevel)
113122
$" Name: {this.hostDetails.Name}" + newLine +
114123
$" ProfileId: {this.hostDetails.ProfileId}" + newLine +
115124
$" Version: {this.hostDetails.Version}" + newLine +
116-
" Arch: {0}" + newLine + newLine +
125+
#if !NanoServer
126+
$" Arch: {processArchitecture}" + newLine + newLine +
117127
" Operating system details:" + newLine + newLine +
118-
$" Version: {Environment.OSVersion.VersionString}" + newLine +
119-
" Arch: {1}",
120-
Environment.Is64BitProcess ? "64-bit" : "32-bit",
121-
Environment.Is64BitOperatingSystem ? "64-bit" : "32-bit"));
128+
$" Version: {osVersionString}" + newLine +
129+
$" Arch: {osArchitecture}"));
130+
#else
131+
""));
132+
#endif
122133
}
123134

124135
/// <summary>

src/PowerShellEditorServices.Protocol/DebugAdapter/Scope.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ public static Scope Create(VariableScope scope)
3030
Name = scope.Name,
3131
VariablesReference = scope.Id,
3232
// Temporary fix for #95 to get debug hover tips to work well at least for the local scope.
33-
Expensive = (scope.Name != VariableContainerDetails.LocalScopeName)
33+
Expensive = ((scope.Name != VariableContainerDetails.LocalScopeName) &&
34+
(scope.Name != VariableContainerDetails.AutoVariablesName))
3435
};
3536
}
3637
}

src/PowerShellEditorServices/Analysis/AnalysisService.cs

+13-3
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,12 @@ private void FindPSScriptAnalyzer()
130130
using (var ps = System.Management.Automation.PowerShell.Create())
131131
{
132132
ps.Runspace = this.analysisRunspace;
133+
133134
var modules = ps.AddCommand("Get-Module")
134135
.AddParameter("List")
135136
.AddParameter("Name", "PSScriptAnalyzer")
136137
.Invoke();
138+
137139
var psModule = modules == null ? null : modules.FirstOrDefault();
138140
if (psModule != null)
139141
{
@@ -160,10 +162,12 @@ private void ImportPSScriptAnalyzer()
160162
using (var ps = System.Management.Automation.PowerShell.Create())
161163
{
162164
ps.Runspace = this.analysisRunspace;
163-
var module = ps.AddCommand("Import-Module").
164-
AddParameter("ModuleInfo", scriptAnalyzerModuleInfo)
165+
166+
var module = ps.AddCommand("Import-Module")
167+
.AddParameter("ModuleInfo", scriptAnalyzerModuleInfo)
165168
.AddParameter("PassThru")
166169
.Invoke();
170+
167171
if (module == null)
168172
{
169173
this.scriptAnalyzerModuleInfo = null;
@@ -186,13 +190,16 @@ private void EnumeratePSScriptAnalyzerRules()
186190
using (var ps = System.Management.Automation.PowerShell.Create())
187191
{
188192
ps.Runspace = this.analysisRunspace;
193+
189194
var rules = ps.AddCommand("Get-ScriptAnalyzerRule").Invoke();
190195
var sb = new StringBuilder();
191196
sb.AppendLine("Available PSScriptAnalyzer Rules:");
197+
192198
foreach (var rule in rules)
193199
{
194200
sb.AppendLine((string)rule.Members["RuleName"].Value);
195201
}
202+
196203
Logger.Write(LogLevel.Verbose, sb.ToString());
197204
}
198205
}
@@ -209,6 +216,7 @@ private void InitializePSScriptAnalyzer()
209216
private IEnumerable<PSObject> GetDiagnosticRecords(ScriptFile file)
210217
{
211218
IEnumerable<PSObject> diagnosticRecords = Enumerable.Empty<PSObject>();
219+
212220
if (this.scriptAnalyzerModuleInfo != null)
213221
{
214222
using (var ps = System.Management.Automation.PowerShell.Create())
@@ -218,15 +226,17 @@ private IEnumerable<PSObject> GetDiagnosticRecords(ScriptFile file)
218226
LogLevel.Verbose,
219227
String.Format("Running PSScriptAnalyzer against {0}", file.FilePath));
220228

221-
// currently not working with include rules
222229
diagnosticRecords = ps.AddCommand("Invoke-ScriptAnalyzer")
223230
.AddParameter("ScriptDefinition", file.Contents)
231+
.AddParameter("IncludeRule", IncludedRules)
224232
.Invoke();
225233
}
226234
}
235+
227236
Logger.Write(
228237
LogLevel.Verbose,
229238
String.Format("Found {0} violations", diagnosticRecords.Count()));
239+
230240
return diagnosticRecords;
231241
}
232242

src/PowerShellEditorServices/Language/AstOperations.cs

+11-9
Original file line numberDiff line numberDiff line change
@@ -197,15 +197,17 @@ static public IEnumerable<SymbolReference> FindSymbolsInDocument(Ast scriptAst,
197197
{
198198
IEnumerable<SymbolReference> symbolReferences = null;
199199

200-
if (powerShellVersion >= new Version(5,0))
201-
{
202-
#if PowerShellv5
203-
FindSymbolsVisitor2 findSymbolsVisitor = new FindSymbolsVisitor2();
204-
scriptAst.Visit(findSymbolsVisitor);
205-
symbolReferences = findSymbolsVisitor.SymbolReferences;
206-
#endif
207-
}
208-
else
200+
// TODO: Restore this when we figure out how to support multiple
201+
// PS versions in the new PSES-as-a-module world (issue #276)
202+
// if (powerShellVersion >= new Version(5,0))
203+
// {
204+
//#if PowerShellv5
205+
// FindSymbolsVisitor2 findSymbolsVisitor = new FindSymbolsVisitor2();
206+
// scriptAst.Visit(findSymbolsVisitor);
207+
// symbolReferences = findSymbolsVisitor.SymbolReferences;
208+
//#endif
209+
// }
210+
// else
209211
{
210212
FindSymbolsVisitor findSymbolsVisitor = new FindSymbolsVisitor();
211213
scriptAst.Visit(findSymbolsVisitor);

src/PowerShellEditorServices/Language/FindSymbolsVisitor2.cs

+62-57
Original file line numberDiff line numberDiff line change
@@ -9,70 +9,75 @@
99
namespace Microsoft.PowerShell.EditorServices
1010
{
1111
#if PowerShellv5
12-
/// <summary>
13-
/// The visitor used to find all the symbols (function and class defs) in the AST.
14-
/// </summary>
15-
/// <remarks>
16-
/// Requires PowerShell v5 or higher
17-
/// </remarks>
18-
internal class FindSymbolsVisitor2 : AstVisitor2
19-
{
20-
private FindSymbolsVisitor findSymbolsVisitor;
2112

22-
public List<SymbolReference> SymbolReferences
23-
{
24-
get
25-
{
26-
return this.findSymbolsVisitor.SymbolReferences;
27-
}
28-
}
13+
// TODO: Restore this when we figure out how to support multiple
14+
// PS versions in the new PSES-as-a-module world (issue #276)
2915

30-
public FindSymbolsVisitor2()
31-
{
32-
this.findSymbolsVisitor = new FindSymbolsVisitor();
33-
}
16+
///// <summary>
17+
///// The visitor used to find all the symbols (function and class defs) in the AST.
18+
///// </summary>
19+
///// <remarks>
20+
///// Requires PowerShell v5 or higher
21+
///// </remarks>
22+
/////
23+
//internal class FindSymbolsVisitor2 : AstVisitor2
24+
//{
25+
// private FindSymbolsVisitor findSymbolsVisitor;
3426

35-
/// <summary>
36-
/// Adds each function defintion as a
37-
/// </summary>
38-
/// <param name="functionDefinitionAst">A functionDefinitionAst object in the script's AST</param>
39-
/// <returns>A decision to stop searching if the right symbol was found,
40-
/// or a decision to continue if it wasn't found</returns>
41-
public override AstVisitAction VisitFunctionDefinition(FunctionDefinitionAst functionDefinitionAst)
42-
{
43-
return this.findSymbolsVisitor.VisitFunctionDefinition(functionDefinitionAst);
44-
}
27+
// public List<SymbolReference> SymbolReferences
28+
// {
29+
// get
30+
// {
31+
// return this.findSymbolsVisitor.SymbolReferences;
32+
// }
33+
// }
4534

46-
/// <summary>
47-
/// Checks to see if this variable expression is the symbol we are looking for.
48-
/// </summary>
49-
/// <param name="variableExpressionAst">A VariableExpressionAst object in the script's AST</param>
50-
/// <returns>A descion to stop searching if the right symbol was found,
51-
/// or a decision to continue if it wasn't found</returns>
52-
public override AstVisitAction VisitVariableExpression(VariableExpressionAst variableExpressionAst)
53-
{
54-
return this.findSymbolsVisitor.VisitVariableExpression(variableExpressionAst);
55-
}
35+
// public FindSymbolsVisitor2()
36+
// {
37+
// this.findSymbolsVisitor = new FindSymbolsVisitor();
38+
// }
5639

57-
public override AstVisitAction VisitConfigurationDefinition(ConfigurationDefinitionAst configurationDefinitionAst)
58-
{
59-
IScriptExtent nameExtent = new ScriptExtent()
60-
{
61-
Text = configurationDefinitionAst.InstanceName.Extent.Text,
62-
StartLineNumber = configurationDefinitionAst.Extent.StartLineNumber,
63-
EndLineNumber = configurationDefinitionAst.Extent.EndLineNumber,
64-
StartColumnNumber = configurationDefinitionAst.Extent.StartColumnNumber,
65-
EndColumnNumber = configurationDefinitionAst.Extent.EndColumnNumber
66-
};
40+
// /// <summary>
41+
// /// Adds each function defintion as a
42+
// /// </summary>
43+
// /// <param name="functionDefinitionAst">A functionDefinitionAst object in the script's AST</param>
44+
// /// <returns>A decision to stop searching if the right symbol was found,
45+
// /// or a decision to continue if it wasn't found</returns>
46+
// public override AstVisitAction VisitFunctionDefinition(FunctionDefinitionAst functionDefinitionAst)
47+
// {
48+
// return this.findSymbolsVisitor.VisitFunctionDefinition(functionDefinitionAst);
49+
// }
6750

68-
this.findSymbolsVisitor.SymbolReferences.Add(
69-
new SymbolReference(
70-
SymbolType.Configuration,
71-
nameExtent));
51+
// /// <summary>
52+
// /// Checks to see if this variable expression is the symbol we are looking for.
53+
// /// </summary>
54+
// /// <param name="variableExpressionAst">A VariableExpressionAst object in the script's AST</param>
55+
// /// <returns>A descion to stop searching if the right symbol was found,
56+
// /// or a decision to continue if it wasn't found</returns>
57+
// public override AstVisitAction VisitVariableExpression(VariableExpressionAst variableExpressionAst)
58+
// {
59+
// return this.findSymbolsVisitor.VisitVariableExpression(variableExpressionAst);
60+
// }
7261

73-
return AstVisitAction.Continue;
74-
}
75-
}
62+
// public override AstVisitAction VisitConfigurationDefinition(ConfigurationDefinitionAst configurationDefinitionAst)
63+
// {
64+
// IScriptExtent nameExtent = new ScriptExtent()
65+
// {
66+
// Text = configurationDefinitionAst.InstanceName.Extent.Text,
67+
// StartLineNumber = configurationDefinitionAst.Extent.StartLineNumber,
68+
// EndLineNumber = configurationDefinitionAst.Extent.EndLineNumber,
69+
// StartColumnNumber = configurationDefinitionAst.Extent.StartColumnNumber,
70+
// EndColumnNumber = configurationDefinitionAst.Extent.EndColumnNumber
71+
// };
72+
73+
// this.findSymbolsVisitor.SymbolReferences.Add(
74+
// new SymbolReference(
75+
// SymbolType.Configuration,
76+
// nameExtent));
77+
78+
// return AstVisitAction.Continue;
79+
// }
80+
//}
7681
#endif
7782
}
7883

test/PowerShellEditorServices.Test.Host/ServerTestsBase.cs

+11-8
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,19 @@ protected async Task<Tuple<int, int>> LaunchService(
3434
string scriptPath = Path.Combine(modulePath, "Start-EditorServices.ps1");
3535

3636
// TODO: Need to determine the right module version programmatically!
37+
string editorServicesModuleVersion = "0.7.1";
3738

3839
string scriptArgs =
39-
"\"" + scriptPath + "\" " +
40-
"-EditorServicesVersion \"0.7.0\" " +
41-
"-HostName \\\"PowerShell Editor Services Test Host\\\" " +
42-
"-HostProfileId \"Test.PowerShellEditorServices\" " +
43-
"-HostVersion \"1.0.0\" " +
44-
"-BundledModulesPath \\\"" + modulePath + "\\\" " +
45-
"-LogLevel \"Verbose\" " +
46-
"-LogPath \"" + logPath + "\" ";
40+
string.Format(
41+
"\"" + scriptPath + "\" " +
42+
"-EditorServicesVersion \"{0}\" " +
43+
"-HostName \\\"PowerShell Editor Services Test Host\\\" " +
44+
"-HostProfileId \"Test.PowerShellEditorServices\" " +
45+
"-HostVersion \"1.0.0\" " +
46+
"-BundledModulesPath \\\"" + modulePath + "\\\" " +
47+
"-LogLevel \"Verbose\" " +
48+
"-LogPath \"" + logPath + "\" ",
49+
editorServicesModuleVersion);
4750

4851
if (waitForDebugger)
4952
{

0 commit comments

Comments
 (0)