< Summary

Line coverage
100%
Covered lines: 30
Uncovered lines: 0
Coverable lines: 30
Total lines: 90
Line coverage: 100%
Branch coverage
100%
Covered branches: 18
Total branches: 18
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.cctor()100%11100%
get_HeaderTextLines()100%11100%
Read()100%1818100%

File(s)

https://raw.githubusercontent.com/JeremyAnsel/JeremyAnsel.Media.WavefrontObj/636b700b450d7d3262bf9218a7cc67966be4ced8/JeremyAnsel.Media.WavefrontObj/JeremyAnsel.Media.WavefrontObj/LineReader.cs

#LineLine coverage
 1// <copyright file="LineReader.cs" company="Jérémy Ansel">
 2// Copyright (c) 2017, 2019 Jérémy Ansel
 3// </copyright>
 4// <license>
 5// Licensed under the MIT license. See LICENSE.txt
 6// </license>
 7
 8#if !NET6_0_OR_GREATER
 9
 10using System.Text;
 11
 12namespace JeremyAnsel.Media.WavefrontObj
 13{
 14    internal class LineReader
 15    {
 116        public static readonly char[] LineSeparators = new char[] { ' ', '\t' };
 17
 112318        public List<string> HeaderTextLines { get; } = new List<string>();
 19
 20        public IEnumerable<string> Read(Stream stream)
 21        {
 59322            using (var reader = new StreamReader(stream, Encoding.UTF8, true, 1024, true))
 23            {
 59324                string line = string.Empty;
 59325                bool isMultiLine = false;
 59326                bool readHeaderText = true;
 27
 183528                while (!reader.EndOfStream)
 29                {
 155330                    string? currentLine = reader.ReadLine();
 31
 155332                    if (string.IsNullOrWhiteSpace(currentLine))
 33                    {
 23934                        if (readHeaderText)
 35                        {
 23936                            this.HeaderTextLines.Add(string.Empty);
 37                        }
 38
 23939                        continue;
 40                    }
 41
 131442                    if (isMultiLine)
 43                    {
 744                        line = line.Substring(0, line.Length - 1) + currentLine;
 45                    }
 46                    else
 47                    {
 130748                        line = currentLine;
 49                    }
 50
 131451                    line = line.Trim();
 52
 131453                    isMultiLine = line.EndsWith("\\", StringComparison.Ordinal);
 54
 131455                    if (isMultiLine)
 56                    {
 57                        continue;
 58                    }
 59
 130760                    int commentIndex = line.IndexOf('#');
 61
 130762                    if (commentIndex == 0)
 63                    {
 1164                        if (readHeaderText)
 65                        {
 966                            this.HeaderTextLines.Add(line.Substring(1));
 67                        }
 68
 969                        continue;
 70                    }
 71
 129672                    if (readHeaderText)
 73                    {
 59274                        readHeaderText = false;
 75                    }
 76
 129677                    if (commentIndex != -1)
 78                    {
 279                        line = line.Substring(0, commentIndex);
 80                    }
 81
 129682                    yield return line;
 83                }
 28284            }
 28285        }
 86    }
 87}
 88
 89#endif
 90