Skip to content

Commit 08d045a

Browse files
author
Kapil Borle
committed
Add xml comment in AnalysisService class
1 parent 0f42699 commit 08d045a

File tree

2 files changed

+21
-33
lines changed

2 files changed

+21
-33
lines changed

src/PowerShellEditorServices.Protocol/Server/LanguageServer.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -199,18 +199,12 @@ private async Task HandleSetPSSARulesRequest(
199199
}
200200

201201
var sendresult = requestContext.SendResult(null);
202-
// send the file uri from the client
203-
// retrieve the file
204-
// requestcontext is the eventcontext
205202
var scripFile = editorSession.Workspace.GetFile((string)dynParams.filepath);
206203
await RunScriptDiagnostics(
207204
new ScriptFile[] { scripFile },
208205
editorSession,
209206
requestContext.SendEvent);
210-
211207
await sendresult;
212-
213-
//await requestContext.SendResult(null);
214208
}
215209

216210
private async Task HandleGetPSSARulesRequest(

src/PowerShellEditorServices/Analysis/AnalysisService.cs

Lines changed: 21 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -42,24 +42,15 @@ public class AnalysisService : IDisposable
4242
"PSMisleadingBacktick",
4343
};
4444

45-
private List<string> activeRules;
46-
4745
#endregion // Private Fields
4846

4947

5048
#region Properties
5149

52-
public string[] ActiveRules
53-
{
54-
get
55-
{
56-
return activeRules != null ? activeRules.ToArray() : null;
57-
}
58-
set
59-
{
60-
activeRules = new List<string>(value); // TODO check the argument
61-
}
62-
}
50+
/// <summary>
51+
/// Set of PSScriptAnalyzer rules used for analysis
52+
/// </summary>
53+
public string[] ActiveRules { get; set; }
6354

6455
/// <summary>
6556
/// Gets or sets the path to a settings file (.psd1)
@@ -89,7 +80,7 @@ public AnalysisService(IConsoleHost consoleHost, string settingsPath = null)
8980
this.analysisRunspace = RunspaceFactory.CreateRunspace(InitialSessionState.CreateDefault2());
9081
this.analysisRunspace.ThreadOptions = PSThreadOptions.ReuseThread;
9182
this.analysisRunspace.Open();
92-
activeRules = new List<string>(IncludedRules);
83+
ActiveRules = IncludedRules.ToArray();
9384
InitializePSScriptAnalyzer();
9485
}
9586
catch (Exception e)
@@ -141,18 +132,8 @@ public ScriptFileMarker[] GetSemanticMarkers(ScriptFile file)
141132
}
142133

143134
/// <summary>
144-
/// Disposes the runspace being used by the analysis service.
135+
/// Returns a list of builtin-in PSScriptAnalyzer rules
145136
/// </summary>
146-
public void Dispose()
147-
{
148-
if (this.analysisRunspace != null)
149-
{
150-
this.analysisRunspace.Close();
151-
this.analysisRunspace.Dispose();
152-
this.analysisRunspace = null;
153-
}
154-
}
155-
156137
public IEnumerable<string> GetPSScriptAnalyzerRules()
157138
{
158139
List<string> ruleNames = new List<string>();
@@ -162,7 +143,7 @@ public IEnumerable<string> GetPSScriptAnalyzerRules()
162143
{
163144
ps.Runspace = this.analysisRunspace;
164145
var ruleObjects = ps.AddCommand("Get-ScriptAnalyzerRule").Invoke();
165-
foreach(var rule in ruleObjects)
146+
foreach (var rule in ruleObjects)
166147
{
167148
ruleNames.Add((string)rule.Members["RuleName"].Value);
168149
}
@@ -172,6 +153,19 @@ public IEnumerable<string> GetPSScriptAnalyzerRules()
172153
return ruleNames;
173154
}
174155

156+
/// <summary>
157+
/// Disposes the runspace being used by the analysis service.
158+
/// </summary>
159+
public void Dispose()
160+
{
161+
if (this.analysisRunspace != null)
162+
{
163+
this.analysisRunspace.Close();
164+
this.analysisRunspace.Dispose();
165+
this.analysisRunspace = null;
166+
}
167+
}
168+
175169
#endregion // public methods
176170

177171
#region Private Methods
@@ -280,7 +274,7 @@ private IEnumerable<PSObject> GetDiagnosticRecords(ScriptFile file)
280274
}
281275
else
282276
{
283-
powerShell.AddParameter("IncludeRule", activeRules.ToArray());
277+
powerShell.AddParameter("IncludeRule", ActiveRules);
284278
}
285279

286280
diagnosticRecords = powerShell.Invoke();

0 commit comments

Comments
 (0)