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

lucaslorentz / durabletask-extensions / 5835751495

pending completion
5835751495

push

github

lucaslorentz
Add husky and apply some code fixes

2502 of 2502 new or added lines in 91 files covered. (100.0%)

2286 of 2792 relevant lines covered (81.88%)

143.14 hits per line

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

90.63
/src/LLL.DurableTask.Core/Serializing/HistoryEventConverter.cs
1
using System;
2
using System.Collections.Generic;
3
using DurableTask.Core.History;
4
using Newtonsoft.Json;
5
using Newtonsoft.Json.Linq;
6

7
namespace LLL.DurableTask.Core.Serializing;
8

9
public class HistoryEventConverter : JsonConverter
10
{
11
    private static readonly Dictionary<EventType, Type> _typesMap = new()
1✔
12
    {
1✔
13
        { EventType.ContinueAsNew, typeof(ContinueAsNewEvent) },
1✔
14
        { EventType.EventRaised, typeof(EventRaisedEvent) },
1✔
15
        { EventType.EventSent, typeof(EventSentEvent) },
1✔
16
        { EventType.ExecutionCompleted, typeof(ExecutionCompletedEvent) },
1✔
17
        //{ EventType.ExecutionFailed, typeof(ExecutionFailedEvent) },
1✔
18
        { EventType.ExecutionStarted, typeof(ExecutionStartedEvent) },
1✔
19
        { EventType.ExecutionTerminated, typeof(ExecutionTerminatedEvent) },
1✔
20
        { EventType.GenericEvent, typeof(GenericEvent) },
1✔
21
        { EventType.HistoryState, typeof(HistoryStateEvent) },
1✔
22
        { EventType.OrchestratorCompleted, typeof(OrchestratorCompletedEvent) },
1✔
23
        { EventType.OrchestratorStarted, typeof(OrchestratorStartedEvent) },
1✔
24
        { EventType.SubOrchestrationInstanceCompleted, typeof(SubOrchestrationInstanceCompletedEvent) },
1✔
25
        { EventType.SubOrchestrationInstanceCreated, typeof(SubOrchestrationInstanceCreatedEvent) },
1✔
26
        { EventType.SubOrchestrationInstanceFailed, typeof(SubOrchestrationInstanceFailedEvent) },
1✔
27
        { EventType.TaskCompleted, typeof(TaskCompletedEvent) },
1✔
28
        { EventType.TaskFailed, typeof(TaskFailedEvent) },
1✔
29
        { EventType.TaskScheduled, typeof(TaskScheduledEvent) },
1✔
30
        { EventType.TimerCreated, typeof(TimerCreatedEvent) },
1✔
31
        { EventType.TimerFired, typeof(TimerFiredEvent) }
1✔
32
    };
1✔
33

34
    public override bool CanWrite => false;
×
35

36
    public override bool CanConvert(Type objectType)
37
    {
38
        // Avoid recursion by only converting when target type is unknown
39
        return objectType == typeof(HistoryEvent);
32,218✔
40
    }
41

42
    public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
43
    {
44
        var jObject = JObject.Load(reader);
693✔
45

46
        var eventTypeToken = jObject.GetValue("EventType", StringComparison.OrdinalIgnoreCase);
693✔
47

48
        if (eventTypeToken == null)
693✔
49
            throw new Exception("Expected EventType field in HistoryEvent");
×
50

51
        var eventType = eventTypeToken.ToObject<EventType>();
693✔
52

53
        var type = _typesMap[eventType];
693✔
54

55
        return jObject.ToObject(type, serializer);
693✔
56
    }
57

58
    public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
59
    {
60
        throw new NotImplementedException();
×
61
    }
62
}
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

© 2025 Coveralls, Inc