< Summary

Information
Class: Elsa.Expressions.JavaScript.TypeDefinitions.Services.TypeDefinitionService
Assembly: Elsa.Expressions.JavaScript
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Expressions.JavaScript/TypeDefinitions/Services/TypeDefinitionService.cs
Line coverage
16%
Covered lines: 5
Uncovered lines: 26
Coverable lines: 31
Total lines: 63
Line coverage: 16.1%
Branch coverage
0%
Covered branches: 0
Total branches: 24
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%
GenerateTypeDefinitionsAsync()100%210%
GetFunctionDefinitionsAsync()0%7280%
GetTypeDefinitionsAsync()0%7280%
GetVariableDefinitionsAsync()0%7280%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Expressions.JavaScript/TypeDefinitions/Services/TypeDefinitionService.cs

#LineLine coverage
 1using Elsa.Expressions.JavaScript.TypeDefinitions.Contracts;
 2using Elsa.Expressions.JavaScript.TypeDefinitions.Models;
 3
 4namespace Elsa.Expressions.JavaScript.TypeDefinitions.Services;
 5
 6/// <inheritdoc />
 17public class TypeDefinitionService(
 18    IEnumerable<ITypeDefinitionProvider> typeDefinitionProviders,
 19    IEnumerable<IFunctionDefinitionProvider> functionDefinitionProviders,
 110    IEnumerable<IVariableDefinitionProvider> variableDefinitionProviders,
 111    ITypeDefinitionDocumentRenderer typeDefinitionDocumentRenderer)
 12    : ITypeDefinitionService
 13{
 14    /// <inheritdoc />
 15    public async Task<string> GenerateTypeDefinitionsAsync(TypeDefinitionContext context)
 16    {
 017        var typeDefinitions = await GetTypeDefinitionsAsync(context).ToListAsync(context.CancellationToken);
 018        var functionDefinitions = await GetFunctionDefinitionsAsync(context).ToListAsync(context.CancellationToken);
 019        var variableDefinitions = await GetVariableDefinitionsAsync(context).ToListAsync(context.CancellationToken);
 20
 021        var document = new TypeDefinitionsDocument
 022        {
 023            Functions = functionDefinitions,
 024            Types = typeDefinitions,
 025            Variables = variableDefinitions
 026        };
 27
 028        return typeDefinitionDocumentRenderer.Render(document);
 029    }
 30
 31    private async IAsyncEnumerable<FunctionDefinition> GetFunctionDefinitionsAsync(TypeDefinitionContext context)
 32    {
 033        foreach (var provider in functionDefinitionProviders)
 34        {
 035            var definitions = await provider.GetFunctionDefinitionsAsync(context);
 36
 037            foreach (var definition in definitions)
 038                yield return definition;
 39        }
 040    }
 41
 42    private async IAsyncEnumerable<TypeDefinition> GetTypeDefinitionsAsync(TypeDefinitionContext context)
 43    {
 044        foreach (var provider in typeDefinitionProviders)
 45        {
 046            var definitions = await provider.GetTypeDefinitionsAsync(context);
 47
 048            foreach (var definition in definitions)
 049                yield return definition;
 50        }
 051    }
 52
 53    private async IAsyncEnumerable<VariableDefinition> GetVariableDefinitionsAsync(TypeDefinitionContext context)
 54    {
 055        foreach (var provider in variableDefinitionProviders)
 56        {
 057            var definitions = await provider.GetVariableDefinitionsAsync(context);
 58
 059            foreach (var definition in definitions)
 060                yield return definition;
 61        }
 062    }
 63}