in src/PSRule/Commands/InvokeConventionCommand.cs [22:71]
protected override void ProcessRecord()
{
var context = RunspaceContext.CurrentThread;
try
{
if (Body == null)
return;
// Evaluate script pre-condition
if (If != null)
{
try
{
context.PushScope(RunspaceScope.Precondition);
var ifResult = RuleConditionHelper.Create(If.Invoke());
if (!ifResult.AllOf())
{
context.Writer.DebugMessage(PSRuleResources.DebugTargetIfMismatch);
return;
}
}
finally
{
context.PopScope(RunspaceScope.Precondition);
}
}
try
{
// Evaluate script block
context.PushScope(Scope);
Body.Invoke();
}
finally
{
context.PopScope(Scope);
}
}
catch (ActionPreferenceStopException ex)
{
context.Error(ex);
}
catch (System.Management.Automation.RuntimeException ex)
{
if (ex.ErrorRecord.FullyQualifiedErrorId == "MethodInvocationNotSupportedInConstrainedLanguage")
throw;
context.Error(ex);
}
}