Public YamlMappingFix (#897)

This commit is contained in:
DamianX
2019-11-21 20:27:19 +01:00
committed by Pieter-Jan Briers
parent cbe2fe698a
commit 844e9776f3
2 changed files with 28 additions and 23 deletions

View File

@@ -17,7 +17,6 @@ using Robust.Shared.Interfaces.GameObjects;
using System.Linq;
using Robust.Server.Interfaces.Timing;
using YamlDotNet.Core;
using YamlDotNet.Core.Events;
namespace Robust.Server.Maps
{
@@ -700,27 +699,5 @@ namespace Robust.Server.Maps
GridCount = ((YamlSequenceNode)RootNode["grids"]).Children.Count;
}
}
private class YamlMappingFix : IEmitter
{
//TODO: This fix exists because of https://github.com/aaubry/YamlDotNet/issues/409.
//Credit: https://stackoverflow.com/a/56452440
private readonly IEmitter _next;
public YamlMappingFix(IEmitter next)
{
_next = next;
}
public void Emit(ParsingEvent @event)
{
if (@event is MappingStart mapping)
{
@event = new MappingStart(mapping.Anchor, mapping.Tag, false, mapping.Style, mapping.Start, mapping.End);
}
_next.Emit(@event);
}
}
}
}

View File

@@ -0,0 +1,28 @@
using YamlDotNet.Core;
using YamlDotNet.Core.Events;
namespace Robust.Shared.Serialization
{
/// <summary>
/// TODO: This fix exists because of https://github.com/aaubry/YamlDotNet/issues/409.
/// Credit: https://stackoverflow.com/a/56452440
/// </summary>
public class YamlMappingFix : IEmitter
{
private readonly IEmitter _next;
public YamlMappingFix(IEmitter next)
{
_next = next;
}
public void Emit(ParsingEvent @event)
{
if (@event is MappingStart mapping)
{
@event = new MappingStart(mapping.Anchor, mapping.Tag, false, mapping.Style, mapping.Start, mapping.End);
}
_next.Emit(@event);
}
}
}