Fixed stackoverflow caused by ParseDerived due to GetDerivedNonAbstract not returning abstract types
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
#nullable enable
|
#nullable enable
|
||||||
|
using Barotrauma.Debugging;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Concurrent;
|
using System.Collections.Concurrent;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@@ -56,6 +57,12 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
return ImmutableArray<Type>.Empty; // No types, don't add to cache
|
return ImmutableArray<Type>.Empty; // No types, don't add to cache
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!TypeSearchCache.TryAdd(typeName, list))
|
||||||
|
{
|
||||||
|
DebugConsoleCore.Log($"ReflectionUtils.AddNonAbstractAssemblyTypes(): Error while adding to quick lookup cache.");
|
||||||
|
}
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -107,7 +114,7 @@ namespace Barotrauma
|
|||||||
public static void ResetCache()
|
public static void ResetCache()
|
||||||
{
|
{
|
||||||
CachedNonAbstractTypes.Clear();
|
CachedNonAbstractTypes.Clear();
|
||||||
CachedNonAbstractTypes.TryAdd(typeof(ReflectionUtils).Assembly, typeof(ReflectionUtils).Assembly.GetTypes().ToImmutableArray());
|
CachedNonAbstractTypes.TryAdd(typeof(ReflectionUtils).Assembly, typeof(ReflectionUtils).Assembly.GetTypes().Where(t => !t.IsAbstract).ToImmutableArray());
|
||||||
TypeSearchCache.Clear();
|
TypeSearchCache.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user