< Summary

Information
Class: Elsa.Expressions.JavaScript.Handlers.ConfigureEngineWithWorkflowVariableTypes
Assembly: Elsa.Expressions.JavaScript
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Expressions.JavaScript/Handlers/ConfigureEngineWithVariableTypes.cs
Line coverage
100%
Covered lines: 15
Uncovered lines: 0
Coverable lines: 15
Total lines: 37
Line coverage: 100%
Branch coverage
100%
Covered branches: 8
Total branches: 8
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
.cctor()100%11100%
HandleAsync(...)100%88100%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Expressions.JavaScript/Handlers/ConfigureEngineWithVariableTypes.cs

#LineLine coverage
 1using Elsa.Expressions.JavaScript.Notifications;
 2using Elsa.Extensions;
 3using Elsa.Mediator.Contracts;
 4using Elsa.Workflows.Management.Options;
 5using JetBrains.Annotations;
 6using Microsoft.Extensions.Options;
 7
 8namespace Elsa.Expressions.JavaScript.Handlers;
 9
 10[UsedImplicitly]
 52011public class ConfigureEngineWithWorkflowVariableTypes(IOptions<ManagementOptions> options)
 12    : INotificationHandler<EvaluatingJavaScript>
 13{
 314    private static readonly Type[] BlacklistedTypes =
 315    [
 316        typeof(string),
 317        typeof(object),
 318        // Add more types if needed.
 319    ];
 20
 21    /// <inheritdoc />
 22    public Task HandleAsync(EvaluatingJavaScript notification, CancellationToken cancellationToken)
 23    {
 18824        var engine = notification.Engine;
 18825        var variableTypes = options.Value.VariableDescriptors
 410026            .Where(x => x.Type is { ContainsGenericParameters: false } && !BlacklistedTypes.Contains(x.Type) && !x.Type.
 278427            .Select(x => x.Type)
 18828            .ToArray();
 29
 594430        foreach (var variableType in variableTypes)
 31        {
 278432            engine.RegisterType(variableType);
 33        }
 34
 18835        return Task.CompletedTask;
 36    }
 37}