[X] Are you running the latest version of AngleSharp?
[ ] Did you check the FAQs to see if that helps you?
[X] Are you reporting to the correct repository? (there are multiple AngleSharp libraries, e.g., AngleSharp.Css for CSS support)
[X] Did you perform a search in the issues?
For more information, see the CONTRIBUTING guide.
Description
Calling CssParser.ParseStyleSheetAsync("") throws a System.NullReferenceException.
Steps to Reproduce
Code:
class Program
{
static async Task Main(string[] args)
{
var parser = new CssParser();
var s = await parser.ParseStyleSheetAsync("");
Console.WriteLine(s);
}
}
Stacktrace:
Unhandled exception. System.NullReferenceException: Object reference not set to an instance of an object.
at AngleSharp.Text.TextSource.DetectByteOrderMarkAsync(CancellationToken cancellationToken)
at AngleSharp.Text.TextSource.PrefetchAllAsync(CancellationToken cancellationToken)
at AngleSharp.Css.Parser.CssParser.ParseStyleSheetAsync(String content, CancellationToken cancelToken)
Expected behavior: [What you expected to happen]
To behave like the non-async version which correctly parses the empty string and returns an empty stylesheet.
Bug Report
Prerequisites
AngleSharp.Css
for CSS support)For more information, see the
CONTRIBUTING
guide.Description
Calling CssParser.ParseStyleSheetAsync("") throws a System.NullReferenceException.
Steps to Reproduce
Code:
Stacktrace: Unhandled exception. System.NullReferenceException: Object reference not set to an instance of an object. at AngleSharp.Text.TextSource.DetectByteOrderMarkAsync(CancellationToken cancellationToken) at AngleSharp.Text.TextSource.PrefetchAllAsync(CancellationToken cancellationToken) at AngleSharp.Css.Parser.CssParser.ParseStyleSheetAsync(String content, CancellationToken cancelToken)
Expected behavior: [What you expected to happen] To behave like the non-async version which correctly parses the empty string and returns an empty stylesheet.
Environment details: [OS, .NET Runtime, ...] Windows 10 .NET Core 3.0.100