File tree Expand file tree Collapse file tree 2 files changed +31
-30
lines changed Expand file tree Collapse file tree 2 files changed +31
-30
lines changed Original file line number Diff line number Diff line change 21
21
using Microsoft . Windows . PowerShell . ScriptAnalyzer . Generic ;
22
22
using System . Management . Automation . Runspaces ;
23
23
using System . Collections ;
24
+ using System . Reflection ;
24
25
25
26
namespace Microsoft . Windows . PowerShell . ScriptAnalyzer
26
27
{
@@ -172,6 +173,35 @@ public void Initialize()
172
173
}
173
174
}
174
175
176
+ /// <summary>
177
+ /// Retrieves the Settings directory from the Module directory structure
178
+ /// </summary>
179
+ public static string GetShippedSettingsDirectory ( )
180
+ {
181
+ // Find the compatibility files in Settings folder
182
+ var path = typeof ( Helper ) . GetTypeInfo ( ) . Assembly . Location ;
183
+ if ( String . IsNullOrWhiteSpace ( path ) )
184
+ {
185
+ return null ;
186
+ }
187
+
188
+ var settingsPath = Path . Combine ( Path . GetDirectoryName ( path ) , "Settings" ) ;
189
+ if ( ! Directory . Exists ( settingsPath ) )
190
+ {
191
+ // try one level down as the PSScriptAnalyzer module structure is not consistent
192
+ // CORECLR binaries are in PSScriptAnalyzer/coreclr/, PowerShell v3 binaries are in PSScriptAnalyzer/PSv3/
193
+ // and PowerShell v5 binaries are in PSScriptAnalyzer/
194
+ settingsPath = Path . Combine ( Path . GetDirectoryName ( Path . GetDirectoryName ( path ) ) , "Settings" ) ;
195
+ if ( ! Directory . Exists ( settingsPath ) )
196
+ {
197
+ return null ;
198
+ }
199
+ }
200
+
201
+ return settingsPath ;
202
+ }
203
+
204
+
175
205
/// <summary>
176
206
/// Returns all the rule arguments
177
207
/// </summary>
Original file line number Diff line number Diff line change @@ -306,8 +306,7 @@ private void SetupCmdletsDictionary()
306
306
return ;
307
307
}
308
308
309
- string settingsPath ;
310
- settingsPath = GetShippedSettingsDirectory ( ) ;
309
+ string settingsPath = Helper . GetShippedSettingsDirectory ( ) ;
311
310
#if DEBUG
312
311
object modeObject ;
313
312
if ( ruleArgs . TryGetValue ( "mode" , out modeObject ) )
@@ -381,34 +380,6 @@ private void ResetCurCmdletCompatibilityMap()
381
380
}
382
381
}
383
382
384
- /// <summary>
385
- /// Retrieves the Settings directory from the Module directory structure
386
- /// </summary>
387
- private string GetShippedSettingsDirectory ( )
388
- {
389
- // Find the compatibility files in Settings folder
390
- var path = this . GetType ( ) . GetTypeInfo ( ) . Assembly . Location ;
391
- if ( String . IsNullOrWhiteSpace ( path ) )
392
- {
393
- return null ;
394
- }
395
-
396
- var settingsPath = Path . Combine ( Path . GetDirectoryName ( path ) , "Settings" ) ;
397
- if ( ! Directory . Exists ( settingsPath ) )
398
- {
399
- // try one level down as the PSScriptAnalyzer module structure is not consistent
400
- // CORECLR binaries are in PSScriptAnalyzer/coreclr/, PowerShell v3 binaries are in PSScriptAnalyzer/PSv3/
401
- // and PowerShell v5 binaries are in PSScriptAnalyzer/
402
- settingsPath = Path . Combine ( Path . GetDirectoryName ( Path . GetDirectoryName ( path ) ) , "Settings" ) ;
403
- if ( ! Directory . Exists ( settingsPath ) )
404
- {
405
- return null ;
406
- }
407
- }
408
-
409
- return settingsPath ;
410
- }
411
-
412
383
private bool IsValidPlatformString ( string fileNameWithoutExt )
413
384
{
414
385
string psedition , psversion , os ;
You can’t perform that action at this time.
0 commit comments