-
Notifications
You must be signed in to change notification settings - Fork 264
Adds setting to configure leaving stream open #605
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
Conversation
public OpenApiDocument Read(Stream input, out OpenApiDiagnostic diagnostic) | ||
{ | ||
using (var reader = new StreamReader(input)) | ||
if (_settings.LeaveStreamOpen) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
var reader = new StreamReader(input);
var result = new OpenApiTextReaderReader(_settings).Read(reader, out diagnostic);
if (!_settings.LeaveStreamOpen)
reader.Dispose();
return result;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. Much cleaner!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like brackets after if
statements though, even for one-liners 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I won't fight coding preferences. It seems that I'm the only one on the team to like one liners with no brackets 😅
- Remove default assignment of false boolean to setting - Code simplification
…ble' into is/OpenApiStreamReader-configurable
Fixes #530
Closes microsoftgraph/microsoft-graph-devx-api#583
This PR:
boolean
setting inOpenApiReaderSettings.cs
:LeaveStreamOpen
to flag whether or not to leave the stream object open after reading from anOpenApiStreamReader
object.Creating a
StreamReader
object within ausing
statement closes thestream
when theDispose()
method of theStreamReader
is called.OpenApiStreamReader
tests to validate setting theLeaveStreamOpen
setting to eithertrue
orfalse
.