Skip to content

Commit 903464a

Browse files
author
Kapil Borle
committed
Check for deprecated manifest keys
1 parent 8059853 commit 903464a

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

Engine/Helper.cs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1651,6 +1651,18 @@ public static IEnumerable<string> GetModuleManifestKeys(Version powershellVersio
16511651
return keys;
16521652
}
16531653

1654+
public static IEnumerable<string> GetDeprecatedModuleManifestKeys()
1655+
{
1656+
return new List<string> { "ModuleToProcess" };
1657+
}
1658+
1659+
public static bool IsModuleManifest(string filepath)
1660+
{
1661+
// 4.0 and 3.0 contain the same keys. Hence, compare only with 4.0.
1662+
return IsModuleManifest(filepath, new Version("5.0"))
1663+
|| IsModuleManifest(filepath, new Version("4.0"));
1664+
}
1665+
16541666
public static bool IsModuleManifest(string filepath, Version powershellVersion)
16551667
{
16561668
Token[] tokens;
@@ -1676,8 +1688,8 @@ public static bool IsModuleManifest(string filepath, Version powershellVersion)
16761688
{
16771689
return false;
16781690
}
1679-
var keys = GetModuleManifestKeys(powershellVersion);
1680-
1691+
var validKeys = GetModuleManifestKeys(powershellVersion);
1692+
var allKeys = validKeys.Concat(GetDeprecatedModuleManifestKeys());
16811693
// check if all the keys in hast.keyvaluepairs are present in keys
16821694
int matchCount = 0;
16831695
foreach(var pair in hast.KeyValuePairs)
@@ -1687,7 +1699,7 @@ public static bool IsModuleManifest(string filepath, Version powershellVersion)
16871699
{
16881700
break;
16891701
}
1690-
foreach(var key in keys)
1702+
foreach(var key in allKeys)
16911703
{
16921704
if (key.Equals(pairKey.Value, StringComparison.OrdinalIgnoreCase))
16931705
{

0 commit comments

Comments
 (0)