< 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: 15
Uncovered lines: 0
Coverable lines: 15
Total lines: 39
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

Metrics

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

File(s)

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

#LineLine coverage
 1namespace MediaBrowser.Model.Extensions
 2{
 3    /// <summary>
 4    /// Helper methods for manipulating strings.
 5    /// </summary>
 6    public static class StringHelper
 7    {
 8        /// <summary>
 9        /// Returns the string with the first character as uppercase.
 10        /// </summary>
 11        /// <param name="str">The input string.</param>
 12        /// <returns>The string with the first character as uppercase.</returns>
 13        public static string FirstToUpper(string str)
 14        {
 12415            if (str.Length == 0)
 16            {
 117                return str;
 18            }
 19
 20            // We check IsLower instead of IsUpper because both return false for non-letters
 12321            if (!char.IsLower(str[0]))
 22            {
 9723                return str;
 24            }
 25
 2626            return string.Create(
 2627                str.Length,
 2628                str,
 2629                (chars, buf) =>
 2630                {
 2631                    chars[0] = char.ToUpperInvariant(buf[0]);
 2632                    for (int i = 1; i < chars.Length; i++)
 2633                    {
 2634                        chars[i] = buf[i];
 2635                    }
 2636                });
 37        }
 38    }
 39}

Methods/Properties

FirstToUpper(System.String)