< Summary

Information
Class: Elsa.Persistence.EFCore.JsonValueConverterHelper
Assembly: Elsa.Persistence.EFCore.Common
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Persistence.EFCore.Common/JsonValueConverterHelper.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 4
Coverable lines: 4
Total lines: 25
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 4
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.cctor()100%210%
Deserialize(...)0%620%
Serialize(...)0%620%
CreateJsonSerializerOptions()100%210%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Persistence.EFCore.Common/JsonValueConverterHelper.cs

#LineLine coverage
 1using System.Text.Json;
 2using Elsa.Persistence.EFCore.Converters;
 3using Elsa.Extensions;
 4
 5namespace Elsa.Persistence.EFCore;
 6
 7internal static class JsonValueConverterHelper
 8{
 09    private static readonly JsonSerializerOptions JsonSerializerOptions = CreateJsonSerializerOptions();
 10
 11    public static T Deserialize<T>(string json) where T : class
 12    {
 013        return (string.IsNullOrWhiteSpace(json) ? null : JsonSerializer.Deserialize<T>(json, JsonSerializerOptions))!;
 14    }
 15
 16    public static string Serialize<T>(T obj) where T : class
 17    {
 018        return (obj == null! ? null : JsonSerializer.Serialize(obj, JsonSerializerOptions))!;
 19    }
 20
 21    private static JsonSerializerOptions CreateJsonSerializerOptions()
 22    {
 023        return new JsonSerializerOptions().WithConverters(new PrimitiveDictionaryConverter());
 24    }
 25}