-
Notifications
You must be signed in to change notification settings - Fork 241
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor readers to reduce surface area #1958
base: dev
Are you sure you want to change the base?
Conversation
{ | ||
JsonNode jsonNode; | ||
|
||
// Parse the YAML text in the TextReader into a sequence of JsonNodes | ||
try | ||
{ | ||
jsonNode = LoadJsonNodesFromYamlDocument(input); | ||
jsonNode = LoadJsonNodesFromYamlDocument(new StreamReader(input)); // Should we leave the stream open? |
Check warning
Code scanning / CodeQL
Missing Dispose call on local IDisposable Warning
@@ -56,7 +73,7 @@ | |||
// Parse the YAML | |||
try | |||
{ | |||
jsonNode = LoadJsonNodesFromYamlDocument(input); | |||
jsonNode = LoadJsonNodesFromYamlDocument(new StreamReader(input)); |
Check warning
Code scanning / CodeQL
Missing Dispose call on local IDisposable Warning
return ParseAsync(input, reader, format, settings).GetAwaiter().GetResult(); | ||
#pragma warning restore VSTHRD002 // Avoid problematic synchronous waits | ||
// Copy string into MemoryStream | ||
var stream = new MemoryStream(Encoding.UTF8.GetBytes(input)); |
Check warning
Code scanning / CodeQL
Missing Dispose call on local IDisposable Warning
@@ -195,8 +163,8 @@ | |||
{ | |||
format ??= OpenApiConstants.Json; | |||
settings ??= new OpenApiReaderSettings(); | |||
using var reader = new StringReader(input); | |||
return Load<T>(reader, version, out diagnostic, format, settings); | |||
var stream = new MemoryStream(Encoding.UTF8.GetBytes(input)); |
Check warning
Code scanning / CodeQL
Missing Dispose call on local IDisposable Warning
{ | ||
return Load<T>(memoryStream, version, format, out diagnostic, settings); | ||
} else { | ||
memoryStream = new MemoryStream(); |
Check warning
Code scanning / CodeQL
Missing Dispose call on local IDisposable Warning
var reader = OpenApiReaderRegistry.GetReader(format); | ||
var readResult = await reader.ReadAsync(input, settings, cancellationToken); | ||
|
||
if (settings.LoadExternalRefs) |
Check warning
Code scanning / CodeQL
Dereferenced variable may be null Warning
settings
Variable
settings
private static ReadResult InternalLoad(MemoryStream input, string format, OpenApiReaderSettings settings = null) | ||
{ | ||
Utils.CheckArgumentNull(format, nameof(format)); | ||
if (settings.LoadExternalRefs) |
Check warning
Code scanning / CodeQL
Dereferenced variable may be null Warning
settings
Variable
settings
Quality Gate failedFailed conditions |
No description provided.