< Summary - Jellyfin

Information
Class: Jellyfin.Api.Formatters.XmlOutputFormatter
Assembly: Jellyfin.Api
File(s): /srv/git/jellyfin/Jellyfin.Api/Formatters/XmlOutputFormatter.cs
Line coverage
42%
Covered lines: 6
Uncovered lines: 8
Coverable lines: 14
Total lines: 42
Line coverage: 42.8%
Branch coverage
0%
Covered branches: 0
Total branches: 4
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100 1/23/2026 - 12:11:06 AM Line coverage: 100% (6/6) Total lines: 424/19/2026 - 12:14:27 AM Line coverage: 42.8% (6/14) Branch coverage: 0% (0/4) Total lines: 42 4/19/2026 - 12:14:27 AM Line coverage: 42.8% (6/14) Branch coverage: 0% (0/4) Total lines: 42

Coverage delta

Coverage delta 58 -58

Metrics

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

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    {
 030        ArgumentNullException.ThrowIfNull(context);
 031        ArgumentNullException.ThrowIfNull(selectedEncoding);
 32
 033        var valueAsString = context.Object?.ToString();
 034        if (string.IsNullOrEmpty(valueAsString))
 35        {
 036            return;
 37        }
 38
 039        var response = context.HttpContext.Response;
 040        await response.WriteAsync(valueAsString, selectedEncoding).ConfigureAwait(false);
 041    }
 42}

Methods/Properties

.ctor()
WriteResponseBodyAsync()