fix(core): Fixes region base type (#635)

Fixes `Region` being loaded instead of `BaseRegion` as the default region type.
This commit is contained in:
Kamron Batman 2021-06-02 23:12:52 -07:00 committed by GitHub
parent 803b4a33cb
commit cc5a8dc4fa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 211 additions and 190 deletions

View file

@ -591,12 +591,33 @@ namespace Server
const BindingFlags bindingFlags = BindingFlags.Public | BindingFlags.NonPublic |
BindingFlags.Instance | BindingFlags.DeclaredOnly;
if (type.GetMethod("Serialize", bindingFlags) == null)
var hasSerializeMethod = false;
var hasDeserializeMethod = false;
foreach (var method in type.GetMethods(bindingFlags))
{
if (method.Name == "Serialize")
{
hasSerializeMethod = true;
}
if (method.Name == "Deserialize")
{
var parameters = method.GetParameters();
if (parameters.Length == 1 && parameters[0].ParameterType == typeof(IGenericReader))
{
hasDeserializeMethod = true;
}
}
}
if (!hasSerializeMethod)
{
errors.AppendLine(" - No Serialize() method");
}
if (type.GetMethod("Deserialize", bindingFlags) == null)
if (!hasDeserializeMethod)
{
errors.AppendLine(" - No Deserialize() method");
}
@ -608,6 +629,10 @@ namespace Server
Utility.PopColor();
}
}
catch (AmbiguousMatchException e)
{
// ignored
}
catch
{
Console.WriteLine("Warning: Exception in serialization verification of type {0}", type);