Repository: tinkerpop
Updated Branches:
  refs/heads/TINKERPOP-1920 [created] 065194814


TINKERPOP-1920 Fixed P.within/without() handling for collections


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

Branch: refs/heads/TINKERPOP-1920
Commit: 065194814b2eafdb82cba665309ba890d04d96dc
Parents: 0bf9b2f
Author: Stephen Mallette <[email protected]>
Authored: Thu Mar 15 12:19:48 2018 -0400
Committer: Stephen Mallette <[email protected]>
Committed: Thu Mar 15 12:19:48 2018 -0400

----------------------------------------------------------------------
 CHANGELOG.asciidoc                              |  1 +
 gremlin-dotnet/glv/P.template                   | 22 +++++++++++++++-
 .../src/Gremlin.Net/Process/Traversal/P.cs      | 27 ++++++++++++++++++--
 .../Gherkin/GherkinTestRunner.cs                |  6 +----
 4 files changed, 48 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/06519481/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index 94ee24f..6f3cd27 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -41,6 +41,7 @@ 
image::https://raw.githubusercontent.com/apache/tinkerpop/master/docs/static/ima
 * Added `IndexedTraverserSet` which indexes on the value of a `Traverser` thus 
improving performance when used.
 * Utilized `IndexedTraverserSet` in `TraversalVertexProgram` to avoid extra 
iteration when doing `Vertex` lookups.
 * Bumped to Netty 4.0.56.Final.
+* Fixed .NET GraphSON serialization of `P.Within()` and `P.without()` when 
passing a `Collection` as an argument.
 * Fixed a bug in Gremlin Console which prevented handling of `gremlin.sh` 
flags that had an "=" between the flag and its arguments.
 * Fixed bug where `SparkMessenger` was not applying the `edgeFunction` from 
`MessageScope`.
 * Fixed a bug in `ComputerAwareStep` that didn't handle `reset()` properly and 
thus occasionally produced some extra traversers.

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/06519481/gremlin-dotnet/glv/P.template
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/glv/P.template b/gremlin-dotnet/glv/P.template
index ad037c1..f3fae2a 100644
--- a/gremlin-dotnet/glv/P.template
+++ b/gremlin-dotnet/glv/P.template
@@ -22,6 +22,12 @@
 #endregion
 
 // THIS IS A GENERATED FILE - DO NOT MODIFY THIS FILE DIRECTLY - see pom.xml
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Linq;
+using System.Reflection;
+
 namespace Gremlin.Net.Process.Traversal
 {
 #pragma warning disable 1591
@@ -88,9 +94,23 @@ namespace Gremlin.Net.Process.Traversal
 <% } %><% pmethods.findAll{ it in ["within", "without"] }.each { method -> %>
         public static P <%= toCSharpMethodName.call(method) %>(params object[] 
args)
         {
-            return new P("<%= method %>", args);
+            if (args.Length == 1 && 
args[0].GetType().GetInterfaces().Contains(typeof(ICollection)))
+                return new P("<%= method %>", 
ToGenericArray((ICollection<object>) args[0]));
+            else
+                return new P("<%= method %>", args);
         }
 <% } %>
+
+        private static T[] ToGenericArray<T>(ICollection<T> collection)
+        {
+            if (collection == null)
+            {
+                return new T[] { };
+            }
+
+            return new List<T>(collection).ToArray();
+        }
+
         /// <inheritdoc />
         public override string ToString()
         {

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/06519481/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/P.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/P.cs 
b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/P.cs
index e3a1e76..8777f7b 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/P.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/P.cs
@@ -22,6 +22,12 @@
 #endregion
 
 // THIS IS A GENERATED FILE - DO NOT MODIFY THIS FILE DIRECTLY - see pom.xml
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Linq;
+using System.Reflection;
+
 namespace Gremlin.Net.Process.Traversal
 {
 #pragma warning disable 1591
@@ -148,12 +154,29 @@ namespace Gremlin.Net.Process.Traversal
 
         public static P Within(params object[] args)
         {
-            return new P("within", args);
+            if (args.Length == 1 && 
args[0].GetType().GetInterfaces().Contains(typeof(ICollection)))
+                return new P("within", ToGenericArray((ICollection<object>) 
args[0]));
+            else
+                return new P("within", args);
         }
 
         public static P Without(params object[] args)
         {
-            return new P("without", args);
+            if (args.Length == 1 && 
args[0].GetType().GetInterfaces().Contains(typeof(ICollection)))
+                return new P("without", ToGenericArray((ICollection<object>) 
args[0]));
+            else
+                return new P("without", args);
+        }
+
+
+        private static T[] ToGenericArray<T>(ICollection<T> collection)
+        {
+            if (collection == null)
+            {
+                return new T[] { };
+            }
+
+            return new List<T>(collection).ToArray();
         }
 
         /// <inheritdoc />

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/06519481/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/GherkinTestRunner.cs
----------------------------------------------------------------------
diff --git 
a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/GherkinTestRunner.cs 
b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/GherkinTestRunner.cs
index e15a492..6d38ccc 100644
--- 
a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/GherkinTestRunner.cs
+++ 
b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/GherkinTestRunner.cs
@@ -38,11 +38,7 @@ namespace Gremlin.Net.IntegrationTest.Gherkin
     public class GherkinTestRunner
     {
         private static readonly IDictionary<string, IgnoreReason> 
IgnoredScenarios =
-            new Dictionary<string, IgnoreReason>
-            {
-                {"g_V_hasIdXwithinXemptyXX_count", 
IgnoreReason.PWithinWrapsArgumentsInArray},
-                {"g_VX1X_out_aggregateXxX_out_whereXnotXwithinXaXXX", 
IgnoreReason.PWithinWrapsArgumentsInArray}
-            };
+            new Dictionary<string, IgnoreReason>();
         
         private static class Keywords
         {

Reply via email to