diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index 8fcbe1a80db..0ec6f6d0f6d 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -42,6 +42,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. diff --git a/gremlin-dotnet/glv/P.template b/gremlin-dotnet/glv/P.template index ad037c15467..fd3b75236ef 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,18 @@ 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] is ICollection collection) + return new P("<%= method %>", ToGenericArray(collection)); + else + return new P("<%= method %>", args); } <% } %> + + private static T[] ToGenericArray(ICollection collection) + { + return collection?.ToArray() ?? new T[0];; + } + /// public override string ToString() { diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/P.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/P.cs index e3a1e7690ac..e718bbefdfc 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,24 @@ public static P Test(params object[] args) public static P Within(params object[] args) { - return new P("within", args); + if (args.Length == 1 && args[0] is ICollection collection) + return new P("within", ToGenericArray(collection)); + else + return new P("within", args); } public static P Without(params object[] args) { - return new P("without", args); + if (args.Length == 1 && args[0] is ICollection collection) + return new P("without", ToGenericArray(collection)); + else + return new P("without", args); + } + + + private static T[] ToGenericArray(ICollection collection) + { + return collection?.ToArray() ?? new T[0];; } /// diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/GherkinTestRunner.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/GherkinTestRunner.cs index e15a492910d..6d38ccc2950 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 IgnoredScenarios = - new Dictionary - { - {"g_V_hasIdXwithinXemptyXX_count", IgnoreReason.PWithinWrapsArgumentsInArray}, - {"g_VX1X_out_aggregateXxX_out_whereXnotXwithinXaXXX", IgnoreReason.PWithinWrapsArgumentsInArray} - }; + new Dictionary(); private static class Keywords { diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/IgnoreException.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/IgnoreException.cs index 9aa5213b2ea..860c11d98b2 100644 --- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/IgnoreException.cs +++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/IgnoreException.cs @@ -40,11 +40,8 @@ private static string GetMessage(IgnoreReason reason) string reasonSuffix = null; switch (reason) { - case IgnoreReason.PWithinWrapsArgumentsInArray: - reasonSuffix = " because P.Within() arguments are incorrectly wrapped in an array (TINKERPOP-1920)"; - break; - case IgnoreReason.PNotDeserializationProblem: - reasonSuffix = " because P.Not() cannot be deserialized by Gremlin Server (TINKERPOP-1922)"; + case IgnoreReason.NoReason: + reasonSuffix = ""; break; } return $"Scenario ignored" + reasonSuffix; @@ -53,7 +50,6 @@ private static string GetMessage(IgnoreReason reason) public enum IgnoreReason { - PWithinWrapsArgumentsInArray, - PNotDeserializationProblem + NoReason } } \ No newline at end of file