< 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>
 3115    public ExpressionDescriptor()
 16    {
 17        // Default deserialization function.
 3118        Deserialize = context =>
 3119        {
 30520            var expression = new Expression(context.ExpressionType, null);
 3121
 30522            if (context.JsonElement.ValueKind == JsonValueKind.Object)
 30523                if (context.JsonElement.TryGetProperty("value", out var expressionValueElement))
 30524                    expression.Value = expressionValueElement.GetValue();
 3125
 30526            return expression;
 3127        };
 3128    }
 29
 30    /// <summary>
 31    /// Gets or sets the syntax name.
 32    /// </summary>
 6233    public string Type { get; init; } = default!;
 34
 35    /// <summary>
 36    /// Gets or sets the display name of the expression type.
 37    /// </summary>
 2838    public string DisplayName { get; set; } = default!;
 39
 40    /// <summary>
 41    /// Gets or sets whether the expression value is serializable.
 42    /// </summary>
 309443    public bool IsSerializable { get; set; } = true;
 44
 45    /// <summary>
 46    /// Gets or sets whether the expression type is browsable.
 47    /// </summary>
 5548    public bool IsBrowsable { get; set; } = true;
 49
 50    /// <summary>
 51    /// Gets or sets the expression type properties.
 52    /// </summary>
 4353    public IDictionary<string, object> Properties { get; set; } = new Dictionary<string, object>();
 54
 55    /// <summary>
 56    /// Gets or sets the expression handler factory.
 57    /// </summary>
 160758    public Func<IServiceProvider, IExpressionHandler> HandlerFactory { get; set; } = default!;
 59
 60    /// <summary>
 61    /// Gets or sets the memory block reference factory.
 62    /// </summary>
 208863    public Func<MemoryBlockReference> MemoryBlockReferenceFactory { get; set; } = () => new MemoryBlockReference();
 64
 65    /// <summary>
 66    /// Gets or sets the expression deserialization function.
 67    /// </summary>
 203468    public Func<ExpressionSerializationContext, Expression> Deserialize { get; set; } = default!;
 69}