< Summary

Information
Class: Elsa.Expressions.Python.Expressions.PythonExpressionHandler
Assembly: Elsa.Expressions.Python
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Expressions.Python/Expressions/PythonExpressionHandler.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 6
Coverable lines: 6
Total lines: 29
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
.ctor(...)100%210%
EvaluateAsync()0%620%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Expressions.Python/Expressions/PythonExpressionHandler.cs

#LineLine coverage
 1using Elsa.Expressions.Contracts;
 2using Elsa.Expressions.Helpers;
 3using Elsa.Expressions.Models;
 4using Elsa.Expressions.Python.Contracts;
 5
 6namespace Elsa.Expressions.Python.Expressions;
 7
 8/// <summary>
 9/// Evaluates C# expressions.
 10/// </summary>
 11public class PythonExpressionHandler : IExpressionHandler
 12{
 13    private readonly IPythonEvaluator _evaluator;
 14
 15    /// <summary>
 16    /// Initializes a new instance of the <see cref="PythonExpressionHandler"/> class.
 17    /// </summary>
 018    public PythonExpressionHandler(IPythonEvaluator evaluator)
 19    {
 020        _evaluator = evaluator;
 021    }
 22
 23    /// <inheritdoc />
 24    public async ValueTask<object?> EvaluateAsync(Expression expression, Type returnType, ExpressionExecutionContext con
 25    {
 026        var pythonExpression = expression.Value.ConvertTo<string>() ?? "";
 027        return await _evaluator.EvaluateAsync(pythonExpression, returnType, context);
 028    }
 29}