< Summary

Information
Class: Elsa.Extensions.JsonElementExtensions
Assembly: Elsa.Workflows.Core
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Core/Extensions/JsonElementExtensions.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 4
Coverable lines: 4
Total lines: 19
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
GetProperty(...)0%2040%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Core/Extensions/JsonElementExtensions.cs

#LineLine coverage
 1using System.Text.Json;
 2
 3// ReSharper disable once CheckNamespace
 4namespace Elsa.Extensions;
 5
 6public static class JsonElementExtensions
 7{
 8    /// <summary>
 9    /// Returns a child element where its name matches any of the specified names.
 10    /// </summary>
 11    public static JsonElement GetProperty(this JsonElement element, params string[] names)
 12    {
 013        foreach (var name in names)
 014            if (element.TryGetProperty(name, out var value))
 015                return value;
 16
 017        throw new KeyNotFoundException($"None of the specified keys were found: {string.Join(", ", names)}");
 18    }
 19}