@@ -34,6 +34,7 @@ public class Helper
3434 private CommandInvocationIntrinsics invokeCommand ;
3535 private IOutputWriter outputWriter ;
3636 private Object getCommandLock = new object ( ) ;
37+ private readonly static Version minSupportedPSVersion = new Version ( 3 , 0 ) ;
3738
3839 #endregion
3940
@@ -1605,7 +1606,7 @@ public bool GetNamedArgumentAttributeValue(NamedAttributeArgumentAst namedAttrib
16051606 /// <summary>
16061607 /// Gets valid keys of a PowerShell module manifest file for a given PowerShell version
16071608 /// </summary>
1608- /// <param name="powershellVersion">Version parameter with valid values: 5.0, 4.0 and 3.0</param>
1609+ /// <param name="powershellVersion">Version parameter; valid if >= 3.0</param>
16091610 /// <returns>Returns an enumerator over valid keys</returns>
16101611 public static IEnumerable < string > GetModuleManifestKeys ( Version powershellVersion )
16111612 {
@@ -1615,7 +1616,7 @@ public static IEnumerable<string> GetModuleManifestKeys(Version powershellVersio
16151616 }
16161617 if ( ! IsPowerShellVersionSupported ( powershellVersion ) )
16171618 {
1618- throw new ArgumentException ( "Invalid PowerShell version. Choose from 3.0, 4.0 or 5 .0" ) ;
1619+ throw new ArgumentException ( "Invalid PowerShell version. Choose from version greater than or equal to 3 .0" ) ;
16191620 }
16201621 var keys = new List < string > ( ) ;
16211622 var keysCommon = new List < string > {
@@ -1648,10 +1649,14 @@ public static IEnumerable<string> GetModuleManifestKeys(Version powershellVersio
16481649 "HelpInfoURI" ,
16491650 "DefaultCommandPrefix" } ;
16501651 keys . AddRange ( keysCommon ) ;
1651- if ( powershellVersion . Major = = 5 )
1652+ if ( powershellVersion . Major > = 5 )
16521653 {
16531654 keys . Add ( "DscResourcesToExport" ) ;
16541655 }
1656+ if ( powershellVersion >= new Version ( 5 , 1 ) )
1657+ {
1658+ keys . Add ( "CompatiblePSEditions" ) ;
1659+ }
16551660 return keys ;
16561661 }
16571662
@@ -1689,7 +1694,7 @@ private static Dictionary<string, StatementAst> GetMapFromHashtableAst(Hashtable
16891694 /// <summary>
16901695 /// Checks if the version is supported
16911696 ///
1692- /// PowerShell versions with Major 5, 4 and 3 are supported
1697+ /// PowerShell versions with Major greater than 3 are supported
16931698 /// </summary>
16941699 /// <param name="version">PowerShell version</param>
16951700 /// <returns>true if the given version is supported else false</returns>
@@ -1699,23 +1704,14 @@ public static bool IsPowerShellVersionSupported(Version version)
16991704 {
17001705 throw new ArgumentNullException ( "version" ) ;
17011706 }
1702-
1703- switch ( version . Major )
1704- {
1705- case 5 :
1706- case 4 :
1707- case 3 :
1708- return true ;
1709- default :
1710- return false ;
1711- }
1707+ return version >= minSupportedPSVersion ;
17121708 }
17131709
17141710 /// <summary>
17151711 /// Checks if a given file is a valid PowerShell module manifest
17161712 /// </summary>
17171713 /// <param name="filepath">Path to module manifest</param>
1718- /// <param name="powershellVersion">Version parameter with valid values: 5.0, 4.0 and 3.0</param>
1714+ /// <param name="powershellVersion">Version parameter; valid if >= 3.0</param>
17191715 /// <returns>true if given filepath points to a module manifest, otherwise false</returns>
17201716 public static bool IsModuleManifest ( string filepath , Version powershellVersion = null )
17211717 {
@@ -1775,8 +1771,8 @@ public static bool IsModuleManifest(string filepath, Version powershellVersion =
17751771 }
17761772 else
17771773 {
1778- // default to version 5.0
1779- allKeys = GetModuleManifestKeys ( new Version ( "5.0 " ) ) ;
1774+ // default to version 5.1
1775+ allKeys = GetModuleManifestKeys ( new Version ( "5.1 " ) ) ;
17801776 }
17811777 }
17821778
0 commit comments