< Summary

Information
Class: Elsa.Expressions.Liquid.Filters.DictionaryKeysFilter
Assembly: Elsa.Expressions.Liquid
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Expressions.Liquid/Filters/DictionaryKeysFilter.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 4
Coverable lines: 4
Total lines: 21
Line coverage: 0%
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
ProcessAsync(...)0%620%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Expressions.Liquid/Filters/DictionaryKeysFilter.cs

#LineLine coverage
 1using Elsa.Expressions.Liquid.Contracts;
 2using Fluid;
 3using Fluid.Values;
 4
 5namespace Elsa.Expressions.Liquid.Filters;
 6
 7/// <summary>
 8/// A liquid filter that extracts the key values from a <see cref="DictionaryValue"/> value.
 9/// </summary>
 10public class DictionaryKeysFilter : ILiquidFilter
 11{
 12    /// <inheritdoc />
 13    public ValueTask<FluidValue> ProcessAsync(FluidValue input, FilterArguments arguments, TemplateContext context)
 14    {
 015        if (input.ToObjectValue() is not IFluidIndexable dictionary)
 016            throw new ArgumentOutOfRangeException($"This filter only works on objects of type {typeof(IFluidIndexable)}"
 17
 018        var keys = dictionary.Keys.Select(x => new StringValue(x)).Cast<FluidValue>().ToArray();
 019        return new ValueTask<FluidValue>(new ArrayValue(keys));
 20    }
 21}