Check for empty string in DefaultLyricProvider

pull/9920/head
Niels van Velzen 1 year ago
parent 6be45f73bc
commit 0ae4d175a1

@ -9,7 +9,7 @@ public class LyricFile
/// Initializes a new instance of the <see cref="LyricFile"/> class. /// Initializes a new instance of the <see cref="LyricFile"/> class.
/// </summary> /// </summary>
/// <param name="name">The name.</param> /// <param name="name">The name.</param>
/// <param name="content">The content.</param> /// <param name="content">The content, must not be empty.</param>
public LyricFile(string name, string content) public LyricFile(string name, string content)
{ {
Name = name; Name = name;

@ -32,8 +32,11 @@ public class DefaultLyricProvider : ILyricProvider
if (path is not null) if (path is not null)
{ {
var content = await File.ReadAllTextAsync(path).ConfigureAwait(false); var content = await File.ReadAllTextAsync(path).ConfigureAwait(false);
if (content.Length != 0)
{
return new LyricFile(path, content); return new LyricFile(path, content);
} }
}
return null; return null;
} }

@ -32,12 +32,6 @@ public class TxtLyricParser : ILyricParser
} }
string[] lyricTextLines = lyrics.Content.Split(_lineBreakCharacters, StringSplitOptions.None); string[] lyricTextLines = lyrics.Content.Split(_lineBreakCharacters, StringSplitOptions.None);
if (lyricTextLines.Length == 0)
{
return null;
}
LyricLine[] lyricList = new LyricLine[lyricTextLines.Length]; LyricLine[] lyricList = new LyricLine[lyricTextLines.Length];
for (int lyricLineIndex = 0; lyricLineIndex < lyricTextLines.Length; lyricLineIndex++) for (int lyricLineIndex = 0; lyricLineIndex < lyricTextLines.Length; lyricLineIndex++)

Loading…
Cancel
Save