using IsDerivedFrom instead of while loop (#1739)

This commit is contained in:
James Frowen 2020-04-19 20:12:37 +01:00 committed by GitHub
parent a86d1cdfff
commit f17cea771e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -417,38 +417,20 @@ static bool WeaveSyncObject(TypeDefinition td)
bool modified = false;
// are ANY parent classes SyncListStruct
TypeReference parent = td.BaseType;
while (parent != null)
if (td.IsDerivedFrom(SyncListType))
{
if (parent.FullName.StartsWith(SyncListType.FullName, StringComparison.Ordinal))
{
SyncListProcessor.Process(td);
modified = true;
break;
}
if (parent.FullName.StartsWith(SyncSetType.FullName, StringComparison.Ordinal))
{
SyncListProcessor.Process(td);
modified = true;
break;
}
if (parent.FullName.StartsWith(SyncDictionaryType.FullName, StringComparison.Ordinal))
{
SyncDictionaryProcessor.Process(td);
modified = true;
break;
}
try
{
parent = parent.Resolve().BaseType;
}
catch (AssemblyResolutionException)
{
// this can happen for pluins.
//Console.WriteLine("AssemblyResolutionException: "+ ex.ToString());
break;
}
SyncListProcessor.Process(td);
modified = true;
}
else if (td.IsDerivedFrom(SyncSetType))
{
SyncListProcessor.Process(td);
modified = true;
}
else if (td.IsDerivedFrom(SyncDictionaryType))
{
SyncDictionaryProcessor.Process(td);
modified = true;
}
// check for embedded types