< Summary - Jellyfin

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

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.Net.Mime;
 2using System.Text;
 3using System.Threading.Tasks;
 4using Microsoft.AspNetCore.Http;
 5using Microsoft.AspNetCore.Mvc.Formatters;
 6
 7namespace Jellyfin.Api.Formatters;
 8
 9/// <summary>
 10/// Xml output formatter.
 11/// </summary>
 12public class XmlOutputFormatter : TextOutputFormatter
 13{
 14    /// <summary>
 15    /// Initializes a new instance of the <see cref="XmlOutputFormatter"/> class.
 16    /// </summary>
 2217    public XmlOutputFormatter()
 18    {
 2219        SupportedMediaTypes.Clear();
 2220        SupportedMediaTypes.Add(MediaTypeNames.Text.Xml);
 21
 2222        SupportedEncodings.Add(Encoding.UTF8);
 2223        SupportedEncodings.Add(Encoding.Unicode);
 2224    }
 25
 26    /// <inheritdoc />
 27    public override Task WriteResponseBodyAsync(OutputFormatterWriteContext context, Encoding selectedEncoding)
 28    {
 029        var stringResponse = context.Object?.ToString();
 030        return stringResponse is null ? Task.CompletedTask : context.HttpContext.Response.WriteAsync(stringResponse);
 31    }
 32}