Apply fix to #1460 to async writing. (#1540)

* Apply fix to #1460 to async writing.

* Replace recursion with iteration.

* Test for 1460 in async use.

* Change infinite loop style.
This commit is contained in:
Jon Hanna
2017-12-20 16:06:07 +13:00
committed by James Newton-King
parent 3ea750d6d6
commit 1b40ebfe26
4 changed files with 314 additions and 257 deletions
@@ -353,24 +353,20 @@ namespace Newtonsoft.Json.Utilities
private static bool InheritsGenericDefinitionInternal(Type currentType, Type genericClassDefinition, out Type implementingType)
{
if (currentType.IsGenericType())
do
{
Type currentGenericClassDefinition = currentType.GetGenericTypeDefinition();
if (genericClassDefinition == currentGenericClassDefinition)
if (currentType.IsGenericType() && genericClassDefinition == currentType.GetGenericTypeDefinition())
{
implementingType = currentType;
return true;
}
}
if (currentType.BaseType() == null)
{
implementingType = null;
return false;
currentType = currentType.BaseType();
}
while (currentType != null);
return InheritsGenericDefinitionInternal(currentType.BaseType(), genericClassDefinition, out implementingType);
implementingType = null;
return false;
}
/// <summary>