• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

lucaslorentz / durabletask-extensions / 16865663961

10 Aug 2025 07:46PM UTC coverage: 83.091% (+0.006%) from 83.085%
16865663961

push

github

web-flow
Merge 90ce21b56 into 6b8f51038

9 of 9 new or added lines in 3 files covered. (100.0%)

16 existing lines in 2 files now uncovered.

2398 of 2886 relevant lines covered (83.09%)

140.77 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

82.35
/src/LLL.DurableTask.Worker/Orchestrations/MethodTaskOrchestration.cs
1
using System;
2
using System.Collections.Generic;
3
using System.Reflection;
4
using System.Runtime.ExceptionServices;
5
using System.Threading.Tasks;
6
using DurableTask.Core;
7
using DurableTask.Core.Serializing;
8
using LLL.DurableTask.Core.Serializing;
9
using LLL.DurableTask.Worker.Utils;
10

11
namespace LLL.DurableTask.Worker.Orchestrations;
12

13
public class MethodTaskOrchestration : TaskOrchestration
14
{
15
    private readonly MethodInfo _methodInfo;
16
    private readonly DataConverter _dataConverter;
17
    private ExtendedOrchestrationContext _extendedContext;
18

19
    public MethodTaskOrchestration(
15✔
20
        object instance,
15✔
21
        MethodInfo methodInfo)
15✔
22
    {
23
        Instance = instance;
15✔
24
        _methodInfo = methodInfo;
15✔
25
        _dataConverter = new TypelessJsonDataConverter();
15✔
26
    }
27

28
    public object Instance { get; }
15✔
29

30
    public override async Task<string> Execute(OrchestrationContext context, string input)
31
    {
32
        context.MessageDataConverter = new TypelessJsonDataConverter();
15✔
33
        context.ErrorDataConverter = new TypelessJsonDataConverter();
15✔
34

35
        var parameters = PrepareParameters(input, new Dictionary<Type, Func<object>>
15✔
36
        {
15✔
37
            [typeof(OrchestrationContext)] = () => context,
19✔
38
            [typeof(ExtendedOrchestrationContext)] = () => _extendedContext = new ExtendedOrchestrationContext(context),
20✔
39
        });
15✔
40

41
        try
42
        {
43
            var result = _methodInfo.Invoke(Instance, parameters);
15✔
44
            return await SerializeResult(result);
14✔
45
        }
46
        catch (TargetInvocationException ex)
47
        {
48
            ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
1✔
UNCOV
49
            throw;
×
50
        }
51
    }
52

53
    public override string GetStatus()
54
    {
55
        return _extendedContext?.StatusProvider?.Invoke();
21✔
56
    }
57

58
    public override void RaiseEvent(OrchestrationContext context, string name, string input)
59
    {
60
        _extendedContext?.RaiseEvent(name, input);
7✔
61
    }
62

63
    private object[] PrepareParameters(
64
        string input,
65
        Dictionary<Type, Func<object>> factories)
66
    {
67
        var parameters = new List<object>();
15✔
68

69
        foreach (var p in _methodInfo.GetParameters())
48✔
70
        {
71
            object value;
72

73
            if (factories.TryGetValue(p.ParameterType, out var factory))
9✔
74
            {
75
                value = factory();
9✔
76
            }
UNCOV
77
            else if (input is not null)
×
78
            {
UNCOV
79
                value = _dataConverter.Deserialize(input, p.ParameterType);
×
80
            }
UNCOV
81
            else if (p.HasDefaultValue)
×
82
            {
UNCOV
83
                value = p.DefaultValue;
×
84
            }
85
            else
UNCOV
86
                throw new Exception($"Orchestration input was not provided.");
×
87

88
            parameters.Add(value);
9✔
89
        }
90

91
        return parameters.ToArray();
15✔
92
    }
93

94
    private async Task<string> SerializeResult(object result)
95
    {
96
        var awaitedResult = await TaskUtils.MaybeAwait(result, _methodInfo.ReturnType);
14✔
97

98
        var serializedResult = _dataConverter.Serialize(awaitedResult);
13✔
99

100
        return serializedResult;
13✔
101
    }
102
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc