|
17 | 17 | using System.IO; |
18 | 18 | using System.Linq; |
19 | 19 | using System.Management.Automation.Language; |
| 20 | +using System.Reflection; |
20 | 21 | using System.Text.RegularExpressions; |
21 | 22 | using Microsoft.Windows.PowerShell.ScriptAnalyzer.Generic; |
22 | 23 |
|
@@ -100,21 +101,42 @@ private void SetupCmdletsDictionary() |
100 | 101 | } |
101 | 102 | } |
102 | 103 |
|
103 | | - var mode = GetStringArgFromListStringArg(ruleArgs["mode"]); |
104 | | - switch (mode) |
| 104 | + object modeObject; |
| 105 | + if (ruleArgs.TryGetValue("mode", out modeObject)) |
105 | 106 | { |
106 | | - case "online": |
107 | | - ProcessOnlineModeArgs(ruleArgs); |
108 | | - break; |
| 107 | + // This is for testing only. User should not be specifying mode! |
| 108 | + var mode = GetStringArgFromListStringArg(modeObject); |
| 109 | + switch (mode) |
| 110 | + { |
| 111 | + case "online": |
| 112 | + ProcessOnlineModeArgs(ruleArgs); |
| 113 | + break; |
109 | 114 |
|
110 | | - case "offline": |
111 | | - ProcessOfflineModeArgs(ruleArgs); |
112 | | - break; |
| 115 | + case "offline": |
| 116 | + ProcessOfflineModeArgs(ruleArgs); |
| 117 | + break; |
113 | 118 |
|
114 | | - case null: |
115 | | - default: |
116 | | - return; |
| 119 | + case null: |
| 120 | + default: |
| 121 | + break; |
| 122 | + } |
| 123 | + |
| 124 | + return; |
| 125 | + } |
| 126 | + |
| 127 | + // Find the compatibility files in Settings folder |
| 128 | + var path = this.GetType().GetTypeInfo().Assembly.Location; |
| 129 | + if (String.IsNullOrWhiteSpace(path)) |
| 130 | + { |
| 131 | + return; |
117 | 132 | } |
| 133 | + |
| 134 | + var settingsPath = Path.Combine(Path.GetDirectoryName(path), "Settings"); |
| 135 | + if (!Directory.Exists(settingsPath)) |
| 136 | + { |
| 137 | + return; |
| 138 | + } |
| 139 | + ProcessDirectory(settingsPath); |
118 | 140 | } |
119 | 141 |
|
120 | 142 | private bool GetVersionInfoFromPlatformString( |
@@ -166,7 +188,13 @@ private void ProcessOfflineModeArgs(Dictionary<string, object> ruleArgs) |
166 | 188 | // TODO: log this |
167 | 189 | return; |
168 | 190 | } |
169 | | - foreach (var filePath in Directory.EnumerateFiles(uri)) |
| 191 | + |
| 192 | + ProcessDirectory(uri); |
| 193 | + } |
| 194 | + |
| 195 | + private void ProcessDirectory(string path) |
| 196 | + { |
| 197 | + foreach (var filePath in Directory.EnumerateFiles(path)) |
170 | 198 | { |
171 | 199 | var extension = Path.GetExtension(filePath); |
172 | 200 | if (String.IsNullOrWhiteSpace(extension) |
|
0 commit comments