Skip to content

Commit

Permalink
fixed TextSerializer not using invariant cultur during serialization (
Browse files Browse the repository at this point in the history
…fixes #170)
  • Loading branch information
Doraku committed Nov 18, 2022
1 parent 4dcd40b commit 2eb8c8a
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
6 changes: 5 additions & 1 deletion documentation/NEXT_RELEASENOTES.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## New features

- World.SetMaxCapacity can now be called multiple times for the same component type (#149)
- World.SetMaxCapacity can now be called multiple times for the same component type (#149)

## Bug fixes

- fixed TextSerializer not using invariant cultur during serialization (#170 thanks to @Helco)
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System;
using System.Globalization;
using System.IO;
using System.Text;

namespace DefaultEcs.Internal.Serialization.TextSerializer
{
internal sealed class InvariantCultureStreamWriter : StreamWriter
{
public InvariantCultureStreamWriter(Stream stream, Encoding encoding, int bufferSize, bool leaveOpen)
: base(stream, encoding, bufferSize, leaveOpen)
{ }

public override IFormatProvider FormatProvider => CultureInfo.InvariantCulture;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ internal sealed class StreamWriterWrapper : IDisposable
{
private int _indentation;

public StreamWriter Stream { get; }
public InvariantCultureStreamWriter Stream { get; }

public TextSerializationContext Context { get; }

public StreamWriterWrapper(Stream stream, TextSerializationContext context)
{
_indentation = 0;

Stream = new StreamWriter(stream, new UTF8Encoding(false, true), 1024, true);
Stream = new InvariantCultureStreamWriter(stream, new UTF8Encoding(false, true), 1024, true);
Context = context;
}

Expand Down

0 comments on commit 2eb8c8a

Please sign in to comment.