Skip to content

Commit 1469738

Browse files
author
Kapil Borle
committed
Add filepath property to settings class
1 parent 02db72f commit 1469738

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

Engine/Generic/Settings.cs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,17 @@ namespace Microsoft.Windows.PowerShell.ScriptAnalyzer.Generic
2121
{
2222
public class Settings
2323
{
24+
private string filePath;
2425
private List<string> includeRules;
2526
private List<string> excludeRules;
2627
private List<string> severities;
2728
private Dictionary<string, Dictionary<string, object>> ruleArguments;
2829

29-
public IEnumerable<string> IncludeRules { get { return includeRules; }}
30-
public IEnumerable<string> ExcludeRules { get { return excludeRules; }}
31-
public IEnumerable<string> Severity { get { return severities; }}
32-
public Dictionary<string, Dictionary<string, object>> RuleArguments { get { return ruleArguments; }}
30+
public string FilePath { get { return filePath; } }
31+
public IEnumerable<string> IncludeRules { get { return includeRules; } }
32+
public IEnumerable<string> ExcludeRules { get { return excludeRules; } }
33+
public IEnumerable<string> Severity { get { return severities; } }
34+
public Dictionary<string, Dictionary<string, object>> RuleArguments { get { return ruleArguments; } }
3335

3436
public Settings(object settings, Func<string, string> presetResolver)
3537
{
@@ -38,6 +40,10 @@ public Settings(object settings, Func<string, string> presetResolver)
3840
throw new ArgumentNullException("settings");
3941
}
4042

43+
includeRules = new List<string>();
44+
excludeRules = new List<string>();
45+
severities = new List<string>();
46+
ruleArguments = new Dictionary<string, Dictionary<string, object>>(StringComparer.OrdinalIgnoreCase);
4147
var settingsFilePath = settings as string;
4248

4349
//it can either be a preset or path to a file or a hashtable
@@ -54,6 +60,7 @@ public Settings(object settings, Func<string, string> presetResolver)
5460

5561
if (File.Exists(settingsFilePath))
5662
{
63+
filePath = settingsFilePath;
5764
parseSettingsFile(settingsFilePath);
5865
}
5966
else
@@ -92,6 +99,7 @@ private Dictionary<string, object> GetDictionaryFromHashtable(Hashtable hashtabl
9299
string key = obj as string;
93100
if (key == null)
94101
{
102+
// TODO localize
95103
throw new InvalidDataException("key not string");
96104
// writer.WriteError(
97105
// new ErrorRecord(

0 commit comments

Comments
 (0)