DefaultEcs icon indicating copy to clipboard operation
DefaultEcs copied to clipboard

TextSerializer is not culture invariant

Open Helco opened this issue 2 years ago • 1 comments

On my machine the Serialize_Should_serialize_World and Serialize_Should_serialize_Entities tests fail as the TextSerializer reads values with an invariant culture but written with the current culture.

It can be fixed by using a thin wrapper over StreamWriter overriding the FormatProvider property (in the StreamWriterWrapper class):

internal sealed class InvariantCultureStreamWriter : StreamWriter
{
    public InvariantCultureStreamWriter(Stream stream, Encoding encoding, int bufferSize, bool leaveOpen) : base(stream, encoding, bufferSize, leaveOpen)
    {
    }

    public override IFormatProvider FormatProvider => global::System.Globalization.CultureInfo.InvariantCulture;
}

Helco avatar Sep 28 '22 09:09 Helco

arg good catch >_< thanks for reporting it, It's even there in all the Parse call here https://github.com/Doraku/DefaultEcs/blob/master/source/DefaultEcs/Internal/Serialization/TextSerializer/Converter.cs#L118 I should have smell something fishy that the WriteLine didn't take one.

Doraku avatar Sep 28 '22 20:09 Doraku