Skip to content

Commit bfd5080

Browse files
author
Kapil Borle
committed
Implement own value getter from hashtable ast
Ideally we should use HashtableAst.SafeGetValue() but that API is available only on PSv4 and onwards. As we support PSv3, we need our own implementation. And since we do not want any discrepancy in behavior across different PS versions, we use this custom implementation for all PS versions.
1 parent 4279c8c commit bfd5080

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

Engine/Generic/Settings.cs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,9 @@ private void parseSettingsFile(string settingsFilePath)
310310
Hashtable hashtable;
311311
try
312312
{
313-
hashtable = hashTableAst.SafeGetValue() as Hashtable;
313+
// ideally we should use HashtableAst.SafeGetValue() but since
314+
// it is not available on PSv3, we resort to our own narrow implementation.
315+
hashtable = GetHashtableFromHashTableAst(hashTableAst);
314316
}
315317
catch (InvalidOperationException e)
316318
{
@@ -325,15 +327,6 @@ private void parseSettingsFile(string settingsFilePath)
325327
parseSettingsHashtable(hashtable);
326328
}
327329

328-
private Hashtable GetValue(HashtableAst hashtableAst)
329-
{
330-
#if !PSV3
331-
return hashtableAst.SafeGetValue() as Hashtable;
332-
#else
333-
return GetHashtableFromHashTableAst(hashTableAst);
334-
#endif
335-
}
336-
337330
private Hashtable GetHashtableFromHashTableAst(HashtableAst hashTableAst)
338331
{
339332
var output = new Hashtable();

0 commit comments

Comments
 (0)