mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-15 03:30:53 +01:00
test/datafield fixes
This commit is contained in:
@@ -131,7 +131,7 @@ namespace Robust.Shared.Serialization.Manager
|
||||
if (node is not SequenceDataNode sequenceDataNode) return new ErrorNode(node);
|
||||
var elementType = underlyingType.GetElementType();
|
||||
if (elementType == null)
|
||||
throw new ArgumentException($"Failed to get elementtype of arraytype {type}", nameof(type));
|
||||
throw new ArgumentException($"Failed to get elementtype of arraytype {underlyingType}", nameof(underlyingType));
|
||||
var validatedList = new List<ValidatedNode>();
|
||||
foreach (var dataNode in sequenceDataNode.Sequence)
|
||||
{
|
||||
@@ -173,12 +173,12 @@ namespace Robust.Shared.Serialization.Manager
|
||||
}
|
||||
}
|
||||
|
||||
if (TryValidateWithTypeReader(type, node, context, out var valid)) return valid;
|
||||
if (TryValidateWithTypeReader(underlyingType, node, context, out var valid)) return valid;
|
||||
|
||||
if (typeof(ISelfSerialize).IsAssignableFrom(type))
|
||||
if (typeof(ISelfSerialize).IsAssignableFrom(underlyingType))
|
||||
return node is ValueDataNode valueDataNode ? new ValidatedValueNode(valueDataNode) : new ErrorNode(node);
|
||||
|
||||
if (TryGetDataDefinition(type, out var dataDefinition))
|
||||
if (TryGetDataDefinition(underlyingType, out var dataDefinition))
|
||||
{
|
||||
return node switch
|
||||
{
|
||||
@@ -214,7 +214,7 @@ namespace Robust.Shared.Serialization.Manager
|
||||
if (!TryGetDataDefinition(obj.GetType(), out var dataDefinition))
|
||||
throw new ArgumentException($"Provided Type is not a data definition ({obj.GetType()})");
|
||||
|
||||
if (!skipHook && obj is IPopulateDefaultValues populateDefaultValues)
|
||||
if (obj is IPopulateDefaultValues populateDefaultValues)
|
||||
{
|
||||
populateDefaultValues.PopulateDefaultValues();
|
||||
}
|
||||
@@ -505,11 +505,16 @@ namespace Robust.Shared.Serialization.Manager
|
||||
return target;
|
||||
}
|
||||
|
||||
if (target is ISerializationHooks beforeHooks)
|
||||
if (!skipHook && source is ISerializationHooks beforeHooks)
|
||||
{
|
||||
beforeHooks.BeforeSerialization();
|
||||
}
|
||||
|
||||
if (target is IPopulateDefaultValues populateDefaultValues)
|
||||
{
|
||||
populateDefaultValues.PopulateDefaultValues();
|
||||
}
|
||||
|
||||
if (!TryGetDataDefinition(commonType, out var dataDef))
|
||||
{
|
||||
throw new InvalidOperationException($"No data definition found for type {commonType} when copying");
|
||||
|
||||
@@ -323,7 +323,7 @@ namespace Robust.Shared.Serialization.Manager
|
||||
if (TryGetWriter<T>(context, out var writer))
|
||||
{
|
||||
node = writer.Write(this, obj, alwaysWrite, context);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user