Skip to content

Commit

Permalink
Merge pull request #328 from UiPath/fix/validation_optimization
Browse files Browse the repository at this point in the history
process locations jit
  • Loading branch information
andrei-balint authored Jun 19, 2024
2 parents 497f08a + 7e85d1f commit 4a2395d
Showing 1 changed file with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public class CompiledExpressionInvoker
private readonly IList<LocationReference> _locationReferences;
private CodeActivityMetadata _metadata;
private CodeActivityPublicEnvironmentAccessor _accessor;
private bool _locationsInitialized;

public CompiledExpressionInvoker(ITextExpression expression, bool isReference, CodeActivityMetadata metadata)
{
Expand All @@ -40,7 +41,10 @@ public CompiledExpressionInvoker(ITextExpression expression, bool isReference, C

_metadataRoot = metadata.Environment.Root;

ProcessLocationReferences();
if (!metadata.Environment.IsValidating)
{
ProcessLocationReferences();
}
}

public object InvokeExpression(ActivityContext activityContext)
Expand All @@ -50,6 +54,11 @@ public object InvokeExpression(ActivityContext activityContext)
throw FxTrace.Exception.ArgumentNull(nameof(activityContext));
}

if (!_locationsInitialized)
{
ProcessLocationReferences();
}

if (_compiledRoot == null || _expressionId < 0)
{
if (!TryGetCompiledExpressionRoot(_expressionActivity, _metadataRoot, out _compiledRoot) ||
Expand Down Expand Up @@ -154,6 +163,11 @@ internal static bool TryGetCompiledExpressionRoot(Activity target, bool forImple

internal Expression GetExpressionTree()
{
if (!_locationsInitialized)
{
ProcessLocationReferences();
}

if (_compiledRoot == null || _expressionId < 0)
{
if (!TryGetCompiledExpressionRootAtDesignTime(_expressionActivity, _metadataRoot, out _compiledRoot, out _expressionId))
Expand Down Expand Up @@ -198,6 +212,8 @@ private bool CanExecuteExpression(ICompiledExpressionRoot compiledExpressionRoot

private void ProcessLocationReferences()
{
_locationsInitialized = true;

Stack<LocationReferenceEnvironment> environments = new();
//
// Build list of location by enumerating environments
Expand Down

0 comments on commit 4a2395d

Please sign in to comment.