< Summary - Jellyfin

Information
Class: Jellyfin.Api.Formatters.XmlOutputFormatter
Assembly: Jellyfin.Api
File(s): /srv/git/jellyfin/Jellyfin.Api/Formatters/XmlOutputFormatter.cs
Line coverage
100%
Covered lines: 6
Uncovered lines: 0
Coverable lines: 6
Total lines: 42
Line coverage: 100%
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

Coverage history

Coverage history 0 25 50 75 100 8/14/2025 - 12:11:05 AM Line coverage: 100% (4/4) Total lines: 1910/28/2025 - 12:11:27 AM Line coverage: 100% (6/6) Total lines: 42

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor()100%11100%

File(s)

/srv/git/jellyfin/Jellyfin.Api/Formatters/XmlOutputFormatter.cs

#LineLine coverage
 1using System;
 2using System.Net.Mime;
 3using System.Text;
 4using System.Threading.Tasks;
 5using Microsoft.AspNetCore.Http;
 6using Microsoft.AspNetCore.Mvc.Formatters;
 7
 8namespace Jellyfin.Api.Formatters;
 9
 10/// <summary>
 11/// Xml output formatter.
 12/// </summary>
 13public sealed class XmlOutputFormatter : TextOutputFormatter
 14{
 15    /// <summary>
 16    /// Initializes a new instance of the <see cref="XmlOutputFormatter"/> class.
 17    /// </summary>
 2118    public XmlOutputFormatter()
 19    {
 2120        SupportedMediaTypes.Clear();
 2121        SupportedMediaTypes.Add(MediaTypeNames.Text.Xml);
 22
 2123        SupportedEncodings.Add(Encoding.UTF8);
 2124        SupportedEncodings.Add(Encoding.Unicode);
 2125    }
 26
 27    /// <inheritdoc />
 28    public override async Task WriteResponseBodyAsync(OutputFormatterWriteContext context, Encoding selectedEncoding)
 29    {
 30        ArgumentNullException.ThrowIfNull(context);
 31        ArgumentNullException.ThrowIfNull(selectedEncoding);
 32
 33        var valueAsString = context.Object?.ToString();
 34        if (string.IsNullOrEmpty(valueAsString))
 35        {
 36            return;
 37        }
 38
 39        var response = context.HttpContext.Response;
 40        await response.WriteAsync(valueAsString, selectedEncoding).ConfigureAwait(false);
 41    }
 42}

Methods/Properties

.ctor()