-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Add sync HttpClient support #13722
Add sync HttpClient support #13722
Changes from 17 commits
3f58d75
e64f474
24a7b32
7e0c46b
812b183
2b57aa3
724c6cd
4d78603
1fb414f
c5247ad
dd594a0
32304e6
8282891
1c897ec
551c2ae
516b69c
fefef2a
78c4638
091c8c4
50cc8fd
f4b84ed
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
// Licensed under the MIT License. | ||
|
||
using System; | ||
using System.Diagnostics.CodeAnalysis; | ||
using System.IO; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
@@ -28,7 +29,7 @@ public static class SerializationExtensions | |
/// <param name="cancellationToken">The <see cref="CancellationToken"/> to use during deserialization.</param> | ||
///<returns>The data converted to the specified type.</returns> | ||
public static T ToObject<T>(this BinaryData data, ObjectSerializer serializer, CancellationToken cancellationToken = default) => | ||
(T)serializer.Deserialize(data.ToStream(), typeof(T), cancellationToken); | ||
(T)serializer.Deserialize(data.ToStream(), typeof(T), cancellationToken)!; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same comment applies to these changed lines in this file. Also, given this is a fully-public API, we should probably be checking parameters here; though, I'm on the side of not checking the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changed the return type to nullable. cc @JoshLove-msft if he wants to file an issue for argument checking. |
||
|
||
/// <summary> | ||
/// Converts the <see cref="BinaryData"/> to the specified type using | ||
|
@@ -42,7 +43,7 @@ public static T ToObject<T>(this BinaryData data, ObjectSerializer serializer, C | |
/// <param name="cancellationToken">The <see cref="CancellationToken"/> to use during deserialization.</param> | ||
///<returns>The data converted to the specified type.</returns> | ||
public static async ValueTask<T> ToObjectAsync<T>(this BinaryData data, ObjectSerializer serializer, CancellationToken cancellationToken = default) => | ||
(T)await serializer.DeserializeAsync(data.ToStream(), typeof(T), cancellationToken).ConfigureAwait(false); | ||
(T)(await serializer.DeserializeAsync(data.ToStream(), typeof(T), cancellationToken).ConfigureAwait(false))!; | ||
|
||
/// <summary> | ||
/// Convert the provided value to it's binary representation and return it as a <see cref="BinaryData"/> instance. | ||
|
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.
Is this strictly true, though?
ToString()
could (though shouldn't) return null. Is that guarded?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.
Changed the return type to nullable.