-
Notifications
You must be signed in to change notification settings - Fork 279
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 https://github.com/microsoftgraph/microsoft-graph-devx-api/issues/583
This PR:
booleansetting inOpenApiReaderSettings.cs:LeaveStreamOpento flag whether or not to leave the stream object open after reading from anOpenApiStreamReaderobject.Creating a
StreamReaderobject within ausingstatement closes thestreamwhen theDispose()method of theStreamReaderis called.OpenApiStreamReadertests to validate setting theLeaveStreamOpensetting to eithertrueorfalse.