You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by pt...@apache.org on 2016/11/22 08:20:29 UTC
ignite git commit: IGNITE-4258 .NET: Fix BinaryReader to use current
stream position
Repository: ignite
Updated Branches:
refs/heads/master 78939417c -> ca97f8736
IGNITE-4258 .NET: Fix BinaryReader to use current stream position
This closes #1255
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/ca97f873
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/ca97f873
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/ca97f873
Branch: refs/heads/master
Commit: ca97f87364c3406bd5d545c66b1bb86fa98eea76
Parents: 7893941
Author: Pavel Tupitsyn <pt...@apache.org>
Authored: Tue Nov 22 11:19:40 2016 +0300
Committer: Pavel Tupitsyn <pt...@apache.org>
Committed: Tue Nov 22 11:19:40 2016 +0300
----------------------------------------------------------------------
.../Binary/BinaryReaderWriterTest.cs | 29 ++++++++++++++++++++
.../Impl/Binary/BinaryReader.cs | 1 +
2 files changed, 30 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/ca97f873/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryReaderWriterTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryReaderWriterTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryReaderWriterTest.cs
index e4cff1b..c17caff 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryReaderWriterTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryReaderWriterTest.cs
@@ -18,9 +18,13 @@
namespace Apache.Ignite.Core.Tests.Binary
{
using System;
+ using System.IO;
using Apache.Ignite.Core.Binary;
using Apache.Ignite.Core.Impl.Binary;
+ using Apache.Ignite.Core.Impl.Binary.IO;
using NUnit.Framework;
+ using BinaryReader = Apache.Ignite.Core.Impl.Binary.BinaryReader;
+ using BinaryWriter = Apache.Ignite.Core.Impl.Binary.BinaryWriter;
/// <summary>
/// Tests the <see cref="Impl.Binary.BinaryReader"/> and <see cref="Impl.Binary.BinaryWriter"/> classes.
@@ -38,6 +42,31 @@ namespace Apache.Ignite.Core.Tests.Binary
marsh.Unmarshal<ReadWriteAll>(marsh.Marshal(new ReadWriteAll()));
}
+ /// <summary>
+ /// Tests the custom stream position.
+ /// </summary>
+ [Test]
+ public void TestCustomPosition()
+ {
+ var stream = new BinaryHeapStream(16);
+
+ stream.WriteLong(54);
+
+ var marsh = new Marshaller(new BinaryConfiguration());
+
+ var writer = new BinaryWriter(marsh, stream);
+
+ writer.WriteChar('x');
+
+ stream.Seek(0, SeekOrigin.Begin);
+
+ Assert.AreEqual(54, stream.ReadLong());
+
+ var reader = new BinaryReader(marsh, stream, BinaryMode.Deserialize, null);
+
+ Assert.AreEqual('x', reader.ReadChar());
+ }
+
private class ReadWriteAll : IBinarizable
{
private static readonly DateTime Date = DateTime.UtcNow;
http://git-wip-us.apache.org/repos/asf/ignite/blob/ca97f873/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryReader.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryReader.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryReader.cs
index 4c34f73..100091f 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryReader.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryReader.cs
@@ -81,6 +81,7 @@ namespace Apache.Ignite.Core.Impl.Binary
_marsh = marsh;
_mode = mode;
_builder = builder;
+ _curPos = stream.Position;
Stream = stream;
}