< Summary

Information
Class: Elsa.Expressions.JavaScript.Providers.WorkflowVariablesTypeDefinitionProvider
Assembly: Elsa.Expressions.JavaScript
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Expressions.JavaScript/Providers/WorkflowVariablesTypeDefinitionProvider.cs
Line coverage
5%
Covered lines: 1
Uncovered lines: 17
Coverable lines: 18
Total lines: 39
Line coverage: 5.5%
Branch coverage
0%
Covered branches: 0
Total branches: 2
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
GetTypeDefinitions()0%2040%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Expressions.JavaScript/Providers/WorkflowVariablesTypeDefinitionProvider.cs

#LineLine coverage
 1using Elsa.Extensions;
 2using Elsa.Expressions.JavaScript.Extensions;
 3using Elsa.Expressions.JavaScript.Options;
 4using Elsa.Expressions.JavaScript.TypeDefinitions.Abstractions;
 5using Elsa.Expressions.JavaScript.TypeDefinitions.Models;
 6using JetBrains.Annotations;
 7using Microsoft.Extensions.Options;
 8
 9namespace Elsa.Expressions.JavaScript.Providers;
 10
 11[UsedImplicitly]
 112internal class WorkflowVariablesTypeDefinitionProvider(IOptions<JintOptions> options) : TypeDefinitionProvider
 13{
 14    protected override IEnumerable<TypeDefinition> GetTypeDefinitions(TypeDefinitionContext context)
 15    {
 016        if(options.Value.DisableWrappers)
 017            yield break;
 18
 019        var variables = context.WorkflowGraph.Workflow.Variables;
 20
 021        var workflowTypeDefinition = new TypeDefinition
 022        {
 023            Name = "WorkflowVariables",
 024            DeclarationKeyword = "class"
 025        };
 26
 027        foreach (var variable in variables.Where(x => x.Name.IsValidVariableName()))
 28        {
 029            var variableType = variable.GetVariableType();
 030            workflowTypeDefinition.Properties.Add(new PropertyDefinition
 031            {
 032                Name = variable.Name,
 033                Type = variableType.Name
 034            });
 35        }
 36
 037        yield return workflowTypeDefinition;
 038    }
 39}