Skip to content

Commit 2c832b9

Browse files
author
Kapil Borle
committed
Merge pull request #532 from PowerShell/FixPSv3Build
Fix PowerShell v3 build
2 parents a6ca7b8 + 63c2444 commit 2c832b9

File tree

6 files changed

+136
-116
lines changed

6 files changed

+136
-116
lines changed

Engine/Commands/InvokeScriptAnalyzerCommand.cs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ public object Settings
189189

190190
private bool stopProcessing;
191191

192+
#if !PSV3
192193
/// <summary>
193194
/// Resolve DSC resource dependency
194195
/// </summary>
@@ -199,9 +200,10 @@ public SwitchParameter SaveDscResourceDependency
199200
set { saveDscResourceDependency = value; }
200201
}
201202
private bool saveDscResourceDependency;
202-
#endregion Parameters
203+
#endif // !PSV3
204+
#endregion Parameters
203205

204-
#region Overrides
206+
#region Overrides
205207

206208
/// <summary>
207209
/// Imports all known rules and loggers.
@@ -238,6 +240,7 @@ protected override void ProcessRecord()
238240
return;
239241
}
240242

243+
#if !PSV3
241244
// TODO Support dependency resolution for analyzing script definitions
242245
if (saveDscResourceDependency)
243246
{
@@ -250,11 +253,10 @@ protected override void ProcessRecord()
250253
ProcessInput();
251254
}
252255
}
256+
return;
253257
}
254-
else
255-
{
256-
ProcessInput();
257-
}
258+
#endif
259+
ProcessInput();
258260
}
259261

260262
protected override void EndProcessing()
@@ -269,9 +271,9 @@ protected override void StopProcessing()
269271
base.StopProcessing();
270272
}
271273

272-
#endregion
274+
#endregion
273275

274-
#region Methods
276+
#region Methods
275277
private void ProcessInput()
276278
{
277279
IEnumerable<DiagnosticRecord> diagnosticsList = Enumerable.Empty<DiagnosticRecord>();
@@ -304,6 +306,6 @@ private void WriteToOutput(IEnumerable<DiagnosticRecord> diagnosticRecords)
304306
}
305307
}
306308
}
307-
#endregion
309+
#endregion
308310
}
309311
}

Engine/Generic/ModuleDependencyHandler.cs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System;
1+
#if !PSV3
2+
using System;
23
using System.Collections.Generic;
34
using System.Collections.ObjectModel;
45
using System.IO;
@@ -13,7 +14,7 @@ namespace Microsoft.Windows.PowerShell.ScriptAnalyzer.Generic
1314
// TODO Support for verbose mode
1415
public class ModuleDependencyHandler : IDisposable
1516
{
16-
#region Private Variables
17+
#region Private Variables
1718
private Runspace runspace;
1819
private string moduleRepository;
1920
private string tempPath; // path to the user temporary directory
@@ -26,9 +27,9 @@ public class ModuleDependencyHandler : IDisposable
2627
private string symLinkPath;
2728
private string oldPSModulePath;
2829
private string curPSModulePath;
29-
#endregion Private Variables
30+
#endregion Private Variables
3031

31-
#region Properties
32+
#region Properties
3233
/// <summary>
3334
/// Path where the object stores the modules
3435
/// </summary>
@@ -123,9 +124,9 @@ public Runspace Runspace
123124
}
124125

125126

126-
#endregion Properties
127+
#endregion Properties
127128

128-
#region Private Methods
129+
#region Private Methods
129130
private static void ThrowIfNull<T>(T obj, string name)
130131
{
131132
if (obj == null)
@@ -226,9 +227,9 @@ private void RestorePSModulePath()
226227
{
227228
Environment.SetEnvironmentVariable("PSModulePath", oldPSModulePath, EnvironmentVariableTarget.Process);
228229
}
229-
#endregion Private Methods
230+
#endregion Private Methods
230231

231-
#region Public Methods
232+
#region Public Methods
232233

233234
/// <summary>
234235
/// Creates an instance of the ModuleDependencyHandler class
@@ -371,6 +372,7 @@ public bool IsModuleAvailable(string moduleName)
371372
return availableModules != null ? availableModules.Any() : false;
372373
}
373374

375+
374376
/// <summary>
375377
/// Extracts out the module names from the error extent that are not available
376378
///
@@ -502,6 +504,7 @@ public void Dispose()
502504
RestorePSModulePath();
503505
}
504506

505-
#endregion Public Methods
507+
#endregion Public Methods
506508
}
507-
}
509+
}
510+
#endif // !PSV3

0 commit comments

Comments
 (0)