Skip to content

Commit bc2ebef

Browse files
author
Kapil Borle
committed
Initialize DSCClassCache only once
1 parent 7fdd87d commit bc2ebef

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

Rules/UseIdenticalMandatoryParametersDSC.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ namespace Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules
3535
#endif
3636
public class UseIdenticalMandatoryParametersDSC : IDSCResourceRule
3737
{
38+
private bool isDSCClassCacheInitialized = false;
39+
3840
/// <summary>
3941
/// AnalyzeDSCResource: Analyzes given DSC Resource
4042
/// </summary>
@@ -121,7 +123,12 @@ private IEnumerable<string> GetKeys(string fileName)
121123
List<CimClass> cimClasses = null;
122124
try
123125
{
124-
DscClassCache.Initialize();
126+
if (!isDSCClassCacheInitialized)
127+
{
128+
DscClassCache.Initialize();
129+
isDSCClassCacheInitialized = true;
130+
}
131+
125132
cimClasses = DscClassCache.ImportClasses(mofFilepath, moduleInfo, errors);
126133
}
127134
catch

0 commit comments

Comments
 (0)