diff --git a/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj b/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj index 05e3e52e6..68ff691bf 100644 --- a/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj +++ b/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj @@ -1,6 +1,7 @@ - netstandard2.0 + netstandard2.0;net6.0; + latest true 2.0.0-preview3 diff --git a/src/Microsoft.OpenApi.Readers/OpenApiYamlReader.cs b/src/Microsoft.OpenApi.Readers/OpenApiYamlReader.cs index 95e58c52f..217db91b3 100644 --- a/src/Microsoft.OpenApi.Readers/OpenApiYamlReader.cs +++ b/src/Microsoft.OpenApi.Readers/OpenApiYamlReader.cs @@ -12,6 +12,7 @@ using System.Linq; using Microsoft.OpenApi.Models; using System; +using System.Text; namespace Microsoft.OpenApi.Readers { @@ -53,7 +54,13 @@ public ReadResult Read(MemoryStream input, // Parse the YAML text in the stream into a sequence of JsonNodes try { +#if NET +// this represents net core, net5 and up using var stream = new StreamReader(input, default, true, -1, settings.LeaveStreamOpen); +#else +// the implementation differs and results in a null reference exception in NETFX + using var stream = new StreamReader(input, Encoding.UTF8, true, 4096, settings.LeaveStreamOpen); +#endif jsonNode = LoadJsonNodesFromYamlDocument(stream); } catch (JsonException ex)