mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-14 19:29:36 +01:00
Public YamlMappingFix (#897)
This commit is contained in:
committed by
Pieter-Jan Briers
parent
cbe2fe698a
commit
844e9776f3
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
28
Robust.Shared/Serialization/YamlMappingFix.cs
Normal file
28
Robust.Shared/Serialization/YamlMappingFix.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user