< Summary

Information
Class: Elsa.Workflows.Serialization.Serializers.JsonActivitySerializer
Assembly: Elsa.Workflows.Core
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Core/Serialization/Serializers/JsonActivitySerializer.cs
Line coverage
78%
Covered lines: 11
Uncovered lines: 3
Coverable lines: 14
Total lines: 42
Line coverage: 78.5%
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%
Serialize(...)100%11100%
Serialize(...)100%210%
Deserialize(...)100%11100%
Deserialize(...)100%210%
Deserialize(...)100%11100%
AddConverters(...)100%11100%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Core/Serialization/Serializers/JsonActivitySerializer.cs

#LineLine coverage
 1using System.Text.Json;
 2using Elsa.Common.Serialization;
 3using Elsa.Workflows.Serialization.Converters;
 4
 5namespace Elsa.Workflows.Serialization.Serializers;
 6
 7/// <inheritdoc cref="IActivitySerializer" />
 1148public class JsonActivitySerializer(IServiceProvider serviceProvider) : ConfigurableSerializer(serviceProvider), IActivi
 9{
 10    /// <inheritdoc />
 11    public string Serialize(IActivity activity)
 12    {
 65213        var options = GetOptionsInternal();
 65214        return JsonSerializer.Serialize(activity, activity.GetType(), options);
 15    }
 16
 17    /// <inheritdoc />
 18    public string Serialize(object value)
 19    {
 020        var options = GetOptionsInternal();
 021        return JsonSerializer.Serialize(value, options);
 22    }
 23
 24    /// <inheritdoc />
 825    public IActivity Deserialize(string serializedActivity) => JsonSerializer.Deserialize<IActivity>(serializedActivity,
 26
 27    /// <inheritdoc />
 028    public object Deserialize(string serializedValue, Type type) => JsonSerializer.Deserialize(serializedValue, type, Ge
 29
 30    /// <inheritdoc />
 106131    public T Deserialize<T>(string serializedValue) => JsonSerializer.Deserialize<T>(serializedValue, GetOptions())!;
 32
 33    /// <inheritdoc />
 34    protected override void AddConverters(JsonSerializerOptions options)
 35    {
 65236        options.Converters.Add(CreateInstance<TypeJsonConverter>());
 65237        options.Converters.Add(CreateInstance<InputJsonConverterFactory>());
 65238        options.Converters.Add(CreateInstance<OutputJsonConverterFactory>());
 65239        options.Converters.Add(CreateInstance<ExpressionJsonConverterFactory>());
 65240        options.Converters.Add(CreateInstance<FuncExpressionValueConverter>());
 65241    }
 42}