Check for empty string in DefaultLyricProvider

This commit is contained in:
Niels van Velzen 2023-07-01 11:16:21 +02:00
parent 6be45f73bc
commit 0ae4d175a1
3 changed files with 5 additions and 8 deletions

View File

@ -9,7 +9,7 @@ public class LyricFile
/// Initializes a new instance of the <see cref="LyricFile"/> class.
/// </summary>
/// <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)
{
Name = name;

View File

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

View File

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