< Summary

Information
Line coverage
0%
Covered lines: 0
Uncovered lines: 6
Coverable lines: 6
Total lines: 49
Line coverage: 0%
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 Cyclomatic complexity NPath complexity Sequence coverage
GetRawUtf8Value(...)100%110%
GetRawUtf8PropertyName(...)100%110%

File(s)

C:\h\w\B31A098C\w\BB5A0A33\e\runtime-utils\Runner\runtime\src\libraries\System.Text.Json\src\System\Runtime\InteropServices\JsonMarshal.cs

#LineLine coverage
 1// Licensed to the .NET Foundation under one or more agreements.
 2// The .NET Foundation licenses this file to you under the MIT license.
 3
 4using System.Text.Json;
 5
 6namespace System.Runtime.InteropServices
 7{
 8    /// <summary>
 9    /// An unsafe class that provides a set of methods to access the underlying data representations of JSON types.
 10    /// </summary>
 11    public static class JsonMarshal
 12    {
 13        /// <summary>
 14        /// Gets a <see cref="ReadOnlySpan{T}"/> view over the raw JSON data of the given <see cref="JsonElement"/>.
 15        /// </summary>
 16        /// <param name="element">The JSON element from which to extract the span.</param>
 17        /// <returns>The span containing the raw JSON data of<paramref name="element"/>.</returns>
 18        /// <exception cref="ObjectDisposedException">The underlying <see cref="JsonDocument"/> has been disposed.</exce
 19        /// <remarks>
 20        /// While the method itself does check for disposal of the underlying <see cref="JsonDocument"/>,
 21        /// it is possible that it could be disposed after the method returns, which would result in
 22        /// the span pointing to a buffer that has been returned to the shared pool. Callers should take
 23        /// extra care to make sure that such a scenario isn't possible to avoid potential data corruption.
 24        /// </remarks>
 25        public static ReadOnlySpan<byte> GetRawUtf8Value(JsonElement element)
 026        {
 027            return element.GetRawValue().Span;
 028        }
 29
 30        /// <summary>
 31        /// Gets a <see cref="ReadOnlySpan{T}"/> view over the raw JSON data of the given <see cref="JsonProperty"/> nam
 32        /// </summary>
 33        /// <param name="property">The JSON property from which to extract the span.</param>
 34        /// <returns>The span containing the raw JSON data of the <paramref name="property"/> name. This will not includ
 35        /// <exception cref="ObjectDisposedException">The underlying <see cref="JsonDocument"/> has been disposed.</exce
 36        /// <remarks>
 37        /// <para>
 38        /// While the method itself does check for disposal of the underlying <see cref="JsonDocument"/>,
 39        /// it is possible that it could be disposed after the method returns, which would result in
 40        /// the span pointing to a buffer that has been returned to the shared pool. Callers should take
 41        /// extra care to make sure that such a scenario isn't possible to avoid potential data corruption.
 42        /// </para>
 43        /// </remarks>
 44        public static ReadOnlySpan<byte> GetRawUtf8PropertyName(JsonProperty property)
 045        {
 046            return property.NameSpan;
 047        }
 48    }
 49}