< Summary

Information
Class: Elsa.Expressions.Models.ExpressionDescriptor
Assembly: Elsa.Expressions
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Expressions/Models/ExpressionDescriptor.cs
Line coverage
100%
Covered lines: 20
Uncovered lines: 0
Coverable lines: 20
Total lines: 69
Line coverage: 100%
Branch coverage
100%
Covered branches: 4
Total branches: 4
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%44100%
get_Type()100%11100%
get_DisplayName()100%11100%
get_IsSerializable()100%11100%
get_IsBrowsable()100%11100%
get_Properties()100%11100%
get_HandlerFactory()100%11100%
get_MemoryBlockReferenceFactory()100%11100%
get_Deserialize()100%11100%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Expressions/Models/ExpressionDescriptor.cs

#LineLine coverage
 1using System.Text.Json;
 2using Elsa.Expressions.Contracts;
 3using Elsa.Extensions;
 4
 5namespace Elsa.Expressions.Models;
 6
 7/// <summary>
 8/// Describes an expression type.
 9/// </summary>
 10public class ExpressionDescriptor
 11{
 12    /// <summary>
 13    /// Initializes a new instance of the <see cref="ExpressionDescriptor"/> class.
 14    /// </summary>
 9115    public ExpressionDescriptor()
 16    {
 17        // Default deserialization function.
 9118        Deserialize = context =>
 9119        {
 36820            var expression = new Expression(context.ExpressionType, null);
 9121
 36822            if (context.JsonElement.ValueKind == JsonValueKind.Object)
 36823                if (context.JsonElement.TryGetProperty("value", out var expressionValueElement))
 36824                    expression.Value = expressionValueElement.GetValue();
 9125
 36826            return expression;
 9127        };
 9128    }
 29
 30    /// <summary>
 31    /// Gets or sets the syntax name.
 32    /// </summary>
 18233    public string Type { get; init; } = default!;
 34
 35    /// <summary>
 36    /// Gets or sets the display name of the expression type.
 37    /// </summary>
 8838    public string DisplayName { get; set; } = default!;
 39
 40    /// <summary>
 41    /// Gets or sets whether the expression value is serializable.
 42    /// </summary>
 1105443    public bool IsSerializable { get; set; } = true;
 44
 45    /// <summary>
 46    /// Gets or sets whether the expression type is browsable.
 47    /// </summary>
 15148    public bool IsBrowsable { get; set; } = true;
 49
 50    /// <summary>
 51    /// Gets or sets the expression type properties.
 52    /// </summary>
 13953    public IDictionary<string, object> Properties { get; set; } = new Dictionary<string, object>();
 54
 55    /// <summary>
 56    /// Gets or sets the expression handler factory.
 57    /// </summary>
 289258    public Func<IServiceProvider, IExpressionHandler> HandlerFactory { get; set; } = default!;
 59
 60    /// <summary>
 61    /// Gets or sets the memory block reference factory.
 62    /// </summary>
 317963    public Func<MemoryBlockReference> MemoryBlockReferenceFactory { get; set; } = () => new MemoryBlockReference();
 64
 65    /// <summary>
 66    /// Gets or sets the expression deserialization function.
 67    /// </summary>
 305968    public Func<ExpressionSerializationContext, Expression> Deserialize { get; set; } = default!;
 69}