-
Notifications
You must be signed in to change notification settings - Fork 265
Description
Describe the bug
Initialization of StreamReader in OpenApiStreamReader throws an ArgumentNullException in version 1.6.14.
To Reproduce
The behavior can be reproduced by calling OpenApiStreamReader.ReadAsync() from within a .NET source generator. The exception is thrown when the source generator is run.
The bug seems to be related to this commit 9a47cb2 where the StreamReader
constructor is changed. Version 1.6.13 did not have the same behavior.
To verify, the same behavior can be reproduced by simply loading a file from within a .NET source generator passing a null-value encoding to the StreamReader
in the same manner as is done inside OpenApiStreamReader.ReadAsync()
:
var reader = new StreamReader(inputStream, encoding: default, detectEncodingFromByteOrderMarks: true, bufferSize: -1, leaveOpen: false);
Additional context
OAS documents are loaded from an external stream from within a .NET source generator.
The exception is thrown when the compiler invokes the source generator, making the source generator fail.
The Visual Studio version is 17.9.3
The source generator targets netstandard2.0
The project that uses the source generator targets .net8