Skip to content
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

Fix XmlDocumentationExtensions deadlock #780

Merged
merged 11 commits into from Sep 21, 2018
2 changes: 1 addition & 1 deletion src/NJsonSchema.Tests/Generation/XmlDocTests.cs
Expand Up @@ -118,7 +118,7 @@ public async Task When_xml_doc_is_missing_then_summary_is_missing()
//// Assert
Assert.Empty(summary);
}

public abstract class BaseBaseClass
{
/// <summary>Foo.</summary>
Expand Down
4 changes: 2 additions & 2 deletions src/NJsonSchema/Generation/JsonSchemaGenerator.cs
Expand Up @@ -325,7 +325,7 @@ public virtual string GetPropertyName(Newtonsoft.Json.Serialization.JsonProperty
schema.IsAbstract = type.GetTypeInfo().IsAbstract;

await GeneratePropertiesAndInheritanceAsync(type, schema, schemaResolver).ConfigureAwait(false);
await ApplyAdditionalPropertiesAsync(type, schema, schemaResolver);
await ApplyAdditionalPropertiesAsync(type, schema, schemaResolver).ConfigureAwait(false);

if (Settings.GenerateKnownTypes)
await GenerateKnownTypesAsync(type, schemaResolver).ConfigureAwait(false);
Expand All @@ -345,7 +345,7 @@ public virtual string GetPropertyName(Newtonsoft.Json.Serialization.JsonProperty
var genericTypeArguments = extensionDataProperty.PropertyType.GetGenericTypeArguments();
var extensionDataPropertyType = genericTypeArguments.Length == 2 ? genericTypeArguments[1] : typeof(object);

schema.AdditionalPropertiesSchema = await GenerateWithReferenceAndNullabilityAsync<JsonSchema4>(extensionDataPropertyType, null, schemaResolver);
schema.AdditionalPropertiesSchema = await GenerateWithReferenceAndNullabilityAsync<JsonSchema4>(extensionDataPropertyType, null, schemaResolver).ConfigureAwait(false);
}
else
schema.AllowAdditionalProperties = false;
Expand Down
8 changes: 4 additions & 4 deletions src/NJsonSchema/Infrastructure/DynamicApis.cs
Expand Up @@ -121,7 +121,7 @@ public static async Task<bool> DirectoryExistsAsync(string filePath)
return false;

return await FromResult((bool)DirectoryType.GetRuntimeMethod("Exists",
new[] { typeof(string) }).Invoke(null, new object[] { filePath }));
new[] { typeof(string) }).Invoke(null, new object[] { filePath })).ConfigureAwait(false);
}

/// <summary>Checks whether a file exists.</summary>
Expand All @@ -137,7 +137,7 @@ public static async Task<bool> FileExistsAsync(string filePath)
return false;

return await FromResult((bool)FileType.GetRuntimeMethod("Exists",
new[] { typeof(string) }).Invoke(null, new object[] { filePath }));
new[] { typeof(string) }).Invoke(null, new object[] { filePath })).ConfigureAwait(false);
}

/// <summary>Reads all content of a file (UTF8).</summary>
Expand Down Expand Up @@ -206,13 +206,13 @@ public static object XPathEvaluate(XDocument document, string path)
}

#if LEGACY
private static async Task<T> FromResult<T>(T result)
internal static async Task<T> FromResult<T>(T result)
{
return result;
}
#else
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static Task<T> FromResult<T>(T result)
internal static Task<T> FromResult<T>(T result)
{
return Task.FromResult(result);
}
Expand Down
355 changes: 176 additions & 179 deletions src/NJsonSchema/Infrastructure/XmlDocumentationExtensions.cs

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/NJsonSchema/JsonReferenceResolver.cs
Expand Up @@ -58,7 +58,7 @@ public void AddDocumentReference(string documentPath, IJsonReference schema)
/// <exception cref="NotSupportedException">Could not resolve the JSON path.</exception>
public async Task<IJsonReference> ResolveReferenceAsync(object rootObject, string jsonPath)
{
return await ResolveReferenceAsync(rootObject, jsonPath, true);
return await ResolveReferenceAsync(rootObject, jsonPath, true).ConfigureAwait(false);
}

/// <summary>Gets the object from the given JSON path.</summary>
Expand All @@ -69,7 +69,7 @@ public async Task<IJsonReference> ResolveReferenceAsync(object rootObject, strin
/// <exception cref="NotSupportedException">Could not resolve the JSON path.</exception>
public async Task<IJsonReference> ResolveReferenceWithoutAppendAsync(object rootObject, string jsonPath)
{
return await ResolveReferenceAsync(rootObject, jsonPath, false);
return await ResolveReferenceAsync(rootObject, jsonPath, false).ConfigureAwait(false);
}

/// <summary>Resolves a document reference.</summary>
Expand Down
2 changes: 1 addition & 1 deletion src/NJsonSchema/JsonSchema4.cs
Expand Up @@ -158,7 +158,7 @@ public static async Task<JsonSchema4> FromUrlAsync(string url)
/// <exception cref="NotSupportedException">The HttpClient.GetAsync API is not available on this platform.</exception>
public static async Task<JsonSchema4> FromUrlAsync(string url, Func<JsonSchema4, JsonReferenceResolver> referenceResolverFactory)
{
var data = await DynamicApis.HttpGetAsync(url);
var data = await DynamicApis.HttpGetAsync(url).ConfigureAwait(false);
return await FromJsonAsync(data, url, referenceResolverFactory).ConfigureAwait(false);
}

Expand Down
4 changes: 2 additions & 2 deletions src/NJsonSchema/JsonSchemaReferenceUtilities.cs
Expand Up @@ -96,9 +96,9 @@ public JsonReferenceUpdater(object rootObject, JsonReferenceResolver referenceRe
public override async Task VisitAsync(object obj)
{
_replaceRefsRound = true;
await base.VisitAsync(obj);
await base.VisitAsync(obj).ConfigureAwait(false);
_replaceRefsRound = false;
await base.VisitAsync(obj);
await base.VisitAsync(obj).ConfigureAwait(false);
}

protected override async Task<IJsonReference> VisitJsonReferenceAsync(IJsonReference reference, string path, string typeNameHint)
Expand Down