< Summary - Jellyfin

Information
Class: MediaBrowser.Model.Extensions.StringHelper
Assembly: MediaBrowser.Model
File(s): /srv/git/jellyfin/MediaBrowser.Model/Extensions/StringHelper.cs
Line coverage
100%
Covered lines: 12
Uncovered lines: 0
Coverable lines: 12
Total lines: 38
Line coverage: 100%
Branch coverage
100%
Covered branches: 4
Total branches: 4
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100 10/5/2025 - 12:11:27 AM Line coverage: 100% (15/15) Branch coverage: 100% (4/4) Total lines: 391/4/2026 - 12:12:33 AM Line coverage: 100% (12/12) Branch coverage: 100% (4/4) Total lines: 38 10/5/2025 - 12:11:27 AM Line coverage: 100% (15/15) Branch coverage: 100% (4/4) Total lines: 391/4/2026 - 12:12:33 AM Line coverage: 100% (12/12) Branch coverage: 100% (4/4) Total lines: 38

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
FirstToUpper(...)100%44100%

File(s)

/srv/git/jellyfin/MediaBrowser.Model/Extensions/StringHelper.cs

#LineLine coverage
 1using System;
 2
 3namespace MediaBrowser.Model.Extensions
 4{
 5    /// <summary>
 6    /// Helper methods for manipulating strings.
 7    /// </summary>
 8    public static class StringHelper
 9    {
 10        /// <summary>
 11        /// Returns the string with the first character as uppercase.
 12        /// </summary>
 13        /// <param name="str">The input string.</param>
 14        /// <returns>The string with the first character as uppercase.</returns>
 15        public static string FirstToUpper(string str)
 16        {
 12417            if (str.Length == 0)
 18            {
 119                return str;
 20            }
 21
 22            // We check IsLower instead of IsUpper because both return false for non-letters
 12323            if (!char.IsLower(str[0]))
 24            {
 10325                return str;
 26            }
 27
 2028            return string.Create(
 2029                str.Length,
 2030                str.AsSpan(),
 2031                (chars, buf) =>
 2032                {
 2033                    chars[0] = char.ToUpperInvariant(buf[0]);
 2034                    buf.Slice(1).CopyTo(chars.Slice(1));
 2035                });
 36        }
 37    }
 38}

Methods/Properties

FirstToUpper(System.String)