@@ -39,7 +39,11 @@ public static ReadResult Load(MemoryStream stream,
3939 string format = null ,
4040 OpenApiReaderSettings settings = null )
4141 {
42+ #if NET6_0_OR_GREATER
43+ ArgumentNullException . ThrowIfNull ( stream ) ;
44+ #else
4245 if ( stream is null ) throw new ArgumentNullException ( nameof ( stream ) ) ;
46+ #endif
4347 settings ??= new OpenApiReaderSettings ( ) ;
4448
4549 // Get the format of the stream if not provided
@@ -112,7 +116,11 @@ public static async Task<T> LoadAsync<T>(string url, OpenApiSpecVersion version,
112116 /// <returns></returns>
113117 public static async Task < ReadResult > LoadAsync ( Stream input , string format = null , OpenApiReaderSettings settings = null , CancellationToken cancellationToken = default )
114118 {
119+ #if NET6_0_OR_GREATER
120+ ArgumentNullException . ThrowIfNull ( input ) ;
121+ #else
115122 if ( input is null ) throw new ArgumentNullException ( nameof ( input ) ) ;
123+ #endif
116124 settings ??= new OpenApiReaderSettings ( ) ;
117125
118126 Stream preparedStream ;
@@ -160,7 +168,11 @@ public static async Task<T> LoadAsync<T>(Stream input,
160168 CancellationToken token = default ) where T : IOpenApiElement
161169 {
162170 Utils . CheckArgumentNull ( openApiDocument ) ;
171+ #if NET6_0_OR_GREATER
172+ ArgumentNullException . ThrowIfNull ( input ) ;
173+ #else
163174 if ( input is null ) throw new ArgumentNullException ( nameof ( input ) ) ;
175+ #endif
164176 if ( input is MemoryStream memoryStream )
165177 {
166178 return Load < T > ( memoryStream , version , format , openApiDocument , out var _ , settings ) ;
@@ -185,7 +197,11 @@ public static ReadResult Parse(string input,
185197 string format = null ,
186198 OpenApiReaderSettings settings = null )
187199 {
188- if ( input is null ) throw new ArgumentNullException ( nameof ( input ) ) ;
200+ #if NET6_0_OR_GREATER
201+ ArgumentException . ThrowIfNullOrEmpty ( input ) ;
202+ #else
203+ if ( string . IsNullOrEmpty ( input ) ) throw new ArgumentNullException ( nameof ( input ) ) ;
204+ #endif
189205 format ??= InspectInputFormat ( input ) ;
190206 settings ??= new OpenApiReaderSettings ( ) ;
191207
@@ -212,7 +228,11 @@ public static T Parse<T>(string input,
212228 string format = null ,
213229 OpenApiReaderSettings settings = null ) where T : IOpenApiElement
214230 {
215- if ( input is null ) throw new ArgumentNullException ( nameof ( input ) ) ;
231+ #if NET6_0_OR_GREATER
232+ ArgumentException . ThrowIfNullOrEmpty ( input ) ;
233+ #else
234+ if ( string . IsNullOrEmpty ( input ) ) throw new ArgumentNullException ( nameof ( input ) ) ;
235+ #endif
216236 format ??= InspectInputFormat ( input ) ;
217237 settings ??= new OpenApiReaderSettings ( ) ;
218238 using var stream = new MemoryStream ( Encoding . UTF8 . GetBytes ( input ) ) ;
@@ -325,8 +345,12 @@ private static string InspectInputFormat(string input)
325345
326346 private static string InspectStreamFormat ( Stream stream )
327347 {
328- if ( stream == null ) throw new ArgumentNullException ( nameof ( stream ) ) ;
329-
348+ #if NET6_0_OR_GREATER
349+ ArgumentNullException . ThrowIfNull ( stream ) ;
350+ #else
351+ if ( stream is null ) throw new ArgumentNullException ( nameof ( stream ) ) ;
352+ #endif
353+
330354 long initialPosition = stream . Position ;
331355 int firstByte = stream . ReadByte ( ) ;
332356
0 commit comments