@@ -1602,6 +1602,11 @@ public bool GetNamedArgumentAttributeValue(NamedAttributeArgumentAst namedAttrib
1602
1602
return false ;
1603
1603
}
1604
1604
1605
+ /// <summary>
1606
+ /// Gets valid keys of a PowerShell module manifest file for a given PowerShell version
1607
+ /// </summary>
1608
+ /// <param name="powershellVersion">Version parameter with valid values: 5.0, 4.0 and 3.0</param>
1609
+ /// <returns>Returns an enumerator over valid keys</returns>
1605
1610
public static IEnumerable < string > GetModuleManifestKeys ( Version powershellVersion )
1606
1611
{
1607
1612
if ( powershellVersion == null )
@@ -1651,18 +1656,33 @@ public static IEnumerable<string> GetModuleManifestKeys(Version powershellVersio
1651
1656
return keys ;
1652
1657
}
1653
1658
1659
+ /// <summary>
1660
+ /// Gets deprecated keys of PowerShell module manifest
1661
+ /// </summary>
1662
+ /// <returns>Returns an enumerator over deprecated keys</returns>
1654
1663
public static IEnumerable < string > GetDeprecatedModuleManifestKeys ( )
1655
1664
{
1656
1665
return new List < string > { "ModuleToProcess" } ;
1657
1666
}
1658
1667
1668
+ /// <summary>
1669
+ /// Checks if a given file is a valid PowerShell module manifest
1670
+ /// </summary>
1671
+ /// <param name="filepath">Path to module manifest</param>
1672
+ /// <returns>true if given filepath points to a module manifest, otherwise false</returns>
1659
1673
public static bool IsModuleManifest ( string filepath )
1660
1674
{
1661
1675
// 4.0 and 3.0 contain the same keys. Hence, compare only with 4.0.
1662
1676
return IsModuleManifest ( filepath , new Version ( "5.0" ) )
1663
1677
|| IsModuleManifest ( filepath , new Version ( "4.0" ) ) ;
1664
1678
}
1665
1679
1680
+ /// <summary>
1681
+ /// Checks if a given file is a valid PowerShell module manifest
1682
+ /// </summary>
1683
+ /// <param name="filepath">Path to module manifest</param>
1684
+ /// <param name="powershellVersion">Version parameter with valid values: 5.0, 4.0 and 3.0</param>
1685
+ /// <returns>true if given filepath points to a module manifest, otherwise false</returns>
1666
1686
public static bool IsModuleManifest ( string filepath , Version powershellVersion )
1667
1687
{
1668
1688
Token [ ] tokens ;
@@ -1690,6 +1710,7 @@ public static bool IsModuleManifest(string filepath, Version powershellVersion)
1690
1710
}
1691
1711
var validKeys = GetModuleManifestKeys ( powershellVersion ) ;
1692
1712
var allKeys = validKeys . Concat ( GetDeprecatedModuleManifestKeys ( ) ) ;
1713
+
1693
1714
// check if all the keys in hast.keyvaluepairs are present in keys
1694
1715
int matchCount = 0 ;
1695
1716
foreach ( var pair in hast . KeyValuePairs )
0 commit comments