-
Notifications
You must be signed in to change notification settings - Fork 352
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
Implement asynchronous support for ODataJsonLightParameterWriter #2096
Implement asynchronous support for ODataJsonLightParameterWriter #2096
Conversation
{ | ||
try | ||
{ | ||
return await func().ConfigureAwait(false); |
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.
return [](start = 16, length = 6)
return is necessary here?
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.
@xuzhg Yes, because we use this overload in scenarios like below where we need the return value:
ODataWriter resourceWriter = await this.InterceptExceptionAsync(
() => this.CreateResourceWriterImplementationAsync(parameterName, itemTypeReference)).ConfigureAwait(false);
It's for that same reason why it accepts a parameter of type Func<Task<T>> func
- as opposed to Func<Task>
for the overload
/// </summary> | ||
/// <param name="action">The delegate to execute asynchronously.</param> | ||
/// <returns>A task that represents the asynchronous operation.</returns> | ||
private async Task InterceptExceptionAsync(Func<Task> action) |
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.
action [](start = 62, length = 6)
here is "action", the below is "func". Maybe need consistent.
Debug.Assert(this.State == ParameterWriterState.Start, "this.State == ParameterWriterState.Start"); | ||
|
||
await this.InterceptExceptionAsync(this.StartPayloadAsync) | ||
.ConfigureAwait(false); |
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.
one line code
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.
Below this line we also have:
this.EnterScope(ParameterWriterState.CanWriteParameter);
We await
the call to this.InterceptExceptionAsync
since we need the this.EnterScope
to be executed in the continuation.
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.
/// <summary> | ||
/// Asynchronously start writing a resourceSet. | ||
/// </summary> | ||
/// <param name="resourceSet">Resource Set/collection to write.</param> | ||
/// <returns>A task instance that represents the asynchronous write operation.</returns> | ||
public sealed override Task WriteStartAsync(ODataResourceSet resourceSet) | ||
public sealed override async Task WriteStartAsync(ODataResourceSet resourceSet) |
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.
async [](start = 31, length = 5)
Is it a breaking change?
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.
No
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.
A few comments
} | ||
|
||
/// <summary> | ||
/// Asynchronously creates a format specific <see cref="ODataWriter"/> to write a resource set. |
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.
check indents
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.
@gathogojr Seems like there are mixed tabs and spaces in this file.
43c46b3
to
5157ad2
Compare
/// <param name="expectedTypeReference">The expected type reference of the parameter value.</param> | ||
/// <returns>A task that represents the asynchronous write operation.</returns> |
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.
/// <param name="expectedTypeReference">The expected type reference of the parameter value.</param> | |
/// <returns>A task that represents the asynchronous write operation.</returns> | |
/// <param name="expectedTypeReference">The expected type reference of the parameter value.</param> | |
/// <returns>A task that represents the asynchronous write operation.</returns> |
ODataEnumValue enumVal = parameterValue as ODataEnumValue; | ||
if (enumVal != null) | ||
{ |
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.
ODataEnumValue enumVal = parameterValue as ODataEnumValue; | |
if (enumVal != null) | |
{ | |
if (parameterValue is ODataEnumValue enumVal) | |
{ | |
} | ||
|
||
/// <summary> | ||
/// Asynchronously creates a format specific <see cref="ODataWriter"/> to write a resource set. |
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.
@gathogojr Seems like there are mixed tabs and spaces in this file.
0c0327a
to
be3e49a
Compare
be3e49a
to
28cda79
Compare
This PR has Quantification details
Why proper sizing of changes matters
Optimal pull request sizes drive a better predictable PR flow as they strike a
What can I do to optimize my changes
How to interpret the change counts in git diff output
Was this comment helpful? 👍 :ok_hand: :thumbsdown: (Email) |
Issues
This pull request is in partial fulfilment of issue #2019.
Description
Implement asynchronous support in
ODataJsonLightParameterWriter
Checklist (Uncheck if it is not completed)
Additional work necessary
If documentation update is needed, please add "Docs Needed" label to the issue and provide details about the required document change in the issue.