Skip to content

Commit 95f7f9d

Browse files
committed
Add .ConfigureAwait(false) everywhere we're doing async
1 parent d19bd8c commit 95f7f9d

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

src/json-ld.net/Core/DocumentLoader.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ JsonLDContentType GetJsonLDContentType(string contentTypeStr)
4747
/// <exception cref="JsonLDNet.Core.JsonLdError"></exception>
4848
public virtual RemoteDocument LoadDocument(string url)
4949
{
50-
return LoadDocumentAsync(url).GetAwaiter().GetResult();
50+
return LoadDocumentAsync(url).ConfigureAwait(false).GetAwaiter().GetResult();
5151
}
5252

5353
/// <exception cref="JsonLDNet.Core.JsonLdError"></exception>
@@ -56,7 +56,7 @@ public virtual async Task<RemoteDocument> LoadDocumentAsync(string url)
5656
RemoteDocument doc = new RemoteDocument(url, null);
5757
try
5858
{
59-
using (HttpResponseMessage response = await JsonLD.Util.LDHttpClient.FetchAsync(url))
59+
using (HttpResponseMessage response = await JsonLD.Util.LDHttpClient.FetchAsync(url).ConfigureAwait(false))
6060
{
6161

6262
var code = (int)response.StatusCode;
@@ -88,12 +88,12 @@ public virtual async Task<RemoteDocument> LoadDocumentAsync(string url)
8888
string header = linkedContexts.First();
8989
string linkedUrl = header.Substring(1, header.IndexOf(">") - 1);
9090
string resolvedUrl = URL.Resolve(finalUrl, linkedUrl);
91-
var remoteContext = this.LoadDocument(resolvedUrl);
91+
var remoteContext = await this.LoadDocumentAsync(resolvedUrl).ConfigureAwait(false);
9292
doc.contextUrl = remoteContext.documentUrl;
9393
doc.context = remoteContext.document;
9494
}
9595

96-
Stream stream = await response.Content.ReadAsStreamAsync();
96+
Stream stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false);
9797

9898
doc.DocumentUrl = finalUrl;
9999
doc.Document = JSONUtils.FromInputStream(stream);

src/json-ld.net/Util/JSONUtils.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public static string ToString(JToken obj)
117117

118118
public static JToken FromURL(Uri url)
119119
{
120-
return FromURLAsync(url).GetAwaiter().GetResult();
120+
return FromURLAsync(url).ConfigureAwait(false).GetAwaiter().GetResult();
121121
}
122122

123123
/// <summary>
@@ -139,8 +139,8 @@ public static JToken FromURL(Uri url)
139139
/// </exception>
140140
public static async Task<JToken> FromURLAsync(Uri url)
141141
{
142-
using (var response = await LDHttpClient.FetchAsync(url.ToString())) {
143-
return FromInputStream(await response.Content.ReadAsStreamAsync());
142+
using (var response = await LDHttpClient.FetchAsync(url.ToString()).ConfigureAwait(false)) {
143+
return FromInputStream(await response.Content.ReadAsStreamAsync().ConfigureAwait(false));
144144
}
145145
}
146146
}

src/json-ld.net/Util/LDHttpClient.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ static public async Task<HttpResponseMessage> FetchAsync(string url)
3232
do
3333
{
3434
HttpRequestMessage httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, redirectedUrl);
35-
response = await _hc.SendAsync(httpRequestMessage);
35+
response = await _hc.SendAsync(httpRequestMessage).ConfigureAwait(false);
3636
if (response.Headers.TryGetValues("Location", out var location))
3737
{
3838
redirectedUrl = location.First();

0 commit comments

Comments
 (0)