< Summary

Information
Class: Microsoft.Extensions.DependencyInjection.DependencyInjectionExtensions
Assembly: Elsa.Expressions.Liquid
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Expressions.Liquid/Extensions/DependencyInjectionExtensions.cs
Line coverage
42%
Covered lines: 3
Uncovered lines: 4
Coverable lines: 7
Total lines: 38
Line coverage: 42.8%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
AddLiquidFilter(...)100%11100%
RegisterLiquidTag(...)100%210%
EnableLiquidConfigurationAccess(...)100%210%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Expressions.Liquid/Extensions/DependencyInjectionExtensions.cs

#LineLine coverage
 1using Elsa.Expressions.Liquid.Contracts;
 2using Elsa.Expressions.Liquid.Options;
 3using Elsa.Expressions.Liquid.Services;
 4
 5// ReSharper disable once CheckNamespace
 6namespace Microsoft.Extensions.DependencyInjection;
 7
 8public static class DependencyInjectionExtensions
 9{
 10    /// <summary>
 11    /// Register a custom Liquid filter.
 12    /// </summary>
 13    public static IServiceCollection AddLiquidFilter<T>(this IServiceCollection services, string name) where T : class, 
 14    {
 415        services.Configure<FluidOptions>(options => options.FilterRegistrations[name] = typeof(T));
 216        services.AddScoped<T>();
 217        return services;
 18    }
 19
 20    /// <summary>
 21    /// Register a custom Liquid tag.
 22    /// </summary>
 23    public static IServiceCollection RegisterLiquidTag(this IServiceCollection services, Action<LiquidParser> configure)
 24    {
 025        services.Configure<FluidOptions>(options => options.ParserConfiguration.Add(configure));
 026        return services;
 27    }
 28
 29    /// <summary>
 30    /// Enables access to .NET configuration via the Configuration keyword.
 31    /// Do not enable this option if you execute user supplied (or otherwise untrusted) workflows.
 32    /// </summary>
 33    public static IServiceCollection EnableLiquidConfigurationAccess(this IServiceCollection services)
 34    {
 035        services.Configure<FluidOptions>(options => options.AllowConfigurationAccess = true);
 036        return services;
 37    }
 38}