< Summary

Information
Class: Elsa.Expressions.Models.Expression
Assembly: Elsa.Expressions
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Expressions/Models/Expression.cs
Line coverage
88%
Covered lines: 16
Uncovered lines: 2
Coverable lines: 18
Total lines: 88
Line coverage: 88.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
.ctor()100%11100%
.ctor(...)100%11100%
get_Type()100%11100%
get_Value()100%11100%
LiteralExpression(...)100%11100%
DelegateExpression(...)100%11100%
DelegateExpression(...)100%210%
DelegateExpression(...)100%210%
DelegateExpression(...)100%11100%
DelegateExpression(...)100%11100%

File(s)

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

#LineLine coverage
 1using System.Text.Json.Serialization;
 2
 3namespace Elsa.Expressions.Models;
 4
 5/// <summary>
 6/// Represents an expression.
 7/// </summary>
 8public partial class Expression
 9{
 10    /// <summary>
 11    /// Initializes a new instance of the <see cref="Expression"/> class.
 12    /// </summary>
 13    [JsonConstructor]
 35514    public Expression()
 15    {
 35516    }
 17
 18    /// <summary>
 19    /// Initializes a new instance of the <see cref="Expression"/> class.
 20    /// </summary>
 21    /// <param name="type">The expression type.</param>
 22    /// <param name="value">The expression.</param>
 555023    public Expression(string type, object? value)
 24    {
 555025        Type = type;
 555026        Value = value;
 555027    }
 28
 29    /// <summary>
 30    /// Gets or sets the expression type.
 31    /// </summary>
 1052932    public string Type { get; set; } = default!;
 33
 34    /// <summary>
 35    /// Gets or sets the expression.
 36    /// </summary>
 922737    public object? Value { get; set; }
 38
 39    /// <summary>
 40    /// Creates an expression that represents a literal value.
 41    /// </summary>
 42    /// <param name="value">The literal value.</param>
 43    /// <returns>An expression that represents a literal value.</returns>
 343844    public static Expression LiteralExpression(object? value) => new("Literal", value);
 45
 46    /// <summary>
 47    /// Creates an expression that represents a delegate.
 48    /// </summary>
 49    /// <param name="value">The delegate.</param>
 50    /// <returns>An expression that represents a delegate.</returns>
 35551    public static Expression DelegateExpression(Func<ExpressionExecutionContext, ValueTask<object?>> value) => new()
 35552    {
 35553        Type = "Delegate",
 35554        Value = value
 35555    };
 56
 57    /// <summary>
 58    /// Creates an expression that represents a delegate.
 59    /// </summary>
 60    /// <param name="value">The delegate.</param>
 61    /// <typeparam name="T">The return type of the delegate.</typeparam>
 62    /// <returns>An expression that represents a delegate.</returns>
 063    public static Expression DelegateExpression<T>(Func<ExpressionExecutionContext, ValueTask<T>> value) => DelegateExpr
 64
 65    /// <summary>
 66    /// Creates an expression that represents a delegate.
 67    /// </summary>
 68    /// <param name="value">The delegate.</param>
 69    /// <typeparam name="T">The return type of the delegate.</typeparam>
 70    /// <returns>An expression that represents a delegate.</returns>
 071    public static Expression DelegateExpression<T>(Func<ValueTask<T>> value) => DelegateExpression(_ => ValueTask.FromRe
 72
 73    /// <summary>
 74    /// Creates an expression that represents a delegate.
 75    /// </summary>
 76    /// <param name="value">The delegate.</param>
 77    /// <typeparam name="T">The return type of the delegate.</typeparam>
 78    /// <returns>An expression that represents a delegate.</returns>
 37679    public static Expression DelegateExpression<T>(Func<ExpressionExecutionContext, T> value) => DelegateExpression(cont
 80
 81    /// <summary>
 82    /// Creates an expression that represents a delegate.
 83    /// </summary>
 84    /// <param name="value">The delegate.</param>
 85    /// <typeparam name="T">The return type of the delegate.</typeparam>
 86    /// <returns>An expression that represents a delegate.</returns>
 1987    public static Expression DelegateExpression<T>(Func<T> value) => DelegateExpression(_ => ValueTask.FromResult<object
 88}