Skip to content

Commit 42472a0

Browse files
author
Quoc Truong
committed
Merge pull request #404 from PowerShell/HashtableConfiguration
Allow scriptanalyzer to accept configuration in the form of a hashtable
2 parents c39b041 + 0cf22a1 commit 42472a0

File tree

6 files changed

+373
-160
lines changed

6 files changed

+373
-160
lines changed

Engine/Commands/InvokeScriptAnalyzerCommand.cs

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -169,17 +169,18 @@ public SwitchParameter SuppressedOnly
169169
private bool suppressedOnly;
170170

171171
/// <summary>
172-
/// Returns path to the file that contains user profile for ScriptAnalyzer
172+
/// Returns path to the file that contains user profile or hash table for ScriptAnalyzer
173173
/// </summary>
174174
[Alias("Profile")]
175175
[Parameter(Mandatory = false)]
176176
[ValidateNotNull]
177-
public string Configuration
177+
public object Settings
178178
{
179-
get { return configuration; }
180-
set { configuration = value; }
179+
get { return settings; }
180+
set { settings = value; }
181181
}
182-
private string configuration;
182+
183+
private object settings;
183184

184185
private bool stopProcessing;
185186

@@ -195,7 +196,7 @@ protected override void BeginProcessing()
195196
string[] rulePaths = Helper.ProcessCustomRulePaths(customRulePath,
196197
this.SessionState, recurseCustomRulePath);
197198

198-
if (!ScriptAnalyzer.Instance.ParseProfile(this.configuration, this.SessionState.Path, this))
199+
if (!ScriptAnalyzer.Instance.ParseProfile(this.settings, this.SessionState.Path, this))
199200
{
200201
stopProcessing = true;
201202
return;
@@ -208,8 +209,7 @@ protected override void BeginProcessing()
208209
this.excludeRule,
209210
this.severity,
210211
null == rulePaths ? true : this.includeDefaultRules,
211-
this.suppressedOnly,
212-
this.configuration);
212+
this.suppressedOnly);
213213
}
214214

215215
/// <summary>
@@ -238,6 +238,18 @@ protected override void ProcessRecord()
238238
}
239239
}
240240

241+
protected override void EndProcessing()
242+
{
243+
ScriptAnalyzer.Instance.CleanUp();
244+
base.EndProcessing();
245+
}
246+
247+
protected override void StopProcessing()
248+
{
249+
ScriptAnalyzer.Instance.CleanUp();
250+
base.StopProcessing();
251+
}
252+
241253
#endregion
242254

243255
#region Methods

0 commit comments

Comments
 (0)