You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by jo...@apache.org on 2017/07/14 16:47:30 UTC

[2/3] tinkerpop git commit: Gremlin .NET: GraphSON3 Serialization

Gremlin .NET: GraphSON3 Serialization


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/8cdc941f
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/8cdc941f
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/8cdc941f

Branch: refs/heads/TINKERPOP-1552-master
Commit: 8cdc941f084ffc0a8d1013d09cd9a44993b44a40
Parents: 6b3fdcb
Author: Jorge Bay Gondra <jo...@gmail.com>
Authored: Fri Jul 14 17:56:41 2017 +0200
Committer: Jorge Bay Gondra <jo...@gmail.com>
Committed: Fri Jul 14 17:56:41 2017 +0200

----------------------------------------------------------------------
 .../src/Gremlin.Net/Driver/GremlinClient.cs     |   2 +-
 .../Structure/IO/GraphSON/GraphSON2Writer.cs    |  51 +++++
 .../Structure/IO/GraphSON/GraphSON3Writer.cs    |  15 +-
 .../Structure/IO/GraphSON/GraphSONUtil.cs       |  21 +++
 .../Structure/IO/GraphSON/GraphSONWriter.cs     |   6 +-
 .../Structure/IO/GraphSON/ListSerializer.cs     |   6 +-
 .../Structure/IO/GraphSON/MapSerializer.cs      |  16 +-
 .../Structure/IO/GraphSON/SetSerializer.cs      |   3 +-
 .../Process/Traversal/GraphSONWriterTests.cs    |  24 ++-
 .../GraphSON/BytecodeGraphSONSerializerTests.cs |  60 +++---
 .../IO/GraphSON/GraphSONReaderTests.cs          |   1 -
 .../IO/GraphSON/GraphSONWriterTests.cs          | 188 ++++++++++++-------
 .../IO/GraphSON/StrategyWriterTests.cs          |  30 ++-
 13 files changed, 313 insertions(+), 110 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/8cdc941f/gremlin-dotnet/src/Gremlin.Net/Driver/GremlinClient.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Driver/GremlinClient.cs b/gremlin-dotnet/src/Gremlin.Net/Driver/GremlinClient.cs
index a81c17e..9781a7c 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Driver/GremlinClient.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Driver/GremlinClient.cs
@@ -46,7 +46,7 @@ namespace Gremlin.Net.Driver
             GraphSONWriter graphSONWriter = null)
         {
             var reader = graphSONReader ?? new GraphSON3Reader();
-            var writer = graphSONWriter ?? new GraphSONWriter();
+            var writer = graphSONWriter ?? new GraphSON3Writer();
             var connectionFactory = new ConnectionFactory(gremlinServer, reader, writer);
             _connectionPool = new ConnectionPool(connectionFactory);
         }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/8cdc941f/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSON2Writer.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSON2Writer.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSON2Writer.cs
new file mode 100644
index 0000000..b1083da
--- /dev/null
+++ b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSON2Writer.cs
@@ -0,0 +1,51 @@
+#region License
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#endregion
+
+using System;
+using System.Collections.Generic;
+
+namespace Gremlin.Net.Structure.IO.GraphSON
+{
+    /// <summary>
+    /// Handles serialization of GraphSON2 data.
+    /// </summary>
+    public class GraphSON2Writer : GraphSONWriter
+    {
+        /// <summary>
+        /// Creates a new instance of <see cref="GraphSON2Writer"/>.
+        /// </summary>
+        public GraphSON2Writer()
+        {
+            
+        }
+        
+        /// <summary>
+        /// Creates a new instance of <see cref="GraphSON2Writer"/>.
+        /// </summary>
+        public GraphSON2Writer(IReadOnlyDictionary<Type, IGraphSONSerializer> customSerializerByType) : 
+            base(customSerializerByType)
+        {
+            
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/8cdc941f/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSON3Writer.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSON3Writer.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSON3Writer.cs
index 96c303c..0469bbe 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSON3Writer.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSON3Writer.cs
@@ -27,16 +27,27 @@ using System.Collections.Generic;
 namespace Gremlin.Net.Structure.IO.GraphSON
 {
     /// <summary>
-    /// Handles deserialization of GraphSON3 data.
+    /// Handles serialization of GraphSON3 data.
     /// </summary>
     public class GraphSON3Writer : GraphSONWriter
     {
+        private static readonly IDictionary<Type, IGraphSONSerializer> GraphSON3SpecificSerializers =
+            new Dictionary<Type, IGraphSONSerializer>
+            {
+                { typeof(IList<object>), new ListSerializer() },
+                { typeof(ISet<object>), new SetSerializer() },
+                { typeof(IDictionary<object, object>), new MapSerializer() }
+            };
+        
         /// <summary>
         /// Creates a new instance of <see cref="GraphSON3Writer"/>.
         /// </summary>
         public GraphSON3Writer()
         {
-            // TODO: Include GraphSON3 specific serializers
+            foreach (var kv in GraphSON3SpecificSerializers)
+            {
+                Serializers[kv.Key] = kv.Value;
+            }
         }
 
         /// <summary>

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/8cdc941f/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSONUtil.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSONUtil.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSONUtil.cs
index 037839b..ccdd47a 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSONUtil.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSONUtil.cs
@@ -21,6 +21,8 @@
 
 #endregion
 
+using System;
+using System.Collections;
 using System.Collections.Generic;
 
 namespace Gremlin.Net.Structure.IO.GraphSON
@@ -58,5 +60,24 @@ namespace Gremlin.Net.Structure.IO.GraphSON
         {
             return $"{namespacePrefix}:{typeName}";
         }
+
+        /// <summary>
+        /// Converts a Collection to a representation of g:List or g:Set
+        /// </summary>
+        internal static Dictionary<string, dynamic> ToCollection(dynamic objectData, GraphSONWriter writer,
+                                                               string typename)
+        {
+            var collection = objectData as IEnumerable;
+            if (collection == null)
+            {
+                throw new InvalidOperationException("Object must implement IEnumerable");
+            }
+            var result = new List<object>();
+            foreach (var item in collection)
+            {
+                result.Add(writer.ToDict(item));
+            }
+            return ToTypedValue(typename, result);
+        }
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/8cdc941f/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSONWriter.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSONWriter.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSONWriter.cs
index db0ae7d..55d24d6 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSONWriter.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSONWriter.cs
@@ -36,7 +36,7 @@ namespace Gremlin.Net.Structure.IO.GraphSON
     /// <summary>
     ///     Allows to serialize objects to GraphSON.
     /// </summary>
-    public class GraphSONWriter
+    public abstract class GraphSONWriter
     {
         /// <summary>
         /// Contains the information of serializers by type.
@@ -66,7 +66,7 @@ namespace Gremlin.Net.Structure.IO.GraphSON
         /// <summary>
         ///     Initializes a new instance of the <see cref="GraphSONWriter" /> class.
         /// </summary>
-        public GraphSONWriter()
+        protected GraphSONWriter()
         {
         }
 
@@ -77,7 +77,7 @@ namespace Gremlin.Net.Structure.IO.GraphSON
         ///     <see cref="IGraphSONSerializer" /> serializers identified by their
         ///     <see cref="Type" />.
         /// </param>
-        public GraphSONWriter(IReadOnlyDictionary<Type, IGraphSONSerializer> customSerializerByType)
+        protected GraphSONWriter(IReadOnlyDictionary<Type, IGraphSONSerializer> customSerializerByType)
         {
             foreach (var serializerAndType in customSerializerByType)
                 Serializers[serializerAndType.Key] = serializerAndType.Value;

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/8cdc941f/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/ListSerializer.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/ListSerializer.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/ListSerializer.cs
index f738ac8..f432c7e 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/ListSerializer.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/ListSerializer.cs
@@ -21,7 +21,11 @@
 
 #endregion
 
+using System;
+using System.Collections;
 using System.Collections.Generic;
+using System.Linq;
+using Microsoft.Win32.SafeHandles;
 using Newtonsoft.Json.Linq;
 
 namespace Gremlin.Net.Structure.IO.GraphSON
@@ -48,7 +52,7 @@ namespace Gremlin.Net.Structure.IO.GraphSON
 
         public Dictionary<string, dynamic> Dictify(dynamic objectData, GraphSONWriter writer)
         {
-            throw new System.NotImplementedException();
+            return GraphSONUtil.ToCollection(objectData, writer, "List");
         }
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/8cdc941f/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/MapSerializer.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/MapSerializer.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/MapSerializer.cs
index 5f9c326..a096e3e 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/MapSerializer.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/MapSerializer.cs
@@ -21,6 +21,8 @@
 
 #endregion
 
+using System;
+using System.Collections;
 using System.Collections.Generic;
 using Newtonsoft.Json.Linq;
 
@@ -46,7 +48,19 @@ namespace Gremlin.Net.Structure.IO.GraphSON
         
         public Dictionary<string, dynamic> Dictify(dynamic objectData, GraphSONWriter writer)
         {
-            throw new System.NotImplementedException();
+            var map = objectData as IDictionary;
+            if (map == null)
+            {
+                throw new InvalidOperationException("Object must implement IDictionary");
+            }
+            var result = new object[map.Count * 2];
+            var index = 0;
+            foreach (var key in map.Keys)
+            {
+                result[index++] = writer.ToDict(key);
+                result[index++] = writer.ToDict(map[key]);
+            }
+            return GraphSONUtil.ToTypedValue("Map", result);
         }
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/8cdc941f/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/SetSerializer.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/SetSerializer.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/SetSerializer.cs
index ed2a973..e657bd8 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/SetSerializer.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/SetSerializer.cs
@@ -21,6 +21,7 @@
 
 #endregion
 
+using System;
 using System.Collections.Generic;
 using System.Linq;
 using Newtonsoft.Json.Linq;
@@ -42,7 +43,7 @@ namespace Gremlin.Net.Structure.IO.GraphSON
 
         public Dictionary<string, dynamic> Dictify(dynamic objectData, GraphSONWriter writer)
         {
-            throw new System.NotImplementedException();
+            return GraphSONUtil.ToCollection(objectData, writer, "Set");
         }
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/8cdc941f/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/GraphSONWriterTests.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/GraphSONWriterTests.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/GraphSONWriterTests.cs
index d8ccabe..a522a22 100644
--- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/GraphSONWriterTests.cs
+++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/GraphSONWriterTests.cs
@@ -21,6 +21,7 @@
 
 #endregion
 
+using System.Collections.Generic;
 using Gremlin.Net.Process.Traversal;
 using Gremlin.Net.Structure.IO.GraphSON;
 using Xunit;
@@ -29,10 +30,19 @@ namespace Gremlin.Net.IntegrationTest.Process.Traversal
 {
     public class GraphSONWriterTests
     {
-        [Fact]
-        public void ShouldSerializeLongPredicateCorrectly()
+        /// <summary>
+        /// Parameters for each test supporting multiple versions of GraphSON
+        /// </summary>
+        public static IEnumerable<object[]> Versions => new []
         {
-            var writer = CreateStandardGraphSONWriter();
+            new object[] { 2 },
+            new object[] { 3 }
+        };
+
+        [Theory, MemberData(nameof(Versions))]
+        public void ShouldSerializeLongPredicateCorrectly(int version)
+        {
+            var writer = CreateGraphSONWriter(version);
             var predicate = P.Lt("b").Or(P.Gt("c")).And(P.Neq("d"));
 
             var graphSon = writer.WriteObject(predicate);
@@ -42,9 +52,13 @@ namespace Gremlin.Net.IntegrationTest.Process.Traversal
             Assert.Equal(expected, graphSon);
         }
 
-        private GraphSONWriter CreateStandardGraphSONWriter()
+        private GraphSONWriter CreateGraphSONWriter(int version)
         {
-            return new GraphSONWriter();
+            if (version == 3)
+            {
+                return new GraphSON3Writer();
+            }
+            return new GraphSON2Writer();
         }
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/8cdc941f/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/BytecodeGraphSONSerializerTests.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/BytecodeGraphSONSerializerTests.cs b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/BytecodeGraphSONSerializerTests.cs
index 8ed7a3d..8b87df6 100644
--- a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/BytecodeGraphSONSerializerTests.cs
+++ b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/BytecodeGraphSONSerializerTests.cs
@@ -22,6 +22,7 @@
 #endregion
 
 using System.Collections.Generic;
+using System.Numerics;
 using Gremlin.Net.Process.Traversal;
 using Gremlin.Net.Structure.IO.GraphSON;
 using Xunit;
@@ -30,13 +31,26 @@ namespace Gremlin.Net.UnitTest.Structure.IO.GraphSON
 {
     public class BytecodeGraphSONSerializerTests
     {
-        private GraphSONWriter CreateGraphSONWriter()
+        /// <summary>
+        /// Parameters for each test supporting multiple versions of GraphSON
+        /// </summary>
+        public static IEnumerable<object[]> Versions => new []
         {
-            return new GraphSONWriter();
+            new object[] { 2 },
+            new object[] { 3 }
+        };
+
+        private GraphSONWriter CreateGraphSONWriter(int version)
+        {
+            if (version == 3)
+            {
+                return new GraphSON3Writer();
+            }
+            return new GraphSON2Writer();
         }
 
-        [Fact]
-        public void ShouldSerializeByteCodeWithNestedTraversal()
+        [Theory, MemberData(nameof(Versions))]
+        public void ShouldSerializeByteCodeWithNestedTraversal(int version)
         {
             var bytecode = new Bytecode();
             bytecode.AddStep("V");
@@ -44,7 +58,7 @@ namespace Gremlin.Net.UnitTest.Structure.IO.GraphSON
             var nestedTraversal = new TestTraversal(nestedBytecode);
             nestedBytecode.AddStep("out");
             bytecode.AddStep("repeat", nestedTraversal);
-            var graphsonWriter = CreateGraphSONWriter();
+            var graphsonWriter = CreateGraphSONWriter(version);
 
             var graphSON = graphsonWriter.WriteObject(bytecode);
 
@@ -53,14 +67,14 @@ namespace Gremlin.Net.UnitTest.Structure.IO.GraphSON
             Assert.Equal(expectedGraphSon, graphSON);
         }
 
-        [Fact]
-        public void ShouldSerializeBytecodeWithNumbers()
+        [Theory, MemberData(nameof(Versions))]
+        public void ShouldSerializeBytecodeWithNumbers(int version)
         {
             var bytecode = new Bytecode();
             bytecode.AddStep("V", (long) 1);
             bytecode.AddStep("has", "age", 20);
             bytecode.AddStep("has", "height", 6.5);
-            var graphsonWriter = CreateGraphSONWriter();
+            var graphsonWriter = CreateGraphSONWriter(version);
 
             var graphSON = graphsonWriter.WriteObject(bytecode);
 
@@ -69,25 +83,25 @@ namespace Gremlin.Net.UnitTest.Structure.IO.GraphSON
             Assert.Equal(expectedGraphSon, graphSON);
         }
 
-        [Fact]
-        public void ShouldSerialize_g_V()
+        [Theory, MemberData(nameof(Versions))]
+        public void ShouldSerialize_g_V(int version)
         {
             var bytecode = new Bytecode();
             bytecode.AddStep("V");
-            var graphsonWriter = CreateGraphSONWriter();
+            var graphsonWriter = CreateGraphSONWriter(version);
 
             var graphSON = graphsonWriter.WriteObject(bytecode);
 
             Assert.Equal("{\"@type\":\"g:Bytecode\",\"@value\":{\"step\":[[\"V\"]]}}", graphSON);
         }
 
-        [Fact]
-        public void ShouldSerialize_g_V_Count()
+        [Theory, MemberData(nameof(Versions))]
+        public void ShouldSerialize_g_V_Count(int version)
         {
             var bytecode = new Bytecode();
             bytecode.AddStep("V");
             bytecode.AddStep("count");
-            var graphsonWriter = CreateGraphSONWriter();
+            var graphsonWriter = CreateGraphSONWriter(version);
 
             var graphSON = graphsonWriter.WriteObject(bytecode);
 
@@ -95,14 +109,14 @@ namespace Gremlin.Net.UnitTest.Structure.IO.GraphSON
             Assert.Equal(expectedGraphSon, graphSON);
         }
 
-        [Fact]
-        public void ShouldSerialize_g_V_HasXPerson_Name_GremlinX_Count()
+        [Theory, MemberData(nameof(Versions))]
+        public void ShouldSerialize_g_V_HasXPerson_Name_GremlinX_Count(int version)
         {
             var bytecode = new Bytecode();
             bytecode.AddStep("V");
             bytecode.AddStep("has", "Person", "Name", "Gremlin");
             bytecode.AddStep("count");
-            var graphsonWriter = CreateGraphSONWriter();
+            var graphsonWriter = CreateGraphSONWriter(version);
 
             var graphSON = graphsonWriter.WriteObject(bytecode);
 
@@ -111,15 +125,15 @@ namespace Gremlin.Net.UnitTest.Structure.IO.GraphSON
             Assert.Equal(expectedGraphSon, graphSON);
         }
 
-        [Fact]
-        public void ShouldSerializeBytecodeWithSourcesStep()
+        [Theory, MemberData(nameof(Versions))]
+        public void ShouldSerializeBytecodeWithSourcesStep(int version)
         {
             var bytecode = new Bytecode();
             bytecode.AddSource("withSideEffect", "a", new List<string> {"josh", "peter"});
             bytecode.AddStep("V", 1);
             bytecode.AddStep("values", "name");
             bytecode.AddStep("where", new TraversalPredicate("within", "a"));
-            var graphsonWriter = CreateGraphSONWriter();
+            var graphsonWriter = CreateGraphSONWriter(version);
 
             var graphSON = graphsonWriter.WriteObject(bytecode);
 
@@ -128,12 +142,12 @@ namespace Gremlin.Net.UnitTest.Structure.IO.GraphSON
             Assert.Equal(expectedGraphSon, graphSON);
         }
 
-        [Fact]
-        public void ShouldSerializeBytecodeWithBindings()
+        [Theory, MemberData(nameof(Versions))]
+        public void ShouldSerializeBytecodeWithBindings(int version)
         {
             var bytecode = new Bytecode();
             bytecode.AddStep("V", new Binding("id", 123));
-            var graphsonWriter = CreateGraphSONWriter();
+            var graphsonWriter = CreateGraphSONWriter(version);
 
             var graphSon = graphsonWriter.WriteObject(bytecode);
 

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/8cdc941f/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/GraphSONReaderTests.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/GraphSONReaderTests.cs b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/GraphSONReaderTests.cs
index e2c6dc9..3fca7f7 100644
--- a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/GraphSONReaderTests.cs
+++ b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/GraphSONReaderTests.cs
@@ -107,7 +107,6 @@ namespace Gremlin.Net.UnitTest.Structure.IO.GraphSON
         [Theory, MemberData(nameof(Versions))]
         public void ShouldDeserializeDictionary(int version)
         {
-            Console.WriteLine("Starting");
             var serializedDict = "{\"age\":[{\"@type\":\"g:Int32\",\"@value\":29}],\"name\":[\"marko\"]}";
             var reader = CreateStandardGraphSONReader(version);
 

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/8cdc941f/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/GraphSONWriterTests.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/GraphSONWriterTests.cs b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/GraphSONWriterTests.cs
index 77af255..a352a3e 100644
--- a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/GraphSONWriterTests.cs
+++ b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/GraphSONWriterTests.cs
@@ -33,65 +33,86 @@ namespace Gremlin.Net.UnitTest.Structure.IO.GraphSON
 {
     public class GraphSONWriterTests
     {
-        private GraphSONWriter CreateStandardGraphSONWriter()
+        /// <summary>
+        /// Parameters for each test supporting multiple versions of GraphSON
+        /// </summary>
+        public static IEnumerable<object[]> Versions => new []
         {
-            return new GraphSONWriter();
+            new object[] { 2 },
+            new object[] { 3 }
+        };
+        
+        /// <summary>
+        /// Parameters for each collections test supporting multiple versions of GraphSON
+        /// </summary>
+        public static IEnumerable<object[]> VersionsSupportingCollections => new []
+        {
+            new object[] { 3 }
+        };
+
+        private GraphSONWriter CreateGraphSONWriter(int version)
+        {
+            if (version == 3)
+            {
+                return new GraphSON3Writer();
+            }
+            return new GraphSON2Writer();
         }
 
-        [Fact]
-        public void ShouldSerializeInt()
+        [Theory, MemberData(nameof(Versions))]
+        public void ShouldSerializeInt(int version)
         {
-            var writer = CreateStandardGraphSONWriter();
+            var writer = CreateGraphSONWriter(version);
 
             var graphSon = writer.WriteObject(1);
 
             Assert.Equal("{\"@type\":\"g:Int32\",\"@value\":1}", graphSon);
         }
 
-        [Fact]
-        public void ShouldSerializeLong()
+        [Theory, MemberData(nameof(Versions))]
+        public void ShouldSerializeLong(int version)
         {
-            var writer = CreateStandardGraphSONWriter();
+            var writer = CreateGraphSONWriter(version);
 
             var graphSon = writer.WriteObject((long) 2);
 
             Assert.Equal("{\"@type\":\"g:Int64\",\"@value\":2}", graphSon);
         }
 
-        [Fact]
-        public void ShouldSerializeFloat()
+        [Theory, MemberData(nameof(Versions))]
+        public void ShouldSerializeFloat(int version)
         {
-            var writer = CreateStandardGraphSONWriter();
+            var writer = CreateGraphSONWriter(version);
 
             var graphSon = writer.WriteObject((float) 3.2);
 
             Assert.Equal("{\"@type\":\"g:Float\",\"@value\":3.2}", graphSon);
         }
 
-        [Fact]
-        public void ShouldSerializeDouble()
+        [Theory, MemberData(nameof(Versions))]
+        public void ShouldSerializeDouble(int version)
         {
-            var writer = CreateStandardGraphSONWriter();
+            var writer = CreateGraphSONWriter(version);
 
             var graphSon = writer.WriteObject(3.2);
 
             Assert.Equal("{\"@type\":\"g:Double\",\"@value\":3.2}", graphSon);
         }
 
-        [Fact]
-        public void ShouldSerializeBoolean()
+        [Theory, MemberData(nameof(Versions))]
+        public void ShouldSerializeBoolean(int version)
         {
-            var writer = CreateStandardGraphSONWriter();
+            var writer = CreateGraphSONWriter(version);
 
             var graphSon = writer.WriteObject(true);
 
             Assert.Equal("true", graphSon);
         }
 
-        [Fact]
-        public void ShouldSerializeArray()
+        [Theory, MemberData(nameof(Versions))]
+        public void ShouldSerializeArray(int version)
         {
-            var writer = CreateStandardGraphSONWriter();
+            var writer = CreateGraphSONWriter(version);
             var array = new[] {5, 6};
 
             var serializedGraphSON = writer.WriteObject(array);
@@ -100,10 +121,10 @@ namespace Gremlin.Net.UnitTest.Structure.IO.GraphSON
             Assert.Equal(expectedGraphSON, serializedGraphSON);
         }
 
-        [Fact]
-        public void ShouldSerializeBinding()
+        [Theory, MemberData(nameof(Versions))]
+        public void ShouldSerializeBinding(int version)
         {
-            var writer = CreateStandardGraphSONWriter();
+            var writer = CreateGraphSONWriter(version);
             var binding = new Binding("theKey", 123);
 
             var graphSon = writer.WriteObject(binding);
@@ -120,7 +141,7 @@ namespace Gremlin.Net.UnitTest.Structure.IO.GraphSON
             {
                 {typeof(TestClass), new TestGraphSONSerializer {TestNamespace = "NS"}}
             };
-            var writer = new GraphSONWriter(customSerializerByType);
+            var writer = new GraphSON2Writer(customSerializerByType);
             var testObj = new TestClass {Value = "test"};
 
             var serialized = writer.WriteObject(testObj);
@@ -136,17 +157,17 @@ namespace Gremlin.Net.UnitTest.Structure.IO.GraphSON
             {
                 {typeof(int), customSerializerMock.Object}
             };
-            var writer = new GraphSONWriter(customSerializerByType);
+            var writer = new GraphSON2Writer(customSerializerByType);
 
             writer.WriteObject(12);
 
             customSerializerMock.Verify(m => m.Dictify(It.Is<int>(v => v == 12), It.IsAny<GraphSONWriter>()));
         }
 
-        [Fact]
-        public void ShouldSerializeDateTime()
+        [Theory, MemberData(nameof(Versions))]
+        public void ShouldSerializeDateTime(int version)
         {
-            var writer = CreateStandardGraphSONWriter();
+            var writer = CreateGraphSONWriter(version);
             var dateTime = TestUtils.FromJavaTime(1475583442552);
 
             var graphSon = writer.WriteObject(dateTime);
@@ -155,10 +176,10 @@ namespace Gremlin.Net.UnitTest.Structure.IO.GraphSON
             Assert.Equal(expected, graphSon);
         }
 
-        [Fact]
-        public void ShouldSerializeDictionary()
+        [Theory, MemberData(nameof(Versions))]
+        public void ShouldSerializeDictionary(int version)
         {
-            var writer = CreateStandardGraphSONWriter();
+            var writer = CreateGraphSONWriter(version);
             var dictionary = new Dictionary<string, dynamic>
             {
                 {"age", new List<int> {29}},
@@ -171,10 +192,10 @@ namespace Gremlin.Net.UnitTest.Structure.IO.GraphSON
             Assert.Equal(expectedGraphSON, serializedDict);
         }
 
-        [Fact]
-        public void ShouldSerializeEdge()
+        [Theory, MemberData(nameof(Versions))]
+        public void ShouldSerializeEdge(int version)
         {
-            var writer = CreateStandardGraphSONWriter();
+            var writer = CreateGraphSONWriter(version);
             var edge = new Edge(7, new Vertex(0, "person"), "knows", new Vertex(1, "dog"));
 
             var graphSON = writer.WriteObject(edge);
@@ -184,10 +205,10 @@ namespace Gremlin.Net.UnitTest.Structure.IO.GraphSON
             Assert.Equal(expected, graphSON);
         }
 
-        [Fact]
-        public void ShouldSerializeEnum()
+        [Theory, MemberData(nameof(Versions))]
+        public void ShouldSerializeEnum(int version)
         {
-            var writer = CreateStandardGraphSONWriter();
+            var writer = CreateGraphSONWriter(version);
 
             var serializedEnum = writer.WriteObject(Direction.Both);
 
@@ -195,10 +216,10 @@ namespace Gremlin.Net.UnitTest.Structure.IO.GraphSON
             Assert.Equal(expectedGraphSON, serializedEnum);
         }
 
-        [Fact]
-        public void ShouldSerializeList()
+        [Theory, MemberData(nameof(Versions))]
+        public void ShouldSerializeList(int version)
         {
-            var writer = CreateStandardGraphSONWriter();
+            var writer = CreateGraphSONWriter(version);
             var list = new List<int> {5, 6};
 
             var serializedGraphSON = writer.WriteObject(list.ToArray());
@@ -207,10 +228,49 @@ namespace Gremlin.Net.UnitTest.Structure.IO.GraphSON
             Assert.Equal(expectedGraphSON, serializedGraphSON);
         }
 
-        [Fact]
-        public void ShouldSerializePredicateWithTwoValues()
+        [Theory, MemberData(nameof(VersionsSupportingCollections))]
+        public void ShouldSerializeGList(int version)
+        {
+            var writer = CreateGraphSONWriter(version);
+            var list = new List<object> {5, 6};
+
+            var serializedGraphSON = writer.WriteObject(list);
+
+            var expectedGraphSON = "{\"@type\":\"g:List\",\"@value\":[{\"@type\":\"g:Int32\",\"@value\":5}," +
+                                   "{\"@type\":\"g:Int32\",\"@value\":6}]}";
+            Assert.Equal(expectedGraphSON, serializedGraphSON);
+        }
+
+        [Theory, MemberData(nameof(VersionsSupportingCollections))]
+        public void ShouldSerializeGSet(int version)
         {
-            var writer = CreateStandardGraphSONWriter();
+            var writer = CreateGraphSONWriter(version);
+            ISet<object> set = new HashSet<object> {600L, 700L};
+
+            var serializedGraphSON = writer.WriteObject(set);
+
+            var expectedGraphSON = "{\"@type\":\"g:Set\",\"@value\":[{\"@type\":\"g:Int64\",\"@value\":600}," +
+                                   "{\"@type\":\"g:Int64\",\"@value\":700}]}";
+            Assert.Equal(expectedGraphSON, serializedGraphSON);
+        }
+
+        [Theory, MemberData(nameof(VersionsSupportingCollections))]
+        public void ShouldSerializeGMap(int version)
+        {
+            var writer = CreateGraphSONWriter(version);
+            IDictionary<object, object> map = new Dictionary<object, object> { { 1L, "a"}, { 200L, "b"}};
+
+            var serializedGraphSON = writer.WriteObject(map);
+
+            var expectedGraphSON = "{\"@type\":\"g:Map\",\"@value\":[{\"@type\":\"g:Int64\",\"@value\":1},\"a\"," +
+                                   "{\"@type\":\"g:Int64\",\"@value\":200},\"b\"]}";
+            Assert.Equal(expectedGraphSON, serializedGraphSON);
+        }
+
+        [Theory, MemberData(nameof(Versions))]
+        public void ShouldSerializePredicateWithTwoValues(int version)
+        {
+            var writer = CreateGraphSONWriter(version);
             var predicate = new TraversalPredicate("within", new List<int> {1, 2});
 
             var serializedPredicate = writer.WriteObject(predicate);
@@ -220,10 +280,10 @@ namespace Gremlin.Net.UnitTest.Structure.IO.GraphSON
             Assert.Equal(expectedGraphSON, serializedPredicate);
         }
 
-        [Fact]
-        public void ShouldSerializePredicateWithSingleValue()
+        [Theory, MemberData(nameof(Versions))]
+        public void ShouldSerializePredicateWithSingleValue(int version)
         {
-            var writer = CreateStandardGraphSONWriter();
+            var writer = CreateGraphSONWriter(version);
             var predicate = new TraversalPredicate("lt", 5);
 
             var serializedPredicate = writer.WriteObject(predicate);
@@ -233,10 +293,10 @@ namespace Gremlin.Net.UnitTest.Structure.IO.GraphSON
             Assert.Equal(expectedGraphSON, serializedPredicate);
         }
 
-        [Fact]
-        public void ShouldSerializePropertyWithEdgeElement()
+        [Theory, MemberData(nameof(Versions))]
+        public void ShouldSerializePropertyWithEdgeElement(int version)
         {
-            var writer = CreateStandardGraphSONWriter();
+            var writer = CreateGraphSONWriter(version);
             var property = new Property("aKey", "aValue", new Edge("anId", new Vertex(1), "edgeLabel", new Vertex(2)));
 
             var graphSON = writer.WriteObject(property);
@@ -246,10 +306,10 @@ namespace Gremlin.Net.UnitTest.Structure.IO.GraphSON
             Assert.Equal(expected, graphSON);
         }
 
-        [Fact]
-        public void ShouldSerializePropertyWithVertexPropertyElement()
+        [Theory, MemberData(nameof(Versions))]
+        public void ShouldSerializePropertyWithVertexPropertyElement(int version)
         {
-            var writer = CreateStandardGraphSONWriter();
+            var writer = CreateGraphSONWriter(version);
             var property = new Property("name", "marko",
                 new VertexProperty("anId", "aKey", 21345, new Vertex("vertexId")));
 
@@ -260,10 +320,10 @@ namespace Gremlin.Net.UnitTest.Structure.IO.GraphSON
             Assert.Equal(expected, graphSON);
         }
 
-        [Fact]
-        public void ShouldSerializeVertexProperty()
+        [Theory, MemberData(nameof(Versions))]
+        public void ShouldSerializeVertexProperty(int version)
         {
-            var writer = CreateStandardGraphSONWriter();
+            var writer = CreateGraphSONWriter(version);
             var vertexProperty = new VertexProperty("blah", "keyA", true, new Vertex("stephen"));
 
             var graphSON = writer.WriteObject(vertexProperty);
@@ -273,10 +333,10 @@ namespace Gremlin.Net.UnitTest.Structure.IO.GraphSON
             Assert.Equal(expected, graphSON);
         }
 
-        [Fact]
-        public void ShouldSerializeGuid()
+        [Theory, MemberData(nameof(Versions))]
+        public void ShouldSerializeGuid(int version)
         {
-            var writer = CreateStandardGraphSONWriter();
+            var writer = CreateGraphSONWriter(version);
             var guid = Guid.Parse("41d2e28a-20a4-4ab0-b379-d810dede3786");
 
             var graphSon = writer.WriteObject(guid);
@@ -285,10 +345,10 @@ namespace Gremlin.Net.UnitTest.Structure.IO.GraphSON
             Assert.Equal(expected, graphSon);
         }
 
-        [Fact]
-        public void ShouldSerializeVertex()
+        [Theory, MemberData(nameof(Versions))]
+        public void ShouldSerializeVertex(int version)
         {
-            var writer = CreateStandardGraphSONWriter();
+            var writer = CreateGraphSONWriter(version);
             var vertex = new Vertex(45.23f);
 
             var graphSON = writer.WriteObject(vertex);
@@ -298,10 +358,10 @@ namespace Gremlin.Net.UnitTest.Structure.IO.GraphSON
             Assert.Equal(expected, graphSON);
         }
 
-        [Fact]
-        public void ShouldSerializeVertexWithLabel()
+        [Theory, MemberData(nameof(Versions))]
+        public void ShouldSerializeVertexWithLabel(int version)
         {
-            var writer = CreateStandardGraphSONWriter();
+            var writer = CreateGraphSONWriter(version);
             var vertex = new Vertex((long) 123, "project");
 
             var graphSON = writer.WriteObject(vertex);

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/8cdc941f/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/StrategyWriterTests.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/StrategyWriterTests.cs b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/StrategyWriterTests.cs
index 4bdb141..5a04b54 100644
--- a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/StrategyWriterTests.cs
+++ b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/StrategyWriterTests.cs
@@ -21,6 +21,7 @@
 
 #endregion
 
+using System.Collections.Generic;
 using Gremlin.Net.Process.Traversal;
 using Gremlin.Net.Process.Traversal.Strategy.Decoration;
 using Gremlin.Net.Structure.IO.GraphSON;
@@ -30,16 +31,29 @@ namespace Gremlin.Net.UnitTest.Structure.IO.GraphSON
 {
     public class StrategyWriterTests
     {
-        private GraphSONWriter CreateGraphSONWriter()
+        /// <summary>
+        /// Parameters for each test supporting multiple versions of GraphSON
+        /// </summary>
+        public static IEnumerable<object[]> Versions => new []
         {
-            return new GraphSONWriter();
+            new object[] { 2 },
+            new object[] { 3 }
+        };
+
+        private GraphSONWriter CreateGraphSONWriter(int version)
+        {
+            if (version == 3)
+            {
+                return new GraphSON3Writer();
+            }
+            return new GraphSON2Writer();
         }
 
-        [Fact]
-        public void ShouldSerializeSubgraphStrategyWithoutValues()
+        [Theory, MemberData(nameof(Versions))]
+        public void ShouldSerializeSubgraphStrategyWithoutValues(int version)
         {
             var subgraphStrategy = new SubgraphStrategy();
-            var writer = CreateGraphSONWriter();
+            var writer = CreateGraphSONWriter(version);
 
             var graphSon = writer.WriteObject(subgraphStrategy);
 
@@ -47,14 +61,14 @@ namespace Gremlin.Net.UnitTest.Structure.IO.GraphSON
             Assert.Equal(expected, graphSon);
         }
 
-        [Fact]
-        public void ShouldDeserializeSubgraphStrategyWithVertexCriterion()
+        [Theory, MemberData(nameof(Versions))]
+        public void ShouldDeserializeSubgraphStrategyWithVertexCriterion(int version)
         {
             var vertexCriterionBytecode = new Bytecode();
             vertexCriterionBytecode.AddStep("has", "name", "marko");
             var vertexCriterion = new TestTraversal(vertexCriterionBytecode);
             var subgraphStrategy = new SubgraphStrategy(vertexCriterion);
-            var writer = CreateGraphSONWriter();
+            var writer = CreateGraphSONWriter(version);
 
             var graphSon = writer.WriteObject(subgraphStrategy);