You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by xi...@apache.org on 2026/03/11 00:36:58 UTC
(tinkerpop) branch dotnet-http updated (45a6d9942c -> 18b65cb2eb)
This is an automated email from the ASF dual-hosted git repository.
xiazcy pushed a change to branch dotnet-http
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git
discard 45a6d9942c Add GraphBinary4 type serializers to gremlin-dotnet (#3313)
discard 4ddf9d147d Fix dotnet bug in getting merge Ids from map
discard 2684e31542 Added missing strategies to gremlin-dotnet
discard e63c2dc608 Replace Bytecode with GremlinLang in .NET driver (#3309)
add 500e2b2750 Bumped to antlr 4.13.2 CTR
add 92f10e1c95 Added claude to gitignore CTR
add 5a075e5c18 Merge branch '3.7-dev' into 3.8-dev
add 9ac17810f6 Merge branch '3.8-dev'
add d3865e5b18 Add changes from v1 section to the GraphBinary specification CTR
add c070d3354a Explicit use of Cardinality for sideEffect test CTR
add 3a214ce90e Merge branch '3.8-dev'
add 544d34439c Fix Merge typecode in graphbinary specification CTR
add 1671d38f9f CTR update dotnet docker test set up to avoid masking build errors
add 6b99e214c8 Merge branch '3.7-dev' into 3.8-dev
add 8b45a6ff04 CTR dotnet fix regex parsing for Gremlin.cs generation to resolve build failure & update examples
add 890209fb49 Merge branch '3.8-dev'
add 4ac34ee026 Pin gremlin-javascript to patch versions.
add 297376f337 Merge branch '3.8-dev'
add b22038a20a Remove grunt dependency for straight jsdoc usage
add b606b20c14 Merge branch '3.7-dev' into 3.8-dev
add a855ac9111 Merge branch '3.8-dev'
add 995d48e299 Updated eslint dependency for gremlin-javascript CTR
add 796162e146 Updated cucumber to latest version CTR
add d10f8dc7fd Merge branch '3.7-dev' into 3.8-dev
add 3937cee5b5 Merge branch '3.8-dev'
add ad74eccabc Removed duplicate cucumber declaration CTR
add 991753b507 Update JS driver to GraphBinary4 (#3312)
new 04a3340554 Replace Bytecode with GremlinLang in .NET driver (#3309)
new 8154ab059a Added missing strategies to gremlin-dotnet
new 3e4408eb2b Fix dotnet bug in getting merge Ids from map
new 18b65cb2eb Add GraphBinary4 type serializers to gremlin-dotnet (#3313)
This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version. This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:
* -- * -- B -- O -- O -- O (45a6d9942c)
\
N -- N -- N refs/heads/dotnet-http (18b65cb2eb)
You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.
Any revisions marked "omit" are not gone; other references still
refer to them. Any revisions marked "discard" are gone forever.
The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.gitignore | 2 +
CHANGELOG.asciidoc | 13 +-
docs/src/dev/io/graphbinary.asciidoc | 100 +-
gremlin-console/src/main/static/LICENSE | 2 +-
.../Examples/BasicGremlin/BasicGremlin.cs | 2 +-
gremlin-dotnet/Examples/Connections/Connections.cs | 10 +-
.../Examples/ModernTraversals/ModernTraversals.cs | 2 +-
gremlin-dotnet/build/generate.groovy | 8 +-
gremlin-dotnet/docker-compose.yml | 5 +-
.../Gremlin.Net.IntegrationTest/Gherkin/Gremlin.cs | 550 +-
gremlin-go/driver/cucumber/gremlin.go | 2 +-
gremlin-javascript/pom.xml | 6 +-
.../javascript/gremlin-javascript/.eslintrc.cjs | 153 -
.../javascript/gremlin-javascript/.prettierrc.cjs | 2 +
.../javascript/gremlin-javascript/Gruntfile.cjs | 34 -
.../gremlin-javascript/eslint.config.mjs | 158 +
.../gremlin-javascript/lib/driver/connection.ts | 18 +-
.../lib/structure/io/binary/GraphBinary.js | 78 +-
.../structure/io/binary/internals/AnySerializer.js | 18 +-
.../io/binary/internals/ArraySerializer.js | 20 +-
...ByteBufferSerializer.js => BinarySerializer.js} | 12 +-
.../io/binary/internals/BulkSetSerializer.js | 125 -
.../io/binary/internals/ByteSerializer.js | 4 +-
.../lib/structure/io/binary/internals/DataType.js | 44 +-
...DateTimeSerializer.js => DateTimeSerializer.js} | 122 +-
.../io/binary/internals/EdgeSerializer.js | 28 +-
.../io/binary/internals/EnumSerializer.js | 86 +-
.../io/binary/internals/GraphBinaryWriter.js | 2 -
.../io/binary/internals/LambdaSerializer.js | 70 -
.../io/binary/internals/LongSerializer.js | 3 +-
.../io/binary/internals/LongSerializerNg.js | 103 -
.../structure/io/binary/internals/MapSerializer.js | 4 +-
.../{DateSerializer.js => MarkerSerializer.js} | 59 +-
.../internals/NumberSerializationStrategy.js | 3 +-
.../structure/io/binary/internals/PSerializer.js | 151 -
.../structure/io/binary/internals/SetSerializer.js | 19 +-
.../io/binary/internals/StubSerializer.js} | 18 +-
.../io/binary/internals/TextPSerializer.js | 145 -
.../internals/TraversalStrategySerializer.js | 68 -
.../io/binary/internals/TraverserSerializer.js | 123 -
.../binary/internals/VertexPropertySerializer.js | 14 +-
.../io/binary/internals/VertexSerializer.js | 12 +-
.../lib/structure/io/type-serializers.ts | 6 +-
.../gremlin-javascript/package-lock.json | 8638 ++++----------------
.../javascript/gremlin-javascript/package.json | 18 +-
.../gremlin-javascript/test/cucumber/gremlin.js | 2 +-
.../test/unit/graphbinary/AnySerializer-test.js | 603 --
.../graphbinary/ArraySerializerTestTemplate.js | 149 -
.../unit/graphbinary/BigIntegerSerializer-test.js | 199 -
.../unit/graphbinary/BooleanSerializer-test.js | 140 -
.../unit/graphbinary/BulkSetSerializer-test.js | 157 -
.../unit/graphbinary/ByteBufferSerializer-test.js | 154 -
.../test/unit/graphbinary/ByteSerializer-test.js | 117 -
.../test/unit/graphbinary/DateSerializer-test.js | 26 -
.../unit/graphbinary/DateSerializerTestTemplate.js | 148 -
.../test/unit/graphbinary/DoubleSerializer-test.js | 151 -
.../test/unit/graphbinary/EdgeSerializer-test.js | 169 -
.../test/unit/graphbinary/EnumSerializer-test.js | 171 -
.../test/unit/graphbinary/FloatSerializer-test.js | 122 -
.../unit/graphbinary/GraphBinaryReader-test.js | 128 -
.../unit/graphbinary/GraphBinaryWriter-test.js | 42 -
.../test/unit/graphbinary/IntSerializer-test.js | 147 -
.../test/unit/graphbinary/LambdaSerializer-test.js | 93 -
.../test/unit/graphbinary/LongSerializer-test.js | 144 -
.../test/unit/graphbinary/LongSerializerNg-test.js | 132 -
.../test/unit/graphbinary/MapSerializer-test.js | 192 -
.../test/unit/graphbinary/PSerializer-test.js | 196 -
.../test/unit/graphbinary/PathSerializer-test.js | 244 -
.../unit/graphbinary/PropertySerializer-test.js | 140 -
.../test/unit/graphbinary/SetSerializer-test.js | 26 -
.../unit/graphbinary/SetSerializerTestTemplate.js | 148 -
.../test/unit/graphbinary/ShortSerializer-test.js | 121 -
.../test/unit/graphbinary/StringSerializer-test.js | 26 -
.../graphbinary/StringSerializerTestTemplate.js | 168 -
.../test/unit/graphbinary/TextPSerializer-test.js | 142 -
.../unit/graphbinary/TimestampSerializer-test.js | 26 -
.../TraversalStrategySerializer-test.js | 99 -
.../unit/graphbinary/TraverserSerializer-test.js | 131 -
.../graphbinary/UnspecifiedNullSerializer-test.js | 101 -
.../test/unit/graphbinary/UuidSerializer-test.js | 147 -
.../graphbinary/VertexPropertySerializer-test.js | 142 -
.../test/unit/graphbinary/VertexSerializer-test.js | 148 -
.../test/unit/graphbinary/error-cases-test.js | 443 +
.../test/unit/graphbinary/model-test.js | 251 +
.../test/unit/graphbinary/model.js | 204 +
.../test/unit/graphbinary/null-handling-test.js | 233 +
.../test/unit/graphbinary/type-detection-test.js | 397 +
.../test/unit/graphbinary/utils.js | 32 -
gremlin-mcp/src/main/javascript/package-lock.json | 2 +-
gremlin-mcp/src/main/javascript/package.json | 2 +-
.../src/main/python/tests/feature/gremlin.py | 2 +-
.../test/features/sideEffect/SideEffect.feature | 8 +-
pom.xml | 2 +-
93 files changed, 3763 insertions(+), 14064 deletions(-)
delete mode 100644 gremlin-javascript/src/main/javascript/gremlin-javascript/.eslintrc.cjs
delete mode 100644 gremlin-javascript/src/main/javascript/gremlin-javascript/Gruntfile.cjs
create mode 100644 gremlin-javascript/src/main/javascript/gremlin-javascript/eslint.config.mjs
rename gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/io/binary/internals/{ByteBufferSerializer.js => BinarySerializer.js} (90%)
delete mode 100644 gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/io/binary/internals/BulkSetSerializer.js
rename gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/io/binary/internals/{OffsetDateTimeSerializer.js => DateTimeSerializer.js} (50%)
delete mode 100644 gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/io/binary/internals/LambdaSerializer.js
delete mode 100644 gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/io/binary/internals/LongSerializerNg.js
rename gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/io/binary/internals/{DateSerializer.js => MarkerSerializer.js} (57%)
delete mode 100644 gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/io/binary/internals/PSerializer.js
rename gremlin-javascript/src/main/javascript/gremlin-javascript/{test/unit/graphbinary/ListSerializer-test.js => lib/structure/io/binary/internals/StubSerializer.js} (72%)
delete mode 100644 gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/io/binary/internals/TextPSerializer.js
delete mode 100644 gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/io/binary/internals/TraversalStrategySerializer.js
delete mode 100644 gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/io/binary/internals/TraverserSerializer.js
delete mode 100644 gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/graphbinary/AnySerializer-test.js
delete mode 100644 gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/graphbinary/ArraySerializerTestTemplate.js
delete mode 100644 gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/graphbinary/BigIntegerSerializer-test.js
delete mode 100644 gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/graphbinary/BooleanSerializer-test.js
delete mode 100644 gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/graphbinary/BulkSetSerializer-test.js
delete mode 100644 gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/graphbinary/ByteBufferSerializer-test.js
delete mode 100644 gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/graphbinary/ByteSerializer-test.js
delete mode 100644 gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/graphbinary/DateSerializer-test.js
delete mode 100644 gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/graphbinary/DateSerializerTestTemplate.js
delete mode 100644 gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/graphbinary/DoubleSerializer-test.js
delete mode 100644 gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/graphbinary/EdgeSerializer-test.js
delete mode 100644 gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/graphbinary/EnumSerializer-test.js
delete mode 100644 gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/graphbinary/FloatSerializer-test.js
delete mode 100644 gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/graphbinary/GraphBinaryReader-test.js
delete mode 100644 gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/graphbinary/GraphBinaryWriter-test.js
delete mode 100644 gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/graphbinary/IntSerializer-test.js
delete mode 100644 gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/graphbinary/LambdaSerializer-test.js
delete mode 100644 gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/graphbinary/LongSerializer-test.js
delete mode 100644 gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/graphbinary/LongSerializerNg-test.js
delete mode 100644 gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/graphbinary/MapSerializer-test.js
delete mode 100644 gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/graphbinary/PSerializer-test.js
delete mode 100644 gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/graphbinary/PathSerializer-test.js
delete mode 100644 gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/graphbinary/PropertySerializer-test.js
delete mode 100644 gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/graphbinary/SetSerializer-test.js
delete mode 100644 gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/graphbinary/SetSerializerTestTemplate.js
delete mode 100644 gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/graphbinary/ShortSerializer-test.js
delete mode 100644 gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/graphbinary/StringSerializer-test.js
delete mode 100644 gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/graphbinary/StringSerializerTestTemplate.js
delete mode 100644 gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/graphbinary/TextPSerializer-test.js
delete mode 100644 gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/graphbinary/TimestampSerializer-test.js
delete mode 100644 gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/graphbinary/TraversalStrategySerializer-test.js
delete mode 100644 gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/graphbinary/TraverserSerializer-test.js
delete mode 100644 gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/graphbinary/UnspecifiedNullSerializer-test.js
delete mode 100644 gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/graphbinary/UuidSerializer-test.js
delete mode 100644 gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/graphbinary/VertexPropertySerializer-test.js
delete mode 100644 gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/graphbinary/VertexSerializer-test.js
create mode 100644 gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/graphbinary/error-cases-test.js
create mode 100644 gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/graphbinary/model-test.js
create mode 100644 gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/graphbinary/model.js
create mode 100644 gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/graphbinary/null-handling-test.js
create mode 100644 gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/graphbinary/type-detection-test.js
delete mode 100644 gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/graphbinary/utils.js
(tinkerpop) 03/04: Fix dotnet bug in getting merge Ids from map
Posted by xi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
xiazcy pushed a commit to branch dotnet-http
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git
commit 3e4408eb2b6c122bc503ea8e1f4686a347024cd4
Author: Ken Hu <10...@users.noreply.github.com>
AuthorDate: Tue Jan 27 13:17:52 2026 -0800
Fix dotnet bug in getting merge Ids from map
---
gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs
index bb61d0078c..2ef46e8991 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs
@@ -1459,10 +1459,10 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, Edge> MergeE (IDictionary<object,object?>? m)
{
- if (m != null && m[Direction.Out] is Vertex outV) {
+ if (m != null && m.TryGetValue(Direction.Out, out var outValue) && outValue is Vertex outV) {
m[Direction.Out] = outV.Id;
}
- if (m != null && m[Direction.In] is Vertex inV) {
+ if (m != null && m.TryGetValue(Direction.In, out var inValue) && inValue is Vertex inV) {
m[Direction.In] = inV.Id;
}
GremlinLang.AddStep("mergeE", m);
(tinkerpop) 01/04: Replace Bytecode with GremlinLang in .NET driver (#3309)
Posted by xi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
xiazcy pushed a commit to branch dotnet-http
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git
commit 04a33405545504fd9d8faced3d7237dbef632138
Author: Yang Xia <55...@users.noreply.github.com>
AuthorDate: Tue Mar 10 15:46:26 2026 -0700
Replace Bytecode with GremlinLang in .NET driver (#3309)
---
gremlin-dotnet/src/Gremlin.Net/Driver/Log.cs | 4 +-
.../Driver/Remote/DriverRemoteConnection.cs | 44 +-
.../Driver/Remote/DriverRemoteTraversal.cs | 2 +-
gremlin-dotnet/src/Gremlin.Net/Driver/Tokens.cs | 5 -
.../Process/Remote/IRemoteConnection.cs | 6 +-
.../Gremlin.Net/Process/Remote/RemoteStrategy.cs | 2 +-
.../Process/Remote/RemoteTransaction.cs | 2 +-
.../Process/Traversal/AnonymousTraversalSource.cs | 2 +-
.../src/Gremlin.Net/Process/Traversal/Binding.cs | 80 --
.../src/Gremlin.Net/Process/Traversal/Bindings.cs | 73 --
.../src/Gremlin.Net/Process/Traversal/Bytecode.cs | 180 ----
.../Process/Traversal/CardinalityValue.cs | 53 +-
.../Process/Traversal/DefaultTraversal.cs | 6 +-
.../src/Gremlin.Net/Process/Traversal/GValue.cs | 128 +++
.../src/Gremlin.Net/Process/Traversal/GraphOp.cs | 16 +-
.../Process/Traversal/GraphTraversal.cs | 539 +++++-----
.../Process/Traversal/GraphTraversalSource.cs | 177 ++--
.../Gremlin.Net/Process/Traversal/GremlinLang.cs | 752 ++++++++++++++
.../Gremlin.Net/Process/Traversal/ITraversal.cs | 4 +-
.../Gremlin.Net/Process/Traversal/Instruction.cs | 95 --
.../Strategy/AbstractTraversalStrategy.cs | 2 +-
.../Traversal/Translator/GroovyTranslator.cs | 207 ----
.../Structure/IO/GraphBinary/DataType.cs | 2 -
.../IO/GraphBinary/TypeSerializerRegistry.cs | 4 -
.../IO/GraphBinary/Types/BindingSerializer.cs | 61 --
.../IO/GraphBinary/Types/ByteCodeSerializer.cs | 117 ---
.../IO/GraphBinary/Types/TraversalSerializer.cs | 6 +-
.../Structure/IO/GraphSON/BindingSerializer.cs | 42 -
.../Structure/IO/GraphSON/BytecodeSerializer.cs | 58 --
.../Structure/IO/GraphSON/GraphSONWriter.cs | 2 -
.../Structure/IO/GraphSON/TraversalSerializer.cs | 5 +-
.../MessageSerializerBenchmarks.cs | 29 +-
.../Docs/Reference/GremlinApplicationsTests.cs | 2 +-
.../Driver/DriverRemoteConnectionTests.cs | 22 +-
.../Gremlin.Net.IntegrationTest/Gherkin/Gremlin.cs | 2 +-
.../Gherkin/IgnoreException.cs | 2 +-
.../Process/Remote/RemoteStrategyTests.cs | 46 +-
.../BytecodeGeneration/BytecodeGenerationTests.cs | 116 ---
.../BytecodeGeneration/StrategiesTests.cs | 162 ---
.../DriverRemoteConnection/GraphTraversalTests.cs | 8 +-
.../GremlinLangGenerationTests.cs | 94 ++
.../GremlinLangGeneration/StrategiesTests.cs | 121 +++
.../Process/Traversal/BytecodeTests.cs | 190 ----
.../Process/Traversal/GraphTraversalSourceTests.cs | 31 +-
.../Process/Traversal/GremlinLangTests.cs | 1045 ++++++++++++++++++++
.../Process/Traversal/TestTraversal.cs | 6 +-
.../Traversal/Translator/GroovyTranslatorTests.cs | 500 ----------
.../Process/Traversal/TraversalTests.cs | 57 +-
.../Structure/IO/GraphBinary/GraphBinaryTests.cs | 34 -
.../IO/GraphSON/BytecodeGraphSONSerializerTests.cs | 169 ----
.../Structure/IO/GraphSON/GraphSONWriterTests.cs | 18 +-
51 files changed, 2666 insertions(+), 2664 deletions(-)
diff --git a/gremlin-dotnet/src/Gremlin.Net/Driver/Log.cs b/gremlin-dotnet/src/Gremlin.Net/Driver/Log.cs
index ae9c712f82..3d5543a8c4 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Driver/Log.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Driver/Log.cs
@@ -40,7 +40,7 @@ namespace Gremlin.Net.Driver
"A connection was closed. Removing it from the pool so it can be replaced.")]
public static partial void RemovingClosedConnectionFromPool(this ILogger logger);
- [LoggerMessage(20003, LogLevel.Debug, "Submitting Bytecode {bytecode} for request: {requestId}")]
- public static partial void SubmittingBytecode(this ILogger logger, Bytecode bytecode, Guid requestId);
+ [LoggerMessage(20003, LogLevel.Debug, "Submitting GremlinLang {gremlinLang} for request: {requestId}")]
+ public static partial void SubmittingGremlinLang(this ILogger logger, GremlinLang gremlinLang, Guid requestId);
}
}
\ No newline at end of file
diff --git a/gremlin-dotnet/src/Gremlin.Net/Driver/Remote/DriverRemoteConnection.cs b/gremlin-dotnet/src/Gremlin.Net/Driver/Remote/DriverRemoteConnection.cs
index b9e0aa09a7..558d103c64 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Driver/Remote/DriverRemoteConnection.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Driver/Remote/DriverRemoteConnection.cs
@@ -105,41 +105,26 @@ namespace Gremlin.Net.Driver.Remote
}
/// <summary>
- /// Submits <see cref="Bytecode" /> for evaluation to a remote Gremlin Server.
+ /// Submits <see cref="GremlinLang" /> for evaluation to a remote Gremlin Server.
/// </summary>
- /// <param name="bytecode">The <see cref="Bytecode" /> to submit.</param>
+ /// <param name="gremlinLang">The <see cref="GremlinLang" /> to submit.</param>
/// <param name="cancellationToken">The token to cancel the operation. The default value is None.</param>
/// <returns>A <see cref="ITraversal" /> allowing to access the results and side-effects.</returns>
- public async Task<ITraversal<TStart, TEnd>> SubmitAsync<TStart, TEnd>(Bytecode bytecode,
+ public async Task<ITraversal<TStart, TEnd>> SubmitAsync<TStart, TEnd>(GremlinLang gremlinLang,
CancellationToken cancellationToken = default)
{
- var requestId = Guid.NewGuid();
- var resultSet = await SubmitBytecodeAsync(requestId, bytecode, cancellationToken).ConfigureAwait(false);
- return new DriverRemoteTraversal<TStart, TEnd>(resultSet);
- }
+ gremlinLang.AddG(_traversalSource);
- private async Task<IEnumerable<Traverser>> SubmitBytecodeAsync(Guid requestid, Bytecode bytecode,
- CancellationToken cancellationToken)
- {
- _logger.SubmittingBytecode(bytecode, requestid);
-
+ var requestId = Guid.NewGuid();
var requestMsg =
- RequestMessage.Build(Tokens.OpsBytecode)
+ RequestMessage.Build(Tokens.OpsEval)
.Processor(Processor)
- .OverrideRequestId(requestid)
- .AddArgument(Tokens.ArgsGremlin, bytecode)
- .AddArgument(Tokens.ArgsAliases, new Dictionary<string, string> {{"g", _traversalSource}});
-
- if (IsSessionBound)
- {
- requestMsg.AddArgument(Tokens.ArgsSession, _sessionId!);
- }
+ .OverrideRequestId(requestId)
+ .AddArgument(Tokens.ArgsGremlin, gremlinLang.GetGremlin())
+ .AddArgument(Tokens.ArgsBindings, gremlinLang.Parameters);
- var optionsStrategyInst = bytecode.SourceInstructions.Find(
- s => s.OperatorName == "withStrategies" && s.Arguments[0] is OptionsStrategy);
- if (optionsStrategyInst != null)
+ foreach (var optionsStrategy in gremlinLang.OptionsStrategies)
{
- OptionsStrategy optionsStrategy = optionsStrategyInst.Arguments[0]!;
foreach (var pair in optionsStrategy.Configuration)
{
if (_allowedKeys.Contains(pair.Key))
@@ -149,7 +134,14 @@ namespace Gremlin.Net.Driver.Remote
}
}
- return await _client.SubmitAsync<Traverser>(requestMsg.Create(), cancellationToken).ConfigureAwait(false);
+ if (IsSessionBound)
+ {
+ requestMsg.AddArgument(Tokens.ArgsSession, _sessionId!);
+ }
+
+ var resultSet = await _client.SubmitAsync<Traverser>(requestMsg.Create(), cancellationToken)
+ .ConfigureAwait(false);
+ return new DriverRemoteTraversal<TStart, TEnd>(resultSet);
}
/// <inheritdoc />
diff --git a/gremlin-dotnet/src/Gremlin.Net/Driver/Remote/DriverRemoteTraversal.cs b/gremlin-dotnet/src/Gremlin.Net/Driver/Remote/DriverRemoteTraversal.cs
index 66501ffc34..e0c538c71b 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Driver/Remote/DriverRemoteTraversal.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Driver/Remote/DriverRemoteTraversal.cs
@@ -34,6 +34,6 @@ namespace Gremlin.Net.Driver.Remote
Traversers = traversers;
}
- public override Bytecode Bytecode => throw new NotSupportedException("Remote traversals do not have Bytecode");
+ public override GremlinLang GremlinLang => throw new NotSupportedException("Remote traversals do not have GremlinLang");
}
}
\ No newline at end of file
diff --git a/gremlin-dotnet/src/Gremlin.Net/Driver/Tokens.cs b/gremlin-dotnet/src/Gremlin.Net/Driver/Tokens.cs
index ad87fdab03..26caff324e 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Driver/Tokens.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Driver/Tokens.cs
@@ -45,11 +45,6 @@ namespace Gremlin.Net.Driver
/// </summary>
public const string OpsAuthentication = "authentication";
- /// <summary>
- /// Operation used for a request that contains the Bytecode representation of a Traversal.
- /// </summary>
- public const string OpsBytecode = "bytecode";
-
/// <summary>
/// Operation used to evaluate a Gremlin script provided as a string.
/// </summary>
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Remote/IRemoteConnection.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Remote/IRemoteConnection.cs
index b721e40c65..fb1d4e4441 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Remote/IRemoteConnection.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Remote/IRemoteConnection.cs
@@ -33,13 +33,13 @@ namespace Gremlin.Net.Process.Remote
public interface IRemoteConnection
{
/// <summary>
- /// Submits <see cref="ITraversal" /> <see cref="Bytecode" /> to a server and returns a
+ /// Submits <see cref="ITraversal" /> <see cref="Traversal.GremlinLang" /> to a server and returns a
/// <see cref="ITraversal" />.
/// </summary>
- /// <param name="bytecode">The <see cref="Bytecode" /> to send.</param>
+ /// <param name="gremlinLang">The <see cref="Traversal.GremlinLang" /> to send.</param>
/// <param name="cancellationToken">The token to cancel the operation. The default value is None.</param>
/// <returns>The <see cref="ITraversal" /> with the results and optional side-effects.</returns>
- Task<ITraversal<TStart, TEnd>> SubmitAsync<TStart, TEnd>(Bytecode bytecode, CancellationToken cancellationToken = default);
+ Task<ITraversal<TStart, TEnd>> SubmitAsync<TStart, TEnd>(GremlinLang gremlinLang, CancellationToken cancellationToken = default);
/// <summary>
/// Creates a <see cref="RemoteTransaction" /> in the context of a <see cref="GraphTraversalSource" /> designed to work with
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Remote/RemoteStrategy.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Remote/RemoteStrategy.cs
index aa39f595ae..94ce6551b0 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Remote/RemoteStrategy.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Remote/RemoteStrategy.cs
@@ -54,7 +54,7 @@ namespace Gremlin.Net.Process.Remote
public async Task ApplyAsync<TStart, TEnd>(ITraversal<TStart, TEnd> traversal, CancellationToken cancellationToken = default)
{
if (traversal.Traversers != null) return;
- var remoteTraversal = await _remoteConnection.SubmitAsync<TStart, TEnd>(traversal.Bytecode, cancellationToken)
+ var remoteTraversal = await _remoteConnection.SubmitAsync<TStart, TEnd>(traversal.GremlinLang, cancellationToken)
.ConfigureAwait(false);
traversal.Traversers = remoteTraversal.Traversers;
}
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Remote/RemoteTransaction.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Remote/RemoteTransaction.cs
index 7d71f17fef..322cccc9c6 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Remote/RemoteTransaction.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Remote/RemoteTransaction.cs
@@ -62,7 +62,7 @@ namespace Gremlin.Net.Process.Remote
{
throw new InvalidOperationException("Transaction already started on this object");
}
- _g = new GraphTraversalSource(_g.TraversalStrategies, _g.Bytecode, _sessionBasedConnection);
+ _g = new GraphTraversalSource(_g.TraversalStrategies, _g.GremlinLang, _sessionBasedConnection);
return _g;
}
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/AnonymousTraversalSource.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/AnonymousTraversalSource.cs
index dd72ace5db..2a6e8f4176 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/AnonymousTraversalSource.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/AnonymousTraversalSource.cs
@@ -58,7 +58,7 @@ namespace Gremlin.Net.Process.Traversal
/// <returns>A <see cref="GraphTraversalSource" /> configured to use the provided <see cref="IRemoteConnection" />.</returns>
public GraphTraversalSource With(IRemoteConnection remoteConnection) =>
new GraphTraversalSource(new List<ITraversalStrategy>(),
- new Bytecode(), remoteConnection);
+ new GremlinLang(), remoteConnection);
}
}
\ No newline at end of file
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Binding.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Binding.cs
deleted file mode 100644
index ce76181f95..0000000000
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Binding.cs
+++ /dev/null
@@ -1,80 +0,0 @@
-#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;
-
-namespace Gremlin.Net.Process.Traversal
-{
- /// <summary>
- /// Associates a variable with a value.
- /// </summary>
- public class Binding : IEquatable<Binding>
- {
- /// <summary>
- /// Initializes a new instance of the <see cref="Binding" /> class.
- /// </summary>
- /// <param name="key">The key that identifies the <see cref="Binding" />.</param>
- /// <param name="value">The value of the <see cref="Binding" />.</param>
- public Binding(string key, object? value)
- {
- Key = key;
- Value = value;
- }
-
- /// <summary>
- /// Gets the key that identifies the <see cref="Binding" />.
- /// </summary>
- public string Key { get; }
-
- /// <summary>
- /// Gets the value of the <see cref="Binding" />.
- /// </summary>
- public object? Value { get; }
-
- /// <inheritdoc />
- public bool Equals(Binding? other)
- {
- if (other == null)
- return false;
- return Key == other.Key && (Value?.Equals(other.Value) ?? other.Value == null);
- }
-
- /// <inheritdoc />
- public override bool Equals(object? other)
- {
- if (ReferenceEquals(null, other)) return false;
- if (ReferenceEquals(this, other)) return true;
- if (other.GetType() != GetType()) return false;
- return Equals(other as Binding);
- }
-
- /// <inheritdoc />
- public override int GetHashCode()
- {
- unchecked
- {
- return ((Key?.GetHashCode() ?? 0) * 397) ^ (Value?.GetHashCode() ?? 0);
- }
- }
- }
-}
\ No newline at end of file
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Bindings.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Bindings.cs
deleted file mode 100644
index 746b4994c3..0000000000
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Bindings.cs
+++ /dev/null
@@ -1,73 +0,0 @@
-#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.Collections.Generic;
-using System.Threading;
-
-namespace Gremlin.Net.Process.Traversal
-{
- /// <summary>
- /// Bindings are used to associate a variable with a value.
- /// </summary>
- public class Bindings
- {
- /// <summary>
- /// Gets an instance of the <see cref="Bindings" /> class.
- /// </summary>
- public static Bindings Instance { get; } = new();
-
- private static readonly ThreadLocal<Dictionary<object, string>> BoundVariableByValue = new();
-
- /// <summary>
- /// Binds the variable to the specified value.
- /// </summary>
- /// <param name="variable">The variable to bind.</param>
- /// <param name="value">The value to which the variable should be bound.</param>
- /// <returns>The bound value.</returns>
- public TV Of<TV>(string variable, TV value) where TV : notnull
- {
- var dict = BoundVariableByValue.Value;
- if (dict == null)
- {
- dict = new Dictionary<object, string>();
- BoundVariableByValue.Value = dict;
- }
- dict[value] = variable;
- return value;
- }
-
- internal static string? GetBoundVariable<TV>(TV value) where TV : notnull
- {
- var dict = BoundVariableByValue.Value;
- if (dict == null)
- return null;
- dict.TryGetValue(value, out var variable);
- return variable;
- }
-
- internal static void Clear()
- {
- BoundVariableByValue.Value?.Clear();
- }
- }
-}
\ No newline at end of file
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Bytecode.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Bytecode.cs
deleted file mode 100644
index 604ba6749e..0000000000
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Bytecode.cs
+++ /dev/null
@@ -1,180 +0,0 @@
-#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;
-using System.Collections.Generic;
-using System.Diagnostics.CodeAnalysis;
-using System.Linq;
-
-namespace Gremlin.Net.Process.Traversal
-{
- /// <summary>
- /// A language agnostic representation of <see cref="ITraversal" /> mutations.
- /// </summary>
- /// <remarks>
- /// Bytecode is simply a list of ordered instructions.
- /// Bytecode can be serialized between environments and machines by way of a GraphSON representation.
- /// Thus, Gremlin.Net can create bytecode in C# and ship it to Gremlin-Java for evaluation in Java.
- /// </remarks>
- public class Bytecode
- {
- private static readonly object[] EmptyArray = Array.Empty<object>();
-
- /// <summary>
- /// Initializes a new instance of the <see cref="Bytecode" /> class.
- /// </summary>
- public Bytecode()
- {
- }
-
- /// <summary>
- /// Initializes a new instance of the <see cref="Bytecode" /> class.
- /// </summary>
- /// <param name="byteCode">Already existing <see cref="Bytecode" /> that should be cloned.</param>
- public Bytecode(Bytecode byteCode)
- {
- SourceInstructions = new List<Instruction>(byteCode.SourceInstructions);
- StepInstructions = new List<Instruction>(byteCode.StepInstructions);
- }
-
- /// <summary>
- /// Gets the traversal source instructions.
- /// </summary>
- public List<Instruction> SourceInstructions { get; } = new();
-
- /// <summary>
- /// Gets the <see cref="ITraversal" /> instructions.
- /// </summary>
- public List<Instruction> StepInstructions { get; } = new();
-
- /// <summary>
- /// Add a traversal source instruction to the bytecode.
- /// </summary>
- /// <param name="sourceName">The traversal source method name (e.g. withSack()).</param>
- /// <param name="args">The traversal source method arguments.</param>
- public void AddSource(string sourceName, params object?[] args)
- {
- SourceInstructions.Add(new Instruction(sourceName, FlattenArguments(args)));
- Bindings.Clear();
- }
-
- /// <summary>
- /// Adds a <see cref="ITraversal" /> instruction to the bytecode.
- /// </summary>
- /// <param name="stepName">The traversal method name (e.g. out()).</param>
- /// <param name="args">The traversal method arguments.</param>
- public void AddStep(string stepName, params object?[] args)
- {
- StepInstructions.Add(new Instruction(stepName, FlattenArguments(args)));
- Bindings.Clear();
- }
-
- private object?[] FlattenArguments(object?[] arguments)
- {
- if (arguments.Length == 0)
- return EmptyArray;
- var flatArguments = new List<object?>();
- foreach (var arg in arguments)
- {
- if (arg is object[] objects)
- {
- flatArguments.AddRange(objects.Select(nestObject => ConvertArgument(nestObject, true)));
- }
- else
- {
- flatArguments.Add(ConvertArgument(arg, true));
- }
- }
- return flatArguments.ToArray();
- }
-
- [return: NotNullIfNotNull("argument")]
- private object? ConvertArgument(object? argument, bool searchBindings)
- {
- if (null == argument)
- {
- return null;
- }
-
- if (searchBindings)
- {
- var variable = Bindings.GetBoundVariable(argument);
- if (variable != null)
- return new Binding(variable, ConvertArgument(argument, false));
- }
-
- if (argument is ITraversal traversal && !traversal.IsAnonymous)
- throw new ArgumentException(
- $"The child traversal of {traversal.Bytecode} was not spawned anonymously - use the __ class rather than a TraversalSource to construct the child traversal");
-
-
- if (IsDictionaryType(argument.GetType()))
- {
- var dict = new Dictionary<object, object?>();
- foreach (DictionaryEntry item in (IDictionary)argument)
- {
- dict[ConvertArgument(item.Key, true)] = ConvertArgument(item.Value, true);
- }
- return dict;
- }
- if (IsListType(argument.GetType()))
- {
- var list = new List<object?>(((IList) argument).Count);
- list.AddRange(from object? item in (IList)argument select ConvertArgument(item, true));
- return list;
- }
- if (IsHashSetType(argument.GetType()))
- {
- var set = new HashSet<object?>();
- foreach (var item in (IEnumerable)argument)
- {
- set.Add(ConvertArgument(item, true));
- }
- return set;
- }
- return argument;
- }
-
- private bool IsDictionaryType(Type type)
- {
- return type.IsConstructedGenericType && type.GetGenericTypeDefinition() == typeof(Dictionary<,>);
- }
-
- private bool IsListType(Type type)
- {
- return type.IsConstructedGenericType && type.GetGenericTypeDefinition() == typeof(List<>);
- }
-
- private bool IsHashSetType(Type type)
- {
- return type.IsConstructedGenericType && type.GetGenericTypeDefinition() == typeof(HashSet<>);
- }
-
- /// <inheritdoc />
- public override string ToString()
- {
- return $"[[{string.Join(", ", SourceInstructions)}], [{string.Join(", ", StepInstructions)}]]";
- }
- }
-}
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/CardinalityValue.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/CardinalityValue.cs
index b184eee495..663b9d8d41 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/CardinalityValue.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/CardinalityValue.cs
@@ -22,71 +22,60 @@
#endregion
using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading;
namespace Gremlin.Net.Process.Traversal
{
/// <summary>
/// Holds a property value with the associated <see cref="Traversal.Cardinality" />.
/// </summary>
- public class CardinalityValue : Bytecode
+ public class CardinalityValue
{
/// <summary>
/// Gets the <see cref="Traversal.Cardinality" /> for the value.
/// </summary>
- public Cardinality? Cardinality
- {
- get
- {
- return this.SourceInstructions[0].Arguments[0];
- }
- }
+ public Cardinality? Cardinality { get; }
/// <summary>
/// Gets the value.
/// </summary>
- public object? Value
- {
- get
- {
- return this.SourceInstructions[0].Arguments[1];
- }
- }
+ public object? Value { get; }
/// <summary>
/// Initializes a new instance of the <see cref="CardinalityValue" /> class.
/// </summary>
- public CardinalityValue(Cardinality card, object val)
+ /// <param name="cardinality">The cardinality for the value.</param>
+ /// <param name="value">The property value.</param>
+ /// <exception cref="ArgumentNullException">Thrown when <paramref name="cardinality" /> is null.</exception>
+ public CardinalityValue(Cardinality cardinality, object? value)
{
- if (card == null)
- throw new ArgumentNullException("Cardinality argument must not be null");
- this.AddSource("CardinalityValueTraversal", card, val);
+ if (cardinality == null)
+ throw new ArgumentNullException(nameof(cardinality), "Cardinality argument must not be null");
+ Cardinality = cardinality;
+ Value = value;
}
/// <summary>
- /// Creates a new <see cref="CardinalityValue" /> with a particular value and Single <see cref="Cardinality" />.
+ /// Creates a new <see cref="CardinalityValue" /> with a particular value and Single <see cref="Traversal.Cardinality" />.
/// </summary>
- public static CardinalityValue Single(object value)
+ public static CardinalityValue Single(object? value)
{
- return new CardinalityValue(Cardinality.Single, value);
+ return new CardinalityValue(Traversal.Cardinality.Single, value);
}
/// <summary>
- /// Creates a new <see cref="CardinalityValue" /> with a particular value and Set <see cref="Cardinality" />.
+ /// Creates a new <see cref="CardinalityValue" /> with a particular value and Set <see cref="Traversal.Cardinality" />.
/// </summary>
- public static CardinalityValue Set(object value)
+ public static CardinalityValue Set(object? value)
{
- return new CardinalityValue(Cardinality.Set, value);
+ return new CardinalityValue(Traversal.Cardinality.Set, value);
}
/// <summary>
- /// Creates a new <see cref="CardinalityValue" /> with a particular value and List <see cref="Cardinality" />.
+ /// Creates a new <see cref="CardinalityValue" /> with a particular value and List <see cref="Traversal.Cardinality" />.
/// </summary>
- public static CardinalityValue List(object value)
+ public static CardinalityValue List(object? value)
{
- return new CardinalityValue(Cardinality.List, value);
+ return new CardinalityValue(Traversal.Cardinality.List, value);
}
}
-}
\ No newline at end of file
+}
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/DefaultTraversal.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/DefaultTraversal.cs
index 1b64474fbb..70674d9788 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/DefaultTraversal.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/DefaultTraversal.cs
@@ -39,9 +39,9 @@ namespace Gremlin.Net.Process.Traversal
private IEnumerator<Traverser>? _traverserEnumerator;
/// <summary>
- /// Gets the <see cref="Traversal.Bytecode" /> representation of this traversal.
+ /// Gets the <see cref="Traversal.GremlinLang" /> representation of this traversal.
/// </summary>
- public abstract Bytecode Bytecode { get; }
+ public abstract GremlinLang GremlinLang { get; }
/// <summary>
/// Determines if this traversal was spawned anonymously or not.
@@ -229,7 +229,7 @@ namespace Gremlin.Net.Process.Traversal
/// <returns>The fully drained traversal.</returns>
public ITraversal<TStart, TEnd> Iterate()
{
- Bytecode.AddStep("discard");
+ GremlinLang.AddStep("discard");
while (MoveNext())
{
}
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GValue.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GValue.cs
new file mode 100644
index 0000000000..84c4eb0402
--- /dev/null
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GValue.cs
@@ -0,0 +1,128 @@
+#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;
+
+namespace Gremlin.Net.Process.Traversal
+{
+ /// <summary>
+ /// Non-generic interface for GValue to allow type-agnostic access in GremlinLang.
+ /// </summary>
+ public interface IGValue
+ {
+ /// <summary>
+ /// Gets the parameter name.
+ /// </summary>
+ string Name { get; }
+
+ /// <summary>
+ /// Gets the parameter value as an object.
+ /// </summary>
+ object? ObjectValue { get; }
+ }
+
+ /// <summary>
+ /// A named parameter wrapper that associates a user-defined name with a value.
+ /// GremlinLang renders the name in the gremlin string and stores the name-to-value
+ /// mapping in the parameters dictionary. Replaces the legacy Binding/Bindings mechanism.
+ /// </summary>
+ /// <typeparam name="T">The type of the parameter value.</typeparam>
+ public class GValue<T> : IGValue, IEquatable<GValue<T>>
+ {
+ /// <summary>
+ /// Initializes a new instance of the <see cref="GValue{T}" /> class.
+ /// </summary>
+ /// <param name="name">The parameter name. Must be a valid identifier, not null, and not start with underscore.</param>
+ /// <param name="value">The parameter value.</param>
+ /// <exception cref="ArgumentNullException">Thrown when <paramref name="name" /> is null.</exception>
+ /// <exception cref="ArgumentException">Thrown when <paramref name="name" /> is not a valid identifier.</exception>
+ public GValue(string name, T value)
+ {
+ if (name == null)
+ throw new ArgumentNullException(nameof(name), "The parameter name cannot be null.");
+
+ if (name.Length == 0)
+ throw new ArgumentException($"Invalid parameter name [{name}].");
+
+ if (name[0] == '_')
+ throw new ArgumentException($"Invalid GValue name {name}. Should not start with _.");
+
+ if (!char.IsLetter(name[0]))
+ throw new ArgumentException($"Invalid parameter name [{name}].");
+
+ for (int i = 1; i < name.Length; i++)
+ {
+ if (!char.IsLetterOrDigit(name[i]))
+ throw new ArgumentException($"Invalid parameter name [{name}].");
+ }
+
+ Name = name;
+ Value = value;
+ }
+
+ /// <summary>
+ /// Gets the parameter name.
+ /// </summary>
+ public string Name { get; }
+
+ /// <summary>
+ /// Gets the parameter value.
+ /// </summary>
+ public T Value { get; }
+
+ /// <inheritdoc />
+ public object? ObjectValue => Value;
+
+ /// <inheritdoc />
+ public bool Equals(GValue<T>? other)
+ {
+ if (ReferenceEquals(null, other)) return false;
+ if (ReferenceEquals(this, other)) return true;
+ return Name == other.Name && Equals(Value, other.Value);
+ }
+
+ /// <inheritdoc />
+ public override bool Equals(object? obj)
+ {
+ if (ReferenceEquals(null, obj)) return false;
+ if (ReferenceEquals(this, obj)) return true;
+ if (obj.GetType() != GetType()) return false;
+ return Equals((GValue<T>)obj);
+ }
+
+ /// <inheritdoc />
+ public override int GetHashCode()
+ {
+ unchecked
+ {
+ return (Name.GetHashCode() * 397) ^ (Value != null ? Value.GetHashCode() : 0);
+ }
+ }
+
+ /// <inheritdoc />
+ public override string ToString()
+ {
+ return $"GValue({Name}, {Value})";
+ }
+ }
+}
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphOp.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphOp.cs
index 20b6975946..a93f748bd5 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphOp.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphOp.cs
@@ -24,7 +24,7 @@
namespace Gremlin.Net.Process.Traversal
{
/// <summary>
- /// A graph operation is a static <see cref="Bytecode" /> form that does not translate to a traversal but instead
+ /// A graph operation is a static <see cref="GremlinLang" /> form that does not translate to a traversal but instead
/// refers to a specific function to perform on a graph instance.
/// </summary>
public static class GraphOp
@@ -32,18 +32,18 @@ namespace Gremlin.Net.Process.Traversal
/// <summary>
/// Commit a transaction.
/// </summary>
- public static Bytecode Commit { get; } = CreateGraphOp("tx", "commit");
+ public static GremlinLang Commit { get; } = CreateGraphOp("tx", "commit");
/// <summary>
/// Rollback a transaction.
/// </summary>
- public static Bytecode Rollback { get; } = CreateGraphOp("tx", "rollback");
+ public static GremlinLang Rollback { get; } = CreateGraphOp("tx", "rollback");
- private static Bytecode CreateGraphOp(string name, object value)
+ private static GremlinLang CreateGraphOp(string name, object value)
{
- var bytecode = new Bytecode();
- bytecode.AddSource(name, value);
- return bytecode;
+ var gremlinLang = new GremlinLang();
+ gremlinLang.AddSource(name, value);
+ return gremlinLang;
}
}
-}
\ No newline at end of file
+}
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs
index c067b1450c..bb61d0078c 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs
@@ -25,7 +25,6 @@ using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
-using Gremlin.Net.Driver;
using Gremlin.Net.Structure;
namespace Gremlin.Net.Process.Traversal
@@ -39,7 +38,7 @@ namespace Gremlin.Net.Process.Traversal
/// Initializes a new instance of the <see cref="GraphTraversal{SType, EType}" /> class.
/// </summary>
public GraphTraversal()
- : this(new List<ITraversalStrategy>(), new Bytecode(), true)
+ : this(new List<ITraversalStrategy>(), new GremlinLang(), true)
{
}
@@ -47,9 +46,9 @@ namespace Gremlin.Net.Process.Traversal
/// Initializes a new instance of the <see cref="GraphTraversal{SType, EType}" /> class.
/// </summary>
/// <param name="traversalStrategies">The traversal strategies to be used by this graph traversal at evaluation time.</param>
- /// <param name="bytecode">The <see cref="Bytecode" /> associated with the construction of this graph traversal.</param>
- public GraphTraversal(ICollection<ITraversalStrategy> traversalStrategies, Bytecode bytecode)
- : this(traversalStrategies, bytecode, false)
+ /// <param name="gremlinLang">The <see cref="Traversal.GremlinLang" /> associated with the construction of this graph traversal.</param>
+ public GraphTraversal(ICollection<ITraversalStrategy> traversalStrategies, GremlinLang gremlinLang)
+ : this(traversalStrategies, gremlinLang, false)
{
}
@@ -57,17 +56,17 @@ namespace Gremlin.Net.Process.Traversal
/// Initializes a new instance of the <see cref="GraphTraversal{SType, EType}" /> class.
/// </summary>
/// <param name="traversalStrategies">The traversal strategies to be used by this graph traversal at evaluation time.</param>
- /// <param name="bytecode">The <see cref="Bytecode" /> associated with the construction of this graph traversal.</param>
+ /// <param name="gremlinLang">The <see cref="Traversal.GremlinLang" /> associated with the construction of this graph traversal.</param>
/// <param name="anonymous">Set to true if spawned from an anonymous traversal source and false otherwise.</param>
- private GraphTraversal(ICollection<ITraversalStrategy> traversalStrategies, Bytecode bytecode, bool anonymous)
+ private GraphTraversal(ICollection<ITraversalStrategy> traversalStrategies, GremlinLang gremlinLang, bool anonymous)
{
TraversalStrategies = traversalStrategies;
- Bytecode = bytecode;
+ GremlinLang = gremlinLang;
IsAnonymous = anonymous;
}
/// <inheritdoc />
- public override Bytecode Bytecode { get; }
+ public override GremlinLang GremlinLang { get; }
private static GraphTraversal<TNewStart, TNewEnd> Wrap<TNewStart, TNewEnd>(GraphTraversal<TStart, TEnd> traversal)
{
@@ -76,7 +75,7 @@ namespace Gremlin.Net.Process.Traversal
return (traversal as GraphTraversal<TNewStart, TNewEnd>)!;
}
// New wrapper
- return new GraphTraversal<TNewStart, TNewEnd>(traversal.TraversalStrategies, traversal.Bytecode, traversal.IsAnonymous);
+ return new GraphTraversal<TNewStart, TNewEnd>(traversal.TraversalStrategies, traversal.GremlinLang, traversal.IsAnonymous);
}
@@ -87,7 +86,7 @@ namespace Gremlin.Net.Process.Traversal
{
if (vertexIdsOrElements == null)
{
- Bytecode.AddStep("V", new object?[] { null });
+ GremlinLang.AddStep("V", new object?[] { null });
}
else
{
@@ -100,7 +99,7 @@ namespace Gremlin.Net.Process.Traversal
}
var args = new List<object?>(vertexIdsOrElements.Length);
args.AddRange(vertexIdsOrElements);
- Bytecode.AddStep("V", args.ToArray());
+ GremlinLang.AddStep("V", args.ToArray());
}
return Wrap<TStart, Vertex>(this);
}
@@ -112,13 +111,13 @@ namespace Gremlin.Net.Process.Traversal
{
if (edgeIdsOrElements == null)
{
- Bytecode.AddStep("E", new object?[] { null });
+ GremlinLang.AddStep("E", new object?[] { null });
}
else
{
var args = new List<object?>(edgeIdsOrElements.Length);
args.AddRange(edgeIdsOrElements);
- Bytecode.AddStep("E", args.ToArray());
+ GremlinLang.AddStep("E", args.ToArray());
}
return Wrap<TStart, Edge>(this);
}
@@ -128,7 +127,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, Edge> AddE (string edgeLabel)
{
- Bytecode.AddStep("addE", edgeLabel);
+ GremlinLang.AddStep("addE", edgeLabel);
return Wrap<TStart, Edge>(this);
}
@@ -137,7 +136,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, Edge> AddE (ITraversal edgeLabelTraversal)
{
- Bytecode.AddStep("addE", edgeLabelTraversal);
+ GremlinLang.AddStep("addE", edgeLabelTraversal);
return Wrap<TStart, Edge>(this);
}
@@ -146,7 +145,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, Vertex> AddV ()
{
- Bytecode.AddStep("addV");
+ GremlinLang.AddStep("addV");
return Wrap<TStart, Vertex>(this);
}
@@ -155,7 +154,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, Vertex> AddV (string vertexLabel)
{
- Bytecode.AddStep("addV", vertexLabel);
+ GremlinLang.AddStep("addV", vertexLabel);
return Wrap<TStart, Vertex>(this);
}
@@ -164,7 +163,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, Vertex> AddV (ITraversal vertexLabelTraversal)
{
- Bytecode.AddStep("addV", vertexLabelTraversal);
+ GremlinLang.AddStep("addV", vertexLabelTraversal);
return Wrap<TStart, Vertex>(this);
}
@@ -173,7 +172,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TEnd> Aggregate (string sideEffectKey)
{
- Bytecode.AddStep("aggregate", sideEffectKey);
+ GremlinLang.AddStep("aggregate", sideEffectKey);
return Wrap<TStart, TEnd>(this);
}
@@ -182,7 +181,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TEnd> All (P? predicate)
{
- Bytecode.AddStep("all", predicate);
+ GremlinLang.AddStep("all", predicate);
return Wrap<TStart, TEnd>(this);
}
@@ -195,7 +194,7 @@ namespace Gremlin.Net.Process.Traversal
var args = new List<object>(andTraversals.Length);
args.AddRange(andTraversals);
- Bytecode.AddStep("and", args.ToArray());
+ GremlinLang.AddStep("and", args.ToArray());
return Wrap<TStart, TEnd>(this);
}
@@ -204,7 +203,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TEnd> Any (P? predicate)
{
- Bytecode.AddStep("any", predicate);
+ GremlinLang.AddStep("any", predicate);
return Wrap<TStart, TEnd>(this);
}
@@ -218,7 +217,7 @@ namespace Gremlin.Net.Process.Traversal
var args = new List<object>(1 + stepLabels.Length) {stepLabel};
args.AddRange(stepLabels);
- Bytecode.AddStep("as", args.ToArray());
+ GremlinLang.AddStep("as", args.ToArray());
return Wrap<TStart, TEnd>(this);
}
@@ -227,7 +226,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, string?> AsString ()
{
- Bytecode.AddStep("asString");
+ GremlinLang.AddStep("asString");
return Wrap<TStart, string?>(this);
}
@@ -236,7 +235,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TNewEnd?> AsString<TNewEnd> (Scope scope)
{
- Bytecode.AddStep("asString", scope);
+ GremlinLang.AddStep("asString", scope);
return Wrap<TStart, TNewEnd?>(this);
}
@@ -245,7 +244,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, DateTimeOffset> AsDate()
{
- Bytecode.AddStep("asDate");
+ GremlinLang.AddStep("asDate");
return Wrap<TStart, DateTimeOffset>(this);
}
@@ -254,7 +253,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, bool> AsBool()
{
- Bytecode.AddStep("asBool");
+ GremlinLang.AddStep("asBool");
return Wrap<TStart, bool>(this);
}
@@ -263,7 +262,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TEnd> Barrier ()
{
- Bytecode.AddStep("barrier");
+ GremlinLang.AddStep("barrier");
return Wrap<TStart, TEnd>(this);
}
@@ -272,7 +271,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TEnd> Barrier (IConsumer barrierConsumer)
{
- Bytecode.AddStep("barrier", barrierConsumer);
+ GremlinLang.AddStep("barrier", barrierConsumer);
return Wrap<TStart, TEnd>(this);
}
@@ -281,7 +280,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TEnd> Barrier (int maxBarrierSize)
{
- Bytecode.AddStep("barrier", maxBarrierSize);
+ GremlinLang.AddStep("barrier", maxBarrierSize);
return Wrap<TStart, TEnd>(this);
}
@@ -294,7 +293,7 @@ namespace Gremlin.Net.Process.Traversal
var args = new List<object?>(edgeLabels.Length);
args.AddRange(edgeLabels);
- Bytecode.AddStep("both", args.ToArray());
+ GremlinLang.AddStep("both", args.ToArray());
return Wrap<TStart, Vertex>(this);
}
@@ -307,7 +306,7 @@ namespace Gremlin.Net.Process.Traversal
var args = new List<object?>(edgeLabels.Length);
args.AddRange(edgeLabels);
- Bytecode.AddStep("bothE", args.ToArray());
+ GremlinLang.AddStep("bothE", args.ToArray());
return Wrap<TStart, Edge>(this);
}
@@ -316,7 +315,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, Vertex> BothV ()
{
- Bytecode.AddStep("bothV");
+ GremlinLang.AddStep("bothV");
return Wrap<TStart, Vertex>(this);
}
@@ -325,7 +324,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TNewEnd> Branch<TNewEnd> (IFunction? function)
{
- Bytecode.AddStep("branch", function);
+ GremlinLang.AddStep("branch", function);
return Wrap<TStart, TNewEnd>(this);
}
@@ -334,7 +333,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TNewEnd> Branch<TNewEnd> (ITraversal branchTraversal)
{
- Bytecode.AddStep("branch", branchTraversal);
+ GremlinLang.AddStep("branch", branchTraversal);
return Wrap<TStart, TNewEnd>(this);
}
@@ -343,7 +342,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TEnd> By ()
{
- Bytecode.AddStep("by");
+ GremlinLang.AddStep("by");
return Wrap<TStart, TEnd>(this);
}
@@ -352,7 +351,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TEnd> By (IComparator comparator)
{
- Bytecode.AddStep("by", comparator);
+ GremlinLang.AddStep("by", comparator);
return Wrap<TStart, TEnd>(this);
}
@@ -361,7 +360,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TEnd> By (IFunction function)
{
- Bytecode.AddStep("by", function);
+ GremlinLang.AddStep("by", function);
return Wrap<TStart, TEnd>(this);
}
@@ -370,7 +369,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TEnd> By (IFunction function, IComparator comparator)
{
- Bytecode.AddStep("by", function, comparator);
+ GremlinLang.AddStep("by", function, comparator);
return Wrap<TStart, TEnd>(this);
}
@@ -379,7 +378,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TEnd> By (Order order)
{
- Bytecode.AddStep("by", order);
+ GremlinLang.AddStep("by", order);
return Wrap<TStart, TEnd>(this);
}
@@ -388,7 +387,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TEnd> By (string? key)
{
- Bytecode.AddStep("by", key);
+ GremlinLang.AddStep("by", key);
return Wrap<TStart, TEnd>(this);
}
@@ -397,7 +396,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TEnd> By (string? key, IComparator comparator)
{
- Bytecode.AddStep("by", key, comparator);
+ GremlinLang.AddStep("by", key, comparator);
return Wrap<TStart, TEnd>(this);
}
@@ -406,7 +405,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TEnd> By (T token)
{
- Bytecode.AddStep("by", token);
+ GremlinLang.AddStep("by", token);
return Wrap<TStart, TEnd>(this);
}
@@ -415,7 +414,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TEnd> By (ITraversal traversal)
{
- Bytecode.AddStep("by", traversal);
+ GremlinLang.AddStep("by", traversal);
return Wrap<TStart, TEnd>(this);
}
@@ -424,7 +423,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TEnd> By (ITraversal traversal, IComparator comparator)
{
- Bytecode.AddStep("by", traversal, comparator);
+ GremlinLang.AddStep("by", traversal, comparator);
return Wrap<TStart, TEnd>(this);
}
@@ -433,7 +432,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TNewEnd> Call<TNewEnd> (string? service)
{
- Bytecode.AddStep("call", service);
+ GremlinLang.AddStep("call", service);
return Wrap<TStart, TNewEnd>(this);
}
@@ -442,7 +441,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TNewEnd> Call<TNewEnd> (string? service, ITraversal? t)
{
- Bytecode.AddStep("call", service, t);
+ GremlinLang.AddStep("call", service, t);
return Wrap<TStart, TNewEnd>(this);
}
@@ -451,7 +450,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TNewEnd> Call<TNewEnd> (string? service, IDictionary<object,object>? m)
{
- Bytecode.AddStep("call", service, m);
+ GremlinLang.AddStep("call", service, m);
return Wrap<TStart, TNewEnd>(this);
}
@@ -461,7 +460,7 @@ namespace Gremlin.Net.Process.Traversal
public GraphTraversal<TStart, TNewEnd> Call<TNewEnd>(string? service, IDictionary<object, object>? m,
ITraversal? t)
{
- Bytecode.AddStep("call", service, m, t);
+ GremlinLang.AddStep("call", service, m, t);
return Wrap<TStart, TNewEnd>(this);
}
@@ -475,7 +474,7 @@ namespace Gremlin.Net.Process.Traversal
var args = new List<object>(1 + sideEffectKeys.Length) { sideEffectKey };
args.AddRange(sideEffectKeys);
- Bytecode.AddStep("cap", args.ToArray());
+ GremlinLang.AddStep("cap", args.ToArray());
return Wrap<TStart, TNewEnd>(this);
}
@@ -484,7 +483,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TNewEnd> Choose<TNewEnd> (IFunction choiceFunction)
{
- Bytecode.AddStep("choose", choiceFunction);
+ GremlinLang.AddStep("choose", choiceFunction);
return Wrap<TStart, TNewEnd>(this);
}
@@ -493,7 +492,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TNewEnd> Choose<TNewEnd> (IPredicate choosePredicate, ITraversal trueChoice)
{
- Bytecode.AddStep("choose", choosePredicate, trueChoice);
+ GremlinLang.AddStep("choose", choosePredicate, trueChoice);
return Wrap<TStart, TNewEnd>(this);
}
@@ -502,7 +501,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TNewEnd> Choose<TNewEnd> (IPredicate choosePredicate, ITraversal trueChoice, ITraversal falseChoice)
{
- Bytecode.AddStep("choose", choosePredicate, trueChoice, falseChoice);
+ GremlinLang.AddStep("choose", choosePredicate, trueChoice, falseChoice);
return Wrap<TStart, TNewEnd>(this);
}
@@ -511,7 +510,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TNewEnd> Choose<TNewEnd> (ITraversal choiceTraversal)
{
- Bytecode.AddStep("choose", choiceTraversal);
+ GremlinLang.AddStep("choose", choiceTraversal);
return Wrap<TStart, TNewEnd>(this);
}
@@ -520,7 +519,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TNewEnd> Choose<TNewEnd> (ITraversal traversalPredicate, ITraversal trueChoice)
{
- Bytecode.AddStep("choose", traversalPredicate, trueChoice);
+ GremlinLang.AddStep("choose", traversalPredicate, trueChoice);
return Wrap<TStart, TNewEnd>(this);
}
@@ -529,7 +528,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TNewEnd> Choose<TNewEnd> (ITraversal traversalPredicate, ITraversal trueChoice, ITraversal falseChoice)
{
- Bytecode.AddStep("choose", traversalPredicate, trueChoice, falseChoice);
+ GremlinLang.AddStep("choose", traversalPredicate, trueChoice, falseChoice);
return Wrap<TStart, TNewEnd>(this);
}
@@ -542,7 +541,7 @@ namespace Gremlin.Net.Process.Traversal
var args = new List<object>(coalesceTraversals.Length);
args.AddRange(coalesceTraversals);
- Bytecode.AddStep("coalesce", args.ToArray());
+ GremlinLang.AddStep("coalesce", args.ToArray());
return Wrap<TStart, TNewEnd>(this);
}
@@ -551,7 +550,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TEnd> Coin (double probability)
{
- Bytecode.AddStep("coin", probability);
+ GremlinLang.AddStep("coin", probability);
return Wrap<TStart, TEnd>(this);
}
@@ -560,7 +559,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TEnd> Combine (object combineObject)
{
- Bytecode.AddStep("combine", combineObject);
+ GremlinLang.AddStep("combine", combineObject);
return Wrap<TStart, TEnd>(this);
}
@@ -579,7 +578,7 @@ namespace Gremlin.Net.Process.Traversal
args = new List<object?>(1 + otherConcatTraversals.Length) { concatTraversal };
args.AddRange(otherConcatTraversals);
}
- Bytecode.AddStep("concat", args.ToArray());
+ GremlinLang.AddStep("concat", args.ToArray());
return Wrap<TStart, string>(this);
}
@@ -592,7 +591,7 @@ namespace Gremlin.Net.Process.Traversal
var args = new List<object?>(concatStrings.Length);
args.AddRange(concatStrings);
- Bytecode.AddStep("concat", args.ToArray());
+ GremlinLang.AddStep("concat", args.ToArray());
return Wrap<TStart, string>(this);
}
@@ -601,7 +600,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TEnd?> Conjoin (string delimiter)
{
- Bytecode.AddStep("conjoin", delimiter);
+ GremlinLang.AddStep("conjoin", delimiter);
return Wrap<TStart, TEnd?>(this);
}
@@ -610,7 +609,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TEnd> ConnectedComponent ()
{
- Bytecode.AddStep("connectedComponent");
+ GremlinLang.AddStep("connectedComponent");
return Wrap<TStart, TEnd>(this);
}
@@ -619,7 +618,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TNewEnd> Constant<TNewEnd> (TNewEnd e)
{
- Bytecode.AddStep("constant", e);
+ GremlinLang.AddStep("constant", e);
return Wrap<TStart, TNewEnd>(this);
}
@@ -628,7 +627,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, long> Count ()
{
- Bytecode.AddStep("count");
+ GremlinLang.AddStep("count");
return Wrap<TStart, long>(this);
}
@@ -637,7 +636,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, long> Count (Scope scope)
{
- Bytecode.AddStep("count", scope);
+ GremlinLang.AddStep("count", scope);
return Wrap<TStart, long>(this);
}
@@ -646,7 +645,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TEnd> CyclicPath ()
{
- Bytecode.AddStep("cyclicPath");
+ GremlinLang.AddStep("cyclicPath");
return Wrap<TStart, TEnd>(this);
}
@@ -655,7 +654,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, DateTimeOffset> DateAdd(DT dateToken, int value)
{
- Bytecode.AddStep("dateAdd", dateToken, value);
+ GremlinLang.AddStep("dateAdd", dateToken, value);
return Wrap<TStart, DateTimeOffset>(this);
}
@@ -664,7 +663,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, long> DateDiff(DateTimeOffset value)
{
- Bytecode.AddStep("dateDiff", value);
+ GremlinLang.AddStep("dateDiff", value);
return Wrap<TStart, long>(this);
}
@@ -673,7 +672,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, long> DateDiff(ITraversal dateTraversal)
{
- Bytecode.AddStep("dateDiff", dateTraversal);
+ GremlinLang.AddStep("dateDiff", dateTraversal);
return Wrap<TStart, long>(this);
}
@@ -682,7 +681,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, object> AsNumber()
{
- Bytecode.AddStep("asNumber");
+ GremlinLang.AddStep("asNumber");
return Wrap<TStart, object>(this);
}
@@ -691,7 +690,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, object> AsNumber(GType typeToken)
{
- Bytecode.AddStep("asNumber", typeToken);
+ GremlinLang.AddStep("asNumber", typeToken);
return Wrap<TStart, object>(this);
}
@@ -704,7 +703,7 @@ namespace Gremlin.Net.Process.Traversal
var args = new List<object?>(1 + dedupLabels.Length) { scope };
args.AddRange(dedupLabels);
- Bytecode.AddStep("dedup", args.ToArray());
+ GremlinLang.AddStep("dedup", args.ToArray());
return Wrap<TStart, TEnd>(this);
}
@@ -717,7 +716,7 @@ namespace Gremlin.Net.Process.Traversal
var args = new List<object?>(dedupLabels.Length);
args.AddRange(dedupLabels);
- Bytecode.AddStep("dedup", args.ToArray());
+ GremlinLang.AddStep("dedup", args.ToArray());
return Wrap<TStart, TEnd>(this);
}
@@ -726,7 +725,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TEnd> Difference (object differenceObject)
{
- Bytecode.AddStep("difference", differenceObject);
+ GremlinLang.AddStep("difference", differenceObject);
return Wrap<TStart, TEnd>(this);
}
@@ -735,7 +734,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TEnd> Discard ()
{
- Bytecode.AddStep("discard");
+ GremlinLang.AddStep("discard");
return Wrap<TStart, TEnd>(this);
}
@@ -744,7 +743,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TEnd> Disjunct (object disjunctObject)
{
- Bytecode.AddStep("disjunct", disjunctObject);
+ GremlinLang.AddStep("disjunct", disjunctObject);
return Wrap<TStart, TEnd>(this);
}
@@ -753,7 +752,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TEnd> Drop ()
{
- Bytecode.AddStep("drop");
+ GremlinLang.AddStep("drop");
return Wrap<TStart, TEnd>(this);
}
@@ -762,7 +761,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, Element> Element ()
{
- Bytecode.AddStep("element");
+ GremlinLang.AddStep("element");
return Wrap<TStart, Element>(this);
}
@@ -775,7 +774,7 @@ namespace Gremlin.Net.Process.Traversal
var args = new List<object?>(0 + propertyKeys.Length);
args.AddRange(propertyKeys);
- Bytecode.AddStep("elementMap", args.ToArray());
+ GremlinLang.AddStep("elementMap", args.ToArray());
return Wrap<TStart, IDictionary<object, TNewEnd>>(this);
}
@@ -784,7 +783,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TEnd> Emit ()
{
- Bytecode.AddStep("emit");
+ GremlinLang.AddStep("emit");
return Wrap<TStart, TEnd>(this);
}
@@ -793,7 +792,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TEnd> Emit (IPredicate emitPredicate)
{
- Bytecode.AddStep("emit", emitPredicate);
+ GremlinLang.AddStep("emit", emitPredicate);
return Wrap<TStart, TEnd>(this);
}
@@ -802,7 +801,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TEnd> Emit (ITraversal emitTraversal)
{
- Bytecode.AddStep("emit", emitTraversal);
+ GremlinLang.AddStep("emit", emitTraversal);
return Wrap<TStart, TEnd>(this);
}
@@ -811,7 +810,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TEnd> Fail ()
{
- Bytecode.AddStep("fail");
+ GremlinLang.AddStep("fail");
return Wrap<TStart, TEnd>(this);
}
@@ -820,7 +819,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TEnd> Fail (string? msg)
{
- Bytecode.AddStep("fail", msg);
+ GremlinLang.AddStep("fail", msg);
return Wrap<TStart, TEnd>(this);
}
@@ -829,7 +828,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TEnd> Fail (string? msg, IDictionary<string,object> m)
{
- Bytecode.AddStep("fail", msg, m);
+ GremlinLang.AddStep("fail", msg, m);
return Wrap<TStart, TEnd>(this);
}
@@ -838,7 +837,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TEnd> Filter (IPredicate? predicate)
{
- Bytecode.AddStep("filter", predicate);
+ GremlinLang.AddStep("filter", predicate);
return Wrap<TStart, TEnd>(this);
}
@@ -847,7 +846,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TEnd> Filter (ITraversal filterTraversal)
{
- Bytecode.AddStep("filter", filterTraversal);
+ GremlinLang.AddStep("filter", filterTraversal);
return Wrap<TStart, TEnd>(this);
}
@@ -856,7 +855,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TNewEnd> FlatMap<TNewEnd> (IFunction? function)
{
- Bytecode.AddStep("flatMap", function);
+ GremlinLang.AddStep("flatMap", function);
return Wrap<TStart, TNewEnd>(this);
}
@@ -865,7 +864,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TNewEnd> FlatMap<TNewEnd> (ITraversal flatMapTraversal)
{
- Bytecode.AddStep("flatMap", flatMapTraversal);
+ GremlinLang.AddStep("flatMap", flatMapTraversal);
return Wrap<TStart, TNewEnd>(this);
}
@@ -874,7 +873,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, IList<TEnd>> Fold ()
{
- Bytecode.AddStep("fold");
+ GremlinLang.AddStep("fold");
return Wrap<TStart, IList<TEnd>>(this);
}
@@ -883,7 +882,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TNewEnd> Fold<TNewEnd> (TNewEnd seed, IBiFunction? foldFunction)
{
- Bytecode.AddStep("fold", seed, foldFunction);
+ GremlinLang.AddStep("fold", seed, foldFunction);
return Wrap<TStart, TNewEnd>(this);
}
@@ -892,7 +891,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, string> Format(string format)
{
- Bytecode.AddStep("format", format);
+ GremlinLang.AddStep("format", format);
return Wrap<TStart, string>(this);
}
@@ -901,7 +900,8 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TEnd> From (object? fromStepVertexIdOrLabel)
{
- Bytecode.AddStep("from", fromStepVertexIdOrLabel is Vertex vertex ? vertex.Id : fromStepVertexIdOrLabel);
+ var fromId = fromStepVertexIdOrLabel is Vertex fromVertex ? fromVertex.Id : fromStepVertexIdOrLabel;
+ GremlinLang.AddStep("from", fromId);
return Wrap<TStart, TEnd>(this);
}
@@ -910,7 +910,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TEnd> From (string? fromStepLabel)
{
- Bytecode.AddStep("from", fromStepLabel);
+ GremlinLang.AddStep("from", fromStepLabel);
return Wrap<TStart, TEnd>(this);
}
@@ -919,7 +919,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TEnd> From (ITraversal fromVertex)
{
- Bytecode.AddStep("from", fromVertex);
+ GremlinLang.AddStep("from", fromVertex);
return Wrap<TStart, TEnd>(this);
}
@@ -928,7 +928,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TEnd> From (Vertex? fromVertex)
{
- Bytecode.AddStep("from", fromVertex?.Id);
+ GremlinLang.AddStep("from", fromVertex?.Id);
return Wrap<TStart, TEnd>(this);
}
@@ -937,7 +937,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, IDictionary<K, V>> Group<K, V> ()
{
- Bytecode.AddStep("group");
+ GremlinLang.AddStep("group");
return Wrap<TStart, IDictionary<K, V>>(this);
}
@@ -946,7 +946,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TEnd> Group (string sideEffectKey)
{
- Bytecode.AddStep("group", sideEffectKey);
+ GremlinLang.AddStep("group", sideEffectKey);
return Wrap<TStart, TEnd>(this);
}
@@ -955,7 +955,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, IDictionary<K, long>> GroupCount<K> ()
{
- Bytecode.AddStep("groupCount");
+ GremlinLang.AddStep("groupCount");
return Wrap<TStart, IDictionary<K, long>>(this);
}
@@ -964,7 +964,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TEnd> GroupCount (string sideEffectKey)
{
- Bytecode.AddStep("groupCount", sideEffectKey);
+ GremlinLang.AddStep("groupCount", sideEffectKey);
return Wrap<TStart, TEnd>(this);
}
@@ -973,7 +973,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TEnd> Has (string? propertyKey)
{
- Bytecode.AddStep("has", propertyKey);
+ GremlinLang.AddStep("has", propertyKey);
return Wrap<TStart, TEnd>(this);
}
@@ -982,7 +982,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TEnd> Has (string? propertyKey, object? value)
{
- Bytecode.AddStep("has", propertyKey, value);
+ GremlinLang.AddStep("has", propertyKey, value);
return Wrap<TStart, TEnd>(this);
}
@@ -991,7 +991,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TEnd> Has (string? propertyKey, P? predicate)
{
- Bytecode.AddStep("has", propertyKey, predicate);
+ GremlinLang.AddStep("has", propertyKey, predicate);
return Wrap<TStart, TEnd>(this);
}
@@ -1000,7 +1000,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TEnd> Has (string? label, string? propertyKey, object? value)
{
- Bytecode.AddStep("has", label, propertyKey, value);
+ GremlinLang.AddStep("has", label, propertyKey, value);
return Wrap<TStart, TEnd>(this);
}
@@ -1009,7 +1009,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TEnd> Has (string? label, string? propertyKey, P? predicate)
{
- Bytecode.AddStep("has", label, propertyKey, predicate);
+ GremlinLang.AddStep("has", label, propertyKey, predicate);
return Wrap<TStart, TEnd>(this);
}
@@ -1018,7 +1018,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TEnd> Has (T accessor, object? value)
{
- Bytecode.AddStep("has", accessor, value);
+ GremlinLang.AddStep("has", accessor, value);
return Wrap<TStart, TEnd>(this);
}
@@ -1027,7 +1027,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TEnd> Has (T accessor, P? predicate)
{
- Bytecode.AddStep("has", accessor, predicate);
+ GremlinLang.AddStep("has", accessor, predicate);
return Wrap<TStart, TEnd>(this);
}
@@ -1046,7 +1046,7 @@ namespace Gremlin.Net.Process.Traversal
args = new List<object?>(1 + otherIds.Length) { id };
args.AddRange(otherIds);
}
- Bytecode.AddStep("hasId", args.ToArray());
+ GremlinLang.AddStep("hasId", args.ToArray());
return Wrap<TStart, TEnd>(this);
}
@@ -1055,7 +1055,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TEnd> HasId (P? predicate)
{
- Bytecode.AddStep("hasId", predicate);
+ GremlinLang.AddStep("hasId", predicate);
return Wrap<TStart, TEnd>(this);
}
@@ -1064,7 +1064,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TEnd> HasKey (P? predicate)
{
- Bytecode.AddStep("hasKey", predicate);
+ GremlinLang.AddStep("hasKey", predicate);
return Wrap<TStart, TEnd>(this);
}
@@ -1083,7 +1083,7 @@ namespace Gremlin.Net.Process.Traversal
args = new List<object?>(1 + otherLabels.Length) { label };
args.AddRange(otherLabels);
}
- Bytecode.AddStep("hasKey", args.ToArray());
+ GremlinLang.AddStep("hasKey", args.ToArray());
return Wrap<TStart, TEnd>(this);
}
@@ -1092,7 +1092,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TEnd> HasLabel (P? predicate)
{
- Bytecode.AddStep("hasLabel", predicate);
+ GremlinLang.AddStep("hasLabel", predicate);
return Wrap<TStart, TEnd>(this);
}
@@ -1111,7 +1111,7 @@ namespace Gremlin.Net.Process.Traversal
args = new List<object?>(1 + otherLabels.Length) { label };
args.AddRange(otherLabels);
}
- Bytecode.AddStep("hasLabel", args.ToArray());
+ GremlinLang.AddStep("hasLabel", args.ToArray());
return Wrap<TStart, TEnd>(this);
}
@@ -1120,7 +1120,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TEnd> HasNot (string? propertyKey)
{
- Bytecode.AddStep("hasNot", propertyKey);
+ GremlinLang.AddStep("hasNot", propertyKey);
return Wrap<TStart, TEnd>(this);
}
@@ -1139,7 +1139,7 @@ namespace Gremlin.Net.Process.Traversal
args = new List<object?>(1 + otherValues.Length) { value };
args.AddRange(otherValues);
}
- Bytecode.AddStep("hasValue", args.ToArray());
+ GremlinLang.AddStep("hasValue", args.ToArray());
return Wrap<TStart, TEnd>(this);
}
@@ -1148,7 +1148,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TEnd> HasValue (P? predicate)
{
- Bytecode.AddStep("hasValue", predicate);
+ GremlinLang.AddStep("hasValue", predicate);
return Wrap<TStart, TEnd>(this);
}
@@ -1157,7 +1157,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, object> Id ()
{
- Bytecode.AddStep("id");
+ GremlinLang.AddStep("id");
return Wrap<TStart, object>(this);
}
@@ -1166,7 +1166,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TEnd> Identity ()
{
- Bytecode.AddStep("identity");
+ GremlinLang.AddStep("identity");
return Wrap<TStart, TEnd>(this);
}
@@ -1179,7 +1179,7 @@ namespace Gremlin.Net.Process.Traversal
var args = new List<object?>(edgeLabels.Length);
args.AddRange(edgeLabels);
- Bytecode.AddStep("in", args.ToArray());
+ GremlinLang.AddStep("in", args.ToArray());
return Wrap<TStart, Vertex>(this);
}
@@ -1192,7 +1192,7 @@ namespace Gremlin.Net.Process.Traversal
var args = new List<object?>(edgeLabels.Length);
args.AddRange(edgeLabels);
- Bytecode.AddStep("inE", args.ToArray());
+ GremlinLang.AddStep("inE", args.ToArray());
return Wrap<TStart, Edge>(this);
}
@@ -1201,7 +1201,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, Vertex> InV ()
{
- Bytecode.AddStep("inV");
+ GremlinLang.AddStep("inV");
return Wrap<TStart, Vertex>(this);
}
@@ -1210,7 +1210,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TNewEnd> Index<TNewEnd> ()
{
- Bytecode.AddStep("index");
+ GremlinLang.AddStep("index");
return Wrap<TStart, TNewEnd>(this);
}
@@ -1222,13 +1222,13 @@ namespace Gremlin.Net.Process.Traversal
// null injections is treated as g.inject(null) meaning inject a single null traverser
if (injections == null)
{
- Bytecode.AddStep("inject", new object?[] { null });
+ GremlinLang.AddStep("inject", new object?[] { null });
}
else
{
var args = new List<object?>(injections.Length);
args.AddRange(injections.Cast<object?>());
- Bytecode.AddStep("inject", args.ToArray());
+ GremlinLang.AddStep("inject", args.ToArray());
}
return Wrap<TStart, TEnd>(this);
@@ -1239,7 +1239,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TEnd> Intersect (object intersectObject)
{
- Bytecode.AddStep("intersect", intersectObject);
+ GremlinLang.AddStep("intersect", intersectObject);
return Wrap<TStart, TEnd>(this);
}
@@ -1248,7 +1248,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TEnd> Is (object? value)
{
- Bytecode.AddStep("is", value);
+ GremlinLang.AddStep("is", value);
return Wrap<TStart, TEnd>(this);
}
@@ -1257,7 +1257,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TEnd> Is (P? predicate)
{
- Bytecode.AddStep("is", predicate);
+ GremlinLang.AddStep("is", predicate);
return Wrap<TStart, TEnd>(this);
}
@@ -1266,7 +1266,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, string> Key ()
{
- Bytecode.AddStep("key");
+ GremlinLang.AddStep("key");
return Wrap<TStart, string>(this);
}
@@ -1275,7 +1275,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, string> Label ()
{
- Bytecode.AddStep("label");
+ GremlinLang.AddStep("label");
return Wrap<TStart, string>(this);
}
@@ -1284,7 +1284,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, int?> Length ()
{
- Bytecode.AddStep("length");
+ GremlinLang.AddStep("length");
return Wrap<TStart, int?>(this);
}
@@ -1293,7 +1293,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TNewEnd?> Length<TNewEnd> (Scope scope)
{
- Bytecode.AddStep("length", scope);
+ GremlinLang.AddStep("length", scope);
return Wrap<TStart, TNewEnd?>(this);
}
@@ -1302,7 +1302,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TNewEnd> Limit<TNewEnd> (Scope scope, long limit)
{
- Bytecode.AddStep("limit", scope, limit);
+ GremlinLang.AddStep("limit", scope, limit);
return Wrap<TStart, TNewEnd>(this);
}
@@ -1311,7 +1311,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TNewEnd> Limit<TNewEnd> (long limit)
{
- Bytecode.AddStep("limit", limit);
+ GremlinLang.AddStep("limit", limit);
return Wrap<TStart, TNewEnd>(this);
}
@@ -1320,7 +1320,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TNewEnd> Local<TNewEnd> (ITraversal localTraversal)
{
- Bytecode.AddStep("local", localTraversal);
+ GremlinLang.AddStep("local", localTraversal);
return Wrap<TStart, TNewEnd>(this);
}
@@ -1329,7 +1329,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, int> Loops ()
{
- Bytecode.AddStep("loops");
+ GremlinLang.AddStep("loops");
return Wrap<TStart, int>(this);
}
@@ -1338,7 +1338,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, int> Loops (string? loopName)
{
- Bytecode.AddStep("loops", loopName);
+ GremlinLang.AddStep("loops", loopName);
return Wrap<TStart, int>(this);
}
@@ -1347,7 +1347,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, string?> LTrim ()
{
- Bytecode.AddStep("lTrim");
+ GremlinLang.AddStep("lTrim");
return Wrap<TStart, string?>(this);
}
@@ -1356,7 +1356,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TNewEnd?> LTrim<TNewEnd> (Scope scope)
{
- Bytecode.AddStep("lTrim", scope);
+ GremlinLang.AddStep("lTrim", scope);
return Wrap<TStart, TNewEnd?>(this);
}
@@ -1365,7 +1365,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TNewEnd> Map<TNewEnd> (IFunction? function)
{
- Bytecode.AddStep("map", function);
+ GremlinLang.AddStep("map", function);
return Wrap<TStart, TNewEnd>(this);
}
@@ -1374,7 +1374,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TNewEnd> Map<TNewEnd> (ITraversal mapTraversal)
{
- Bytecode.AddStep("map", mapTraversal);
+ GremlinLang.AddStep("map", mapTraversal);
return Wrap<TStart, TNewEnd>(this);
}
@@ -1387,7 +1387,7 @@ namespace Gremlin.Net.Process.Traversal
var args = new List<object>(matchTraversals.Length);
args.AddRange(matchTraversals);
- Bytecode.AddStep("match", args.ToArray());
+ GremlinLang.AddStep("match", args.ToArray());
return Wrap<TStart, IDictionary<string, TNewEnd>>(this);
}
@@ -1396,7 +1396,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, double> Math (string expression)
{
- Bytecode.AddStep("math", expression);
+ GremlinLang.AddStep("math", expression);
return Wrap<TStart, double>(this);
}
@@ -1405,7 +1405,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TNewEnd> Max<TNewEnd> ()
{
- Bytecode.AddStep("max");
+ GremlinLang.AddStep("max");
return Wrap<TStart, TNewEnd>(this);
}
@@ -1414,7 +1414,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TNewEnd> Max<TNewEnd> (Scope scope)
{
- Bytecode.AddStep("max", scope);
+ GremlinLang.AddStep("max", scope);
return Wrap<TStart, TNewEnd>(this);
}
@@ -1423,7 +1423,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TNewEnd> Mean<TNewEnd> ()
{
- Bytecode.AddStep("mean");
+ GremlinLang.AddStep("mean");
return Wrap<TStart, TNewEnd>(this);
}
@@ -1432,7 +1432,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TNewEnd> Mean<TNewEnd> (Scope scope)
{
- Bytecode.AddStep("mean", scope);
+ GremlinLang.AddStep("mean", scope);
return Wrap<TStart, TNewEnd>(this);
}
@@ -1441,7 +1441,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TEnd> Merge (object mergeObject)
{
- Bytecode.AddStep("merge", mergeObject);
+ GremlinLang.AddStep("merge", mergeObject);
return Wrap<TStart, TEnd>(this);
}
@@ -1450,7 +1450,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, Edge> MergeE ()
{
- Bytecode.AddStep("mergeE");
+ GremlinLang.AddStep("mergeE");
return Wrap<TStart, Edge>(this);
}
@@ -1465,7 +1465,7 @@ namespace Gremlin.Net.Process.Traversal
if (m != null && m[Direction.In] is Vertex inV) {
m[Direction.In] = inV.Id;
}
- Bytecode.AddStep("mergeE", m);
+ GremlinLang.AddStep("mergeE", m);
return Wrap<TStart, Edge>(this);
}
@@ -1474,7 +1474,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, Edge> MergeE (ITraversal? t)
{
- Bytecode.AddStep("mergeE", t);
+ GremlinLang.AddStep("mergeE", t);
return Wrap<TStart, Edge>(this);
}
@@ -1483,7 +1483,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, Vertex> MergeV ()
{
- Bytecode.AddStep("mergeV");
+ GremlinLang.AddStep("mergeV");
return Wrap<TStart, Vertex>(this);
}
@@ -1492,7 +1492,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, Vertex> MergeV (IDictionary<object,object>? m)
{
- Bytecode.AddStep("mergeV", m);
+ GremlinLang.AddStep("mergeV", m);
return Wrap<TStart, Vertex>(this);
}
@@ -1501,7 +1501,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, Vertex> MergeV (ITraversal? t)
{
- Bytecode.AddStep("mergeV", t);
+ GremlinLang.AddStep("mergeV", t);
return Wrap<TStart, Vertex>(this);
}
@@ -1510,7 +1510,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TNewEnd> Min<TNewEnd> ()
{
- Bytecode.AddStep("min");
+ GremlinLang.AddStep("min");
return Wrap<TStart, TNewEnd>(this);
}
@@ -1519,7 +1519,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TNewEnd> Min<TNewEnd> (Scope scope)
{
- Bytecode.AddStep("min", scope);
+ GremlinLang.AddStep("min", scope);
return Wrap<TStart, TNewEnd>(this);
}
@@ -1528,7 +1528,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TEnd> None (P? predicate)
{
- Bytecode.AddStep("none", predicate);
+ GremlinLang.AddStep("none", predicate);
return Wrap<TStart, TEnd>(this);
}
@@ -1537,7 +1537,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TEnd> Not (ITraversal notTraversal)
{
- Bytecode.AddStep("not", notTraversal);
+ GremlinLang.AddStep("not", notTraversal);
return Wrap<TStart, TEnd>(this);
}
@@ -1546,7 +1546,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TEnd> Option (object pickToken, ITraversal? traversalOption)
{
- Bytecode.AddStep("option", pickToken, traversalOption);
+ GremlinLang.AddStep("option", pickToken, traversalOption);
return Wrap<TStart, TEnd>(this);
}
@@ -1555,7 +1555,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TEnd> Option (object pickToken, IDictionary<object,object>? traversalOption)
{
- Bytecode.AddStep("option", pickToken, traversalOption);
+ GremlinLang.AddStep("option", pickToken, traversalOption);
return Wrap<TStart, TEnd>(this);
}
@@ -1564,7 +1564,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TEnd> Option (object pickToken, IDictionary<object,object> traversalOption, Cardinality cardinality)
{
- Bytecode.AddStep("option", pickToken, traversalOption, cardinality);
+ GremlinLang.AddStep("option", pickToken, traversalOption, cardinality);
return Wrap<TStart, TEnd>(this);
}
@@ -1573,7 +1573,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TEnd> Option (ITraversal? traversalOption)
{
- Bytecode.AddStep("option", traversalOption);
+ GremlinLang.AddStep("option", traversalOption);
return Wrap<TStart, TEnd>(this);
}
@@ -1582,7 +1582,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TNewEnd> Optional<TNewEnd> (ITraversal optionalTraversal)
{
- Bytecode.AddStep("optional", optionalTraversal);
+ GremlinLang.AddStep("optional", optionalTraversal);
return Wrap<TStart, TNewEnd>(this);
}
@@ -1595,7 +1595,7 @@ namespace Gremlin.Net.Process.Traversal
var args = new List<object>(orTraversals.Length);
args.AddRange(orTraversals);
- Bytecode.AddStep("or", args.ToArray());
+ GremlinLang.AddStep("or", args.ToArray());
return Wrap<TStart, TEnd>(this);
}
@@ -1604,7 +1604,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TEnd> Order ()
{
- Bytecode.AddStep("order");
+ GremlinLang.AddStep("order");
return Wrap<TStart, TEnd>(this);
}
@@ -1613,7 +1613,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TEnd> Order (Scope scope)
{
- Bytecode.AddStep("order", scope);
+ GremlinLang.AddStep("order", scope);
return Wrap<TStart, TEnd>(this);
}
@@ -1622,7 +1622,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, Vertex> OtherV ()
{
- Bytecode.AddStep("otherV");
+ GremlinLang.AddStep("otherV");
return Wrap<TStart, Vertex>(this);
}
@@ -1635,7 +1635,7 @@ namespace Gremlin.Net.Process.Traversal
var args = new List<object?>(edgeLabels.Length);
args.AddRange(edgeLabels);
- Bytecode.AddStep("out", args.ToArray());
+ GremlinLang.AddStep("out", args.ToArray());
return Wrap<TStart, Vertex>(this);
}
@@ -1648,7 +1648,7 @@ namespace Gremlin.Net.Process.Traversal
var args = new List<object?>(edgeLabels.Length);
args.AddRange(edgeLabels);
- Bytecode.AddStep("outE", args.ToArray());
+ GremlinLang.AddStep("outE", args.ToArray());
return Wrap<TStart, Edge>(this);
}
@@ -1657,7 +1657,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, Vertex> OutV ()
{
- Bytecode.AddStep("outV");
+ GremlinLang.AddStep("outV");
return Wrap<TStart, Vertex>(this);
}
@@ -1666,7 +1666,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TEnd> PageRank ()
{
- Bytecode.AddStep("pageRank");
+ GremlinLang.AddStep("pageRank");
return Wrap<TStart, TEnd>(this);
}
@@ -1675,7 +1675,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TEnd> PageRank (double alpha)
{
- Bytecode.AddStep("pageRank", alpha);
+ GremlinLang.AddStep("pageRank", alpha);
return Wrap<TStart, TEnd>(this);
}
@@ -1684,7 +1684,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, Path> Path ()
{
- Bytecode.AddStep("path");
+ GremlinLang.AddStep("path");
return Wrap<TStart, Path>(this);
}
@@ -1693,7 +1693,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TEnd> PeerPressure ()
{
- Bytecode.AddStep("peerPressure");
+ GremlinLang.AddStep("peerPressure");
return Wrap<TStart, TEnd>(this);
}
@@ -1702,7 +1702,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TEnd> Product (object productObject)
{
- Bytecode.AddStep("product", productObject);
+ GremlinLang.AddStep("product", productObject);
return Wrap<TStart, TEnd>(this);
}
@@ -1711,7 +1711,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TNewEnd> Profile<TNewEnd> ()
{
- Bytecode.AddStep("profile");
+ GremlinLang.AddStep("profile");
return Wrap<TStart, TNewEnd>(this);
}
@@ -1720,7 +1720,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TEnd> Profile (string sideEffectKey)
{
- Bytecode.AddStep("profile", sideEffectKey);
+ GremlinLang.AddStep("profile", sideEffectKey);
return Wrap<TStart, TEnd>(this);
}
@@ -1729,7 +1729,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TEnd> Program (object vertexProgram)
{
- Bytecode.AddStep("program", vertexProgram);
+ GremlinLang.AddStep("program", vertexProgram);
return Wrap<TStart, TEnd>(this);
}
@@ -1746,7 +1746,7 @@ namespace Gremlin.Net.Process.Traversal
var args = new List<object?>(1 + otherProjectKeys.Length) { projectKey };
args.AddRange(otherProjectKeys);
- Bytecode.AddStep("project", args.ToArray());
+ GremlinLang.AddStep("project", args.ToArray());
return Wrap<TStart, IDictionary<string, TNewEnd>>(this);
}
@@ -1761,7 +1761,7 @@ namespace Gremlin.Net.Process.Traversal
var args = new List<object?>(propertyKeys.Length);
args.AddRange(propertyKeys);
- Bytecode.AddStep("properties", args.ToArray());
+ GremlinLang.AddStep("properties", args.ToArray());
return Wrap<TStart, TNewEnd>(this);
}
@@ -1775,7 +1775,7 @@ namespace Gremlin.Net.Process.Traversal
var args = new List<object?>(3 + keyValues.Length) { cardinality, key, value };
args.AddRange(keyValues);
- Bytecode.AddStep("property", args.ToArray());
+ GremlinLang.AddStep("property", args.ToArray());
return Wrap<TStart, TEnd>(this);
}
@@ -1788,7 +1788,7 @@ namespace Gremlin.Net.Process.Traversal
var args = new List<object?>(2 + keyValues.Length) { key, value };
args.AddRange(keyValues);
- Bytecode.AddStep("property", args.ToArray());
+ GremlinLang.AddStep("property", args.ToArray());
return Wrap<TStart, TEnd>(this);
}
@@ -1797,7 +1797,31 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TEnd> Property (IDictionary<object, object> map)
{
- Bytecode.AddStep("property", map);
+ GremlinLang.AddStep("property", map);
+ return Wrap<TStart, TEnd>(this);
+ }
+
+ /// <summary>
+ /// Adds the property step to this <see cref="GraphTraversal{SType, EType}" />.
+ /// When a <see cref="IDictionary{TKey, TValue}" /> is supplied, each key/value pair in the map
+ /// will be added as a property with the given <see cref="Cardinality" />.
+ /// A value may be a <see cref="CardinalityValue" /> to override the cardinality for that entry.
+ /// </summary>
+ public GraphTraversal<TStart, TEnd> Property(Cardinality cardinality, IDictionary<object, object> map)
+ {
+ if (map == null) throw new ArgumentNullException(nameof(map));
+
+ foreach (var entry in map)
+ {
+ if (entry.Value is CardinalityValue cardVal)
+ {
+ Property(cardVal.Cardinality!, entry.Key, cardVal.Value);
+ }
+ else
+ {
+ Property(cardinality, entry.Key, entry.Value);
+ }
+ }
return Wrap<TStart, TEnd>(this);
}
@@ -1811,7 +1835,7 @@ namespace Gremlin.Net.Process.Traversal
var args = new List<object?>(propertyKeys.Length);
args.AddRange(propertyKeys);
- Bytecode.AddStep("propertyMap", args.ToArray());
+ GremlinLang.AddStep("propertyMap", args.ToArray());
return Wrap<TStart, IDictionary<string, TNewEnd>>(this);
}
@@ -1820,7 +1844,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TNewEnd> Range<TNewEnd> (Scope scope, long low, long high)
{
- Bytecode.AddStep("range", scope, low, high);
+ GremlinLang.AddStep("range", scope, low, high);
return Wrap<TStart, TNewEnd>(this);
}
@@ -1829,7 +1853,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TNewEnd> Range<TNewEnd> (long low, long high)
{
- Bytecode.AddStep("range", low, high);
+ GremlinLang.AddStep("range", low, high);
return Wrap<TStart, TNewEnd>(this);
}
@@ -1838,7 +1862,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TEnd> Read ()
{
- Bytecode.AddStep("read");
+ GremlinLang.AddStep("read");
return Wrap<TStart, TEnd>(this);
}
@@ -1847,7 +1871,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TEnd> Repeat (string loopName, ITraversal repeatTraversal)
{
- Bytecode.AddStep("repeat", loopName, repeatTraversal);
+ GremlinLang.AddStep("repeat", loopName, repeatTraversal);
return Wrap<TStart, TEnd>(this);
}
@@ -1856,7 +1880,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TEnd> Repeat (ITraversal repeatTraversal)
{
- Bytecode.AddStep("repeat", repeatTraversal);
+ GremlinLang.AddStep("repeat", repeatTraversal);
return Wrap<TStart, TEnd>(this);
}
@@ -1865,7 +1889,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, string?> Replace (string? oldChar, string? newChar)
{
- Bytecode.AddStep("replace", oldChar, newChar);
+ GremlinLang.AddStep("replace", oldChar, newChar);
return Wrap<TStart, string?>(this);
}
@@ -1874,7 +1898,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TNewEnd?> Replace<TNewEnd> (Scope scope, string? oldChar, string? newChar)
{
- Bytecode.AddStep("replace", scope, oldChar, newChar);
+ GremlinLang.AddStep("replace", scope, oldChar, newChar);
return Wrap<TStart, TNewEnd?>(this);
}
@@ -1883,7 +1907,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TEnd> Reverse ()
{
- Bytecode.AddStep("reverse");
+ GremlinLang.AddStep("reverse");
return Wrap<TStart, TEnd>(this);
}
@@ -1892,7 +1916,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, string?> RTrim ()
{
- Bytecode.AddStep("rTrim");
+ GremlinLang.AddStep("rTrim");
return Wrap<TStart, string?>(this);
}
@@ -1901,7 +1925,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TNewEnd?> RTrim<TNewEnd> (Scope scope)
{
- Bytecode.AddStep("rTrim", scope);
+ GremlinLang.AddStep("rTrim", scope);
return Wrap<TStart, TNewEnd?>(this);
}
@@ -1910,7 +1934,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TNewEnd> Sack<TNewEnd> ()
{
- Bytecode.AddStep("sack");
+ GremlinLang.AddStep("sack");
return Wrap<TStart, TNewEnd>(this);
}
@@ -1919,7 +1943,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TEnd> Sack (IBiFunction sackOperator)
{
- Bytecode.AddStep("sack", sackOperator);
+ GremlinLang.AddStep("sack", sackOperator);
return Wrap<TStart, TEnd>(this);
}
@@ -1928,7 +1952,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TEnd> Sample (Scope scope, int amountToSample)
{
- Bytecode.AddStep("sample", scope, amountToSample);
+ GremlinLang.AddStep("sample", scope, amountToSample);
return Wrap<TStart, TEnd>(this);
}
@@ -1937,7 +1961,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TEnd> Sample (int amountToSample)
{
- Bytecode.AddStep("sample", amountToSample);
+ GremlinLang.AddStep("sample", amountToSample);
return Wrap<TStart, TEnd>(this);
}
@@ -1946,7 +1970,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, ICollection<TNewEnd>> Select<TNewEnd> (Column column)
{
- Bytecode.AddStep("select", column);
+ GremlinLang.AddStep("select", column);
return Wrap<TStart, ICollection<TNewEnd>>(this);
}
@@ -1955,7 +1979,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TNewEnd> Select<TNewEnd> (Pop pop, string? selectKey)
{
- Bytecode.AddStep("select", pop, selectKey);
+ GremlinLang.AddStep("select", pop, selectKey);
return Wrap<TStart, TNewEnd>(this);
}
@@ -1969,7 +1993,7 @@ namespace Gremlin.Net.Process.Traversal
var args = new List<object?>(3 + otherSelectKeys.Length) { pop, selectKey1, selectKey2 };
args.AddRange(otherSelectKeys);
- Bytecode.AddStep("select", args.ToArray());
+ GremlinLang.AddStep("select", args.ToArray());
return Wrap<TStart, IDictionary<string, TNewEnd>>(this);
}
@@ -1978,7 +2002,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TNewEnd> Select<TNewEnd> (Pop pop, ITraversal keyTraversal)
{
- Bytecode.AddStep("select", pop, keyTraversal);
+ GremlinLang.AddStep("select", pop, keyTraversal);
return Wrap<TStart, TNewEnd>(this);
}
@@ -1987,7 +2011,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TNewEnd> Select<TNewEnd> (string? selectKey)
{
- Bytecode.AddStep("select", selectKey);
+ GremlinLang.AddStep("select", selectKey);
return Wrap<TStart, TNewEnd>(this);
}
@@ -2001,7 +2025,7 @@ namespace Gremlin.Net.Process.Traversal
var args = new List<object?>(2 + otherSelectKeys.Length) { selectKey1, selectKey2 };
args.AddRange(otherSelectKeys);
- Bytecode.AddStep("select", args.ToArray());
+ GremlinLang.AddStep("select", args.ToArray());
return Wrap<TStart, IDictionary<string, TNewEnd>>(this);
}
@@ -2010,7 +2034,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TNewEnd> Select<TNewEnd> (ITraversal keyTraversal)
{
- Bytecode.AddStep("select", keyTraversal);
+ GremlinLang.AddStep("select", keyTraversal);
return Wrap<TStart, TNewEnd>(this);
}
@@ -2019,7 +2043,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, Path> ShortestPath ()
{
- Bytecode.AddStep("shortestPath");
+ GremlinLang.AddStep("shortestPath");
return Wrap<TStart, Path>(this);
}
@@ -2028,7 +2052,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TEnd> SideEffect (IConsumer? consumer)
{
- Bytecode.AddStep("sideEffect", consumer);
+ GremlinLang.AddStep("sideEffect", consumer);
return Wrap<TStart, TEnd>(this);
}
@@ -2037,7 +2061,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TEnd> SideEffect (ITraversal sideEffectTraversal)
{
- Bytecode.AddStep("sideEffect", sideEffectTraversal);
+ GremlinLang.AddStep("sideEffect", sideEffectTraversal);
return Wrap<TStart, TEnd>(this);
}
@@ -2046,7 +2070,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TEnd> SimplePath ()
{
- Bytecode.AddStep("simplePath");
+ GremlinLang.AddStep("simplePath");
return Wrap<TStart, TEnd>(this);
}
@@ -2055,7 +2079,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TNewEnd> Skip<TNewEnd> (Scope scope, long skip)
{
- Bytecode.AddStep("skip", scope, skip);
+ GremlinLang.AddStep("skip", scope, skip);
return Wrap<TStart, TNewEnd>(this);
}
@@ -2064,7 +2088,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TNewEnd> Skip<TNewEnd> (long skip)
{
- Bytecode.AddStep("skip", skip);
+ GremlinLang.AddStep("skip", skip);
return Wrap<TStart, TNewEnd>(this);
}
@@ -2073,7 +2097,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, List<string>?> Split (string? splitChar)
{
- Bytecode.AddStep("split", splitChar);
+ GremlinLang.AddStep("split", splitChar);
return Wrap<TStart, List<string>?>(this);
}
@@ -2082,7 +2106,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, List<TNewEnd>?> Split<TNewEnd> (Scope scope, string? splitChar)
{
- Bytecode.AddStep("split", scope, splitChar);
+ GremlinLang.AddStep("split", scope, splitChar);
return Wrap<TStart, List<TNewEnd>?>(this);
}
@@ -2091,7 +2115,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, Edge> Subgraph (string sideEffectKey)
{
- Bytecode.AddStep("subgraph", sideEffectKey);
+ GremlinLang.AddStep("subgraph", sideEffectKey);
return Wrap<TStart, Edge>(this);
}
@@ -2100,7 +2124,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, string?> Substring (int startIndex)
{
- Bytecode.AddStep("substring", startIndex);
+ GremlinLang.AddStep("substring", startIndex);
return Wrap<TStart, string?>(this);
}
@@ -2109,7 +2133,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TNewEnd?> Substring<TNewEnd> (Scope scope, int startIndex)
{
- Bytecode.AddStep("substring", scope, startIndex);
+ GremlinLang.AddStep("substring", scope, startIndex);
return Wrap<TStart, TNewEnd?>(this);
}
@@ -2118,7 +2142,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, string?> Substring (int startIndex, int endIndex)
{
- Bytecode.AddStep("substring", startIndex, endIndex);
+ GremlinLang.AddStep("substring", startIndex, endIndex);
return Wrap<TStart, string?>(this);
}
@@ -2127,7 +2151,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TNewEnd?> Substring<TNewEnd> (Scope scope, int startIndex, int endIndex)
{
- Bytecode.AddStep("substring", scope, startIndex, endIndex);
+ GremlinLang.AddStep("substring", scope, startIndex, endIndex);
return Wrap<TStart, TNewEnd?>(this);
}
@@ -2136,7 +2160,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TNewEnd> Sum<TNewEnd> ()
{
- Bytecode.AddStep("sum");
+ GremlinLang.AddStep("sum");
return Wrap<TStart, TNewEnd>(this);
}
@@ -2145,7 +2169,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TNewEnd> Sum<TNewEnd> (Scope scope)
{
- Bytecode.AddStep("sum", scope);
+ GremlinLang.AddStep("sum", scope);
return Wrap<TStart, TNewEnd>(this);
}
@@ -2154,7 +2178,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TNewEnd> Tail<TNewEnd> ()
{
- Bytecode.AddStep("tail");
+ GremlinLang.AddStep("tail");
return Wrap<TStart, TNewEnd>(this);
}
@@ -2163,7 +2187,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TNewEnd> Tail<TNewEnd> (Scope scope)
{
- Bytecode.AddStep("tail", scope);
+ GremlinLang.AddStep("tail", scope);
return Wrap<TStart, TNewEnd>(this);
}
@@ -2172,7 +2196,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TNewEnd> Tail<TNewEnd> (Scope scope, long limit)
{
- Bytecode.AddStep("tail", scope, limit);
+ GremlinLang.AddStep("tail", scope, limit);
return Wrap<TStart, TNewEnd>(this);
}
@@ -2181,7 +2205,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TNewEnd> Tail<TNewEnd> (long limit)
{
- Bytecode.AddStep("tail", limit);
+ GremlinLang.AddStep("tail", limit);
return Wrap<TStart, TNewEnd>(this);
}
@@ -2190,7 +2214,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TEnd> TimeLimit (long timeLimit)
{
- Bytecode.AddStep("timeLimit", timeLimit);
+ GremlinLang.AddStep("timeLimit", timeLimit);
return Wrap<TStart, TEnd>(this);
}
@@ -2199,7 +2223,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TEnd> Times (int maxLoops)
{
- Bytecode.AddStep("times", maxLoops);
+ GremlinLang.AddStep("times", maxLoops);
return Wrap<TStart, TEnd>(this);
}
@@ -2212,7 +2236,7 @@ namespace Gremlin.Net.Process.Traversal
var args = new List<object?>(1 + edgeLabels.Length) { direction };
args.AddRange(edgeLabels);
- Bytecode.AddStep("to", args.ToArray());
+ GremlinLang.AddStep("to", args.ToArray());
return Wrap<TStart, Vertex>(this);
}
@@ -2221,7 +2245,8 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TEnd> To (object? toStepVertexIdOrLabel)
{
- Bytecode.AddStep("to", toStepVertexIdOrLabel is Vertex vertex ? vertex.Id : toStepVertexIdOrLabel );
+ var toId = toStepVertexIdOrLabel is Vertex toVertex ? toVertex.Id : toStepVertexIdOrLabel;
+ GremlinLang.AddStep("to", toId);
return Wrap<TStart, TEnd>(this);
}
@@ -2230,7 +2255,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TEnd> To (string? toStepLabel)
{
- Bytecode.AddStep("to", toStepLabel);
+ GremlinLang.AddStep("to", toStepLabel);
return Wrap<TStart, TEnd>(this);
}
@@ -2239,7 +2264,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TEnd> To (ITraversal toVertex)
{
- Bytecode.AddStep("to", toVertex);
+ GremlinLang.AddStep("to", toVertex);
return Wrap<TStart, TEnd>(this);
}
@@ -2248,7 +2273,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TEnd> To (Vertex? toVertex)
{
- Bytecode.AddStep("to", toVertex?.Id);
+ GremlinLang.AddStep("to", toVertex?.Id);
return Wrap<TStart, TEnd>(this);
}
@@ -2261,7 +2286,7 @@ namespace Gremlin.Net.Process.Traversal
var args = new List<object?>(1 + edgeLabels.Length) {direction};
args.AddRange(edgeLabels);
- Bytecode.AddStep("toE", args.ToArray());
+ GremlinLang.AddStep("toE", args.ToArray());
return Wrap<TStart, Edge>(this);
}
@@ -2270,7 +2295,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, string?> ToLower ()
{
- Bytecode.AddStep("toLower");
+ GremlinLang.AddStep("toLower");
return Wrap<TStart, string?>(this);
}
@@ -2279,7 +2304,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TNewEnd?> ToLower<TNewEnd> (Scope scope)
{
- Bytecode.AddStep("toLower", scope);
+ GremlinLang.AddStep("toLower", scope);
return Wrap<TStart, TNewEnd?>(this);
}
@@ -2288,7 +2313,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, string?> ToUpper ()
{
- Bytecode.AddStep("toUpper");
+ GremlinLang.AddStep("toUpper");
return Wrap<TStart, string?>(this);
}
@@ -2297,7 +2322,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TNewEnd?> ToUpper<TNewEnd> (Scope scope)
{
- Bytecode.AddStep("toUpper", scope);
+ GremlinLang.AddStep("toUpper", scope);
return Wrap<TStart, TNewEnd?>(this);
}
@@ -2306,7 +2331,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, Vertex> ToV (Direction? direction)
{
- Bytecode.AddStep("toV", direction);
+ GremlinLang.AddStep("toV", direction);
return Wrap<TStart, Vertex>(this);
}
@@ -2315,7 +2340,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TNewEnd> Tree<TNewEnd> ()
{
- Bytecode.AddStep("tree");
+ GremlinLang.AddStep("tree");
return Wrap<TStart, TNewEnd>(this);
}
@@ -2324,7 +2349,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TEnd> Tree (string sideEffectKey)
{
- Bytecode.AddStep("tree", sideEffectKey);
+ GremlinLang.AddStep("tree", sideEffectKey);
return Wrap<TStart, TEnd>(this);
}
@@ -2333,7 +2358,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, string?> Trim ()
{
- Bytecode.AddStep("trim");
+ GremlinLang.AddStep("trim");
return Wrap<TStart, string?>(this);
}
@@ -2342,7 +2367,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TNewEnd?> Trim<TNewEnd> (Scope scope)
{
- Bytecode.AddStep("trim", scope);
+ GremlinLang.AddStep("trim", scope);
return Wrap<TStart, TNewEnd?>(this);
}
@@ -2351,7 +2376,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TNewEnd> Unfold<TNewEnd> ()
{
- Bytecode.AddStep("unfold");
+ GremlinLang.AddStep("unfold");
return Wrap<TStart, TNewEnd>(this);
}
@@ -2364,7 +2389,7 @@ namespace Gremlin.Net.Process.Traversal
var args = new List<object>(unionTraversals.Length);
args.AddRange(unionTraversals);
- Bytecode.AddStep("union", args.ToArray());
+ GremlinLang.AddStep("union", args.ToArray());
return Wrap<TStart, TNewEnd>(this);
}
@@ -2373,7 +2398,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TEnd> Until (IPredicate untilPredicate)
{
- Bytecode.AddStep("until", untilPredicate);
+ GremlinLang.AddStep("until", untilPredicate);
return Wrap<TStart, TEnd>(this);
}
@@ -2382,7 +2407,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TEnd> Until (ITraversal untilTraversal)
{
- Bytecode.AddStep("until", untilTraversal);
+ GremlinLang.AddStep("until", untilTraversal);
return Wrap<TStart, TEnd>(this);
}
@@ -2391,7 +2416,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TNewEnd> Value<TNewEnd> ()
{
- Bytecode.AddStep("value");
+ GremlinLang.AddStep("value");
return Wrap<TStart, TNewEnd>(this);
}
@@ -2404,7 +2429,7 @@ namespace Gremlin.Net.Process.Traversal
var args = new List<object?>(propertyKeys.Length);
args.AddRange(propertyKeys);
- Bytecode.AddStep("valueMap", args.ToArray());
+ GremlinLang.AddStep("valueMap", args.ToArray());
return Wrap<TStart, IDictionary<TKey, TValue>>(this);
}
@@ -2418,7 +2443,7 @@ namespace Gremlin.Net.Process.Traversal
var args = new List<object?>(1 + propertyKeys.Length) { includeTokens };
args.AddRange(propertyKeys);
- Bytecode.AddStep("valueMap", args.ToArray());
+ GremlinLang.AddStep("valueMap", args.ToArray());
return Wrap<TStart, IDictionary<TKey, TValue>>(this);
}
@@ -2431,7 +2456,7 @@ namespace Gremlin.Net.Process.Traversal
var args = new List<object?>(propertyKeys.Length);
args.AddRange(propertyKeys);
- Bytecode.AddStep("values", args.ToArray());
+ GremlinLang.AddStep("values", args.ToArray());
return Wrap<TStart, TNewEnd>(this);
}
@@ -2440,7 +2465,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TEnd> Where (P predicate)
{
- Bytecode.AddStep("where", predicate);
+ GremlinLang.AddStep("where", predicate);
return Wrap<TStart, TEnd>(this);
}
@@ -2449,7 +2474,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TEnd> Where (string startKey, P predicate)
{
- Bytecode.AddStep("where", startKey, predicate);
+ GremlinLang.AddStep("where", startKey, predicate);
return Wrap<TStart, TEnd>(this);
}
@@ -2458,7 +2483,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TEnd> Where (ITraversal whereTraversal)
{
- Bytecode.AddStep("where", whereTraversal);
+ GremlinLang.AddStep("where", whereTraversal);
return Wrap<TStart, TEnd>(this);
}
@@ -2467,7 +2492,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TEnd> With (string key)
{
- Bytecode.AddStep("with", key);
+ GremlinLang.AddStep("with", key);
return Wrap<TStart, TEnd>(this);
}
@@ -2476,7 +2501,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TEnd> With (string key, object? value)
{
- Bytecode.AddStep("with", key, value);
+ GremlinLang.AddStep("with", key, value);
return Wrap<TStart, TEnd>(this);
}
@@ -2485,7 +2510,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TEnd> Write ()
{
- Bytecode.AddStep("write");
+ GremlinLang.AddStep("write");
return Wrap<TStart, TEnd>(this);
}
@@ -2495,7 +2520,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TEnd> Clone()
{
- return new GraphTraversal<TStart, TEnd>(TraversalStrategies, new Bytecode(Bytecode));
+ return new GraphTraversal<TStart, TEnd>(TraversalStrategies, GremlinLang.Clone());
}
}
}
\ No newline at end of file
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversalSource.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversalSource.cs
index 0ab9cbf745..72b5ef5929 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversalSource.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversalSource.cs
@@ -48,16 +48,16 @@ namespace Gremlin.Net.Process.Traversal
public ICollection<ITraversalStrategy> TraversalStrategies { get; set; }
/// <summary>
- /// Gets or sets the <see cref="Traversal.Bytecode" /> associated with the current state of this graph traversal
+ /// Gets or sets the <see cref="Traversal.GremlinLang" /> associated with the current state of this graph traversal
/// source.
/// </summary>
- public Bytecode Bytecode { get; set; }
+ public GremlinLang GremlinLang { get; set; }
/// <summary>
/// Initializes a new instance of the <see cref="GraphTraversalSource" /> class.
/// </summary>
public GraphTraversalSource()
- : this(new List<ITraversalStrategy>(), new Bytecode())
+ : this(new List<ITraversalStrategy>(), new GremlinLang())
{
}
@@ -65,20 +65,20 @@ namespace Gremlin.Net.Process.Traversal
/// Initializes a new instance of the <see cref="GraphTraversalSource" /> class.
/// </summary>
/// <param name="traversalStrategies">The traversal strategies associated with this graph traversal source.</param>
- /// <param name="bytecode">
- /// The <see cref="Traversal.Bytecode" /> associated with the current state of this graph traversal
+ /// <param name="gremlinLang">
+ /// The <see cref="Traversal.GremlinLang" /> associated with the current state of this graph traversal
/// source.
/// </param>
- public GraphTraversalSource(ICollection<ITraversalStrategy> traversalStrategies, Bytecode bytecode)
+ public GraphTraversalSource(ICollection<ITraversalStrategy> traversalStrategies, GremlinLang gremlinLang)
{
TraversalStrategies = traversalStrategies;
- Bytecode = bytecode;
+ GremlinLang = gremlinLang;
}
- public GraphTraversalSource(ICollection<ITraversalStrategy> traversalStrategies, Bytecode bytecode,
+ public GraphTraversalSource(ICollection<ITraversalStrategy> traversalStrategies, GremlinLang gremlinLang,
IRemoteConnection connection)
: this(traversalStrategies.Where(strategy => strategy.GetType() != typeof(RemoteStrategy)).ToList(),
- bytecode)
+ gremlinLang)
{
_connection = connection;
TraversalStrategies.Add(new RemoteStrategy(connection));
@@ -91,61 +91,60 @@ namespace Gremlin.Net.Process.Traversal
public GraphTraversalSource With(string key, object? value)
{
- var optionsStrategyInst = Bytecode.SourceInstructions.Find(
- inst => inst.OperatorName == "withStrategies" && inst.Arguments[0] is OptionsStrategy);
+ var existingOptions = GremlinLang.OptionsStrategies;
OptionsStrategy optionsStrategy;
- if (optionsStrategyInst == null)
+ if (existingOptions.Count == 0)
{
optionsStrategy = new OptionsStrategy();
optionsStrategy.Configuration[key] = value;
return WithStrategies(optionsStrategy);
}
- optionsStrategy = optionsStrategyInst.Arguments[0]!;
+ optionsStrategy = existingOptions[existingOptions.Count - 1];
optionsStrategy.Configuration[key] = value;
return new GraphTraversalSource(new List<ITraversalStrategy>(TraversalStrategies),
- new Bytecode(Bytecode));
+ GremlinLang.Clone());
}
public GraphTraversalSource WithBulk(bool useBulk)
{
var source = new GraphTraversalSource(new List<ITraversalStrategy>(TraversalStrategies),
- new Bytecode(Bytecode));
- source.Bytecode.AddSource("withBulk", useBulk);
+ GremlinLang.Clone());
+ source.GremlinLang.AddSource("withBulk", useBulk);
return source;
}
public GraphTraversalSource WithPath()
{
var source = new GraphTraversalSource(new List<ITraversalStrategy>(TraversalStrategies),
- new Bytecode(Bytecode));
- source.Bytecode.AddSource("withPath");
+ GremlinLang.Clone());
+ source.GremlinLang.AddSource("withPath");
return source;
}
public GraphTraversalSource WithSack(object? initialValue)
{
var source = new GraphTraversalSource(new List<ITraversalStrategy>(TraversalStrategies),
- new Bytecode(Bytecode));
- source.Bytecode.AddSource("withSack", initialValue);
+ GremlinLang.Clone());
+ source.GremlinLang.AddSource("withSack", initialValue);
return source;
}
public GraphTraversalSource WithSack(object? initialValue, IBinaryOperator? mergeOperator)
{
var source = new GraphTraversalSource(new List<ITraversalStrategy>(TraversalStrategies),
- new Bytecode(Bytecode));
- source.Bytecode.AddSource("withSack", initialValue, mergeOperator);
+ GremlinLang.Clone());
+ source.GremlinLang.AddSource("withSack", initialValue, mergeOperator);
return source;
}
public GraphTraversalSource WithSack(object? initialValue, IUnaryOperator? splitOperator)
{
var source = new GraphTraversalSource(new List<ITraversalStrategy>(TraversalStrategies),
- new Bytecode(Bytecode));
- source.Bytecode.AddSource("withSack", initialValue, splitOperator);
+ GremlinLang.Clone());
+ source.GremlinLang.AddSource("withSack", initialValue, splitOperator);
return source;
}
@@ -153,32 +152,32 @@ namespace Gremlin.Net.Process.Traversal
IBinaryOperator? mergeOperator)
{
var source = new GraphTraversalSource(new List<ITraversalStrategy>(TraversalStrategies),
- new Bytecode(Bytecode));
- source.Bytecode.AddSource("withSack", initialValue, splitOperator, mergeOperator);
+ GremlinLang.Clone());
+ source.GremlinLang.AddSource("withSack", initialValue, splitOperator, mergeOperator);
return source;
}
public GraphTraversalSource WithSack(ISupplier? initialValue)
{
var source = new GraphTraversalSource(new List<ITraversalStrategy>(TraversalStrategies),
- new Bytecode(Bytecode));
- source.Bytecode.AddSource("withSack", initialValue);
+ GremlinLang.Clone());
+ source.GremlinLang.AddSource("withSack", initialValue);
return source;
}
public GraphTraversalSource WithSack(ISupplier? initialValue, IBinaryOperator? mergeOperator)
{
var source = new GraphTraversalSource(new List<ITraversalStrategy>(TraversalStrategies),
- new Bytecode(Bytecode));
- source.Bytecode.AddSource("withSack", initialValue, mergeOperator);
+ GremlinLang.Clone());
+ source.GremlinLang.AddSource("withSack", initialValue, mergeOperator);
return source;
}
public GraphTraversalSource WithSack(ISupplier? initialValue, IUnaryOperator? splitOperator)
{
var source = new GraphTraversalSource(new List<ITraversalStrategy>(TraversalStrategies),
- new Bytecode(Bytecode));
- source.Bytecode.AddSource("withSack", initialValue, splitOperator);
+ GremlinLang.Clone());
+ source.GremlinLang.AddSource("withSack", initialValue, splitOperator);
return source;
}
@@ -186,40 +185,40 @@ namespace Gremlin.Net.Process.Traversal
IBinaryOperator? mergeOperator)
{
var source = new GraphTraversalSource(new List<ITraversalStrategy>(TraversalStrategies),
- new Bytecode(Bytecode));
- source.Bytecode.AddSource("withSack", initialValue, splitOperator, mergeOperator);
+ GremlinLang.Clone());
+ source.GremlinLang.AddSource("withSack", initialValue, splitOperator, mergeOperator);
return source;
}
public GraphTraversalSource WithSideEffect(string? key, object? initialValue)
{
var source = new GraphTraversalSource(new List<ITraversalStrategy>(TraversalStrategies),
- new Bytecode(Bytecode));
- source.Bytecode.AddSource("withSideEffect", key, initialValue);
+ GremlinLang.Clone());
+ source.GremlinLang.AddSource("withSideEffect", key, initialValue);
return source;
}
public GraphTraversalSource WithSideEffect(string? key, object? initialValue, IBinaryOperator reducer)
{
var source = new GraphTraversalSource(new List<ITraversalStrategy>(TraversalStrategies),
- new Bytecode(Bytecode));
- source.Bytecode.AddSource("withSideEffect", key, initialValue, reducer);
+ GremlinLang.Clone());
+ source.GremlinLang.AddSource("withSideEffect", key, initialValue, reducer);
return source;
}
public GraphTraversalSource WithSideEffect(string? key, ISupplier? initialValue)
{
var source = new GraphTraversalSource(new List<ITraversalStrategy>(TraversalStrategies),
- new Bytecode(Bytecode));
- source.Bytecode.AddSource("withSideEffect", key, initialValue);
+ GremlinLang.Clone());
+ source.GremlinLang.AddSource("withSideEffect", key, initialValue);
return source;
}
public GraphTraversalSource WithSideEffect(string? key, ISupplier? initialValue, IBinaryOperator? reducer)
{
var source = new GraphTraversalSource(new List<ITraversalStrategy>(TraversalStrategies),
- new Bytecode(Bytecode));
- source.Bytecode.AddSource("withSideEffect", key, initialValue, reducer);
+ GremlinLang.Clone());
+ source.GremlinLang.AddSource("withSideEffect", key, initialValue, reducer);
return source;
}
@@ -228,10 +227,10 @@ namespace Gremlin.Net.Process.Traversal
if (traversalStrategies == null) throw new ArgumentNullException(nameof(traversalStrategies));
var source = new GraphTraversalSource(new List<ITraversalStrategy>(TraversalStrategies),
- new Bytecode(Bytecode));
+ GremlinLang.Clone());
var args = new List<object>(traversalStrategies.Length);
args.AddRange(traversalStrategies);
- source.Bytecode.AddSource("withStrategies", args.ToArray());
+ source.GremlinLang.AddSource("withStrategies", args.ToArray());
return source;
}
@@ -240,14 +239,14 @@ namespace Gremlin.Net.Process.Traversal
if (traversalStrategyClasses == null) throw new ArgumentNullException(nameof(traversalStrategyClasses));
var source = new GraphTraversalSource(new List<ITraversalStrategy>(TraversalStrategies),
- new Bytecode(Bytecode));
+ GremlinLang.Clone());
var args = new List<object?>(traversalStrategyClasses.Length);
args.AddRange(traversalStrategyClasses);
- source.Bytecode.AddSource("withoutStrategies", args.ToArray());
+ source.GremlinLang.AddSource("withoutStrategies", args.ToArray());
return source;
}
- [Obsolete("Use the Bindings class instead.", false)]
+ [Obsolete("Use GValue instead.", false)]
public GraphTraversalSource WithBindings(object? bindings)
{
return this;
@@ -265,7 +264,7 @@ namespace Gremlin.Net.Process.Traversal
[Obsolete("Prefer use of AnonymousTraversalSource.with().", false)]
public GraphTraversalSource WithRemote(IRemoteConnection remoteConnection) =>
new GraphTraversalSource(new List<ITraversalStrategy>(TraversalStrategies),
- new Bytecode(Bytecode), remoteConnection);
+ GremlinLang.Clone(), remoteConnection);
/// <summary>
/// Spawns a new <see cref="RemoteTransaction"/> object that can then start and stop a transaction.
@@ -301,16 +300,16 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<Edge, Edge> E(params object?[]? edgesIds)
{
- var traversal = new GraphTraversal<Edge, Edge>(TraversalStrategies, new Bytecode(Bytecode));
+ var traversal = new GraphTraversal<Edge, Edge>(TraversalStrategies, GremlinLang.Clone());
if (edgesIds == null)
{
- traversal.Bytecode.AddStep("E", new object?[] { null });
+ traversal.GremlinLang.AddStep("E", new object?[] { null });
}
else
{
var args = new List<object?>(edgesIds.Length);
args.AddRange(edgesIds);
- traversal.Bytecode.AddStep("E", args.ToArray());
+ traversal.GremlinLang.AddStep("E", args.ToArray());
}
return traversal;
}
@@ -321,10 +320,10 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<Vertex, Vertex> V(params object?[]? vertexIds)
{
- var traversal = new GraphTraversal<Vertex, Vertex>(TraversalStrategies, new Bytecode(Bytecode));
+ var traversal = new GraphTraversal<Vertex, Vertex>(TraversalStrategies, GremlinLang.Clone());
if (vertexIds == null)
{
- traversal.Bytecode.AddStep("V", new object?[] { null });
+ traversal.GremlinLang.AddStep("V", new object?[] { null });
}
else
{
@@ -337,7 +336,7 @@ namespace Gremlin.Net.Process.Traversal
}
var args = new List<object?>(vertexIds.Length);
args.AddRange(vertexIds);
- traversal.Bytecode.AddStep("V", args.ToArray());
+ traversal.GremlinLang.AddStep("V", args.ToArray());
}
return traversal;
}
@@ -348,8 +347,8 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<Edge, Edge> AddE(string label)
{
- var traversal = new GraphTraversal<Edge, Edge>(TraversalStrategies, new Bytecode(Bytecode));
- traversal.Bytecode.AddStep("addE", label);
+ var traversal = new GraphTraversal<Edge, Edge>(TraversalStrategies, GremlinLang.Clone());
+ traversal.GremlinLang.AddStep("addE", label);
return traversal;
}
@@ -359,8 +358,8 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<Edge, Edge> AddE(ITraversal edgeLabelTraversal)
{
- var traversal = new GraphTraversal<Edge, Edge>(TraversalStrategies, new Bytecode(Bytecode));
- traversal.Bytecode.AddStep("addE", edgeLabelTraversal);
+ var traversal = new GraphTraversal<Edge, Edge>(TraversalStrategies, GremlinLang.Clone());
+ traversal.GremlinLang.AddStep("addE", edgeLabelTraversal);
return traversal;
}
@@ -376,8 +375,8 @@ namespace Gremlin.Net.Process.Traversal
if (m != null && m[Direction.In] is Vertex inV) {
m[Direction.In] = inV.Id;
}
- var traversal = new GraphTraversal<Edge, Edge>(TraversalStrategies, new Bytecode(Bytecode));
- traversal.Bytecode.AddStep("mergeE", m);
+ var traversal = new GraphTraversal<Edge, Edge>(TraversalStrategies, GremlinLang.Clone());
+ traversal.GremlinLang.AddStep("mergeE", m);
return traversal;
}
@@ -387,8 +386,8 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<Edge, Edge> MergeE(ITraversal? t)
{
- var traversal = new GraphTraversal<Edge, Edge>(TraversalStrategies, new Bytecode(Bytecode));
- traversal.Bytecode.AddStep("mergeE", t);
+ var traversal = new GraphTraversal<Edge, Edge>(TraversalStrategies, GremlinLang.Clone());
+ traversal.GremlinLang.AddStep("mergeE", t);
return traversal;
}
@@ -398,8 +397,8 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<Vertex, Vertex> AddV()
{
- var traversal = new GraphTraversal<Vertex, Vertex>(TraversalStrategies, new Bytecode(Bytecode));
- traversal.Bytecode.AddStep("addV");
+ var traversal = new GraphTraversal<Vertex, Vertex>(TraversalStrategies, GremlinLang.Clone());
+ traversal.GremlinLang.AddStep("addV");
return traversal;
}
@@ -409,8 +408,8 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<Vertex, Vertex> AddV(string label)
{
- var traversal = new GraphTraversal<Vertex, Vertex>(TraversalStrategies, new Bytecode(Bytecode));
- traversal.Bytecode.AddStep("addV", label);
+ var traversal = new GraphTraversal<Vertex, Vertex>(TraversalStrategies, GremlinLang.Clone());
+ traversal.GremlinLang.AddStep("addV", label);
return traversal;
}
@@ -420,8 +419,8 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<Vertex, Vertex> AddV(ITraversal vertexLabelTraversal)
{
- var traversal = new GraphTraversal<Vertex, Vertex>(TraversalStrategies, new Bytecode(Bytecode));
- traversal.Bytecode.AddStep("addV", vertexLabelTraversal);
+ var traversal = new GraphTraversal<Vertex, Vertex>(TraversalStrategies, GremlinLang.Clone());
+ traversal.GremlinLang.AddStep("addV", vertexLabelTraversal);
return traversal;
}
@@ -431,8 +430,8 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<Vertex, Vertex> MergeV(IDictionary<object,object>? m)
{
- var traversal = new GraphTraversal<Vertex, Vertex>(TraversalStrategies, new Bytecode(Bytecode));
- traversal.Bytecode.AddStep("mergeV", m);
+ var traversal = new GraphTraversal<Vertex, Vertex>(TraversalStrategies, GremlinLang.Clone());
+ traversal.GremlinLang.AddStep("mergeV", m);
return traversal;
}
@@ -442,8 +441,8 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<Vertex, Vertex> MergeV(ITraversal? t)
{
- var traversal = new GraphTraversal<Vertex, Vertex>(TraversalStrategies, new Bytecode(Bytecode));
- traversal.Bytecode.AddStep("mergeV", t);
+ var traversal = new GraphTraversal<Vertex, Vertex>(TraversalStrategies, GremlinLang.Clone());
+ traversal.GremlinLang.AddStep("mergeV", t);
return traversal;
}
@@ -453,18 +452,18 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TStart> Inject<TStart>(params TStart?[]? starts)
{
- var traversal = new GraphTraversal<TStart, TStart>(TraversalStrategies, new Bytecode(Bytecode));
+ var traversal = new GraphTraversal<TStart, TStart>(TraversalStrategies, GremlinLang.Clone());
// null starts is treated as g.inject(null) meaning inject a single null traverser
if (starts == null)
{
- traversal.Bytecode.AddStep("inject", new object?[] { null });
+ traversal.GremlinLang.AddStep("inject", new object?[] { null });
}
else
{
var args = new List<object?>(starts.Length);
args.AddRange(starts.Cast<object?>());
- traversal.Bytecode.AddStep("inject", args.ToArray());
+ traversal.GremlinLang.AddStep("inject", args.ToArray());
}
return traversal;
@@ -476,8 +475,8 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TStart> Io<TStart>(string file)
{
- var traversal = new GraphTraversal<TStart, TStart>(TraversalStrategies, new Bytecode(Bytecode));
- traversal.Bytecode.AddStep("io", file);
+ var traversal = new GraphTraversal<TStart, TStart>(TraversalStrategies, GremlinLang.Clone());
+ traversal.GremlinLang.AddStep("io", file);
return traversal;
}
@@ -487,8 +486,8 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TStart> Call<TStart>()
{
- var traversal = new GraphTraversal<TStart, TStart>(TraversalStrategies, new Bytecode(Bytecode));
- traversal.Bytecode.AddStep("call");
+ var traversal = new GraphTraversal<TStart, TStart>(TraversalStrategies, GremlinLang.Clone());
+ traversal.GremlinLang.AddStep("call");
return traversal;
}
@@ -498,8 +497,8 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TStart> Call<TStart>(string? service)
{
- var traversal = new GraphTraversal<TStart, TStart>(TraversalStrategies, new Bytecode(Bytecode));
- traversal.Bytecode.AddStep("call", service);
+ var traversal = new GraphTraversal<TStart, TStart>(TraversalStrategies, GremlinLang.Clone());
+ traversal.GremlinLang.AddStep("call", service);
return traversal;
}
@@ -509,8 +508,8 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TStart> Call<TStart>(string? service, IDictionary<object, object>? m)
{
- var traversal = new GraphTraversal<TStart, TStart>(TraversalStrategies, new Bytecode(Bytecode));
- traversal.Bytecode.AddStep("call", service, m);
+ var traversal = new GraphTraversal<TStart, TStart>(TraversalStrategies, GremlinLang.Clone());
+ traversal.GremlinLang.AddStep("call", service, m);
return traversal;
}
@@ -520,8 +519,8 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TStart> Call<TStart>(string? service, ITraversal? t)
{
- var traversal = new GraphTraversal<TStart, TStart>(TraversalStrategies, new Bytecode(Bytecode));
- traversal.Bytecode.AddStep("call", service, t);
+ var traversal = new GraphTraversal<TStart, TStart>(TraversalStrategies, GremlinLang.Clone());
+ traversal.GremlinLang.AddStep("call", service, t);
return traversal;
}
@@ -532,8 +531,8 @@ namespace Gremlin.Net.Process.Traversal
public GraphTraversal<TStart, TStart> Call<TStart>(string? service, IDictionary<object, object>? m,
ITraversal? t)
{
- var traversal = new GraphTraversal<TStart, TStart>(TraversalStrategies, new Bytecode(Bytecode));
- traversal.Bytecode.AddStep("call", service, m, t);
+ var traversal = new GraphTraversal<TStart, TStart>(TraversalStrategies, GremlinLang.Clone());
+ traversal.GremlinLang.AddStep("call", service, m, t);
return traversal;
}
@@ -543,10 +542,10 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<TStart, TStart> Union<TStart>(params ITraversal[] unionTraversals)
{
- var traversal = new GraphTraversal<TStart, TStart>(TraversalStrategies, new Bytecode(Bytecode));
+ var traversal = new GraphTraversal<TStart, TStart>(TraversalStrategies, GremlinLang.Clone());
var args = new List<object>(unionTraversals.Length);
args.AddRange(unionTraversals);
- traversal.Bytecode.AddStep("union", args.ToArray());
+ traversal.GremlinLang.AddStep("union", args.ToArray());
return traversal;
}
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GremlinLang.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GremlinLang.cs
new file mode 100644
index 0000000000..e4cd199348
--- /dev/null
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GremlinLang.cs
@@ -0,0 +1,752 @@
+#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;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Numerics;
+using System.Text;
+using System.Threading;
+using Gremlin.Net.Process.Traversal.Strategy;
+using Gremlin.Net.Process.Traversal.Strategy.Decoration;
+using Gremlin.Net.Structure;
+
+namespace Gremlin.Net.Process.Traversal
+{
+ /// <summary>
+ /// Builds a gremlin-lang compatible string representation of a traversal,
+ /// along with a map of named parameters.
+ /// </summary>
+ public class GremlinLang : ICloneable, IEquatable<GremlinLang>
+ {
+ private static readonly object[] EmptyArray = Array.Empty<object>();
+
+ private StringBuilder _gremlin = new();
+ private Dictionary<string, object> _parameters = new();
+ private static int _paramCount;
+ private List<OptionsStrategy> _optionsStrategies = new();
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="GremlinLang" /> class.
+ /// </summary>
+ public GremlinLang()
+ {
+ }
+
+ /// <summary>
+ /// Adds a traversal source instruction to the GremlinLang.
+ /// </summary>
+ /// <param name="sourceName">The traversal source method name (e.g. withSack()).</param>
+ /// <param name="arguments">The traversal source method arguments.</param>
+ public void AddSource(string sourceName, params object?[] arguments)
+ {
+ if (sourceName == "withStrategies" && arguments.Length != 0)
+ {
+ var args = BuildStrategyArgs(arguments);
+ if (args.Length != 0)
+ {
+ _gremlin.Append('.').Append("withStrategies").Append('(').Append(args).Append(')');
+ }
+ return;
+ }
+
+ AddToGremlin(sourceName, arguments);
+ }
+
+ /// <summary>
+ /// Adds a traversal step instruction to the GremlinLang.
+ /// </summary>
+ /// <param name="stepName">The traversal method name (e.g. out()).</param>
+ /// <param name="arguments">The traversal method arguments.</param>
+ public void AddStep(string stepName, params object?[] arguments)
+ {
+ AddToGremlin(stepName, arguments);
+ }
+
+ /// <summary>
+ /// Sets the alias for the traversal source.
+ /// </summary>
+ /// <param name="g">The alias to set.</param>
+ public void AddG(string g)
+ {
+ _parameters["g"] = g;
+ }
+
+ /// <summary>
+ /// Gets the gremlin-lang compatible string representation prefixed with "g".
+ /// </summary>
+ /// <returns>The gremlin-lang string.</returns>
+ public string GetGremlin()
+ {
+ return GetGremlin("g");
+ }
+
+ /// <summary>
+ /// Gets the gremlin-lang compatible string representation with the specified prefix.
+ /// </summary>
+ /// <param name="prefix">The prefix to use (e.g. "g" or "__").</param>
+ /// <returns>The gremlin-lang string.</returns>
+ public string GetGremlin(string prefix)
+ {
+ var gremlinStr = _gremlin.ToString();
+ // special handling for CardinalityValueTraversal
+ if (gremlinStr.Length != 0 && gremlinStr[0] != '.')
+ {
+ return gremlinStr;
+ }
+ return prefix + gremlinStr;
+ }
+
+ /// <summary>
+ /// Gets the parameters used in the traversal.
+ /// </summary>
+ public Dictionary<string, object> Parameters => _parameters;
+
+ /// <summary>
+ /// Gets the list of extracted OptionsStrategy instances.
+ /// </summary>
+ public List<OptionsStrategy> OptionsStrategies => _optionsStrategies;
+
+ /// <summary>
+ /// Gets a value indicating whether this GremlinLang has no content.
+ /// </summary>
+ public bool IsEmpty => _gremlin.Length == 0;
+
+ /// <summary>
+ /// Resets the static parameter counter. Intended for test determinism.
+ /// </summary>
+ public static void ResetCounter()
+ {
+ Interlocked.Exchange(ref _paramCount, 0);
+ }
+
+ private void AddToGremlin(string name, object?[] arguments)
+ {
+ var flattenedArguments = FlattenArguments(arguments);
+
+ // special handling for CardinalityValueTraversal
+ if (name == "CardinalityValueTraversal")
+ {
+ _gremlin.Append("Cardinality.").Append(flattenedArguments[0])
+ .Append('(').Append(flattenedArguments[1]).Append(')');
+ return;
+ }
+
+ _gremlin.Append('.').Append(name).Append('(');
+
+ for (int i = 0; i < flattenedArguments.Length; i++)
+ {
+ if (i != 0)
+ {
+ _gremlin.Append(',');
+ }
+ _gremlin.Append(ArgAsString(flattenedArguments[i]));
+ }
+
+ _gremlin.Append(')');
+ }
+
+ private string ArgAsString(object? arg)
+ {
+ if (arg == null)
+ return "null";
+
+ if (arg is string s)
+ return $"\"{EscapeJava(s)}\"";
+
+ if (arg is bool b)
+ return b ? "true" : "false";
+
+ if (arg is byte byteVal)
+ return $"{byteVal}B";
+ if (arg is sbyte sbyteVal)
+ return $"{sbyteVal}B";
+ if (arg is short shortVal)
+ return $"{shortVal}S";
+ if (arg is int intVal)
+ return intVal.ToString(CultureInfo.InvariantCulture);
+ if (arg is long longVal)
+ return $"{longVal}L";
+
+ if (arg is BigInteger bigIntVal)
+ return $"{bigIntVal}N";
+
+ if (arg is float floatVal)
+ {
+ if (float.IsNaN(floatVal))
+ return "NaN";
+ if (float.IsPositiveInfinity(floatVal))
+ return "+Infinity";
+ if (float.IsNegativeInfinity(floatVal))
+ return "-Infinity";
+ return $"{FormatFloatingPoint(floatVal.ToString(CultureInfo.InvariantCulture))}F";
+ }
+
+ if (arg is double doubleVal)
+ {
+ if (double.IsNaN(doubleVal))
+ return "NaN";
+ if (double.IsPositiveInfinity(doubleVal))
+ return "+Infinity";
+ if (double.IsNegativeInfinity(doubleVal))
+ return "-Infinity";
+ return $"{FormatFloatingPoint(doubleVal.ToString(CultureInfo.InvariantCulture))}D";
+ }
+
+ if (arg is decimal decimalVal)
+ return $"{decimalVal.ToString(CultureInfo.InvariantCulture)}M";
+
+ if (arg is DateTimeOffset dto)
+ return $"datetime(\"{dto.ToUniversalTime():yyyy-MM-ddTHH:mm:ssZ}\")";
+
+ if (arg is Guid guid)
+ return $"UUID(\"{guid}\")";
+
+ if (arg is EnumWrapper enumWrapper)
+ return $"{enumWrapper.EnumName}.{enumWrapper.EnumValue}";
+
+ if (arg is Vertex vertex)
+ return ArgAsString(vertex.Id);
+
+ if (arg is P p)
+ return AsString(p);
+
+ if (arg is GremlinLang gl)
+ {
+ foreach (var kvp in gl._parameters)
+ {
+ _parameters[kvp.Key] = kvp.Value;
+ }
+ return gl.GetGremlin("__");
+ }
+
+ if (arg is ITraversal traversal)
+ {
+ var traversalGl = traversal.GremlinLang;
+ foreach (var kvp in traversalGl._parameters)
+ {
+ _parameters[kvp.Key] = kvp.Value;
+ }
+ return traversalGl.GetGremlin("__");
+ }
+
+ if (arg is IGValue gValue)
+ {
+ var key = gValue.Name;
+
+ if (key == null)
+ {
+ return ArgAsString(gValue.ObjectValue);
+ }
+
+ if (!IsValidIdentifier(key))
+ {
+ throw new ArgumentException($"Invalid parameter name [{key}].");
+ }
+
+ if (_parameters.ContainsKey(key))
+ {
+ if (!Equals(_parameters[key], gValue.ObjectValue))
+ {
+ throw new ArgumentException($"Parameter with name [{key}] already defined.");
+ }
+ }
+ else
+ {
+ _parameters[key] = gValue.ObjectValue!;
+ }
+ return key;
+ }
+
+ if (arg is CardinalityValue cv)
+ return $"Cardinality.{cv.Cardinality!.EnumValue}({ArgAsString(cv.Value)})";
+
+ if (arg is IDictionary dict)
+ return AsString(dict);
+
+ if (arg is ISet<object?> objSet)
+ return AsStringSet(objSet);
+
+ // Check for generic HashSet types
+ if (IsHashSetType(arg.GetType()))
+ return AsStringSetEnumerable((IEnumerable)arg);
+
+ if (arg is IList list)
+ return AsStringList(list);
+
+ if (arg is Array arr)
+ return AsStringList(arr);
+
+ if (arg is Type type)
+ return type.Name;
+
+ return AsParameter(arg);
+ }
+
+ private string AsParameter(object arg)
+ {
+ var paramName = $"_{Interlocked.Increment(ref _paramCount) - 1}";
+ _parameters[paramName] = arg;
+ return paramName;
+ }
+
+ private string AsString(P p)
+ {
+ var sb = new StringBuilder();
+
+ if (p is TextP)
+ {
+ // Check for connective (and/or) on TextP
+ if (p.OperatorName == "and" || p.OperatorName == "or")
+ {
+ // Value is the left P, Other is the right P
+ sb.Append(ArgAsString(p.Value));
+ sb.Append('.').Append(p.OperatorName).Append('(');
+ sb.Append(ArgAsString(p.Other));
+ sb.Append(')');
+ }
+ else
+ {
+ sb.Append(p.OperatorName).Append('(');
+ sb.Append(ArgAsString(p.Value));
+ sb.Append(')');
+ }
+ }
+ else if (p.OperatorName == "and" || p.OperatorName == "or")
+ {
+ // Connective P: Value is the left P, Other is the right P
+ sb.Append(ArgAsString(p.Value));
+ sb.Append('.').Append(p.OperatorName).Append('(');
+ sb.Append(ArgAsString(p.Other));
+ sb.Append(')');
+ }
+ else if (p.OperatorName == "not")
+ {
+ sb.Append("P.not(");
+ sb.Append(ArgAsString(p.Value));
+ sb.Append(')');
+ }
+ else
+ {
+ // Regular P: render without "P." prefix to match Java/Go/Python behavior
+ sb.Append(p.OperatorName).Append('(');
+
+ // For predicates like between/inside, the value is an object[] with 2 elements
+ if (p.Value is object[] valArr)
+ {
+ if (valArr.Length > 1 && p.OperatorName != "between" && p.OperatorName != "inside")
+ {
+ sb.Append('[');
+ for (int i = 0; i < valArr.Length; i++)
+ {
+ if (i > 0) sb.Append(',');
+ sb.Append(ArgAsString(valArr[i]));
+ }
+ sb.Append(']');
+ }
+ else
+ {
+ for (int i = 0; i < valArr.Length; i++)
+ {
+ if (i > 0) sb.Append(',');
+ sb.Append(ArgAsString(valArr[i]));
+ }
+ }
+ }
+ else if (p.Value is IList listVal && (p.OperatorName == "within" || p.OperatorName == "without"))
+ {
+ // within/without with a list value - render as [e1,e2,...]
+ if (listVal.Count == 0)
+ {
+ // empty within() - no brackets
+ }
+ else
+ {
+ sb.Append('[');
+ for (int i = 0; i < listVal.Count; i++)
+ {
+ if (i > 0) sb.Append(',');
+ sb.Append(ArgAsString(listVal[i]));
+ }
+ sb.Append(']');
+ }
+ }
+ else
+ {
+ sb.Append(ArgAsString(p.Value));
+ }
+
+ sb.Append(')');
+ }
+
+ return sb.ToString();
+ }
+
+ private string AsString(IDictionary dict)
+ {
+ var sb = new StringBuilder("[");
+ int size = dict.Count;
+
+ if (size == 0)
+ {
+ sb.Append(':');
+ }
+ else
+ {
+ foreach (DictionaryEntry entry in dict)
+ {
+ var key = ArgAsString(entry.Key);
+ // special handling for enum keys
+ if (entry.Key is EnumWrapper && key.Contains("."))
+ {
+ key = $"({key})";
+ }
+ sb.Append(key).Append(':').Append(ArgAsString(entry.Value));
+ if (--size > 0)
+ {
+ sb.Append(',');
+ }
+ }
+ }
+
+ sb.Append(']');
+ return sb.ToString();
+ }
+
+ private string AsStringSet(ISet<object?> set)
+ {
+ var sb = new StringBuilder("{");
+ var first = true;
+ foreach (var item in set)
+ {
+ if (!first) sb.Append(',');
+ sb.Append(ArgAsString(item));
+ first = false;
+ }
+ sb.Append('}');
+ return sb.ToString();
+ }
+
+ private string AsStringSetEnumerable(IEnumerable set)
+ {
+ var sb = new StringBuilder("{");
+ var first = true;
+ foreach (var item in set)
+ {
+ if (!first) sb.Append(',');
+ sb.Append(ArgAsString(item));
+ first = false;
+ }
+ sb.Append('}');
+ return sb.ToString();
+ }
+
+ private string AsStringList(IEnumerable list)
+ {
+ var sb = new StringBuilder("[");
+ var first = true;
+ foreach (var item in list)
+ {
+ if (!first) sb.Append(',');
+ sb.Append(ArgAsString(item));
+ first = false;
+ }
+ sb.Append(']');
+ return sb.ToString();
+ }
+
+ private string BuildStrategyArgs(object?[] arguments)
+ {
+ var sb = new StringBuilder();
+ var count = 0;
+ foreach (var arg in arguments)
+ {
+ if (arg is OptionsStrategy optionsStrategy)
+ {
+ _optionsStrategies.Add(optionsStrategy);
+ continue;
+ }
+
+ if (count > 0)
+ sb.Append(',');
+
+ if (arg is AbstractTraversalStrategy strategy)
+ {
+ var strategyName = strategy.StrategyName;
+ var configuration = strategy.Configuration;
+
+ if (configuration.Count == 0)
+ {
+ sb.Append(strategyName);
+ }
+ else
+ {
+ sb.Append("new ").Append(strategyName).Append('(');
+ var first = true;
+ foreach (var kvp in configuration)
+ {
+ if (kvp.Key == "strategy")
+ continue;
+
+ if (!first)
+ sb.Append(',');
+
+ sb.Append(kvp.Key).Append(':');
+
+ if (kvp.Value is ITraversal traversalVal)
+ {
+ sb.Append(ArgAsString(traversalVal.GremlinLang));
+ }
+ else
+ {
+ sb.Append(ArgAsString(kvp.Value));
+ }
+ first = false;
+ }
+ sb.Append(')');
+ }
+ count++;
+ }
+ }
+
+ return sb.ToString();
+ }
+
+ private object?[] FlattenArguments(object?[] arguments)
+ {
+ if (arguments == null || arguments.Length == 0)
+ return EmptyArray;
+
+ var flatArguments = new List<object?>(arguments.Length);
+ foreach (var arg in arguments)
+ {
+ if (arg is object[] objects)
+ {
+ foreach (var nestObject in objects)
+ {
+ flatArguments.Add(ConvertArgument(nestObject));
+ }
+ }
+ else
+ {
+ flatArguments.Add(ConvertArgument(arg));
+ }
+ }
+ return flatArguments.ToArray();
+ }
+
+ private object? ConvertArgument(object? argument)
+ {
+ if (argument == null)
+ return null;
+
+ if (argument is ITraversal traversal)
+ {
+ if (!traversal.IsAnonymous)
+ {
+ throw new InvalidOperationException(
+ $"The child traversal of {traversal} was not spawned anonymously - use the __ class rather than a TraversalSource to construct the child traversal");
+ }
+ return traversal.GremlinLang;
+ }
+
+ if (IsDictionaryType(argument.GetType()))
+ {
+ var dict = new Dictionary<object, object?>();
+ foreach (DictionaryEntry item in (IDictionary)argument)
+ {
+ dict[ConvertArgument(item.Key)!] = ConvertArgument(item.Value);
+ }
+ return dict;
+ }
+
+ if (IsListType(argument.GetType()))
+ {
+ var list = new List<object?>(((IList)argument).Count);
+ foreach (var item in (IList)argument)
+ {
+ list.Add(ConvertArgument(item));
+ }
+ return list;
+ }
+
+ if (IsHashSetType(argument.GetType()))
+ {
+ var set = new HashSet<object?>();
+ foreach (var item in (IEnumerable)argument)
+ {
+ set.Add(ConvertArgument(item));
+ }
+ return set;
+ }
+
+ return argument;
+ }
+
+ private static bool IsDictionaryType(Type type)
+ {
+ return type.IsConstructedGenericType && type.GetGenericTypeDefinition() == typeof(Dictionary<,>);
+ }
+
+ private static bool IsListType(Type type)
+ {
+ return type.IsConstructedGenericType && type.GetGenericTypeDefinition() == typeof(List<>);
+ }
+
+ private static bool IsHashSetType(Type type)
+ {
+ return type.IsConstructedGenericType && type.GetGenericTypeDefinition() == typeof(HashSet<>);
+ }
+
+ private static string EscapeJava(string value)
+ {
+ var sb = new StringBuilder(value.Length);
+ foreach (var c in value)
+ {
+ switch (c)
+ {
+ case '\\':
+ sb.Append("\\\\");
+ break;
+ case '"':
+ sb.Append("\\\"");
+ break;
+ case '\n':
+ sb.Append("\\n");
+ break;
+ case '\r':
+ sb.Append("\\r");
+ break;
+ case '\t':
+ sb.Append("\\t");
+ break;
+ case '\b':
+ sb.Append("\\b");
+ break;
+ case '\f':
+ sb.Append("\\f");
+ break;
+ default:
+ sb.Append(c);
+ break;
+ }
+ }
+ return sb.ToString();
+ }
+
+ /// <summary>
+ /// Ensures a floating-point string representation always contains a decimal point,
+ /// matching Java's Double/Float toString() behavior (e.g., "5.0" not "5").
+ /// </summary>
+ private static string FormatFloatingPoint(string value)
+ {
+ if (value.IndexOf('.') < 0 && value.IndexOf('E') < 0 && value.IndexOf('e') < 0)
+ {
+ return value + ".0";
+ }
+ return value;
+ }
+
+ private static bool IsValidIdentifier(string name)
+ {
+ if (string.IsNullOrEmpty(name))
+ return false;
+ if (!char.IsLetter(name[0]))
+ return false;
+ for (int i = 1; i < name.Length; i++)
+ {
+ if (!char.IsLetterOrDigit(name[i]))
+ return false;
+ }
+ return true;
+ }
+
+ /// <summary>
+ /// Creates a deep copy of this <see cref="GremlinLang" /> instance.
+ /// </summary>
+ /// <returns>A new <see cref="GremlinLang" /> with copied state.</returns>
+ public GremlinLang Clone()
+ {
+ var clone = new GremlinLang
+ {
+ _gremlin = new StringBuilder(_gremlin.ToString()),
+ _parameters = new Dictionary<string, object>(_parameters),
+ _optionsStrategies = new List<OptionsStrategy>(_optionsStrategies)
+ };
+ return clone;
+ }
+
+ /// <inheritdoc />
+ object ICloneable.Clone() => Clone();
+
+ /// <inheritdoc />
+ public bool Equals(GremlinLang? other)
+ {
+ if (ReferenceEquals(null, other)) return false;
+ if (ReferenceEquals(this, other)) return true;
+ return _gremlin.ToString() == other._gremlin.ToString() &&
+ DictionaryEquals(_parameters, other._parameters);
+ }
+
+ /// <inheritdoc />
+ public override bool Equals(object? obj)
+ {
+ if (ReferenceEquals(null, obj)) return false;
+ if (ReferenceEquals(this, obj)) return true;
+ if (obj.GetType() != GetType()) return false;
+ return Equals((GremlinLang)obj);
+ }
+
+ /// <inheritdoc />
+ public override int GetHashCode()
+ {
+ unchecked
+ {
+ var hash = _gremlin.ToString().GetHashCode() * 397;
+ foreach (var kvp in _parameters)
+ {
+ hash ^= (kvp.Key.GetHashCode() * 31) + (kvp.Value?.GetHashCode() ?? 0);
+ }
+ return hash;
+ }
+ }
+
+ /// <inheritdoc />
+ public override string ToString()
+ {
+ return _gremlin.ToString();
+ }
+
+ private static bool DictionaryEquals(Dictionary<string, object> a, Dictionary<string, object> b)
+ {
+ if (a.Count != b.Count) return false;
+ foreach (var kvp in a)
+ {
+ if (!b.TryGetValue(kvp.Key, out var value)) return false;
+ if (!Equals(kvp.Value, value)) return false;
+ }
+ return true;
+ }
+ }
+}
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/ITraversal.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/ITraversal.cs
index 17874b502e..e1d363de10 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/ITraversal.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/ITraversal.cs
@@ -36,9 +36,9 @@ namespace Gremlin.Net.Process.Traversal
public interface ITraversal: IEnumerator
{
/// <summary>
- /// Gets the <see cref="Bytecode" /> representation of this traversal.
+ /// Gets the <see cref="Traversal.GremlinLang" /> representation of this traversal.
/// </summary>
- Bytecode Bytecode { get; }
+ GremlinLang GremlinLang { get; }
/// <summary>
/// Determines if this traversal was spawned anonymously or not.
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Instruction.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Instruction.cs
deleted file mode 100644
index cf9cd0c9c3..0000000000
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Instruction.cs
+++ /dev/null
@@ -1,95 +0,0 @@
-#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.Linq;
-
-namespace Gremlin.Net.Process.Traversal
-{
- /// <summary>
- /// Represents a <see cref="Bytecode" /> instruction by an operator name and its arguments.
- /// </summary>
- public class Instruction : IEquatable<Instruction>
- {
- /// <summary>
- /// Initializes a new instance of the <see cref="Instruction" /> class.
- /// </summary>
- /// <param name="operatorName">The name of the operator.</param>
- /// <param name="arguments">The arguments.</param>
- public Instruction(string operatorName, params dynamic?[] arguments)
- {
- OperatorName = operatorName ?? throw new ArgumentNullException(nameof(operatorName));
- Arguments = arguments ?? throw new ArgumentNullException(nameof(arguments));
- }
-
- /// <summary>
- /// Gets the name of the operator.
- /// </summary>
- public string OperatorName { get; }
-
- /// <summary>
- /// Gets the arguments.
- /// </summary>
- public dynamic?[] Arguments { get; }
-
- /// <summary>
- /// String representation of the <see cref="Instruction"/>.
- /// </summary>
- public override string ToString()
- {
- return $"{OperatorName}({string.Join(", ", Arguments.Select(a => a ?? "null"))})";
- }
-
- /// <inheritdoc />
- public bool Equals(Instruction? other)
- {
- if (ReferenceEquals(null, other)) return false;
- if (ReferenceEquals(this, other)) return true;
- return OperatorName == other.OperatorName && Arguments.SequenceEqual(other.Arguments);
- }
-
- /// <inheritdoc />
- public override bool Equals(object? obj)
- {
- if (ReferenceEquals(null, obj)) return false;
- if (ReferenceEquals(this, obj)) return true;
- if (obj.GetType() != GetType()) return false;
- return Equals((Instruction) obj);
- }
-
- /// <inheritdoc />
- public override int GetHashCode()
- {
- unchecked
- {
- var hash = 19;
- hash = hash * 397 + OperatorName.GetHashCode();
-
- hash = Arguments.Aggregate(hash,
- (current, value) => current * 31 + (value == null ? 0 : value.GetHashCode()));
-
- return hash;
- }
- }
- }
-}
\ No newline at end of file
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/AbstractTraversalStrategy.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/AbstractTraversalStrategy.cs
index 2c6a2a5386..49c863dc49 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/AbstractTraversalStrategy.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/AbstractTraversalStrategy.cs
@@ -29,7 +29,7 @@ using System.Threading.Tasks;
namespace Gremlin.Net.Process.Traversal.Strategy
{
/// <summary>
- /// Provides a common base class for strategies that are only included in <see cref="Bytecode" />
+ /// Provides a common base class for strategies that are only included in <see cref="GremlinLang" />
/// to be applied remotely.
/// </summary>
public abstract class AbstractTraversalStrategy : ITraversalStrategy, IEquatable<AbstractTraversalStrategy>
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Translator/GroovyTranslator.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Translator/GroovyTranslator.cs
deleted file mode 100644
index 4ff5627d12..0000000000
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Translator/GroovyTranslator.cs
+++ /dev/null
@@ -1,207 +0,0 @@
-#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;
-using System.Collections.Generic;
-using System.Globalization;
-using System.Linq;
-using System.Text;
-using Gremlin.Net.Process.Traversal;
-using Gremlin.Net.Process.Traversal.Strategy;
-using Gremlin.Net.Process.Traversal.Strategy.Decoration;
-
-namespace Gremlin.Net.Process.Traversal.Translator
-{
- /// <summary>
- /// Converts bytecode to a Groovy string of Gremlin.
- /// </summary>
- public class GroovyTranslator
- {
- private GroovyTranslator(string traversalSource)
- {
- TraversalSource = traversalSource;
- }
-
- /// <summary>
- /// Creates the translator.
- /// </summary>
- /// <param name="traversalSource">The traversal source for the traversal to be translated.</param>
- /// <returns>The created translator instance.</returns>
- public static GroovyTranslator Of(string traversalSource)
- {
- return new GroovyTranslator(traversalSource);
- }
-
- /// <summary>
- /// Get the language that the translator is converting the traversal byte code to.
- /// </summary>
- public string TargetLanguage => "gremlin-groovy";
-
- /// <summary>
- /// Gets the <see cref="TraversalSource"/> representation rooting this translator.
- /// This is typically a "g".
- /// </summary>
- public string TraversalSource { get; }
-
- /// <summary>
- /// Translate <see cref="ITraversal"/> into gremlin-groovy.
- /// </summary>
- /// <param name="traversal">The traversal to translate.</param>
- /// <param name="isChildTraversal">Whether this is an anonymous traversal (started via '__').</param>
- /// <returns>The translated gremlin-groovy traversal.</returns>
- public string Translate(ITraversal traversal, bool isChildTraversal = false)
- {
- return Translate(traversal.Bytecode, isChildTraversal);
- }
-
- /// <summary>
- /// Translate <see cref="Bytecode"/> into gremlin-groovy.
- /// </summary>
- /// <param name="bytecode">The bytecode representing traversal source and traversal manipulations.</param>
- /// <param name="isChildTraversal">Whether this is an anonymous traversal (started via '__').</param>
- /// <returns>The translated gremlin-groovy traversal.</returns>
- public string Translate(Bytecode bytecode, bool isChildTraversal = false)
- {
- var sb = new StringBuilder(isChildTraversal ? "__" : TraversalSource);
-
- foreach (var step in bytecode.SourceInstructions)
- {
- sb.Append(TranslateStep(step));
- }
-
- foreach (var step in bytecode.StepInstructions)
- {
- sb.Append(TranslateStep(step));
- }
-
- return sb.ToString();
- }
-
- private string TranslateStep(Instruction step)
- {
- if (step.OperatorName == "with")
- {
- return $".{step.OperatorName}({TranslateWithArguments(step.Arguments)})";
- }
- return $".{step.OperatorName}({TranslateArguments(step.Arguments)})";
- }
-
- private string TranslateWithArguments(dynamic?[] arguments)
- {
- if (arguments[0] == WithOptions.Tokens)
- {
- return string.Join(", ", arguments.Select(a => PropertyMapOptionsTranslation[a]));
- }
- if (arguments[0] == WithOptions.Indexer)
- {
- return string.Join(", ", arguments.Select(a => IndexOptionsTranslation[a]));
- }
- return string.Join(", ", arguments.Select(TranslateArgument));
- }
-
- private static readonly Dictionary<object, string> PropertyMapOptionsTranslation = new Dictionary<object, string>
- {
- { WithOptions.Tokens, "WithOptions.tokens" },
- { WithOptions.None, "WithOptions.none" },
- { WithOptions.Ids, "WithOptions.ids" },
- { WithOptions.Labels, "WithOptions.labels" },
- { WithOptions.Keys, "WithOptions.keys" },
- { WithOptions.Values, "WithOptions.values" },
- { WithOptions.All, "WithOptions.all" }
- };
-
- private static readonly Dictionary<object, string> IndexOptionsTranslation = new Dictionary<object, string>
- {
- { WithOptions.Indexer, "WithOptions.indexer" },
- { WithOptions.List, "WithOptions.list" },
- { WithOptions.Map, "WithOptions.map" }
- };
-
- private string TranslateArguments(IEnumerable<object?> arguments) =>
- string.Join(", ", arguments.Select(TranslateArgument));
-
- private string TranslateArgument(object? argument)
- {
- return argument switch
- {
- null => "null",
- string str => $"'{str}'",
- char c => $"'{c}'",
- bool b => b ? "true" : "false",
- DateTimeOffset dto => TranslateDateTimeOffset(dto),
- DateTime dt => TranslateDateTimeOffset(dt),
- Guid guid => $"UUID.fromString('{guid}')",
- P p => TranslateP(p),
- IDictionary dict => TranslateDictionary(dict),
- IEnumerable e => TranslateCollection(e),
- ITraversal t => TranslateTraversal(t),
- AbstractTraversalStrategy strategy => TranslateStrategy(strategy),
- _ => Convert.ToString(argument, CultureInfo.InvariantCulture)!
- };
- }
-
- private static string TranslateDateTimeOffset(DateTimeOffset dto)
- {
- var year = dto.Year - 1900;
- var month = dto.Month - 1;
- var dayOfMonth = dto.Day;
- var hour = dto.Hour;
- var minute = dto.Minute;
- var second = dto.Second;
- return $"new Date({year}, {month}, {dayOfMonth}, {hour}, {minute}, {second})";
- }
-
- private string TranslateP(P p)
- {
- return p.Other == null
- ? $"P.{p.OperatorName}({TranslateArgument(p.Value)})"
- : $"P.{p.OperatorName}({TranslateArgument(p.Value)}, {TranslateArgument(p.Other)})";
- }
-
- private string TranslateDictionary(IDictionary dict)
- {
- var kvStrings = new List<string>(dict.Count);
- foreach (DictionaryEntry kv in dict)
- {
- kvStrings.Add($"{TranslateArgument(kv.Key)}: {TranslateArgument(kv.Value)}");
- }
-
- return $"[{string.Join(", ", kvStrings)}]";
- }
-
- private string TranslateCollection(IEnumerable enumerable) =>
- $"[{TranslateArguments(enumerable.Cast<object>().ToArray())}]";
-
- private string TranslateTraversal(ITraversal traversal) => Translate(traversal.Bytecode, true);
-
- private string TranslateStrategy(AbstractTraversalStrategy strategy)
- {
- var config = string.Join(", ",
- strategy.Configuration.Select(opt =>
- $"{(strategy.StrategyName == nameof(OptionsStrategy) ? $"'{opt.Key}'" : opt.Key)}: {TranslateArgument(opt.Value)}"));
-
- return $"new {strategy.StrategyName}({config})";
- }
- }
-}
\ No newline at end of file
diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphBinary/DataType.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphBinary/DataType.cs
index 6e7260eb05..f161c4a519 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphBinary/DataType.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphBinary/DataType.cs
@@ -50,8 +50,6 @@ namespace Gremlin.Net.Structure.IO.GraphBinary
public static readonly DataType Vertex = new DataType(0x11);
public static readonly DataType VertexProperty = new DataType(0x12);
public static readonly DataType Barrier = new DataType(0x13);
- public static readonly DataType Binding = new DataType(0x14);
- public static readonly DataType Bytecode = new DataType(0x15);
public static readonly DataType Cardinality = new DataType(0x16);
public static readonly DataType Column = new DataType(0x17);
public static readonly DataType Direction = new DataType(0x18);
diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphBinary/TypeSerializerRegistry.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphBinary/TypeSerializerRegistry.cs
index 52cff84fe0..52b7098f02 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphBinary/TypeSerializerRegistry.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphBinary/TypeSerializerRegistry.cs
@@ -56,8 +56,6 @@ namespace Gremlin.Net.Structure.IO.GraphBinary
{typeof(Vertex), new VertexSerializer()},
{typeof(VertexProperty), new VertexPropertySerializer()},
{typeof(Barrier), EnumSerializers.BarrierSerializer},
- {typeof(Binding), new BindingSerializer()},
- {typeof(Bytecode), new BytecodeSerializer()},
{typeof(ITraversal), new TraversalSerializer()},
{typeof(Cardinality), EnumSerializers.CardinalitySerializer},
{typeof(Column), EnumSerializers.ColumnSerializer},
@@ -107,8 +105,6 @@ namespace Gremlin.Net.Structure.IO.GraphBinary
{DataType.Vertex, new VertexSerializer()},
{DataType.VertexProperty, new VertexPropertySerializer()},
{DataType.Barrier, EnumSerializers.BarrierSerializer},
- {DataType.Binding, new BindingSerializer()},
- {DataType.Bytecode, new BytecodeSerializer()},
{DataType.Cardinality, EnumSerializers.CardinalitySerializer},
{DataType.Column, EnumSerializers.ColumnSerializer},
{DataType.Direction, EnumSerializers.DirectionSerializer},
diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphBinary/Types/BindingSerializer.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphBinary/Types/BindingSerializer.cs
deleted file mode 100644
index 87b884e912..0000000000
--- a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphBinary/Types/BindingSerializer.cs
+++ /dev/null
@@ -1,61 +0,0 @@
-#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.IO;
-using System.Threading;
-using System.Threading.Tasks;
-using Gremlin.Net.Process.Traversal;
-
-namespace Gremlin.Net.Structure.IO.GraphBinary.Types
-{
- /// <summary>
- /// A serializer for <see cref="Binding"/> values.
- /// </summary>
- public class BindingSerializer : SimpleTypeSerializer<Binding>
- {
- /// <summary>
- /// Initializes a new instance of the <see cref="BindingSerializer" /> class.
- /// </summary>
- public BindingSerializer() : base(DataType.Binding)
- {
- }
-
- /// <inheritdoc />
- protected override async Task WriteValueAsync(Binding value, Stream stream, GraphBinaryWriter writer,
- CancellationToken cancellationToken = default)
- {
- await writer.WriteNonNullableValueAsync(value.Key, stream, cancellationToken).ConfigureAwait(false);
- await writer.WriteAsync(value.Value, stream, cancellationToken).ConfigureAwait(false);
- }
-
- /// <inheritdoc />
- protected override async Task<Binding> ReadValueAsync(Stream stream, GraphBinaryReader reader,
- CancellationToken cancellationToken = default)
- {
- var key = (string)await reader.ReadNonNullableValueAsync<string>(stream, cancellationToken)
- .ConfigureAwait(false);
- var value = await reader.ReadAsync(stream, cancellationToken).ConfigureAwait(false);
- return new Binding(key, value);
- }
- }
-}
\ No newline at end of file
diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphBinary/Types/ByteCodeSerializer.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphBinary/Types/ByteCodeSerializer.cs
deleted file mode 100644
index 3f043d1a34..0000000000
--- a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphBinary/Types/ByteCodeSerializer.cs
+++ /dev/null
@@ -1,117 +0,0 @@
-#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.Collections.Generic;
-using System.IO;
-using System.Threading;
-using System.Threading.Tasks;
-using Gremlin.Net.Process.Traversal;
-
-namespace Gremlin.Net.Structure.IO.GraphBinary.Types
-{
- /// <summary>
- /// A <see cref="Bytecode"/> serializer.
- /// </summary>
- public class BytecodeSerializer : SimpleTypeSerializer<Bytecode>
- {
- /// <summary>
- /// Initializes a new instance of the <see cref="BytecodeSerializer" /> class.
- /// </summary>
- public BytecodeSerializer() : base(DataType.Bytecode)
- {
- }
-
- /// <inheritdoc />
- protected override async Task WriteValueAsync(Bytecode value, Stream stream, GraphBinaryWriter writer,
- CancellationToken cancellationToken = default)
- {
- await WriteInstructionsAsync(value.StepInstructions, stream, writer, cancellationToken)
- .ConfigureAwait(false);
- await WriteInstructionsAsync(value.SourceInstructions, stream, writer, cancellationToken)
- .ConfigureAwait(false);
- }
-
- private static async Task WriteInstructionsAsync(IReadOnlyCollection<Instruction> instructions, Stream stream,
- GraphBinaryWriter writer, CancellationToken cancellationToken)
- {
- await writer.WriteNonNullableValueAsync(instructions.Count, stream, cancellationToken).ConfigureAwait(false);
-
- foreach (var instruction in instructions)
- {
- await writer.WriteNonNullableValueAsync(instruction.OperatorName, stream, cancellationToken)
- .ConfigureAwait(false);
- await WriteArgumentsAsync(instruction.Arguments, stream, writer, cancellationToken)
- .ConfigureAwait(false);
- }
- }
-
- private static async Task WriteArgumentsAsync(object?[] arguments, Stream stream, GraphBinaryWriter writer,
- CancellationToken cancellationToken)
- {
- await writer.WriteNonNullableValueAsync(arguments.Length, stream, cancellationToken).ConfigureAwait(false);
-
- foreach (var value in arguments)
- {
- await writer.WriteAsync(value, stream, cancellationToken).ConfigureAwait(false);
- }
- }
-
- /// <inheritdoc />
- protected override async Task<Bytecode> ReadValueAsync(Stream stream, GraphBinaryReader reader,
- CancellationToken cancellationToken = default)
- {
- var result = new Bytecode();
-
- var stepsLength = (int) await reader.ReadNonNullableValueAsync<int>(stream, cancellationToken).ConfigureAwait(false);
- for (var i = 0; i < stepsLength; i++)
- {
- result.AddStep(
- (string)await reader.ReadNonNullableValueAsync<string>(stream, cancellationToken).ConfigureAwait(false),
- await ReadArgumentsAsync(stream, reader, cancellationToken).ConfigureAwait(false));
- }
-
- var sourcesLength = await stream.ReadIntAsync(cancellationToken).ConfigureAwait(false);
- for (var i = 0; i < sourcesLength; i++)
- {
- result.AddSource(
- (string)await reader.ReadNonNullableValueAsync<string>(stream, cancellationToken).ConfigureAwait(false),
- await ReadArgumentsAsync(stream, reader, cancellationToken).ConfigureAwait(false));
- }
-
- return result;
- }
-
- private static async Task<object?[]> ReadArgumentsAsync(Stream stream, GraphBinaryReader reader,
- CancellationToken cancellationToken)
- {
- var valuesLength =
- (int)await reader.ReadNonNullableValueAsync<int>(stream, cancellationToken).ConfigureAwait(false);
- var values = new object?[valuesLength];
- for (var i = 0; i < valuesLength; i++)
- {
- values[i] = await reader.ReadAsync(stream, cancellationToken).ConfigureAwait(false);
- }
- return values;
- }
- }
-}
\ No newline at end of file
diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphBinary/Types/TraversalSerializer.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphBinary/Types/TraversalSerializer.cs
index 1e00047534..3c56b5fc34 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphBinary/Types/TraversalSerializer.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphBinary/Types/TraversalSerializer.cs
@@ -37,15 +37,15 @@ namespace Gremlin.Net.Structure.IO.GraphBinary.Types
/// <summary>
/// Initializes a new instance of the <see cref="TraversalSerializer" /> class.
/// </summary>
- public TraversalSerializer() : base(DataType.Bytecode)
+ public TraversalSerializer() : base(DataType.FromTypeCode(0x15))
{
}
/// <inheritdoc />
- protected override async Task WriteValueAsync(ITraversal value, Stream stream, GraphBinaryWriter writer,
+ protected override Task WriteValueAsync(ITraversal value, Stream stream, GraphBinaryWriter writer,
CancellationToken cancellationToken = default)
{
- await writer.WriteNonNullableValueAsync(value.Bytecode, stream, cancellationToken).ConfigureAwait(false);
+ throw new NotSupportedException("Traversal serialization via GraphBinary is no longer supported. Use GremlinLang instead.");
}
/// <summary>
diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/BindingSerializer.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/BindingSerializer.cs
deleted file mode 100644
index d183447b90..0000000000
--- a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/BindingSerializer.cs
+++ /dev/null
@@ -1,42 +0,0 @@
-#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.Collections.Generic;
-using Gremlin.Net.Process.Traversal;
-
-namespace Gremlin.Net.Structure.IO.GraphSON
-{
- internal class BindingSerializer : IGraphSONSerializer
- {
- public Dictionary<string, dynamic> Dictify(dynamic objectData, GraphSONWriter writer)
- {
- var binding = (Binding) objectData;
- var valueDict = new Dictionary<string, object>
- {
- {"value", writer.ToDict(binding.Value)},
- {"key", binding.Key}
- };
- return GraphSONUtil.ToTypedValue(nameof(Binding), valueDict);
- }
- }
-}
\ No newline at end of file
diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/BytecodeSerializer.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/BytecodeSerializer.cs
deleted file mode 100644
index 28cfe0a1d0..0000000000
--- a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/BytecodeSerializer.cs
+++ /dev/null
@@ -1,58 +0,0 @@
-#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.Collections.Generic;
-using System.Linq;
-using Gremlin.Net.Process.Traversal;
-
-namespace Gremlin.Net.Structure.IO.GraphSON
-{
- internal class BytecodeSerializer : IGraphSONSerializer
- {
- public Dictionary<string, dynamic> Dictify(dynamic bytecodeObj, GraphSONWriter writer)
- {
- Bytecode bytecode = bytecodeObj;
-
- var valueDict = new Dictionary<string, IEnumerable<IEnumerable<dynamic>>>();
- if (bytecode.SourceInstructions.Count > 0)
- valueDict["source"] = DictifyInstructions(bytecode.SourceInstructions, writer);
- if (bytecode.StepInstructions.Count > 0)
- valueDict["step"] = DictifyInstructions(bytecode.StepInstructions, writer);
-
- return GraphSONUtil.ToTypedValue(nameof(Bytecode), valueDict);
- }
-
- private IEnumerable<IEnumerable<dynamic>> DictifyInstructions(IEnumerable<Instruction> instructions,
- GraphSONWriter writer)
- {
- return instructions.Select(instruction => DictifyInstruction(instruction, writer));
- }
-
- private IEnumerable<dynamic> DictifyInstruction(Instruction instruction, GraphSONWriter writer)
- {
- var result = new List<dynamic> {instruction.OperatorName};
- result.AddRange(instruction.Arguments.Select(arg => writer.ToDict(arg)));
- return result;
- }
- }
-}
\ No newline at end of file
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 4424505261..c367595209 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSONWriter.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSONWriter.cs
@@ -49,8 +49,6 @@ namespace Gremlin.Net.Structure.IO.GraphSON
protected readonly Dictionary<Type, IGraphSONSerializer> Serializers = new()
{
{ typeof(ITraversal), new TraversalSerializer() },
- { typeof(Bytecode), new BytecodeSerializer() },
- { typeof(Binding), new BindingSerializer() },
{ typeof(RequestMessage), new RequestMessageSerializer() },
{ typeof(int), new Int32Converter() },
{ typeof(long), new Int64Converter() },
diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/TraversalSerializer.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/TraversalSerializer.cs
index cc809aaafe..60692b4eab 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/TraversalSerializer.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/TraversalSerializer.cs
@@ -21,6 +21,7 @@
#endregion
+using System;
using System.Collections.Generic;
using Gremlin.Net.Process.Traversal;
@@ -30,9 +31,7 @@ namespace Gremlin.Net.Structure.IO.GraphSON
{
public Dictionary<string, dynamic> Dictify(dynamic objectData, GraphSONWriter writer)
{
- ITraversal traversal = objectData;
- var bytecode = traversal.Bytecode;
- return writer.ToDict(bytecode);
+ throw new NotSupportedException("Traversal serialization via GraphSON is no longer supported. Use GremlinLang instead.");
}
}
}
\ No newline at end of file
diff --git a/gremlin-dotnet/test/Gremlin.Net.Benchmarks/MessageSerializerBenchmarks.cs b/gremlin-dotnet/test/Gremlin.Net.Benchmarks/MessageSerializerBenchmarks.cs
index aae0d2b2dd..337a80624a 100644
--- a/gremlin-dotnet/test/Gremlin.Net.Benchmarks/MessageSerializerBenchmarks.cs
+++ b/gremlin-dotnet/test/Gremlin.Net.Benchmarks/MessageSerializerBenchmarks.cs
@@ -39,9 +39,9 @@ namespace Gremlin.Net.Benchmarks
[MemoryDiagnoser]
public class MessageSerializerBenchmarks
{
- private static readonly Bytecode EmptyBytecode = new Bytecode();
+ private static readonly GremlinLang EmptyGremlinLang = new GremlinLang();
- private static readonly Bytecode SomeBytecode = Traversal().With(null).WithComputer().V().
+ private static readonly GremlinLang SomeGremlinLang = Traversal().With(null).WithComputer().V().
Has("Name", "marko").
Where(
Out("knows").
@@ -49,15 +49,16 @@ namespace Gremlin.Net.Benchmarks
Count().
Is(Gt(3))).
Has("birthDate", Lt(DateTimeOffset.Parse("1980-01-01 00:00:00"))).
- Bytecode;
+ GremlinLang;
- private static readonly RequestMessage RequestMessageWithEmptyBytecode = RequestMessageFor(EmptyBytecode);
+ private static readonly RequestMessage RequestMessageWithEmptyGremlinLang = RequestMessageFor(EmptyGremlinLang);
- private static readonly RequestMessage RequestMessage = RequestMessageFor(SomeBytecode);
+ private static readonly RequestMessage RequestMessage = RequestMessageFor(SomeGremlinLang);
- private static RequestMessage RequestMessageFor(Bytecode bytecode) => RequestMessage.Build(Tokens.OpsBytecode)
+ private static RequestMessage RequestMessageFor(GremlinLang gremlinLang) => RequestMessage.Build(Tokens.OpsEval)
.Processor(Tokens.ProcessorTraversal).OverrideRequestId(Guid.NewGuid())
- .AddArgument(Tokens.ArgsGremlin, bytecode).Create();
+ .AddArgument(Tokens.ArgsGremlin, gremlinLang.GetGremlin())
+ .AddArgument(Tokens.ArgsBindings, gremlinLang.Parameters).Create();
private static readonly GraphBinaryMessageSerializer BinaryMessageSerializer =
new GraphBinaryMessageSerializer();
@@ -66,22 +67,22 @@ namespace Gremlin.Net.Benchmarks
GraphSON3MessageSerializer = new GraphSON3MessageSerializer();
[Benchmark]
- public async Task<byte[]> TestWriteEmptyBytecodeBinary() =>
- await BinaryMessageSerializer.SerializeMessageAsync(RequestMessageWithEmptyBytecode)
+ public async Task<byte[]> TestWriteEmptyGremlinLangBinary() =>
+ await BinaryMessageSerializer.SerializeMessageAsync(RequestMessageWithEmptyGremlinLang)
.ConfigureAwait(false);
[Benchmark]
- public async Task<byte[]> TestWriteEmptyBytecodeGraphSON3() =>
- await GraphSON3MessageSerializer.SerializeMessageAsync(RequestMessageWithEmptyBytecode)
+ public async Task<byte[]> TestWriteEmptyGremlinLangGraphSON3() =>
+ await GraphSON3MessageSerializer.SerializeMessageAsync(RequestMessageWithEmptyGremlinLang)
.ConfigureAwait(false);
[Benchmark]
- public async Task<byte[]> TestWriteBytecodeBinary() =>
+ public async Task<byte[]> TestWriteGremlinLangBinary() =>
await BinaryMessageSerializer.SerializeMessageAsync(RequestMessage)
.ConfigureAwait(false);
[Benchmark]
- public async Task<byte[]> TestWriteBytecodeGraphSON3() =>
+ public async Task<byte[]> TestWriteGremlinLangGraphSON3() =>
await GraphSON3MessageSerializer.SerializeMessageAsync(RequestMessage)
.ConfigureAwait(false);
@@ -105,4 +106,4 @@ namespace Gremlin.Net.Benchmarks
await GraphSON3MessageSerializer.DeserializeMessageAsync(TestMessages.BigGraphSON3ResponseMessageBytes)
.ConfigureAwait(false);
}
-}
\ No newline at end of file
+}
diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Docs/Reference/GremlinApplicationsTests.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Docs/Reference/GremlinApplicationsTests.cs
index 9d03783505..a1e512c193 100644
--- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Docs/Reference/GremlinApplicationsTests.cs
+++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Docs/Reference/GremlinApplicationsTests.cs
@@ -50,7 +50,7 @@ using (var gremlinClient = new GremlinClient(gremlinServer))
bindings);
}
-// bytecode
+// traversal
using (var gremlinClient = new GremlinClient(new GremlinServer("localhost", 8182)))
{
var g = Traversal().With(new DriverRemoteConnection(gremlinClient));
diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Driver/DriverRemoteConnectionTests.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Driver/DriverRemoteConnectionTests.cs
index 3415343edd..6630f713e7 100644
--- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Driver/DriverRemoteConnectionTests.cs
+++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Driver/DriverRemoteConnectionTests.cs
@@ -45,11 +45,11 @@ public class DriverRemoteConnectionTests
logger.IsEnabled(Arg.Any<LogLevel>()).Returns(true);
loggerFactory.CreateLogger(Arg.Any<string>()).Returns(logger);
using var driverRemoteConnection = new DriverRemoteConnection(TestHost, TestPort, loggerFactory: loggerFactory);
- var bytecodeToLog = SomeValidBytecode;
+ var gremlinLangToLog = SomeValidGremlinLang;
- await driverRemoteConnection.SubmitAsync<object, object>(bytecodeToLog);
+ await driverRemoteConnection.SubmitAsync<object, object>(gremlinLangToLog);
- logger.VerifyMessageWasLogged(LogLevel.Debug, bytecodeToLog.ToString());
+ logger.VerifyMessageWasLogged(LogLevel.Debug, gremlinLangToLog.ToString());
}
[Fact]
@@ -61,7 +61,7 @@ public class DriverRemoteConnectionTests
loggerFactory.CreateLogger(Arg.Any<string>()).Returns(logger);
using var driverRemoteConnection = new DriverRemoteConnection(TestHost, TestPort, loggerFactory: loggerFactory);
- await driverRemoteConnection.SubmitAsync<object, object>(SomeValidBytecode);
+ await driverRemoteConnection.SubmitAsync<object, object>(SomeValidGremlinLang);
logger.VerifyNothingWasLogged();
}
@@ -76,20 +76,20 @@ public class DriverRemoteConnectionTests
using var gremlinClient =
new GremlinClient(new GremlinServer(TestHost, TestPort), loggerFactory: loggerFactory);
var driverRemoteConnection = new DriverRemoteConnection(gremlinClient);
- var bytecodeToLog = SomeValidBytecode;
+ var gremlinLangToLog = SomeValidGremlinLang;
- await driverRemoteConnection.SubmitAsync<object, object>(SomeValidBytecode);
+ await driverRemoteConnection.SubmitAsync<object, object>(SomeValidGremlinLang);
- logger.VerifyMessageWasLogged(LogLevel.Debug, bytecodeToLog.ToString());
+ logger.VerifyMessageWasLogged(LogLevel.Debug, gremlinLangToLog.ToString());
}
- private static Bytecode SomeValidBytecode
+ private static GremlinLang SomeValidGremlinLang
{
get
{
- var bytecode = new Bytecode();
- bytecode.StepInstructions.Add(new Instruction("inject", 1, 2));
- return bytecode;
+ var gremlinLang = new GremlinLang();
+ gremlinLang.AddStep("inject", 1, 2);
+ return gremlinLang;
}
}
}
\ No newline at end of file
diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/Gremlin.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/Gremlin.cs
index 98770fb3e8..94b48735d2 100644
--- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/Gremlin.cs
+++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/Gremlin.cs
@@ -2109,7 +2109,7 @@ namespace Gremlin.Net.IntegrationTest.Gherkin
ITraversal traversal = f.Invoke(g, parameters);
foreach (var sideEffect in sideEffects)
{
- traversal.Bytecode.AddSource("withSideEffect", sideEffect.Key, sideEffect.Value);
+ traversal.GremlinLang.AddSource("withSideEffect", sideEffect.Key, sideEffect.Value);
}
return traversal;
}
diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/IgnoreException.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/IgnoreException.cs
index 4203dabfc9..232931a5c2 100644
--- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/IgnoreException.cs
+++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/IgnoreException.cs
@@ -70,7 +70,7 @@ namespace Gremlin.Net.IntegrationTest.Gherkin
/// <summary>
/// tree() is not supported yet
/// </summary>
- TreeStepNotSupported
+ TreeStepNotSupported,
/// <summary>
/// write() is not supported yet for testing
diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Remote/RemoteStrategyTests.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Remote/RemoteStrategyTests.cs
index 33b4ab4889..41060908e2 100644
--- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Remote/RemoteStrategyTests.cs
+++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Remote/RemoteStrategyTests.cs
@@ -38,14 +38,14 @@ namespace Gremlin.Net.IntegrationTest.Process.Remote
private static readonly int TestPort = Convert.ToInt32(ConfigProvider.Configuration["TestServerPort"]);
[Fact]
- public void ShouldSendBytecodeToGremlinServer()
+ public void ShouldSendGremlinLangToGremlinServer()
{
const string expectedResult = "gremlin";
- var testBytecode = new Bytecode();
- testBytecode.AddStep("V");
- testBytecode.AddStep("has", "test");
- testBytecode.AddStep("inject", expectedResult);
- var testTraversal = CreateTraversalWithRemoteStrategy(testBytecode);
+ var gremlinLang = new GremlinLang();
+ gremlinLang.AddStep("V");
+ gremlinLang.AddStep("has", "test");
+ gremlinLang.AddStep("inject", expectedResult);
+ var testTraversal = CreateTraversalWithRemoteStrategy(gremlinLang);
var actualResult = testTraversal.Next();
@@ -53,47 +53,47 @@ namespace Gremlin.Net.IntegrationTest.Process.Remote
}
[Fact]
- public void ShouldThrowOriginalExceptionWhenByteCodeIsInvalid()
+ public void ShouldThrowOriginalExceptionWhenGremlinLangIsInvalid()
{
- var testBytecode = new Bytecode();
- testBytecode.AddStep("V");
- testBytecode.AddStep("this_step_does_not_exist", "test");
- var testTraversal = CreateTraversalWithRemoteStrategy(testBytecode);
+ var gremlinLang = new GremlinLang();
+ gremlinLang.AddStep("V");
+ gremlinLang.AddStep("this_step_does_not_exist", "test");
+ var testTraversal = CreateTraversalWithRemoteStrategy(gremlinLang);
Assert.Throws<ResponseException>(() => testTraversal.Next());
}
[Fact]
- public async Task ShouldSendBytecodeToGremlinServerAsynchronouslyForTraversalPromise()
+ public async Task ShouldSendGremlinLangToGremlinServerAsynchronouslyForTraversalPromise()
{
const string expectedResult = "gremlin";
- var testBytecode = new Bytecode();
- testBytecode.AddStep("V");
- testBytecode.AddStep("has", "test");
- testBytecode.AddStep("inject", expectedResult);
- var testTraversal = CreateTraversalWithRemoteStrategy(testBytecode);
+ var gremlinLang = new GremlinLang();
+ gremlinLang.AddStep("V");
+ gremlinLang.AddStep("has", "test");
+ gremlinLang.AddStep("inject", expectedResult);
+ var testTraversal = CreateTraversalWithRemoteStrategy(gremlinLang);
var actualResult = await testTraversal.Promise(t => t.Next());
Assert.Equal(expectedResult, actualResult);
}
- private DefaultTraversal<object, object> CreateTraversalWithRemoteStrategy(Bytecode bytecode)
+ private DefaultTraversal<object, object> CreateTraversalWithRemoteStrategy(GremlinLang gremlinLang)
{
var remoteStrategy =
new RemoteStrategy(new DriverRemoteConnection(new GremlinClient(new GremlinServer(TestHost, TestPort))));
- return new TestTraversal(remoteStrategy, bytecode);
+ return new TestTraversal(remoteStrategy, gremlinLang);
}
}
internal class TestTraversal : DefaultTraversal<object, object>
{
- public TestTraversal(ITraversalStrategy traversalStrategy, Bytecode bytecode)
+ public TestTraversal(ITraversalStrategy traversalStrategy, GremlinLang gremlinLang)
{
TraversalStrategies.Add(traversalStrategy);
- Bytecode = bytecode;
+ GremlinLang = gremlinLang;
}
- public override Bytecode Bytecode { get; }
+ public override GremlinLang GremlinLang { get; }
}
-}
\ No newline at end of file
+}
diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/BytecodeGeneration/BytecodeGenerationTests.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/BytecodeGeneration/BytecodeGenerationTests.cs
deleted file mode 100644
index a00a3eef36..0000000000
--- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/BytecodeGeneration/BytecodeGenerationTests.cs
+++ /dev/null
@@ -1,116 +0,0 @@
-#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 Gremlin.Net.Process.Traversal;
-using Xunit;
-
-namespace Gremlin.Net.IntegrationTest.Process.Traversal.BytecodeGeneration
-{
- public class BytecodeGenerationTests
- {
- [Fact]
- public void GraphTraversalStepsShouldUnrollParamsParameters()
- {
- var g = AnonymousTraversalSource.Traversal().With(null);
-
- var bytecode = g.V().HasLabel("firstLabel", "secondLabel", "thirdLabel").Bytecode;
-
- Assert.Empty(bytecode.SourceInstructions);
- Assert.Equal(2, bytecode.StepInstructions.Count);
- Assert.Equal(3, bytecode.StepInstructions[1].Arguments.Length);
- }
-
- [Fact]
- public void g_V_OutXcreatedX()
- {
- var g = AnonymousTraversalSource.Traversal().With(null);
-
- var bytecode = g.V().Out("created").Bytecode;
-
- Assert.Empty(bytecode.SourceInstructions);
- Assert.Equal(2, bytecode.StepInstructions.Count);
- Assert.Equal("V", bytecode.StepInstructions[0].OperatorName);
- Assert.Equal("out", bytecode.StepInstructions[1].OperatorName);
- Assert.Equal("created", bytecode.StepInstructions[1].Arguments[0]);
- Assert.Single(bytecode.StepInstructions[1].Arguments);
- }
-
- [Fact]
- public void g_WithSackX1X_E_GroupCount_ByXweightX()
- {
- var g = AnonymousTraversalSource.Traversal().With(null);
-
- var bytecode = g.WithSack(1).E().GroupCount<double>().By("weight").Bytecode;
-
- Assert.Single(bytecode.SourceInstructions);
- Assert.Equal("withSack", bytecode.SourceInstructions[0].OperatorName);
- Assert.Equal(1, bytecode.SourceInstructions[0].Arguments[0]);
- Assert.Equal(3, bytecode.StepInstructions.Count);
- Assert.Equal("E", bytecode.StepInstructions[0].OperatorName);
- Assert.Equal("groupCount", bytecode.StepInstructions[1].OperatorName);
- Assert.Equal("by", bytecode.StepInstructions[2].OperatorName);
- Assert.Equal("weight", bytecode.StepInstructions[2].Arguments[0]);
- Assert.Empty(bytecode.StepInstructions[0].Arguments);
- Assert.Empty(bytecode.StepInstructions[1].Arguments);
- Assert.Single(bytecode.StepInstructions[2].Arguments);
- }
-
- [Fact]
- public void g_InjectX1_2_3X()
- {
- var g = AnonymousTraversalSource.Traversal().With(null);
-
- var bytecode = g.Inject(1, 2, 3).Bytecode;
-
- Assert.Single(bytecode.StepInstructions);
- Assert.Equal("inject", bytecode.StepInstructions[0].OperatorName);
- Assert.Equal(3, bytecode.StepInstructions[0].Arguments.Length);
- }
-
- [Fact]
- public void AnonymousTraversal_Start_EmptyBytecode()
- {
- var bytecode = __.Start().Bytecode;
-
- Assert.Empty(bytecode.SourceInstructions);
- Assert.Empty(bytecode.StepInstructions);
- }
-
- [Fact]
- public void AnonymousTraversal_VXnullX()
- {
- var bytecode = __.V(null).Bytecode;
-
- Assert.Single(bytecode.StepInstructions);
- Assert.Single(bytecode.StepInstructions[0].Arguments);
- Assert.Null(bytecode.StepInstructions[0].Arguments[0]);
- }
-
- [Fact]
- public void AnonymousTraversal_OutXnullX()
- {
- Assert.Throws<ArgumentNullException>(() => __.Out(null!));
- }
- }
-}
\ No newline at end of file
diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/BytecodeGeneration/StrategiesTests.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/BytecodeGeneration/StrategiesTests.cs
deleted file mode 100644
index 85c2abc625..0000000000
--- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/BytecodeGeneration/StrategiesTests.cs
+++ /dev/null
@@ -1,162 +0,0 @@
-#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.Collections.Generic;
-using Gremlin.Net.Process.Traversal;
-using Gremlin.Net.Process.Traversal.Strategy.Decoration;
-using Gremlin.Net.Process.Traversal.Strategy.Finalization;
-using Gremlin.Net.Process.Traversal.Strategy.Optimization;
-using Gremlin.Net.Process.Traversal.Strategy.Verification;
-using Xunit;
-
-namespace Gremlin.Net.IntegrationTest.Process.Traversal.BytecodeGeneration
-{
- public class StrategiesTests
- {
- [Fact]
- public void TraversalWithoutStrategies_AfterWithStrategiesWasCalled_WithStrategiesNotAffected()
- {
- var g = new GraphTraversalSource().WithStrategies(new ReadOnlyStrategy(), new IncidentToAdjacentStrategy());
-
- var bytecode = g.WithoutStrategies(typeof(ReadOnlyStrategy)).Bytecode;
-
- Assert.Equal(2, bytecode.SourceInstructions.Count);
- Assert.Equal("withStrategies", bytecode.SourceInstructions[0].OperatorName);
- Assert.Equal(2, bytecode.SourceInstructions[0].Arguments.Length);
- Assert.Equal(new ReadOnlyStrategy(), bytecode.SourceInstructions[0].Arguments[0]);
- Assert.Equal(new IncidentToAdjacentStrategy(), bytecode.SourceInstructions[0].Arguments[1]);
-
- Assert.Equal("withoutStrategies", bytecode.SourceInstructions[1].OperatorName);
- Assert.Single(bytecode.SourceInstructions[1].Arguments);
- Assert.Equal(typeof(ReadOnlyStrategy), bytecode.SourceInstructions[1].Arguments[0]);
- }
-
- [Fact]
- public void ShouldIncludeMultipleStrategiesInBytecodeWhenGivenToWithoutStrategies()
- {
- var g = new GraphTraversalSource();
-
- var bytecode = g.WithoutStrategies(typeof(ReadOnlyStrategy), typeof(LazyBarrierStrategy)).Bytecode;
-
- Assert.Single(bytecode.SourceInstructions);
- Assert.Equal(2, bytecode.SourceInstructions[0].Arguments.Length);
- Assert.Equal("withoutStrategies", bytecode.SourceInstructions[0].OperatorName);
- Assert.Equal(typeof(ReadOnlyStrategy), bytecode.SourceInstructions[0].Arguments[0]);
- Assert.Equal(typeof(LazyBarrierStrategy), bytecode.SourceInstructions[0].Arguments[1]);
- }
-
- [Fact]
- public void ShouldIncludeOneStrategyInBytecodeWhenGivenToWithoutStrategies()
- {
- var g = new GraphTraversalSource();
-
- var bytecode = g.WithoutStrategies(typeof(ReadOnlyStrategy)).Bytecode;
-
- Assert.Single(bytecode.SourceInstructions);
- Assert.Single(bytecode.SourceInstructions[0].Arguments);
- Assert.Equal("withoutStrategies", bytecode.SourceInstructions[0].OperatorName);
- Assert.Equal(typeof(ReadOnlyStrategy), bytecode.SourceInstructions[0].Arguments[0]);
- }
-
- [Fact]
- public void ShouldIncludeConfigurationInBytecodeWhenGivenToWithStrategies()
- {
- var g = new GraphTraversalSource();
-
- var bytecode = g.WithStrategies(new MatchAlgorithmStrategy("greedy")).Bytecode;
-
- Assert.Single(bytecode.SourceInstructions);
- Assert.Single(bytecode.SourceInstructions[0].Arguments);
- Assert.Equal("withStrategies", bytecode.SourceInstructions[0].OperatorName);
- Assert.Equal(new MatchAlgorithmStrategy(), bytecode.SourceInstructions[0].Arguments[0]);
- Assert.Contains("greedy",
- ((MatchAlgorithmStrategy) bytecode.SourceInstructions[0].Arguments[0]!).Configuration.Values);
- }
-
- [Fact]
- public void ShouldIncludeMultipleStrategiesInBytecodeWhenGivenToWithStrategies()
- {
- var g = new GraphTraversalSource();
-
- var bytecode = g.WithStrategies(new ReadOnlyStrategy(), new IncidentToAdjacentStrategy()).Bytecode;
-
- Assert.Single(bytecode.SourceInstructions);
- Assert.Equal(2, bytecode.SourceInstructions[0].Arguments.Length);
- Assert.Equal("withStrategies", bytecode.SourceInstructions[0].OperatorName);
- Assert.Equal(new ReadOnlyStrategy(), bytecode.SourceInstructions[0].Arguments[0]);
- Assert.Equal(new IncidentToAdjacentStrategy(), bytecode.SourceInstructions[0].Arguments[1]);
- }
-
- [Fact]
- public void ShouldIncludeOneStrategyInBytecodeWhenGivenToWithStrategies()
- {
- var g = new GraphTraversalSource();
-
- var bytecode = g.WithStrategies(new ReadOnlyStrategy()).Bytecode;
-
- Assert.Single(bytecode.SourceInstructions);
- Assert.Single(bytecode.SourceInstructions[0].Arguments);
- Assert.Equal("withStrategies", bytecode.SourceInstructions[0].OperatorName);
- Assert.Equal(new ReadOnlyStrategy(), bytecode.SourceInstructions[0].Arguments[0]);
- Assert.Equal("ReadOnlyStrategy", bytecode.SourceInstructions[0].Arguments[0]!.ToString());
- Assert.Equal(new ReadOnlyStrategy().GetHashCode(),
- bytecode.SourceInstructions[0].Arguments[0]!.GetHashCode());
- Assert.Equal(0, g.TraversalStrategies.Count);
- }
-
- [Fact]
- public void TraversalWithStrategies_Strategies_ApplyToReusedGraphTraversalSource()
- {
- var g = new GraphTraversalSource().WithStrategies(new ReadOnlyStrategy(), new IncidentToAdjacentStrategy());
-
- var bytecode = g.V().Bytecode;
-
- Assert.Single(bytecode.SourceInstructions);
- Assert.Equal(2, bytecode.SourceInstructions[0].Arguments.Length);
- Assert.Equal("withStrategies", bytecode.SourceInstructions[0].OperatorName);
- Assert.Equal(new ReadOnlyStrategy(), bytecode.SourceInstructions[0].Arguments[0]);
- Assert.Equal(new IncidentToAdjacentStrategy(), bytecode.SourceInstructions[0].Arguments[1]);
- Assert.Single(bytecode.StepInstructions);
- Assert.Equal("V", bytecode.StepInstructions[0].OperatorName);
- }
-
- [Fact]
- public void TraversalWithStrategies_StrategyWithTraversalInConfig_IncludeTraversalInInConfigInBytecode()
- {
- var g = new GraphTraversalSource();
-
- var bytecode = g.WithStrategies(new SubgraphStrategy(__.Has("name", "marko"), checkAdjacentVertices: false)).Bytecode;
-
- Assert.Single(bytecode.SourceInstructions);
- Assert.Single(bytecode.SourceInstructions[0].Arguments);
- Assert.Equal("withStrategies", bytecode.SourceInstructions[0].OperatorName);
- Assert.Equal(new SubgraphStrategy(), bytecode.SourceInstructions[0].Arguments[0]);
- SubgraphStrategy strategy = bytecode.SourceInstructions[0].Arguments[0]!;
- Assert.Equal(typeof(GraphTraversal<object, object>), strategy.Configuration["vertices"]!.GetType());
- ITraversal traversal = strategy.Configuration["vertices"]!;
- Assert.Equal("has", traversal.Bytecode.StepInstructions[0].OperatorName);
- Assert.Equal(new List<string> {"name", "marko"}, traversal.Bytecode.StepInstructions[0].Arguments);
- Assert.Equal(false, strategy.Configuration["checkAdjacentVertices"]);
- }
- }
-}
\ No newline at end of file
diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/DriverRemoteConnection/GraphTraversalTests.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/DriverRemoteConnection/GraphTraversalTests.cs
index c939ac900f..bfcda7f824 100644
--- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/DriverRemoteConnection/GraphTraversalTests.cs
+++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/DriverRemoteConnection/GraphTraversalTests.cs
@@ -56,8 +56,7 @@ namespace Gremlin.Net.IntegrationTest.Process.Traversal.DriverRemoteConnection
var connection = _connectionFactory.CreateRemoteConnection();
var g = AnonymousTraversalSource.Traversal().With(connection);
- var b = Bindings.Instance;
- var count = g.V().Has("person", "age", b.Of("x", P.Lt(30))).Count().Next();
+ var count = g.V().Has("person", "age", P.Lt(30)).Count().Next();
Assert.Equal(2, count);
}
@@ -191,13 +190,12 @@ namespace Gremlin.Net.IntegrationTest.Process.Traversal.DriverRemoteConnection
}
[Fact]
- public void ShouldUseBindingsInTraversal()
+ public void ShouldUseParametersInTraversal()
{
var connection = _connectionFactory.CreateRemoteConnection();
var g = AnonymousTraversalSource.Traversal().With(connection);
- var b = new Bindings();
- var count = g.V().Has(b.Of("propertyKey", "name"), b.Of("propertyValue", "marko")).OutE().Count().Next();
+ var count = g.V().Has("name", "marko").OutE().Count().Next();
Assert.Equal(3, count);
}
diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/GremlinLangGeneration/GremlinLangGenerationTests.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/GremlinLangGeneration/GremlinLangGenerationTests.cs
new file mode 100644
index 0000000000..e1c01a9ef2
--- /dev/null
+++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/GremlinLangGeneration/GremlinLangGenerationTests.cs
@@ -0,0 +1,94 @@
+#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 Gremlin.Net.Process.Traversal;
+using Xunit;
+
+namespace Gremlin.Net.IntegrationTest.Process.Traversal.GremlinLangGeneration
+{
+ public class GremlinLangGenerationTests
+ {
+ [Fact]
+ public void GraphTraversalStepsShouldUnrollParamsParameters()
+ {
+ var g = AnonymousTraversalSource.Traversal().With(null);
+
+ var gremlin = g.V().HasLabel("firstLabel", "secondLabel", "thirdLabel").GremlinLang.GetGremlin();
+
+ Assert.Equal("g.V().hasLabel(\"firstLabel\",\"secondLabel\",\"thirdLabel\")", gremlin);
+ }
+
+ [Fact]
+ public void g_V_OutXcreatedX()
+ {
+ var g = AnonymousTraversalSource.Traversal().With(null);
+
+ var gremlin = g.V().Out("created").GremlinLang.GetGremlin();
+
+ Assert.Equal("g.V().out(\"created\")", gremlin);
+ }
+
+ [Fact]
+ public void g_WithSackX1X_E_GroupCount_ByXweightX()
+ {
+ var g = AnonymousTraversalSource.Traversal().With(null);
+
+ var gremlin = g.WithSack(1).E().GroupCount<double>().By("weight").GremlinLang.GetGremlin();
+
+ Assert.Equal("g.withSack(1).E().groupCount().by(\"weight\")", gremlin);
+ }
+
+ [Fact]
+ public void g_InjectX1_2_3X()
+ {
+ var g = AnonymousTraversalSource.Traversal().With(null);
+
+ var gremlin = g.Inject(1, 2, 3).GremlinLang.GetGremlin();
+
+ Assert.Equal("g.inject(1,2,3)", gremlin);
+ }
+
+ [Fact]
+ public void AnonymousTraversal_Start_EmptyGremlinLang()
+ {
+ var gremlinLang = __.Start().GremlinLang;
+
+ Assert.True(gremlinLang.IsEmpty);
+ }
+
+ [Fact]
+ public void AnonymousTraversal_VXnullX()
+ {
+ var gremlin = __.V(null).GremlinLang.GetGremlin();
+
+ Assert.Contains(".V(null)", gremlin);
+ }
+
+ [Fact]
+ public void AnonymousTraversal_OutXnullX()
+ {
+ Assert.Throws<ArgumentNullException>(() => __.Out(null!));
+ }
+ }
+}
diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/GremlinLangGeneration/StrategiesTests.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/GremlinLangGeneration/StrategiesTests.cs
new file mode 100644
index 0000000000..528ed25df9
--- /dev/null
+++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/GremlinLangGeneration/StrategiesTests.cs
@@ -0,0 +1,121 @@
+#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 Gremlin.Net.Process.Traversal;
+using Gremlin.Net.Process.Traversal.Strategy.Decoration;
+using Gremlin.Net.Process.Traversal.Strategy.Finalization;
+using Gremlin.Net.Process.Traversal.Strategy.Optimization;
+using Gremlin.Net.Process.Traversal.Strategy.Verification;
+using Xunit;
+
+namespace Gremlin.Net.IntegrationTest.Process.Traversal.GremlinLangGeneration
+{
+ public class StrategiesTests
+ {
+ [Fact]
+ public void TraversalWithoutStrategies_AfterWithStrategiesWasCalled_WithStrategiesNotAffected()
+ {
+ var g = new GraphTraversalSource().WithStrategies(new ReadOnlyStrategy(), new IncidentToAdjacentStrategy());
+
+ var gremlin = g.WithoutStrategies(typeof(ReadOnlyStrategy)).GremlinLang.GetGremlin();
+
+ Assert.Contains("withStrategies(", gremlin);
+ Assert.Contains("withoutStrategies(", gremlin);
+ }
+
+ [Fact]
+ public void ShouldIncludeMultipleStrategiesInGremlinLangWhenGivenToWithoutStrategies()
+ {
+ var g = new GraphTraversalSource();
+
+ var gremlin = g.WithoutStrategies(typeof(ReadOnlyStrategy), typeof(LazyBarrierStrategy)).GremlinLang.GetGremlin();
+
+ Assert.Contains("withoutStrategies(", gremlin);
+ Assert.Contains("ReadOnlyStrategy", gremlin);
+ Assert.Contains("LazyBarrierStrategy", gremlin);
+ }
+
+ [Fact]
+ public void ShouldIncludeOneStrategyInGremlinLangWhenGivenToWithoutStrategies()
+ {
+ var g = new GraphTraversalSource();
+
+ var gremlin = g.WithoutStrategies(typeof(ReadOnlyStrategy)).GremlinLang.GetGremlin();
+
+ Assert.Contains("withoutStrategies(", gremlin);
+ Assert.Contains("ReadOnlyStrategy", gremlin);
+ }
+
+ [Fact]
+ public void ShouldIncludeConfigurationInGremlinLangWhenGivenToWithStrategies()
+ {
+ var g = new GraphTraversalSource();
+
+ var gremlin = g.WithStrategies(new MatchAlgorithmStrategy("greedy")).GremlinLang.GetGremlin();
+
+ Assert.Contains("withStrategies(", gremlin);
+ }
+
+ [Fact]
+ public void ShouldIncludeMultipleStrategiesInGremlinLangWhenGivenToWithStrategies()
+ {
+ var g = new GraphTraversalSource();
+
+ var gremlin = g.WithStrategies(new ReadOnlyStrategy(), new IncidentToAdjacentStrategy()).GremlinLang.GetGremlin();
+
+ Assert.Contains("withStrategies(", gremlin);
+ }
+
+ [Fact]
+ public void ShouldIncludeOneStrategyInGremlinLangWhenGivenToWithStrategies()
+ {
+ var g = new GraphTraversalSource();
+
+ var gremlin = g.WithStrategies(new ReadOnlyStrategy()).GremlinLang.GetGremlin();
+
+ Assert.Contains("withStrategies(", gremlin);
+ Assert.Equal(0, g.TraversalStrategies.Count);
+ }
+
+ [Fact]
+ public void TraversalWithStrategies_Strategies_ApplyToReusedGraphTraversalSource()
+ {
+ var g = new GraphTraversalSource().WithStrategies(new ReadOnlyStrategy(), new IncidentToAdjacentStrategy());
+
+ var gremlin = g.V().GremlinLang.GetGremlin();
+
+ Assert.Contains("withStrategies(", gremlin);
+ Assert.Contains(".V()", gremlin);
+ }
+
+ [Fact]
+ public void TraversalWithStrategies_StrategyWithTraversalInConfig_IncludeTraversalInGremlinLang()
+ {
+ var g = new GraphTraversalSource();
+
+ var gremlin = g.WithStrategies(new SubgraphStrategy(__.Has("name", "marko"), checkAdjacentVertices: false)).GremlinLang.GetGremlin();
+
+ Assert.Contains("withStrategies(", gremlin);
+ }
+ }
+}
diff --git a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/BytecodeTests.cs b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/BytecodeTests.cs
deleted file mode 100644
index 1f91af649a..0000000000
--- a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/BytecodeTests.cs
+++ /dev/null
@@ -1,190 +0,0 @@
-#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.Collections;
-using System.Collections.Generic;
-using System.Linq;
-using Gremlin.Net.Process.Traversal;
-using Xunit;
-
-namespace Gremlin.Net.UnitTest.Process.Traversal
-{
- public class BytecodeTests
- {
- [Fact]
- public void ShouldUseBingingsForSimpleValueInStepArgument()
- {
- var bytecode = new Bytecode();
- var bindings = Bindings.Instance;
-
- bytecode.AddStep("hasLabel", bindings.Of("label", "testvalue"));
-
- Assert.Equal(new Binding("label", "testvalue"), bytecode.StepInstructions[0].Arguments[0]);
- }
-
- [Fact]
- public void ShouldUseBindingsInsideArrayInStepArgument()
- {
- var bytecode = new Bytecode();
- var b = Bindings.Instance;
-
- bytecode.AddStep("someStep", "test", new[] {b.Of("arrayVariable", "arrayValue")});
-
- Assert.Equal(new Binding("arrayVariable", "arrayValue"), bytecode.StepInstructions[0].Arguments[1]);
- }
-
- [Fact]
- public void ShouldUseBindingsInsideDictionaryValuesInStepArgument()
- {
- var bytecode = new Bytecode();
- var b = Bindings.Instance;
-
- bytecode.AddStep("someStep", new Dictionary<string, object> {{"someKey", b.Of("valVariable", "valValue")}});
-
- var arg = bytecode.StepInstructions[0].Arguments[0] as IDictionary;
- Assert.Equal(new Binding("valVariable", "valValue"), arg!["someKey"]);
- }
-
- [Fact]
- public void ShouldUseBindingsInsideDictionaryKeysInStepArgument()
- {
- var bytecode = new Bytecode();
- var b = Bindings.Instance;
-
- bytecode.AddStep("someStep", new Dictionary<string, object> {{b.Of("keyVariable", "keyValue"), 1234}});
-
- var arg = bytecode.StepInstructions[0].Arguments[0];
- var binding = ((Dictionary<object, object>) arg!).Keys.First() as Binding;
- Assert.Equal(new Binding("keyVariable", "keyValue"), binding);
- }
-
- [Fact]
- public void ShouldUseBindingsInsideListInStepArgument()
- {
- var bytecode = new Bytecode();
- var b = Bindings.Instance;
-
- bytecode.AddStep("someStep", new List<string> {"test", b.Of("listVariable", "listValue")});
-
- var arg = bytecode.StepInstructions[0].Arguments[0] as IList;
- Assert.Equal(new Binding("listVariable", "listValue"), arg![1]);
- }
-
- [Fact]
- public void ShouldUseBindingsInsideHashSetInStepArgument()
- {
- var bytecode = new Bytecode();
- var b = Bindings.Instance;
-
- bytecode.AddStep("someStep", new HashSet<string> { "test", b.Of("setVariable", "setValue") });
-
- var arg = bytecode.StepInstructions[0].Arguments[0] as ISet<object>;
- Assert.Equal(new Binding("setVariable", "setValue"), arg!.ToList()[1]);
- }
-
- [Fact]
- public void ShouldUseBingingsForSimpleValueInSourceArgument()
- {
- var bytecode = new Bytecode();
- var bindings = Bindings.Instance;
-
- bytecode.AddSource("hasLabel", bindings.Of("label", "testvalue"));
-
- Assert.Equal(new Binding("label", "testvalue"), bytecode.SourceInstructions[0].Arguments[0]);
- }
-
- [Fact]
- public void ShouldUseBindingsInsideArrayInSourceArgument()
- {
- var bytecode = new Bytecode();
- var b = Bindings.Instance;
-
- bytecode.AddSource("someSource", "test", new[] { b.Of("arrayVariable", "arrayValue") });
-
- Assert.Equal(new Binding("arrayVariable", "arrayValue"), bytecode.SourceInstructions[0].Arguments[1]);
- }
-
- [Fact]
- public void ShouldUseBindingsInsideDictionaryValuesInSourceArgument()
- {
- var bytecode = new Bytecode();
- var b = Bindings.Instance;
-
- bytecode.AddSource("someSource", new Dictionary<string, object> { { "someKey", b.Of("valVariable", "valValue") } });
-
- var arg = bytecode.SourceInstructions[0].Arguments[0] as IDictionary;
- Assert.Equal(new Binding("valVariable", "valValue"), arg!["someKey"]);
- }
-
- [Fact]
- public void ShouldUseBindingsInsideDictionaryKeysInSourceArgument()
- {
- var bytecode = new Bytecode();
- var b = Bindings.Instance;
-
- bytecode.AddSource("someSource", new Dictionary<string, object> { { b.Of("keyVariable", "keyValue"), 1234 } });
-
- var arg = bytecode.SourceInstructions[0].Arguments[0];
- var binding = ((Dictionary<object, object>)arg!).Keys.First() as Binding;
- Assert.Equal(new Binding("keyVariable", "keyValue"), binding);
- }
-
- [Fact]
- public void ShouldUseBindingsInsideListInSourceArgument()
- {
- var bytecode = new Bytecode();
- var b = Bindings.Instance;
-
- bytecode.AddSource("someSource", new List<string> { "test", b.Of("listVariable", "listValue") });
-
- var arg = bytecode.SourceInstructions[0].Arguments[0] as IList;
- Assert.Equal(new Binding("listVariable", "listValue"), arg![1]);
- }
-
- [Fact]
- public void ShouldUseBindingsInsideHashSetInSourceArgument()
- {
- var bytecode = new Bytecode();
- var b = Bindings.Instance;
-
- bytecode.AddSource("someSource", new HashSet<string> { "test", b.Of("setVariable", "setValue") });
-
- var arg = bytecode.SourceInstructions[0].Arguments[0] as ISet<object>;
- Assert.Equal(new Binding("setVariable", "setValue"), arg!.ToList()[1]);
- }
-
- [Fact]
- public void ShouldIncludeStepAndSourceInstructionsForToString()
- {
- var bytecode = new Bytecode();
- bytecode.AddSource("source", 1, 2);
- bytecode.AddStep("step1", 9, 8);
- bytecode.AddStep("step2", 0);
- bytecode.AddStep("step3", 0, null, 0d);
- bytecode.AddStep("step4", "0), stepX(\"hello\"");
-
- Assert.Equal("[[source(1, 2)], [step1(9, 8), step2(0), step3(0, null, 0), step4(0), stepX(\"hello\")]]",
- bytecode.ToString());
- }
- }
-}
\ No newline at end of file
diff --git a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/GraphTraversalSourceTests.cs b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/GraphTraversalSourceTests.cs
index 9756967783..6acc99c08e 100644
--- a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/GraphTraversalSourceTests.cs
+++ b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/GraphTraversalSourceTests.cs
@@ -32,46 +32,45 @@ namespace Gremlin.Net.UnitTest.Process.Traversal
public class GraphTraversalSourceTests
{
[Fact]
- public void ShouldBeIndependentFromReturnedGraphTraversalModifyingBytecode()
+ public void ShouldBeIndependentFromReturnedGraphTraversal()
{
var g = AnonymousTraversalSource.Traversal().With(null);
g.V().Has("someKey", "someValue").Drop();
- Assert.Empty(g.Bytecode.StepInstructions);
- Assert.Empty(g.Bytecode.SourceInstructions);
+ Assert.True(g.GremlinLang.IsEmpty);
}
[Fact]
- public void ShouldBeIndependentFromReturnedGraphTraversalSourceModifyingBytecode()
+ public void ShouldBeIndependentFromReturnedGraphTraversalSource()
{
var g1 = AnonymousTraversalSource.Traversal().With(null);
var g2 = g1.WithSideEffect("someSideEffectKey", "someSideEffectValue");
- Assert.Empty(g1.Bytecode.SourceInstructions);
- Assert.Empty(g1.Bytecode.StepInstructions);
- Assert.Single(g2.Bytecode.SourceInstructions);
+ Assert.True(g1.GremlinLang.IsEmpty);
+ Assert.False(g2.GremlinLang.IsEmpty);
}
[Fact]
- public void CloneShouldCreateIndependentGraphTraversalModifyingBytecode()
+ public void CloneShouldCreateIndependentGraphTraversal()
{
+ GremlinLang.ResetCounter();
var g = AnonymousTraversalSource.Traversal().With(null);
var original = g.V().Out("created");
var clone = original.Clone().Out("knows");
var cloneClone = clone.Clone().Out("created");
- Assert.Equal(2, original.Bytecode.StepInstructions.Count);
- Assert.Equal(3, clone.Bytecode.StepInstructions.Count);
- Assert.Equal(4, cloneClone.Bytecode.StepInstructions.Count);
+ Assert.Equal("g.V().out(\"created\")", original.GremlinLang.GetGremlin());
+ Assert.Equal("g.V().out(\"created\").out(\"knows\")", clone.GremlinLang.GetGremlin());
+ Assert.Equal("g.V().out(\"created\").out(\"knows\").out(\"created\")", cloneClone.GremlinLang.GetGremlin());
original.Has("person", "name", "marko");
clone.V().Out();
- Assert.Equal(3, original.Bytecode.StepInstructions.Count);
- Assert.Equal(5, clone.Bytecode.StepInstructions.Count);
- Assert.Equal(4, cloneClone.Bytecode.StepInstructions.Count);
+ Assert.Equal("g.V().out(\"created\").has(\"person\",\"name\",\"marko\")", original.GremlinLang.GetGremlin());
+ Assert.Equal("g.V().out(\"created\").out(\"knows\").V().out()", clone.GremlinLang.GetGremlin());
+ Assert.Equal("g.V().out(\"created\").out(\"knows\").out(\"created\")", cloneClone.GremlinLang.GetGremlin());
}
[Fact]
@@ -81,7 +80,7 @@ namespace Gremlin.Net.UnitTest.Process.Traversal
g.V(0).AddE("self").To(__.V(1));
- Assert.Throws<ArgumentException>(() => g.V(0).AddE("self").To(g.V(1)));
+ Assert.Throws<InvalidOperationException>(() => g.V(0).AddE("self").To(g.V(1)));
}
}
-}
\ No newline at end of file
+}
diff --git a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/GremlinLangTests.cs b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/GremlinLangTests.cs
new file mode 100644
index 0000000000..f1a78c1ae2
--- /dev/null
+++ b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/GremlinLangTests.cs
@@ -0,0 +1,1045 @@
+#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;
+using System.Numerics;
+using Gremlin.Net.Process.Traversal;
+using Gremlin.Net.Process.Traversal.Strategy.Decoration;
+using Gremlin.Net.Process.Traversal.Strategy.Verification;
+using Gremlin.Net.Structure;
+using Xunit;
+
+namespace Gremlin.Net.UnitTest.Process.Traversal
+{
+ public class GremlinLangTests : IDisposable
+ {
+ private readonly GraphTraversalSource _g;
+
+ public GremlinLangTests()
+ {
+ GremlinLang.ResetCounter();
+ _g = new GraphTraversalSource();
+ }
+
+ public void Dispose()
+ {
+ }
+
+ // --- Core Traversal Tests 1-30 ---
+
+ [Fact]
+ public void g_V()
+ {
+ Assert.Equal("g.V()", _g.V().GremlinLang.GetGremlin());
+ }
+
+ [Fact]
+ public void g_V_1234()
+ {
+ Assert.Equal("g.V(\"1\",\"2\",\"3\",\"4\")", _g.V("1", "2", "3", "4").GremlinLang.GetGremlin());
+ }
+
+ [Fact]
+ public void g_V_3_ValueMap_true()
+ {
+ Assert.Equal("g.V(\"3\").valueMap(true)", _g.V("3").ValueMap<object, object>(true).GremlinLang.GetGremlin());
+ }
+
+ [Fact]
+ public void g_V_Constant_5()
+ {
+ Assert.Equal("g.V().constant(5)", _g.V().Constant(5).GremlinLang.GetGremlin());
+ }
+
+ [Fact]
+ public void g_V_Constant_1_5()
+ {
+ Assert.Equal("g.V().constant(1.5D)", _g.V().Constant(1.5).GremlinLang.GetGremlin());
+ }
+
+ [Fact]
+ public void g_V_Constant_Hello()
+ {
+ Assert.Equal("g.V().constant(\"Hello\")", _g.V().Constant("Hello").GremlinLang.GetGremlin());
+ }
+
+ [Fact]
+ public void g_V_HasLabel_airport_Limit_5()
+ {
+ Assert.Equal("g.V().hasLabel(\"airport\").limit(5L)", _g.V().HasLabel("airport").Limit<object>(5).GremlinLang.GetGremlin());
+ }
+
+ [Fact]
+ public void g_V_HasLabel_P_Within()
+ {
+ Assert.Equal("g.V().hasLabel(within([\"a\",\"b\",\"c\"]))", _g.V().HasLabel(P.Within("a", "b", "c")).GremlinLang.GetGremlin());
+ }
+
+ [Fact]
+ public void g_V_HasLabel_airport_continent_Out_Limit_5()
+ {
+ Assert.Equal("g.V().hasLabel(\"airport\",\"continent\").out().limit(5L)",
+ _g.V().HasLabel("airport", "continent").Out().Limit<object>(5).GremlinLang.GetGremlin());
+ }
+
+ [Fact]
+ public void g_V_HasLabel_airport_Out_Values_code_Limit_5()
+ {
+ Assert.Equal("g.V().hasLabel(\"airport\").out().values(\"code\").limit(5L)",
+ _g.V().HasLabel("airport").Out().Values<object>("code").Limit<object>(5).GremlinLang.GetGremlin());
+ }
+
+ [Fact]
+ public void g_V_3_As_a_Out_route_Limit_10_Where_Eq_a_By_region()
+ {
+ Assert.Equal("g.V(\"3\").as(\"a\").out(\"route\").limit(10L).where(eq(\"a\")).by(\"region\")",
+ _g.V("3").As("a").Out("route").Limit<object>(10).Where(P.Eq("a")).By("region").GremlinLang.GetGremlin());
+ }
+
+ [Fact]
+ public void g_V_3_Repeat_Out_route_SimplePath_Times_2_Path_By_code()
+ {
+ Assert.Equal("g.V(\"3\").repeat(__.out(\"route\").simplePath()).times(2).path().by(\"code\")",
+ _g.V("3").Repeat(__.Out("route").SimplePath()).Times(2).Path().By("code").GremlinLang.GetGremlin());
+ }
+
+ [Fact]
+ public void g_V_HasLabel_airport_Out_Has_region_USTX_Values_code_Limit_5()
+ {
+ Assert.Equal("g.V().hasLabel(\"airport\").out().has(\"region\",\"US-TX\").values(\"code\").limit(5L)",
+ _g.V().HasLabel("airport").Out().Has("region", "US-TX").Values<object>("code").Limit<object>(5).GremlinLang.GetGremlin());
+ }
+
+ [Fact]
+ public void g_V_HasLabel_airport_Union_Values_city_Values_region_Limit_5()
+ {
+ Assert.Equal("g.V().hasLabel(\"airport\").union(__.values(\"city\"),__.values(\"region\")).limit(5L)",
+ _g.V().HasLabel("airport").Union<object>(__.Values<object>("city"), __.Values<object>("region")).Limit<object>(5).GremlinLang.GetGremlin());
+ }
+
+ [Fact]
+ public void g_V_3_As_a_Out_route_routes()
+ {
+ Assert.Equal("g.V(\"3\").as(\"a\").out(\"route\",\"routes\")",
+ _g.V("3").As("a").Out("route", "routes").GremlinLang.GetGremlin());
+ }
+
+ [Fact]
+ public void g_V_Where_Values_runways_Is_5()
+ {
+ Assert.Equal("g.V().where(__.values(\"runways\").is(5))",
+ _g.V().Where(__.Values<object>("runways").Is(5)).GremlinLang.GetGremlin());
+ }
+
+ [Fact]
+ public void g_V_3_Repeat_Out_SimplePath_Until_Has_code_AGR_Path_By_code_Limit_5()
+ {
+ Assert.Equal("g.V(\"3\").repeat(__.out().simplePath()).until(__.has(\"code\",\"AGR\")).path().by(\"code\").limit(5L)",
+ _g.V("3").Repeat(__.Out().SimplePath()).Until(__.Has("code", "AGR")).Path().By("code").Limit<object>(5).GremlinLang.GetGremlin());
+ }
+
+ [Fact]
+ public void g_V_HasLabel_airport_Order_By_Id()
+ {
+ Assert.Equal("g.V().hasLabel(\"airport\").order().by(__.id())",
+ _g.V().HasLabel("airport").Order().By(__.Id()).GremlinLang.GetGremlin());
+ }
+
+ [Fact]
+ public void g_V_HasLabel_airport_Order_By_T_Id()
+ {
+ Assert.Equal("g.V().hasLabel(\"airport\").order().by(T.id)",
+ _g.V().HasLabel("airport").Order().By(T.Id).GremlinLang.GetGremlin());
+ }
+
+ [Fact]
+ public void g_V_HasLabel_airport_Order_By_Id_Desc()
+ {
+ Assert.Equal("g.V().hasLabel(\"airport\").order().by(__.id(),Order.desc)",
+ _g.V().HasLabel("airport").Order().By(__.Id(), Order.Desc).GremlinLang.GetGremlin());
+ }
+
+ [Fact]
+ public void g_V_HasLabel_airport_Order_By_code_Desc()
+ {
+ Assert.Equal("g.V().hasLabel(\"airport\").order().by(\"code\",Order.desc)",
+ _g.V().HasLabel("airport").Order().By("code", Order.Desc).GremlinLang.GetGremlin());
+ }
+
+ [Fact]
+ public void g_V_123_Local_Out_Out_Dedup_Fold()
+ {
+ Assert.Equal("g.V(\"1\",\"2\",\"3\").local(__.out().out().dedup().fold())",
+ _g.V("1", "2", "3").Local<object>(__.Out().Out().Dedup().Fold()).GremlinLang.GetGremlin());
+ }
+
+ [Fact]
+ public void g_V_3_Out_Path_Count_Scope_Local()
+ {
+ Assert.Equal("g.V(\"3\").out().path().count(Scope.local)",
+ _g.V("3").Out().Path().Count(Scope.Local).GremlinLang.GetGremlin());
+ }
+
+ [Fact]
+ public void g_E_Count()
+ {
+ Assert.Equal("g.E().count()", _g.E().Count().GremlinLang.GetGremlin());
+ }
+
+ [Fact]
+ public void g_V_5_OutE_route_InV_Path_Limit_10()
+ {
+ Assert.Equal("g.V(\"5\").outE(\"route\").inV().path().limit(10L)",
+ _g.V("5").OutE("route").InV().Path().Limit<object>(10).GremlinLang.GetGremlin());
+ }
+
+ [Fact]
+ public void g_V_5_PropertyMap_Select_Column_Keys()
+ {
+ Assert.Equal("g.V(\"5\").propertyMap().select(Column.keys)",
+ _g.V("5").PropertyMap<object>().Select<object>(Column.Keys).GremlinLang.GetGremlin());
+ }
+
+ [Fact]
+ public void g_V_5_PropertyMap_Select_Column_Values()
+ {
+ Assert.Equal("g.V(\"5\").propertyMap().select(Column.values)",
+ _g.V("5").PropertyMap<object>().Select<object>(Column.Values).GremlinLang.GetGremlin());
+ }
+
+ [Fact]
+ public void g_V_3_Values_runways_Math()
+ {
+ Assert.Equal("g.V(\"3\").values(\"runways\").math(\"_ + 1\")",
+ _g.V("3").Values<object>("runways").Math("_ + 1").GremlinLang.GetGremlin());
+ }
+
+ [Fact]
+ public void g_V_3_Emit_Repeat_Out_SimplePath_Times_3_Limit_5_Path()
+ {
+ Assert.Equal("g.V(\"3\").emit().repeat(__.out().simplePath()).times(3).limit(5L).path()",
+ _g.V("3").Emit().Repeat(__.Out().SimplePath()).Times(3).Limit<object>(5).Path().GremlinLang.GetGremlin());
+ }
+
+ [Fact]
+ public void g_V_Match_As_a_Has_code_LHR_As_b_Select_b_By_code()
+ {
+ Assert.Equal("g.V().match(__.as(\"a\").has(\"code\",\"LHR\").as(\"b\")).select(\"b\").by(\"code\")",
+ _g.V().Match<object>(__.As("a").Has("code", "LHR").As("b")).Select<object>("b").By("code").GremlinLang.GetGremlin());
+ }
+
+ // --- Core Traversal Tests 31-60 ---
+
+ [Fact]
+ public void g_V_Has_keyword_property_repeat()
+ {
+ Assert.Equal("g.V().has(\"test-using-keyword-as-property\",\"repeat\")",
+ _g.V().Has("test-using-keyword-as-property", "repeat").GremlinLang.GetGremlin());
+ }
+
+ [Fact]
+ public void g_V_1_AddE_test_To_V_4()
+ {
+ Assert.Equal("g.V(\"1\").addE(\"test\").to(__.V(\"4\"))",
+ _g.V("1").AddE("test").To(__.V("4")).GremlinLang.GetGremlin());
+ }
+
+ [Fact]
+ public void g_V_Values_runways_Max()
+ {
+ Assert.Equal("g.V().values(\"runways\").max()",
+ _g.V().Values<object>("runways").Max<object>().GremlinLang.GetGremlin());
+ }
+
+ [Fact]
+ public void g_V_Values_runways_Min()
+ {
+ Assert.Equal("g.V().values(\"runways\").min()",
+ _g.V().Values<object>("runways").Min<object>().GremlinLang.GetGremlin());
+ }
+
+ [Fact]
+ public void g_V_Values_runways_Sum()
+ {
+ Assert.Equal("g.V().values(\"runways\").sum()",
+ _g.V().Values<object>("runways").Sum<object>().GremlinLang.GetGremlin());
+ }
+
+ [Fact]
+ public void g_V_Values_runways_Mean()
+ {
+ Assert.Equal("g.V().values(\"runways\").mean()",
+ _g.V().Values<object>("runways").Mean<object>().GremlinLang.GetGremlin());
+ }
+
+ [Fact]
+ public void g_WithSack_0_V_35_Sack_Operator_Sum_By_runways_Sack()
+ {
+ Assert.Equal("g.withSack(0).V(\"3\",\"5\").sack(Operator.sum).by(\"runways\").sack()",
+ _g.WithSack(0).V("3", "5").Sack(Operator.Sum).By("runways").Sack<object>().GremlinLang.GetGremlin());
+ }
+
+ [Fact]
+ public void g_Inject_3_4_5()
+ {
+ Assert.Equal("g.inject(3,4,5)", _g.Inject(3, 4, 5).GremlinLang.GetGremlin());
+ }
+
+ [Fact]
+ public void g_Inject_List_3_4_5()
+ {
+ Assert.Equal("g.inject([3,4,5])",
+ _g.Inject(new List<object> { 3, 4, 5 }).GremlinLang.GetGremlin());
+ }
+
+ [Fact]
+ public void g_Inject_3_4_5_Count()
+ {
+ Assert.Equal("g.inject(3,4,5).count()", _g.Inject(3, 4, 5).Count().GremlinLang.GetGremlin());
+ }
+
+ [Fact]
+ public void g_V_Has_runways_Gt_5_Count()
+ {
+ Assert.Equal("g.V().has(\"runways\",gt(5)).count()",
+ _g.V().Has("runways", P.Gt(5)).Count().GremlinLang.GetGremlin());
+ }
+
+ [Fact]
+ public void g_V_Has_runways_Lte_5_3_Count()
+ {
+ Assert.Equal("g.V().has(\"runways\",lte(5.3D)).count()",
+ _g.V().Has("runways", P.Lte(5.3)).Count().GremlinLang.GetGremlin());
+ }
+
+ [Fact]
+ public void g_V_Has_code_Within_123_124()
+ {
+ Assert.Equal("g.V().has(\"code\",within([123,124]))",
+ _g.V().Has("code", P.Within(123, 124)).GremlinLang.GetGremlin());
+ }
+
+ [Fact]
+ public void g_V_Has_code_Within_123_abc()
+ {
+ Assert.Equal("g.V().has(\"code\",within([123,\"abc\"]))",
+ _g.V().Has("code", P.Within(123, "abc")).GremlinLang.GetGremlin());
+ }
+
+ [Fact]
+ public void g_V_Has_code_Within_abc_123()
+ {
+ Assert.Equal("g.V().has(\"code\",within([\"abc\",123]))",
+ _g.V().Has("code", P.Within("abc", 123)).GremlinLang.GetGremlin());
+ }
+
+ [Fact]
+ public void g_V_Has_code_Within_abc_xyz()
+ {
+ Assert.Equal("g.V().has(\"code\",within([\"abc\",\"xyz\"]))",
+ _g.V().Has("code", P.Within("abc", "xyz")).GremlinLang.GetGremlin());
+ }
+
+ [Fact]
+ public void g_V_12_Has_region_Within_USTX_USGA()
+ {
+ Assert.Equal("g.V(\"1\",\"2\").has(\"region\",within([\"US-TX\",\"US-GA\"]))",
+ _g.V("1", "2").Has("region", P.Within("US-TX", "US-GA")).GremlinLang.GetGremlin());
+ }
+
+ [Fact]
+ public void g_V_And_Has_runways_Gt_5_Has_region_USTX()
+ {
+ Assert.Equal("g.V().and(__.has(\"runways\",gt(5)),__.has(\"region\",\"US-TX\"))",
+ _g.V().And(__.Has("runways", P.Gt(5)), __.Has("region", "US-TX")).GremlinLang.GetGremlin());
+ }
+
+ [Fact]
+ public void g_V_Union_Has_runways_Gt_5_Has_region_USTX()
+ {
+ Assert.Equal("g.V().union(__.has(\"runways\",gt(5)),__.has(\"region\",\"US-TX\"))",
+ _g.V().Union<object>(__.Has("runways", P.Gt(5)), __.Has("region", "US-TX")).GremlinLang.GetGremlin());
+ }
+
+ [Fact]
+ public void g_V_3_Choose_Values_runways_Is_3_Constant_three_Constant_not_three()
+ {
+ Assert.Equal("g.V(\"3\").choose(__.values(\"runways\").is(3),__.constant(\"three\"),__.constant(\"not three\"))",
+ _g.V("3").Choose<object>(__.Values<object>("runways").Is(3), __.Constant("three"), __.Constant("not three")).GremlinLang.GetGremlin());
+ }
+
+ [Fact]
+ public void g_V_3_Choose_Values_runways_Option_1_Option_2()
+ {
+ Assert.Equal("g.V(\"3\").choose(__.values(\"runways\")).option(1,__.constant(\"three\")).option(2,__.constant(\"not three\"))",
+ _g.V("3").Choose<object>(__.Values<object>("runways")).Option(1, __.Constant("three")).Option(2, __.Constant("not three")).GremlinLang.GetGremlin());
+ }
+
+ [Fact]
+ public void g_V_3_Choose_Values_runways_Option_1_5_Option_2()
+ {
+ Assert.Equal("g.V(\"3\").choose(__.values(\"runways\")).option(1.5D,__.constant(\"one and a half\")).option(2,__.constant(\"not three\"))",
+ _g.V("3").Choose<object>(__.Values<object>("runways")).Option(1.5, __.Constant("one and a half")).Option(2, __.Constant("not three")).GremlinLang.GetGremlin());
+ }
+
+ [Fact]
+ public void g_V_3_Repeat_Out_SimplePath_Until_Loops_Is_1_Count()
+ {
+ Assert.Equal("g.V(\"3\").repeat(__.out().simplePath()).until(__.loops().is(1)).count()",
+ _g.V("3").Repeat(__.Out().SimplePath()).Until(__.Loops().Is(1)).Count().GremlinLang.GetGremlin());
+ }
+
+ [Fact]
+ public void g_V_HasLabel_airport_Limit_20_Group_By_region_By_code_Order_Local_By_Keys()
+ {
+ Assert.Equal("g.V().hasLabel(\"airport\").limit(20L).group().by(\"region\").by(\"code\").order(Scope.local).by(Column.keys)",
+ _g.V().HasLabel("airport").Limit<object>(20).Group<object, object>().By("region").By("code").Order(Scope.Local).By(Column.Keys).GremlinLang.GetGremlin());
+ }
+
+ [Fact]
+ public void g_V_1_As_a_V_2_As_a_Select_Pop_All_a()
+ {
+ Assert.Equal("g.V(\"1\").as(\"a\").V(\"2\").as(\"a\").select(Pop.all,\"a\")",
+ _g.V("1").As("a").V("2").As("a").Select<object>(Pop.All, "a").GremlinLang.GetGremlin());
+ }
+
+ [Fact]
+ public void g_AddV_test_Property_Cardinality_Set_p1_10()
+ {
+ Assert.Equal("g.addV(\"test\").property(Cardinality.set,\"p1\",10)",
+ _g.AddV("test").Property(Cardinality.Set, "p1", 10).GremlinLang.GetGremlin());
+ }
+
+ [Fact]
+ public void g_AddV_test_Property_Cardinality_List_p1_10()
+ {
+ Assert.Equal("g.addV(\"test\").property(Cardinality.list,\"p1\",10)",
+ _g.AddV("test").Property(Cardinality.List, "p1", 10).GremlinLang.GetGremlin());
+ }
+
+ [Fact]
+ public void g_AddV_test_Property_Cardinality_Single_p1_10()
+ {
+ Assert.Equal("g.addV(\"test\").property(Cardinality.single,\"p1\",10)",
+ _g.AddV("test").Property(Cardinality.Single, "p1", 10).GremlinLang.GetGremlin());
+ }
+
+ [Fact]
+ public void g_V_Limit_5_Order_By_Label()
+ {
+ Assert.Equal("g.V().limit(5L).order().by(__.label())",
+ _g.V().Limit<object>(5).Order().By(__.Label()).GremlinLang.GetGremlin());
+ }
+
+ [Fact]
+ public void g_V_Range_1_5()
+ {
+ Assert.Equal("g.V().range(1L,5L)", _g.V().Range<object>(1, 5).GremlinLang.GetGremlin());
+ }
+
+ // --- Core Traversal Tests 61-88 ---
+
+ [Fact]
+ public void g_AddV_test_Property_p1_123()
+ {
+ Assert.Equal("g.addV(\"test\").property(\"p1\",123)",
+ _g.AddV("test").Property("p1", 123).GremlinLang.GetGremlin());
+ }
+
+ [Fact]
+ public void g_AddV_test_Property_date_DateTimeOffset()
+ {
+ Assert.Equal("g.addV(\"test\").property(\"date\",datetime(\"2021-02-01T09:30:00Z\"))",
+ _g.AddV("test").Property("date", new DateTimeOffset(2021, 2, 1, 9, 30, 0, TimeSpan.Zero)).GremlinLang.GetGremlin());
+ }
+
+ [Fact]
+ public void g_AddV_test_Property_date_DateTimeOffset_midnight()
+ {
+ Assert.Equal("g.addV(\"test\").property(\"date\",datetime(\"2021-02-01T00:00:00Z\"))",
+ _g.AddV("test").Property("date", new DateTimeOffset(2021, 2, 1, 0, 0, 0, TimeSpan.Zero)).GremlinLang.GetGremlin());
+ }
+
+ [Fact]
+ public void g_AddE_route_From_V_1_To_V_2()
+ {
+ Assert.Equal("g.addE(\"route\").from(__.V(\"1\")).to(__.V(\"2\"))",
+ _g.AddE("route").From(__.V("1")).To(__.V("2")).GremlinLang.GetGremlin());
+ }
+
+ [Fact]
+ public void g_WithSideEffect_a_list_V_3_Select_a()
+ {
+ Assert.Equal("g.withSideEffect(\"a\",[1,2]).V(\"3\").select(\"a\")",
+ _g.WithSideEffect("a", new List<object> { 1, 2 }).V("3").Select<object>("a").GremlinLang.GetGremlin());
+ }
+
+ [Fact]
+ public void g_WithSideEffect_a_1_V_3_Select_a()
+ {
+ Assert.Equal("g.withSideEffect(\"a\",1).V(\"3\").select(\"a\")",
+ _g.WithSideEffect("a", 1).V("3").Select<object>("a").GremlinLang.GetGremlin());
+ }
+
+ [Fact]
+ public void g_WithSideEffect_a_abc_V_3_Select_a()
+ {
+ Assert.Equal("g.withSideEffect(\"a\",\"abc\").V(\"3\").select(\"a\")",
+ _g.WithSideEffect("a", "abc").V("3").Select<object>("a").GremlinLang.GetGremlin());
+ }
+
+ [Fact]
+ public void g_V_Has_airport_region_USNM_Limit_3_Values_elev_Fold_Index()
+ {
+ Assert.Equal("g.V().has(\"airport\",\"region\",\"US-NM\").limit(3L).values(\"elev\").fold().index()",
+ _g.V().Has("airport", "region", "US-NM").Limit<object>(3).Values<object>("elev").Fold().Index<object>().GremlinLang.GetGremlin());
+ }
+
+ [Fact]
+ public void g_V_3_Repeat_TimeLimit_1000_Out_SimplePath_Until_Has_code_AGR_Path()
+ {
+ Assert.Equal("g.V(\"3\").repeat(__.timeLimit(1000L).out().simplePath()).until(__.has(\"code\",\"AGR\")).path()",
+ _g.V("3").Repeat(__.TimeLimit(1000).Out().SimplePath()).Until(__.Has("code", "AGR")).Path().GremlinLang.GetGremlin());
+ }
+
+ [Fact]
+ public void g_V_HasLabel_airport_Where_Values_elev_Is_Gt_14000()
+ {
+ Assert.Equal("g.V().hasLabel(\"airport\").where(__.values(\"elev\").is(gt(14000)))",
+ _g.V().HasLabel("airport").Where(__.Values<object>("elev").Is(P.Gt(14000))).GremlinLang.GetGremlin());
+ }
+
+ [Fact]
+ public void g_V_HasLabel_airport_Where_Out_Count_Is_Gt_250_Values_code()
+ {
+ Assert.Equal("g.V().hasLabel(\"airport\").where(__.out().count().is(gt(250))).values(\"code\")",
+ _g.V().HasLabel("airport").Where(__.Out().Count().Is(P.Gt(250))).Values<object>("code").GremlinLang.GetGremlin());
+ }
+
+ [Fact]
+ public void g_V_HasLabel_airport_Filter_Out_Count_Is_Gt_250_Values_code()
+ {
+ Assert.Equal("g.V().hasLabel(\"airport\").filter(__.out().count().is(gt(250))).values(\"code\")",
+ _g.V().HasLabel("airport").Filter(__.Out().Count().Is(P.Gt(250))).Values<object>("code").GremlinLang.GetGremlin());
+ }
+
+ [Fact]
+ public void g_Complex_sack_repeat_until_local_union()
+ {
+ Assert.Equal("g.withSack(0).V(\"3\").repeat(__.outE(\"route\").sack(Operator.sum).by(\"dist\").inV()).until(__.has(\"code\",\"AGR\").or().loops().is(4)).has(\"code\",\"AGR\").local(__.union(__.path().by(\"code\").by(\"dist\"),__.sack()).fold()).limit(10L)",
+ _g.WithSack(0).V("3")
+ .Repeat(__.OutE("route").Sack(Operator.Sum).By("dist").InV())
+ .Until(__.Has("code", "AGR").Or().Loops().Is(4))
+ .Has("code", "AGR")
+ .Local<object>(__.Union<object>(__.Path().By("code").By("dist"), __.Sack<object>()).Fold())
+ .Limit<object>(10).GremlinLang.GetGremlin());
+ }
+
+ [Fact]
+ public void g_AddV_As_a_AddV_As_b_AddE_knows_From_a_To_b()
+ {
+ Assert.Equal("g.addV().as(\"a\").addV().as(\"b\").addE(\"knows\").from(\"a\").to(\"b\")",
+ _g.AddV().As("a").AddV().As("b").AddE("knows").From("a").To("b").GremlinLang.GetGremlin());
+ }
+
+ [Fact]
+ public void g_AddV_Person_As_a_AddV_Person_As_b_AddE_knows_From_a_To_b()
+ {
+ Assert.Equal("g.addV(\"Person\").as(\"a\").addV(\"Person\").as(\"b\").addE(\"knows\").from(\"a\").to(\"b\")",
+ _g.AddV("Person").As("a").AddV("Person").As("b").AddE("knows").From("a").To("b").GremlinLang.GetGremlin());
+ }
+
+ [Fact]
+ public void g_V_3_Project_Out_In_By_Out_Count_By_In_Count()
+ {
+ Assert.Equal("g.V(\"3\").project(\"Out\",\"In\").by(__.out().count()).by(__.in().count())",
+ _g.V("3").Project<object>("Out", "In").By(__.Out().Count()).By(__.In().Count()).GremlinLang.GetGremlin());
+ }
+
+ [Fact]
+ public void g_V_44_Out_Aggregate_a_Out_Where_Within_a_Path()
+ {
+ Assert.Equal("g.V(\"44\").out().aggregate(\"a\").out().where(within([\"a\"])).path()",
+ _g.V("44").Out().Aggregate("a").Out().Where(P.Within("a")).Path().GremlinLang.GetGremlin());
+ }
+
+ [Fact]
+ public void g_V_Has_date_DateTimeOffset()
+ {
+ Assert.Equal("g.V().has(\"date\",datetime(\"2021-02-22T00:00:00Z\"))",
+ _g.V().Has("date", new DateTimeOffset(2021, 2, 22, 0, 0, 0, TimeSpan.Zero)).GremlinLang.GetGremlin());
+ }
+
+ [Fact]
+ public void g_V_Has_date_Within_dates()
+ {
+ Assert.Equal("g.V().has(\"date\",within([datetime(\"2021-02-22T00:00:00Z\"),datetime(\"2021-01-01T00:00:00Z\")]))",
+ _g.V().Has("date", P.Within(
+ new DateTimeOffset(2021, 2, 22, 0, 0, 0, TimeSpan.Zero),
+ new DateTimeOffset(2021, 1, 1, 0, 0, 0, TimeSpan.Zero))).GremlinLang.GetGremlin());
+ }
+
+ [Fact]
+ public void g_V_Has_date_Between_dates()
+ {
+ Assert.Equal("g.V().has(\"date\",between(datetime(\"2021-01-01T00:00:00Z\"),datetime(\"2021-02-22T00:00:00Z\")))",
+ _g.V().Has("date", P.Between(
+ new DateTimeOffset(2021, 1, 1, 0, 0, 0, TimeSpan.Zero),
+ new DateTimeOffset(2021, 2, 22, 0, 0, 0, TimeSpan.Zero))).GremlinLang.GetGremlin());
+ }
+
+ [Fact]
+ public void g_V_Has_date_Inside_dates()
+ {
+ Assert.Equal("g.V().has(\"date\",inside(datetime(\"2021-01-01T00:00:00Z\"),datetime(\"2021-02-22T00:00:00Z\")))",
+ _g.V().Has("date", P.Inside(
+ new DateTimeOffset(2021, 1, 1, 0, 0, 0, TimeSpan.Zero),
+ new DateTimeOffset(2021, 2, 22, 0, 0, 0, TimeSpan.Zero))).GremlinLang.GetGremlin());
+ }
+
+ [Fact]
+ public void g_V_Has_date_Gt_DateTimeOffset()
+ {
+ Assert.Equal("g.V().has(\"date\",gt(datetime(\"2021-01-01T09:30:00Z\")))",
+ _g.V().Has("date", P.Gt(new DateTimeOffset(2021, 1, 1, 9, 30, 0, TimeSpan.Zero))).GremlinLang.GetGremlin());
+ }
+
+ [Fact]
+ public void g_V_Has_runways_Between_3_5()
+ {
+ Assert.Equal("g.V().has(\"runways\",between(3,5))",
+ _g.V().Has("runways", P.Between(3, 5)).GremlinLang.GetGremlin());
+ }
+
+ [Fact]
+ public void g_V_Has_runways_Inside_3_5()
+ {
+ Assert.Equal("g.V().has(\"runways\",inside(3,5))",
+ _g.V().Has("runways", P.Inside(3, 5)).GremlinLang.GetGremlin());
+ }
+
+ [Fact]
+ public void g_V_44_OutE_ElementMap()
+ {
+ Assert.Equal("g.V(\"44\").outE().elementMap()",
+ _g.V("44").OutE().ElementMap<object>().GremlinLang.GetGremlin());
+ }
+
+ [Fact]
+ public void g_V_44_ValueMap_By_Unfold()
+ {
+ Assert.Equal("g.V(\"44\").valueMap().by(__.unfold())",
+ _g.V("44").ValueMap<object, object>().By(__.Unfold<object>()).GremlinLang.GetGremlin());
+ }
+
+ [Fact]
+ public void g_V_44_ValueMap_With_Tokens_Labels()
+ {
+ Assert.Equal("g.V(\"44\").valueMap().with(\"~tinkerpop.valueMap.tokens\",2)",
+ _g.V("44").ValueMap<object, object>().With(WithOptions.Tokens, WithOptions.Labels).GremlinLang.GetGremlin());
+ }
+
+ [Fact]
+ public void g_V_44_ValueMap_With_Tokens()
+ {
+ Assert.Equal("g.V(\"44\").valueMap().with(\"~tinkerpop.valueMap.tokens\")",
+ _g.V("44").ValueMap<object, object>().With(WithOptions.Tokens).GremlinLang.GetGremlin());
+ }
+
+ // --- Strategy Tests 89-97 ---
+
+ [Fact]
+ public void g_WithStrategies_ReadOnlyStrategy_AddV_test()
+ {
+ Assert.Equal("g.withStrategies(ReadOnlyStrategy).addV(\"test\")",
+ _g.WithStrategies(new ReadOnlyStrategy()).AddV("test").GremlinLang.GetGremlin());
+ }
+
+ [Fact]
+ public void g_WithStrategies_SubgraphStrategy_vertices_edges_V_Count()
+ {
+ var result = _g.WithStrategies(new SubgraphStrategy(
+ vertices: __.Has("region", "US-TX"),
+ edges: __.HasLabel("route"))).V().Count().GremlinLang.GetGremlin();
+ Assert.Contains("g.withStrategies(new SubgraphStrategy(", result);
+ Assert.Contains("vertices:__.has(\"region\",\"US-TX\")", result);
+ Assert.Contains("edges:__.hasLabel(\"route\")", result);
+ Assert.Contains(")).V().count()", result);
+ }
+
+ [Fact]
+ public void g_WithStrategies_SubgraphStrategy_vertexProperties_V_Count()
+ {
+ Assert.Equal("g.withStrategies(new SubgraphStrategy(vertexProperties:__.hasNot(\"runways\"))).V().count()",
+ _g.WithStrategies(new SubgraphStrategy(vertexProperties: __.HasNot("runways"))).V().Count().GremlinLang.GetGremlin());
+ }
+
+ [Fact]
+ public void g_WithStrategies_SubgraphStrategy_vertices_vertexProperties_V_Count()
+ {
+ var result = _g.WithStrategies(new SubgraphStrategy(
+ vertices: __.Has("region", "US-TX"),
+ vertexProperties: __.HasNot("runways"))).V().Count().GremlinLang.GetGremlin();
+ Assert.Contains("g.withStrategies(new SubgraphStrategy(", result);
+ Assert.Contains("vertices:__.has(\"region\",\"US-TX\")", result);
+ Assert.Contains("vertexProperties:__.hasNot(\"runways\")", result);
+ Assert.Contains(")).V().count()", result);
+ }
+
+ [Fact]
+ public void g_WithStrategies_ReadOnly_SubgraphStrategy_vertices_edges_V_Count()
+ {
+ var result = _g.WithStrategies(new ReadOnlyStrategy(), new SubgraphStrategy(
+ vertices: __.Has("region", "US-TX"),
+ edges: __.HasLabel("route"))).V().Count().GremlinLang.GetGremlin();
+ Assert.Contains("ReadOnlyStrategy", result);
+ Assert.Contains("new SubgraphStrategy(", result);
+ Assert.Contains("vertices:__.has(\"region\",\"US-TX\")", result);
+ Assert.Contains("edges:__.hasLabel(\"route\")", result);
+ }
+
+ [Fact]
+ public void g_WithStrategies_ReadOnly_SubgraphStrategy_vertices_V_Count()
+ {
+ Assert.Equal("g.withStrategies(ReadOnlyStrategy,new SubgraphStrategy(vertices:__.has(\"region\",\"US-TX\"))).V().count()",
+ _g.WithStrategies(new ReadOnlyStrategy(), new SubgraphStrategy(
+ vertices: __.Has("region", "US-TX"))).V().Count().GremlinLang.GetGremlin());
+ }
+
+ [Fact]
+ public void g_WithStrategies_OptionsStrategy_V_Count()
+ {
+ // OptionsStrategy is extracted, not rendered in the script
+ Assert.Equal("g.V().count()",
+ _g.WithStrategies(new OptionsStrategy(new Dictionary<string, object> { { "evaluationTimeout", 500 } })).V().Count().GremlinLang.GetGremlin());
+ }
+
+ [Fact]
+ public void g_WithStrategies_PartitionStrategy_AddV_test()
+ {
+ var result = _g.WithStrategies(new PartitionStrategy(
+ partitionKey: "partition",
+ writePartition: "a",
+ readPartitions: new List<string> { "a" },
+ includeMetaProperties: false)).AddV("test").GremlinLang.GetGremlin();
+ Assert.Contains("g.withStrategies(new PartitionStrategy(", result);
+ Assert.Contains("partitionKey:\"partition\"", result);
+ Assert.Contains("writePartition:\"a\"", result);
+ Assert.Contains("readPartitions:[\"a\"]", result);
+ Assert.Contains(")).addV(\"test\")", result);
+ }
+
+ [Fact]
+ public void g_WithStrategies_VertexProgramStrategy_V_ShortestPath_With()
+ {
+ Assert.Equal("g.withStrategies(VertexProgramStrategy).V().shortestPath().with(\"~tinkerpop.shortestPath.target\",__.has(\"name\",\"peter\"))",
+ _g.WithStrategies(new VertexProgramStrategy()).V().ShortestPath().With("~tinkerpop.shortestPath.target", __.Has("name", "peter")).GremlinLang.GetGremlin());
+ }
+
+ // --- TextP and Misc Tests 98-105 ---
+
+ [Fact]
+ public void g_V_Coalesce_E_AddE_person()
+ {
+ Assert.Equal("g.V().coalesce(__.E(),__.addE(\"person\"))",
+ _g.V().Coalesce<object>(__.E(), __.AddE("person")).GremlinLang.GetGremlin());
+ }
+
+ [Fact]
+ public void g_Inject_1_E()
+ {
+ Assert.Equal("g.inject(1).E()", _g.Inject(1).E().GremlinLang.GetGremlin());
+ }
+
+ [Fact]
+ public void g_V_Has_p1_StartingWith_foo()
+ {
+ Assert.Equal("g.V().has(\"p1\",startingWith(\"foo\"))",
+ _g.V().Has("p1", TextP.StartingWith("foo")).GremlinLang.GetGremlin());
+ }
+
+ [Fact]
+ public void g_V_Has_p1_EndingWith_foo()
+ {
+ Assert.Equal("g.V().has(\"p1\",endingWith(\"foo\"))",
+ _g.V().Has("p1", TextP.EndingWith("foo")).GremlinLang.GetGremlin());
+ }
+
+ [Fact]
+ public void g_V_Has_p1_Containing_foo()
+ {
+ Assert.Equal("g.V().has(\"p1\",containing(\"foo\"))",
+ _g.V().Has("p1", TextP.Containing("foo")).GremlinLang.GetGremlin());
+ }
+
+ [Fact]
+ public void g_V_Has_p1_null()
+ {
+ Assert.Equal("g.V().has(\"p1\",null)",
+ _g.V().Has("p1", (object?)null).GremlinLang.GetGremlin());
+ }
+
+ [Fact]
+ public void g_V_Vertex_0_person()
+ {
+ Assert.Equal("g.V(0)", _g.V(new Vertex(0, "person")).GremlinLang.GetGremlin());
+ }
+
+ [Fact]
+ public void g_Inject_Guid()
+ {
+ var guid = new Guid("f47af10b-58cc-4372-a567-0f02b2f3d479");
+ Assert.Equal("g.inject(UUID(\"f47af10b-58cc-4372-a567-0f02b2f3d479\"))",
+ _g.Inject((object)guid).GremlinLang.GetGremlin());
+ }
+
+ // --- Python-Only Tests 106-116 ---
+
+ [Fact]
+ public void g_E_Edge_renders_as_parameter()
+ {
+ GremlinLang.ResetCounter();
+ var edge = new Edge(2, new Vertex(1), "knows", new Vertex(3));
+ var result = _g.E(edge).GremlinLang.GetGremlin();
+ Assert.Equal("g.E(_0)", result);
+ }
+
+ [Fact]
+ public void g_Inject_VertexProperty_renders_as_parameter()
+ {
+ GremlinLang.ResetCounter();
+ var vp = new VertexProperty(3, "time", "18:00", null);
+ var result = _g.Inject((object)vp).GremlinLang.GetGremlin();
+ Assert.Equal("g.inject(_0)", result);
+ }
+
+ [Fact]
+ public void g_Inject_dicts_with_enum_keys()
+ {
+ GremlinLang.ResetCounter();
+ var dict1 = new Dictionary<object, object> { { "name", "java" } };
+ var dict2 = new Dictionary<object, object> { { T.Id, 0 } };
+ var dict3 = new Dictionary<object, object>();
+ var dict4 = new Dictionary<object, object>
+ {
+ { "age", 10.0 },
+ { "pos_inf", double.PositiveInfinity },
+ { "neg_inf", double.NegativeInfinity },
+ { "nan", double.NaN }
+ };
+ var result = _g.Inject((object)dict1, (object)dict2, (object)dict3, (object)dict4).GremlinLang.GetGremlin();
+ Assert.Contains("[\"name\":\"java\"]", result);
+ Assert.Contains("[(T.id):0]", result);
+ Assert.Contains("[:]", result);
+ Assert.Contains("10.0D", result);
+ Assert.Contains("+Infinity", result);
+ Assert.Contains("-Infinity", result);
+ Assert.Contains("NaN", result);
+ }
+
+ [Fact]
+ public void g_Inject_1_0_Is_Eq_1_Or_Gt_2_Or_Lte_3_Or_Gte_4()
+ {
+ Assert.Equal("g.inject(1.0D).is(eq(1).or(gt(2)).or(lte(3)).or(gte(4)))",
+ _g.Inject(1.0).Is(P.Eq(1).Or(P.Gt(2)).Or(P.Lte(3)).Or(P.Gte(4))).GremlinLang.GetGremlin());
+ }
+
+ [Fact]
+ public void g_V_HasLabel_person_Has_age_complex_connective_P()
+ {
+ Assert.Equal("g.V().hasLabel(\"person\").has(\"age\",gt(10).or(gte(11).and(lt(20))).and(lt(29).or(eq(35)))).values(\"name\")",
+ _g.V().HasLabel("person").Has("age",
+ P.Gt(10).Or(P.Gte(11).And(P.Lt(20))).And(P.Lt(29).Or(P.Eq(35))))
+ .Values<object>("name").GremlinLang.GetGremlin());
+ }
+
+ [Fact]
+ public void g_Inject_HashSet()
+ {
+ Assert.Equal("g.inject({\"a\"})",
+ _g.Inject((object)new HashSet<object> { "a" }).GremlinLang.GetGremlin());
+ }
+
+ [Fact]
+ public void g_MergeV_null()
+ {
+ Assert.Equal("g.mergeV(null)", _g.MergeV((IDictionary<object, object>?)null).GremlinLang.GetGremlin());
+ }
+
+ [Fact]
+ public void g_MergeE_null()
+ {
+ Assert.Equal("g.mergeE(null)", _g.MergeE((IDictionary<object, object?>?)null).GremlinLang.GetGremlin());
+ }
+
+ [Fact]
+ public void g_AddV_escaped_quotes()
+ {
+ Assert.Equal("g.addV(\"\\\"test\\\"\")", _g.AddV("\"test\"").GremlinLang.GetGremlin());
+ }
+
+ [Fact]
+ public void g_AddV_escaped_mixed_quotes()
+ {
+ Assert.Equal("g.addV(\"t'\\\"est\")", _g.AddV("t'\"est").GremlinLang.GetGremlin());
+ }
+
+ [Fact]
+ public void g_Inject_all_numeric_types()
+ {
+ Assert.Equal("g.inject(true,1B,2S,3,4L,5.0D,6.0D,7N,8M)",
+ _g.Inject((object)true, (object)(byte)1, (object)(short)2, (object)3, (object)(long)4,
+ (object)5.0, (object)6.0, (object)new BigInteger(7), (object)(decimal)8).GremlinLang.GetGremlin());
+ }
+
+ // --- Go-Only Tests 117-123 ---
+
+ [Fact]
+ public void g_V_44_ValueMap_With_All()
+ {
+ Assert.Equal("g.V(\"44\").valueMap().with(\"~tinkerpop.valueMap.tokens\",15)",
+ _g.V("44").ValueMap<object, object>().With(WithOptions.Tokens, WithOptions.All).GremlinLang.GetGremlin());
+ }
+
+ [Fact]
+ public void g_V_44_ValueMap_With_Indexer()
+ {
+ Assert.Equal("g.V(\"44\").valueMap().with(\"~tinkerpop.index.indexer\")",
+ _g.V("44").ValueMap<object, object>().With(WithOptions.Indexer).GremlinLang.GetGremlin());
+ }
+
+ [Fact]
+ public void g_V_Filter_Has_name_TextP_StartingWith_m_Or_StartingWith_p()
+ {
+ Assert.Equal("g.V().filter(__.has(\"name\",startingWith(\"m\").or(startingWith(\"p\"))))",
+ _g.V().Filter(__.Has("name", TextP.StartingWith("m").Or(TextP.StartingWith("p")))).GremlinLang.GetGremlin());
+ }
+
+ [Fact]
+ public void g_V_Has_person_age_Within_empty()
+ {
+ Assert.Equal("g.V().has(\"person\",\"age\",within())",
+ _g.V().Has("person", "age", P.Within()).GremlinLang.GetGremlin());
+ }
+
+ [Fact]
+ public void g_Inject_NaN_Is_Eq_NaN()
+ {
+ Assert.Equal("g.inject(NaN).is(eq(NaN))",
+ _g.Inject(double.NaN).Is(P.Eq(double.NaN)).GremlinLang.GetGremlin());
+ }
+
+ [Fact]
+ public void g_V_HasLabel_person_Values_age_Is_Between_26_30_Or_Gt_34()
+ {
+ Assert.Equal("g.V().hasLabel(\"person\").values(\"age\").is(between(26,30).or(gt(34)))",
+ _g.V().HasLabel("person").Values<object>("age").Is(P.Between(26, 30).Or(P.Gt(34))).GremlinLang.GetGremlin());
+ }
+
+ [Fact]
+ public void g_Inject_1_AsNumber_GType_Double()
+ {
+ Assert.Equal("g.inject(1).asNumber(GType.DOUBLE)",
+ _g.Inject(1).AsNumber(GType.Double).GremlinLang.GetGremlin());
+ }
+
+ // --- GValue Validation Tests 124-130 ---
+
+ [Fact]
+ public void GValue_null_name_throws_ArgumentNullException()
+ {
+ Assert.Throws<ArgumentNullException>(() => new GValue<int>(null!, 1));
+ }
+
+ [Fact]
+ public void GValue_special_char_name_throws_ArgumentException()
+ {
+ Assert.Throws<ArgumentException>(() => new GValue<int>("\"", 1));
+ }
+
+ [Fact]
+ public void GValue_numeric_name_throws_ArgumentException()
+ {
+ Assert.Throws<ArgumentException>(() => new GValue<int>("1", 1));
+ }
+
+ [Fact]
+ public void GValue_invalid_identifier_name_throws_ArgumentException()
+ {
+ Assert.Throws<ArgumentException>(() => new GValue<int>("1a", 1));
+ }
+
+ [Fact]
+ public void GValue_underscore_name_throws_ArgumentException()
+ {
+ Assert.Throws<ArgumentException>(() => new GValue<int>("_1", 1));
+ }
+
+ [Fact]
+ public void GValue_duplicate_name_different_value_throws_ArgumentException()
+ {
+ var gval1 = new GValue<int>("x", 1);
+ var gval2 = new GValue<int>("x", 2);
+ Assert.Throws<ArgumentException>(() => _g.Inject((object)gval1).V(gval2));
+ }
+
+ [Fact]
+ public void GValue_reuse_same_instance()
+ {
+ var gval = new GValue<IList<object>>("ids", new List<object> { 1, 2, 3 });
+ var result = _g.Inject((object)gval).V(gval).GremlinLang;
+ Assert.Equal("g.inject(ids).V(ids)", result.GetGremlin());
+ Assert.True(result.Parameters.ContainsKey("ids"));
+ }
+
+ // --- Cardinality with Map Tests ---
+
+ [Fact]
+ public void g_V_1_Property_List_Map_With_CardinalityValue()
+ {
+ var map = new Dictionary<object, object>
+ {
+ { "age", CardinalityValue.Single(36) },
+ { "city", "wilmington" },
+ { "state", "delaware" }
+ };
+ Assert.Equal(
+ "g.V(\"1\").property(Cardinality.single,\"age\",36).property(Cardinality.list,\"city\",\"wilmington\").property(Cardinality.list,\"state\",\"delaware\")",
+ _g.V("1").Property(Cardinality.List, map).GremlinLang.GetGremlin());
+ }
+
+ [Fact]
+ public void g_V_1_Property_Set_Map_All_Same_Cardinality()
+ {
+ var map = new Dictionary<object, object>
+ {
+ { "city", "wilmington" },
+ { "state", "delaware" }
+ };
+ Assert.Equal(
+ "g.V(\"1\").property(Cardinality.set,\"city\",\"wilmington\").property(Cardinality.set,\"state\",\"delaware\")",
+ _g.V("1").Property(Cardinality.Set, map).GremlinLang.GetGremlin());
+ }
+ }
+}
diff --git a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/TestTraversal.cs b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/TestTraversal.cs
index d618aec1d0..f36c2ee3f5 100644
--- a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/TestTraversal.cs
+++ b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/TestTraversal.cs
@@ -34,7 +34,6 @@ namespace Gremlin.Net.UnitTest.Process.Traversal
var traversers = new List<Traverser>(traverserObjs.Count);
traverserObjs.ForEach(o => traversers.Add(new Traverser(o)));
Traversers = traversers;
- Bytecode = new Bytecode();
}
public TestTraversal(IReadOnlyList<object?> traverserObjs, IReadOnlyList<long> traverserBulks)
@@ -42,7 +41,6 @@ namespace Gremlin.Net.UnitTest.Process.Traversal
var traversers = new List<Traverser>(traverserObjs.Count);
traversers.AddRange(traverserObjs.Select((t, i) => new Traverser(t, traverserBulks[i])));
Traversers = traversers;
- Bytecode = new Bytecode();
}
public TestTraversal(IList<ITraversalStrategy> traversalStrategies)
@@ -50,6 +48,6 @@ namespace Gremlin.Net.UnitTest.Process.Traversal
TraversalStrategies = traversalStrategies;
}
- public override Bytecode Bytecode { get; } = new();
+ public override GremlinLang GremlinLang { get; } = new();
}
-}
\ No newline at end of file
+}
diff --git a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/Translator/GroovyTranslatorTests.cs b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/Translator/GroovyTranslatorTests.cs
deleted file mode 100644
index 469c1dbb5c..0000000000
--- a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/Translator/GroovyTranslatorTests.cs
+++ /dev/null
@@ -1,500 +0,0 @@
-#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;
-using Gremlin.Net.Process.Traversal;
-using Gremlin.Net.Process.Traversal.Strategy.Decoration;
-using Gremlin.Net.Process.Traversal.Strategy.Verification;
-using Gremlin.Net.Process.Traversal.Translator;
-using Gremlin.Net.Structure;
-using Xunit;
-
-namespace Gremlin.Net.UnitTest.Process.Traversal.Translator;
-
-public class GroovyTranslatorTests
-{
- private readonly GraphTraversalSource _g = AnonymousTraversalSource.Traversal().With(null);
-
- [Fact]
- public void ShouldTranslateStepsWithSingleArguments()
- {
- var translator = GroovyTranslator.Of("g");
-
- var translated = translator.Translate(_g.V().Values<string>("name").Bytecode);
-
- Assert.Equal("g.V().values('name')", translated);
- }
-
- [Fact]
- public void ShouldTranslateStepsWithMultipleArguments()
- {
- var translator = GroovyTranslator.Of("g");
-
- var translated = translator.Translate(_g.V().Values<string>("name", "age").Bytecode);
-
- Assert.Equal("g.V().values('name', 'age')", translated);
- }
-
- [Fact]
- public void ShouldTranslateNullArgument()
- {
- AssertTranslation("null", null);
- }
-
- [Theory]
- [InlineData("3, 5", 3, 5)]
- [InlineData("3.2, 5.1", 3.2, 5.1)]
- [InlineData("'c'", 'c')]
- [InlineData("true", true)]
- [InlineData("false", false)]
- public void ShouldTranslateSimpleTypes(string expectedGroovy, params object[] simpleTypes)
- {
- AssertTranslation(expectedGroovy, simpleTypes);
- }
-
- [Fact]
- public void ShouldTranslateDateTimeOffsetArgument()
- {
- AssertTranslation("new Date(122, 11, 30, 12, 0, 1)", DateTimeOffset.Parse("2022-12-30T12:00:01Z"));
- }
-
- [Fact]
- public void ShouldTranslateDateTimeArgument()
- {
- AssertTranslation("new Date(122, 11, 30, 12, 0, 1)", DateTime.Parse("2022-12-30T12:00:01"));
- }
-
- [Fact]
- public void ShouldTranslateGuid()
- {
- AssertTranslation("UUID.fromString('ffffffff-fd49-1e4b-0000-00000d4b8a1d')",
- Guid.Parse("ffffffff-fd49-1e4b-0000-00000d4b8a1d"));
- }
-
- [Fact]
- public void ShouldTranslateCollection()
- {
- AssertTranslation("['test1', 'test2']", new List<string>{"test1", "test2"});
- }
-
- [Fact]
- public void ShouldTranslateDictionary()
- {
- var dictionary = new Dictionary<object, object>
- {
- { "key1", "value1" },
- { 1, "value2" }
- };
- AssertTranslation("['key1': 'value1', 1: 'value2']", dictionary);
- }
-
- [Fact]
- public void ShouldTranslateColumn()
- {
- AssertTranslation("Column.keys", Column.Keys);
- }
-
- [Fact]
- public void ShouldTranslateDirection()
- {
- AssertTranslation("Direction.BOTH", Direction.Both);
- }
-
- [Fact]
- public void ShouldTranslateOrder()
- {
- AssertTranslation("Order.desc", Order.Desc);
- }
-
- [Fact]
- public void ShouldTranslatePop()
- {
- AssertTranslation("Pop.last", Pop.Last);
- }
-
- [Fact]
- public void ShouldTranslateScope()
- {
- AssertTranslation("Scope.local", Scope.Local);
- }
-
- [Fact]
- public void ShouldTranslateP()
- {
- AssertTranslation("P.and(P.gt(20), P.lt(30))", P.Gt(20).And(P.Lt(30)));
- }
-
- [Fact]
- public void ShouldTranslatePBetween()
- {
- AssertTranslation("P.between([20, 30])", P.Between(20, 30));
- }
-
- [Fact]
- public void ShouldTranslateValueMapOptions()
- {
- AssertTraversalTranslation("g.V().valueMap().with(WithOptions.tokens, WithOptions.all).V()",
- _g.V().ValueMap<object, object>().With(WithOptions.Tokens, WithOptions.All).V());
- }
-
- [Fact]
- public void ShouldTranslateIndexerOptions()
- {
- AssertTraversalTranslation("g.V().index().with(WithOptions.indexer, WithOptions.list)",
- _g.V().Index<object>().With(WithOptions.Indexer, WithOptions.List));
- }
-
- [Fact]
- public void ShouldTranslateGraphTraversalSourceOptions()
- {
- AssertTraversalTranslation("g.withStrategies(new OptionsStrategy('~tinkerpop.valueMap.tokens': true)).V()",
- _g.With(WithOptions.Tokens).V());
- }
-
- [Fact]
- public void TranslationTest()
- {
- var expectedGroovyScriptByTraversal = new Dictionary<ITraversal, string>
- {
- { _g.V(), "g.V()" },
- { _g.V("1", "2", "3", "4"), "g.V('1', '2', '3', '4')" },
- { _g.V("3").ValueMap<object, object>(true), "g.V('3').valueMap(true)" },
- { _g.V().Constant(5), "g.V().constant(5)" },
- { _g.V().Constant(1.5), "g.V().constant(1.5)" },
- { _g.V().Constant("Hello"), "g.V().constant('Hello')" },
- { _g.V().HasLabel("airport").Limit<Vertex>(5), "g.V().hasLabel('airport').limit(5)" },
- {
- _g.V().HasLabel(P.Within(new List<string> { "a", "b", "c" })),
- "g.V().hasLabel(P.within(['a', 'b', 'c']))"
- },
- {
- _g.V().HasLabel("airport", "continent").Out().Limit<Vertex>(5),
- "g.V().hasLabel('airport', 'continent').out().limit(5)"
- },
- {
- _g.V().HasLabel("airport").Out().Values<string>("code").Limit<Vertex>(5),
- "g.V().hasLabel('airport').out().values('code').limit(5)"
- },
- {
- _g.V("3").As("a").Out("route").Limit<Vertex>(10).Where(P.Eq("a")).By("region"),
- "g.V('3').as('a').out('route').limit(10).where(P.eq('a')).by('region')"
- },
- {
- _g.V("3").Repeat(__.Out("route").SimplePath()).Times(2).Path().By("code"),
- "g.V('3').repeat(__.out('route').simplePath()).times(2).path().by('code')"
- },
- {
- _g.V().HasLabel("airport").Out().Has("region", "US-TX").Values<string>("code").Limit<string>(5),
- "g.V().hasLabel('airport').out().has('region', 'US-TX').values('code').limit(5)"
- },
- {
- _g.V().HasLabel("airport").Union<string>(__.Values<string>("city"), __.Values<string>("region"))
- .Limit<string>(5),
- "g.V().hasLabel('airport').union(__.values('city'), __.values('region')).limit(5)"
- },
- { _g.V("3").As("a").Out("route", "routes"), "g.V('3').as('a').out('route', 'routes')" },
- { _g.V().Where(__.Values<int>("runways").Is(5)), "g.V().where(__.values('runways').is(5))" },
- {
- _g.V("3").Repeat(__.Out().SimplePath()).Until(__.Has("code", "AGR")).Path().By("code").Limit<Path>(5),
- "g.V('3').repeat(__.out().simplePath()).until(__.has('code', 'AGR')).path().by('code').limit(5)"
- },
- { _g.V().HasLabel("airport").Order().By(__.Id()), "g.V().hasLabel('airport').order().by(__.id())" },
- { _g.V().HasLabel("airport").Order().By(T.Id), "g.V().hasLabel('airport').order().by(T.id)" },
- {
- _g.V().HasLabel("airport").Order().By(__.Id(), Order.Desc),
- "g.V().hasLabel('airport').order().by(__.id(), Order.desc)"
- },
- {
- _g.V().HasLabel("airport").Order().By("code", Order.Desc),
- "g.V().hasLabel('airport').order().by('code', Order.desc)"
- },
- {
- _g.V("1", "2", "3").Local<object>(__.Out().Out().Dedup().Fold()),
- "g.V('1', '2', '3').local(__.out().out().dedup().fold())"
- },
- { _g.V("3").Out().Path().Count(Scope.Local), "g.V('3').out().path().count(Scope.local)" },
- { _g.E().Count(), "g.E().count()" },
- { _g.V('5').OutE("route").InV().Path().Limit<Path>(10), "g.V('5').outE('route').inV().path().limit(10)" },
- {
- _g.V('5').PropertyMap<object>().Select<object>(Column.Keys),
- "g.V('5').propertyMap().select(Column.keys)"
- },
- {
- _g.V('5').PropertyMap<object>().Select<object>(Column.Values),
- "g.V('5').propertyMap().select(Column.values)"
- },
- { _g.V("3").Values<string>("runways").Math("_ + 1"), "g.V('3').values('runways').math('_ + 1')" },
- {
- _g.V("3").Emit().Repeat(__.Out().SimplePath()).Times(3).Limit<Vertex>(5).Path(),
- "g.V('3').emit().repeat(__.out().simplePath()).times(3).limit(5).path()"
- },
- {
- _g.V().Match<object>(__.As("a").Has("code", "LHR").As("b")).Select<object>("b").By("code"),
- "g.V().match(__.as('a').has('code', 'LHR').as('b')).select('b').by('code')"
- },
- {
- _g.V().Has("test-using-keyword-as-property", "repeat"),
- "g.V().has('test-using-keyword-as-property', 'repeat')"
- },
- { _g.V('1').AddE("test").To(__.V('4')), "g.V('1').addE('test').to(__.V('4'))" },
- { _g.V().Values<int>("runways").Max<int>(), "g.V().values('runways').max()" },
- { _g.V().Values<int>("runways").Min<int>(), "g.V().values('runways').min()" },
- { _g.V().Values<int>("runways").Sum<int>(), "g.V().values('runways').sum()" },
- { _g.V().Values<int>("runways").Mean<double>(), "g.V().values('runways').mean()" },
- {
- _g.WithSack(0).V('3', '5').Sack(Operator.Sum).By("runways").Sack<object>(),
- "g.withSack(0).V('3', '5').sack(Operator.sum).by('runways').sack()"
- },
- { _g.Inject(3, 4, 5), "g.inject(3, 4, 5)" },
- { _g.Inject(new List<int> { 3, 4, 5 }), "g.inject([3, 4, 5])" },
- { _g.Inject(3, 4, 5).Count(), "g.inject(3, 4, 5).count()" },
- { _g.V().Has("runways", P.Gt(5)).Count(), "g.V().has('runways', P.gt(5)).count()" },
- { _g.V().Has("runways", P.Lte(5.3)).Count(), "g.V().has('runways', P.lte(5.3)).count()" },
- { _g.V().Has("code", P.Within(new List<int> { 123, 124 })), "g.V().has('code', P.within([123, 124]))" },
- {
- _g.V('1', '2').Has("region", P.Within(new List<string> { "US-TX", "US-GA" })),
- "g.V('1', '2').has('region', P.within(['US-TX', 'US-GA']))"
- },
- {
- _g.V().And(__.Has("runways", P.Gt(5)), __.Has("region", "US-TX")),
- "g.V().and(__.has('runways', P.gt(5)), __.has('region', 'US-TX'))"
- },
- {
- _g.V().Union<object>(__.Has("runways", P.Gt(5)), __.Has("region", "US-TX")),
- "g.V().union(__.has('runways', P.gt(5)), __.has('region', 'US-TX'))"
- },
- {
- _g.V("3").Choose<object>(__.Values<object>("runways").Is(3), __.Constant("three"),
- __.Constant("not three")),
- "g.V('3').choose(__.values('runways').is(3), __.constant('three'), __.constant('not three'))"
- },
- {
- _g.V("3").Choose<object>(__.Values<object>("runways")).Option(1, __.Constant("three"))
- .Option(2, __.Constant("not three")),
- "g.V('3').choose(__.values('runways')).option(1, __.constant('three')).option(2, __.constant('not three'))"
- },
- {
- _g.V("3").Choose<object>(__.Values<object>("runways")).Option(1.5, __.Constant("one and a half"))
- .Option(2, __.Constant("not three")),
- "g.V('3').choose(__.values('runways')).option(1.5, __.constant('one and a half')).option(2, __.constant('not three'))"
- },
- {
- _g.V("3").Repeat(__.Out().SimplePath()).Until(__.Loops().Is(1)).Count(),
- "g.V('3').repeat(__.out().simplePath()).until(__.loops().is(1)).count()"
- },
- {
- _g.V().HasLabel("airport").Limit<Vertex>(20).Group<Vertex, object>().By("region").By("code")
- .Order(Scope.Local).By(Column.Keys),
- "g.V().hasLabel('airport').limit(20).group().by('region').by('code').order(Scope.local).by(Column.keys)"
- },
- {
- _g.V('1').As("a").V("2").As("a").Select<object>(Pop.All, "a"),
- "g.V('1').as('a').V('2').as('a').select(Pop.all, 'a')"
- },
- {
- _g.AddV("test").Property(Cardinality.Set, "p1", 10),
- "g.addV('test').property(Cardinality.set, 'p1', 10)"
- },
- {
- _g.AddV("test").Property(Cardinality.List, "p1", 10),
- "g.addV('test').property(Cardinality.list, 'p1', 10)"
- },
-
- {
- _g.AddV("test").Property(Cardinality.Single, "p1", 10),
- "g.addV('test').property(Cardinality.single, 'p1', 10)"
- },
- { _g.V().Limit<Vertex>(5).Order().By(T.Label), "g.V().limit(5).order().by(T.label)" },
-
- { _g.V().Range<Vertex>(1, 5), "g.V().range(1, 5)" },
-
- { _g.AddV("test").Property("p1", 123), "g.addV('test').property('p1', 123)" },
-
- {
- _g.AddV("test").Property("date", new DateTime(2021, 3, 1, 9, 30, 0)),
- "g.addV('test').property('date', new Date(121, 2, 1, 9, 30, 0))"
- },
- {
- _g.AddV("test").Property("date", new DateTime(2021, 3, 1, 0, 0, 0)),
- "g.addV('test').property('date', new Date(121, 2, 1, 0, 0, 0))"
- },
- { _g.AddE("route").From(__.V('1')).To(__.V('2')), "g.addE('route').from(__.V('1')).to(__.V('2'))" },
- {
- _g.WithSideEffect("a", new List<int> { 1, 2 }).V('3').Select<object>("a"),
- "g.withSideEffect('a', [1, 2]).V('3').select('a')"
- },
- { _g.WithSideEffect("a", 1).V('3').Select<object>("a"), "g.withSideEffect('a', 1).V('3').select('a')" },
- {
- _g.WithSideEffect("a", "abc").V("3").Select<object>("a"),
- "g.withSideEffect('a', 'abc').V('3').select('a')"
- },
- {
- _g.V().Has("airport", "region", "US-NM").Limit<Vertex>(3).Values<object>("elev").Fold().Index<object>(),
- "g.V().has('airport', 'region', 'US-NM').limit(3).values('elev').fold().index()"
- },
- {
- _g.V("3").Repeat(__.TimeLimit(1000).Out().SimplePath()).Until(__.Has("code", "AGR")).Path(),
- "g.V('3').repeat(__.timeLimit(1000).out().simplePath()).until(__.has('code', 'AGR')).path()"
- },
- {
- _g.V().HasLabel("airport").Where(__.Values<object>("elev").Is(P.Gt(14000))),
- "g.V().hasLabel('airport').where(__.values('elev').is(P.gt(14000)))"
- },
- {
- _g.V().HasLabel("airport").Where(__.Out().Count().Is(P.Gt(250))).Values<object>("code"),
- "g.V().hasLabel('airport').where(__.out().count().is(P.gt(250))).values('code')"
- },
- {
- _g.V().HasLabel("airport").Filter(__.Out().Count().Is(P.Gt(250))).Values<object>("code"),
- "g.V().hasLabel('airport').filter(__.out().count().is(P.gt(250))).values('code')"
- },
- {
- _g.WithSack(0).V('3').Repeat(__.OutE("route").Sack(Operator.Sum).By("dist").InV())
- .Until(__.Has("code", "AGR").Or().Loops().Is(4)).Has("code", "AGR")
- .Local<object>(__.Union<object>(__.Path().By("code").By("dist"), __.Sack<object>()).Fold())
- .Limit<object>(10),
- "g.withSack(0).V('3').repeat(__.outE('route').sack(Operator.sum).by('dist').inV()).until(__.has('code', 'AGR').or().loops().is(4)).has('code', 'AGR').local(__.union(__.path().by('code').by('dist'), __.sack()).fold()).limit(10)"
- },
- {
- _g.AddV().As("a").AddV().As("b").AddE("knows").From("a").To("b"),
- "g.addV().as('a').addV().as('b').addE('knows').from('a').to('b')"
- },
- {
- _g.AddV("Person").As("a").AddV("Person").As("b").AddE("knows").From("a").To("b"),
- "g.addV('Person').as('a').addV('Person').as('b').addE('knows').from('a').to('b')"
- },
- {
- _g.V("3").Project<object>("Out", "In").By(__.Out().Count()).By(__.In().Count()),
- "g.V('3').project('Out', 'In').by(__.out().count()).by(__.in().count())"
- },
- {
- _g.V("44").Out().Aggregate("a").Out().Where(P.Within(new List<string> { "a" })).Path(),
- "g.V('44').out().aggregate('a').out().where(P.within(['a'])).path()"
- },
- { _g.V().Has("date", new DateTime(2021, 3, 22)), "g.V().has('date', new Date(121, 2, 22, 0, 0, 0))" },
- {
- _g.V().Has("date", P.Within(new DateTime(2021, 3, 22, 0, 0, 0), new DateTime(2021, 2, 1, 0, 0, 0))),
- "g.V().has('date', P.within([new Date(121, 2, 22, 0, 0, 0), new Date(121, 1, 1, 0, 0, 0)]))"
- },
- {
- _g.V().Has("date", P.Between(new DateTime(2021, 2, 1, 0, 0, 0), new DateTime(2021, 3, 22, 0, 0, 0))),
- "g.V().has('date', P.between([new Date(121, 1, 1, 0, 0, 0), new Date(121, 2, 22, 0, 0, 0)]))"
- },
- {
- _g.V().Has("date", P.Inside(new DateTime(2021, 2, 1, 0, 0, 0), new DateTime(2021, 3, 22, 0, 0, 0))),
- "g.V().has('date', P.inside([new Date(121, 1, 1, 0, 0, 0), new Date(121, 2, 22, 0, 0, 0)]))"
- },
- {
- _g.V().Has("date", P.Gt(new DateTime(2021, 2, 1, 9, 30, 0))),
- "g.V().has('date', P.gt(new Date(121, 1, 1, 9, 30, 0)))"
- },
- { _g.V().Has("runways", P.Between(3, 5)), "g.V().has('runways', P.between([3, 5]))" },
- { _g.V().Has("runways", P.Inside(3, 5)), "g.V().has('runways', P.inside([3, 5]))" },
- { _g.V("44").OutE().ElementMap<object>(), "g.V('44').outE().elementMap()" },
- { _g.V("44").ValueMap<object, object>().By(__.Unfold<object>()), "g.V('44').valueMap().by(__.unfold())" },
- {
- _g.V().Property(new Dictionary<object, object> { { "name", "test" }, { "age", 30 } }),
- "g.V().property(['name': 'test', 'age': 30])"
- },
- { _g.V().E("1"), "g.V().E('1')" },
-
- // TODO: Support WithOptions
- {
- _g.V("44").ValueMap<object, object>().With(WithOptions.Tokens, WithOptions.Labels),
- "g.V('44').valueMap().with(WithOptions.tokens, WithOptions.labels)"
- },
- {
- _g.V("44").ValueMap<object, object>().With(WithOptions.Tokens),
- "g.V('44').valueMap().with(WithOptions.tokens)"
- },
- {
- _g.WithStrategies(new ReadOnlyStrategy()).AddV("test"),
- "g.withStrategies(new ReadOnlyStrategy()).addV('test')"
- },
- {
- _g.WithStrategies(
- new SubgraphStrategy(vertices: __.Has("region", "US-TX"), edges: __.HasLabel("route"))).V().Count(),
- "g.withStrategies(new SubgraphStrategy(vertices: __.has('region', 'US-TX'), edges: __.hasLabel('route'))).V().count()"
- },
- {
- _g.WithStrategies(new SubgraphStrategy(vertexProperties: __.HasNot("runways"))).V().Count(),
- "g.withStrategies(new SubgraphStrategy(vertexProperties: __.hasNot('runways'))).V().count()"
- },
- {
- _g.WithStrategies(new SubgraphStrategy(vertices: __.Has("region", "US-TX"),
- vertexProperties: __.HasNot("runways"))).V().Count(),
- "g.withStrategies(new SubgraphStrategy(vertices: __.has('region', 'US-TX'), vertexProperties: __.hasNot('runways'))).V().count()"
- },
- {
- _g.WithStrategies(new ReadOnlyStrategy(),
- new SubgraphStrategy(vertices: __.Has("region", "US-TX"), edges: __.HasLabel("route"))).V().Count(),
- "g.withStrategies(new ReadOnlyStrategy(), new SubgraphStrategy(vertices: __.has('region', 'US-TX'), edges: __.hasLabel('route'))).V().count()"
- },
- {
- _g.WithStrategies(new ReadOnlyStrategy(),
- new SubgraphStrategy(vertices: __.Has("region", "US-TX"), checkAdjacentVertices: true)).V()
- .Count(),
- "g.withStrategies(new ReadOnlyStrategy(), new SubgraphStrategy(vertices: __.has('region', 'US-TX'), checkAdjacentVertices: true)).V().count()"
- },
- {
- _g.With("evaluationTimeout", 500).V().Count(),
- "g.withStrategies(new OptionsStrategy('evaluationTimeout': 500)).V().count()"
- },
- {
- _g.WithStrategies(new OptionsStrategy(new Dictionary<string, object> { { "evaluationTimeout", 500 } }))
- .V().Count(),
- "g.withStrategies(new OptionsStrategy('evaluationTimeout': 500)).V().count()"
- },
- {
- _g.WithStrategies(new PartitionStrategy(partitionKey: "partition", writePartition: "a",
- readPartitions: new List<string> { "a" })).AddV("test"),
- "g.withStrategies(new PartitionStrategy(partitionKey: 'partition', writePartition: 'a', readPartitions: ['a'])).addV('test')"
- },
- {
- _g.WithStrategies(new VertexProgramStrategy()).V().ShortestPath()
- .With(ShortestPath.target, __.Has("name", "peter")),
- "g.withStrategies(new VertexProgramStrategy()).V().shortestPath().with('~tinkerpop.shortestPath.target', __.has('name', 'peter'))"
- }
- };
-
- foreach (var ( traversal, expectedGroovyScript) in expectedGroovyScriptByTraversal)
- {
- AssertTraversalTranslation(expectedGroovyScript, traversal);
- }
- }
-
- private void AssertTranslation(string expectedTranslation, params object?[]? objs)
- {
- AssertTraversalTranslation($"g.inject({expectedTranslation})", _g.Inject(objs));
- }
-
- private static void AssertTraversalTranslation(string expectedTranslation, ITraversal traversal)
- {
- var translator = GroovyTranslator.Of("g");
-
- var translated = translator.Translate(traversal);
-
- Assert.Equal(expectedTranslation, translated);
- }
-}
\ No newline at end of file
diff --git a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/TraversalTests.cs b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/TraversalTests.cs
index 63489f4fef..7d41509120 100644
--- a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/TraversalTests.cs
+++ b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/TraversalTests.cs
@@ -184,36 +184,20 @@ namespace Gremlin.Net.UnitTest.Process.Traversal
[Fact]
public void ShouldExtractIdFromVertex()
{
+ GremlinLang.ResetCounter();
var g = AnonymousTraversalSource.Traversal().With(null);
// Test basic V() step with mixed ID types
var vStart = g.V(1, new Vertex(2));
- var vStartBytecode = vStart.Bytecode;
- Assert.Single(vStartBytecode.StepInstructions);
- Assert.Equal("V", vStartBytecode.StepInstructions[0].OperatorName);
- Assert.Equal(1, (int)vStartBytecode.StepInstructions[0].Arguments[0]);
- Assert.Equal(2, (int)vStartBytecode.StepInstructions[0].Arguments[1]); // ID should be extracted from Vertex
+ Assert.Equal("g.V(1,2)", vStart.GremlinLang.GetGremlin());
// Test V() step in the middle of a traversal
var vMid = g.Inject("foo").V(1, new Vertex(2));
- var vMidBytecode = vMid.Bytecode;
- Assert.Equal(2, vMidBytecode.StepInstructions.Count);
- Assert.Equal("inject", vMidBytecode.StepInstructions[0].OperatorName);
- Assert.Equal("foo", (string)vMidBytecode.StepInstructions[0].Arguments[0]);
- Assert.Equal("V", vMidBytecode.StepInstructions[1].OperatorName);
- Assert.Equal(1, (int)vMidBytecode.StepInstructions[1].Arguments[0]);
- Assert.Equal(2, (int)vMidBytecode.StepInstructions[1].Arguments[1]); // ID should be extracted from Vertex
+ Assert.Equal("g.inject(\"foo\").V(1,2)", vMid.GremlinLang.GetGremlin());
// Test edge creation with from/to vertices
var fromTo = g.AddE("Edge").From(new Vertex(1)).To(new Vertex(2));
- var fromToBytecode = fromTo.Bytecode;
- Assert.Equal(3, fromToBytecode.StepInstructions.Count);
- Assert.Equal("addE", fromToBytecode.StepInstructions[0].OperatorName);
- Assert.Equal("Edge", (string)fromToBytecode.StepInstructions[0].Arguments[0]);
- Assert.Equal("from", fromToBytecode.StepInstructions[1].OperatorName);
- Assert.Equal(1, (int)fromToBytecode.StepInstructions[1].Arguments[0]); // ID should be extracted from Vertex
- Assert.Equal("to", fromToBytecode.StepInstructions[2].OperatorName);
- Assert.Equal(2, (int)fromToBytecode.StepInstructions[2].Arguments[0]); // ID should be extracted from Vertex
+ Assert.Equal("g.addE(\"Edge\").from(1).to(2)", fromTo.GremlinLang.GetGremlin());
// Test mergeE() with Vertex in dictionary
var mergeMap = new Dictionary<object, object>
@@ -224,29 +208,20 @@ namespace Gremlin.Net.UnitTest.Process.Traversal
};
var mergeEStart = g.MergeE(mergeMap);
- var mergeEStartBytecode = mergeEStart.Bytecode;
- Assert.Single(mergeEStartBytecode.StepInstructions);
- Assert.Equal("mergeE", mergeEStartBytecode.StepInstructions[0].OperatorName);
-
- // Check that the dictionary contains extracted IDs
- var mergeMapArg = (Dictionary<object, object>)mergeEStartBytecode.StepInstructions[0].Arguments[0];
- Assert.Equal("knows", (string)mergeMapArg[T.Label]);
- Assert.Equal(1, (int)mergeMapArg[Direction.Out]); // ID should be extracted from Vertex
- Assert.Equal(2, (int)mergeMapArg[Direction.In]); // ID should be extracted from Vertex
+ // Verify the dictionary had Vertex IDs extracted (the map is mutated in place)
+ Assert.Equal(1, mergeMap[Direction.Out]);
+ Assert.Equal(2, mergeMap[Direction.In]);
// Test mergeE() in the middle of a traversal
- var mergeEMid = g.Inject("foo").MergeE(mergeMap);
- var mergeEMidBytecode = mergeEMid.Bytecode;
- Assert.Equal(2, mergeEMidBytecode.StepInstructions.Count);
- Assert.Equal("inject", mergeEMidBytecode.StepInstructions[0].OperatorName);
- Assert.Equal("foo", (string)mergeEMidBytecode.StepInstructions[0].Arguments[0]);
- Assert.Equal("mergeE", mergeEMidBytecode.StepInstructions[1].OperatorName);
-
- // Check that the dictionary contains extracted IDs
- var mergeMapArg2 = (Dictionary<object, object>)mergeEMidBytecode.StepInstructions[1].Arguments[0];
- Assert.Equal("knows", (string)mergeMapArg2[T.Label]);
- Assert.Equal(1, (int)mergeMapArg2[Direction.Out]); // ID should be extracted from Vertex
- Assert.Equal(2, (int)mergeMapArg2[Direction.In]); // ID should be extracted from Vertex
+ var mergeMap2 = new Dictionary<object, object>
+ {
+ { T.Label, "knows" },
+ { Direction.Out, new Vertex(1) },
+ { Direction.In, new Vertex(2) }
+ };
+ var mergeEMid = g.Inject("foo").MergeE(mergeMap2);
+ Assert.Equal(1, mergeMap2[Direction.Out]);
+ Assert.Equal(2, mergeMap2[Direction.In]);
}
}
}
\ No newline at end of file
diff --git a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphBinary/GraphBinaryTests.cs b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphBinary/GraphBinaryTests.cs
index 51b6032be4..fccbef8f99 100644
--- a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphBinary/GraphBinaryTests.cs
+++ b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphBinary/GraphBinaryTests.cs
@@ -671,40 +671,6 @@ namespace Gremlin.Net.UnitTest.Structure.IO.GraphBinary
Assert.Equal(expected, actual);
}
- [Fact]
- public async Task TestBinding()
- {
- var expected = new Binding("name", "marko");
- var writer = CreateGraphBinaryWriter();
- var reader = CreateGraphBinaryReader();
- var serializationStream = new MemoryStream();
-
- await writer.WriteAsync(expected, serializationStream);
- serializationStream.Position = 0;
- var actual = await reader.ReadAsync(serializationStream);
-
- Assert.Equal(expected, actual);
- }
-
- [Fact]
- public async Task TestBytecode()
- {
- var expected = new Bytecode();
- expected.SourceInstructions.Add(new Instruction("withStrategies", "SubgraphStrategy"));
- expected.StepInstructions.Add(new Instruction("V", 1, 2, 3));
- expected.StepInstructions.Add(new Instruction("out"));
- var writer = CreateGraphBinaryWriter();
- var reader = CreateGraphBinaryReader();
- var serializationStream = new MemoryStream();
-
- await writer.WriteAsync(expected, serializationStream);
- serializationStream.Position = 0;
- var actual = (Bytecode?) await reader.ReadAsync(serializationStream);
-
- Assert.Equal(expected.SourceInstructions, actual!.SourceInstructions);
- Assert.Equal(expected.StepInstructions, actual.StepInstructions);
- }
-
[Theory]
[InlineData(1)]
[InlineData(123)]
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
deleted file mode 100644
index da6a6a75e8..0000000000
--- a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/BytecodeGraphSONSerializerTests.cs
+++ /dev/null
@@ -1,169 +0,0 @@
-#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.Collections.Generic;
-using Gremlin.Net.Process.Traversal;
-using Gremlin.Net.Structure.IO.GraphSON;
-using Xunit;
-
-namespace Gremlin.Net.UnitTest.Structure.IO.GraphSON
-{
- public class BytecodeGraphSONSerializerTests
- {
- /// <summary>
- /// Parameters for each test supporting multiple versions of GraphSON
- /// </summary>
- public static IEnumerable<object[]> Versions => new []
- {
- new object[] { 2 },
- new object[] { 3 }
- };
-
- private GraphSONWriter CreateGraphSONWriter(int version)
- {
- if (version == 3)
- {
- return new GraphSON3Writer();
- }
- return new GraphSON2Writer();
- }
-
- [Theory, MemberData(nameof(Versions))]
- public void ShouldSerializeByteCodeWithNestedTraversal(int version)
- {
- var bytecode = new Bytecode();
- bytecode.AddStep("V");
- var nestedBytecode = new Bytecode();
- var nestedTraversal = new TestTraversal(nestedBytecode);
- nestedBytecode.AddStep("out");
- bytecode.AddStep("repeat", nestedTraversal);
- var graphsonWriter = CreateGraphSONWriter(version);
-
- var graphSON = graphsonWriter.WriteObject(bytecode);
-
- var expectedGraphSon =
- "{\"@type\":\"g:Bytecode\",\"@value\":{\"step\":[[\"V\"],[\"repeat\",{\"@type\":\"g:Bytecode\",\"@value\":{\"step\":[[\"out\"]]}}]]}}";
- Assert.Equal(expectedGraphSon, graphSON);
- }
-
- [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(version);
-
- var graphSON = graphsonWriter.WriteObject(bytecode);
-
- var expectedGraphSon =
- "{\"@type\":\"g:Bytecode\",\"@value\":{\"step\":[[\"V\",{\"@type\":\"g:Int64\",\"@value\":1}],[\"has\",\"age\",{\"@type\":\"g:Int32\",\"@value\":20}],[\"has\",\"height\",{\"@type\":\"g:Double\",\"@value\":6.5}]]}}";
- Assert.Equal(expectedGraphSon, graphSON);
- }
-
- [Theory, MemberData(nameof(Versions))]
- public void ShouldSerialize_g_V(int version)
- {
- var bytecode = new Bytecode();
- bytecode.AddStep("V");
- var graphsonWriter = CreateGraphSONWriter(version);
-
- var graphSON = graphsonWriter.WriteObject(bytecode);
-
- Assert.Equal("{\"@type\":\"g:Bytecode\",\"@value\":{\"step\":[[\"V\"]]}}", graphSON);
- }
-
- [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(version);
-
- var graphSON = graphsonWriter.WriteObject(bytecode);
-
- var expectedGraphSon = "{\"@type\":\"g:Bytecode\",\"@value\":{\"step\":[[\"V\"],[\"count\"]]}}";
- Assert.Equal(expectedGraphSon, graphSON);
- }
-
- [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(version);
-
- var graphSON = graphsonWriter.WriteObject(bytecode);
-
- var expectedGraphSon =
- "{\"@type\":\"g:Bytecode\",\"@value\":{\"step\":[[\"V\"],[\"has\",\"Person\",\"Name\",\"Gremlin\"],[\"count\"]]}}";
- Assert.Equal(expectedGraphSon, graphSON);
- }
-
- [Theory, MemberData(nameof(Versions))]
- public void ShouldSerializeBytecodeWithSourcesStep(int version)
- {
- var bytecode = new Bytecode();
- bytecode.AddSource("withSideEffect", "a", "josh");
- bytecode.AddStep("V", 1);
- bytecode.AddStep("values", "name");
- bytecode.AddStep("where", new P("within", "a"));
- var graphsonWriter = CreateGraphSONWriter(version);
-
- var graphSON = graphsonWriter.WriteObject(bytecode);
-
- var expectedGraphSon =
- "{\"@type\":\"g:Bytecode\",\"@value\":{\"source\":[[\"withSideEffect\",\"a\",\"josh\"]],\"step\":[[\"V\",{\"@type\":\"g:Int32\",\"@value\":1}],[\"values\",\"name\"],[\"where\",{\"@type\":\"g:P\",\"@value\":{\"predicate\":\"within\",\"value\":\"a\"}}]]}}";
- Assert.Equal(expectedGraphSon, graphSON);
- }
-
- [Theory, MemberData(nameof(Versions))]
- public void ShouldSerializeBytecodeWithBindings(int version)
- {
- var bytecode = new Bytecode();
- bytecode.AddStep("V", new Binding("id", 123));
- var graphsonWriter = CreateGraphSONWriter(version);
-
- var graphSon = graphsonWriter.WriteObject(bytecode);
-
- var expectedGraphSon =
- "{\"@type\":\"g:Bytecode\",\"@value\":{\"step\":[[\"V\",{\"@type\":\"g:Binding\",\"@value\":{\"value\":{\"@type\":\"g:Int32\",\"@value\":123},\"key\":\"id\"}}]]}}";
- Assert.Equal(expectedGraphSon, graphSon);
- }
- }
-
- internal class TestTraversal : DefaultTraversal<object, object>
- {
- public TestTraversal(Bytecode bytecode)
- {
- Bytecode = bytecode;
- IsAnonymous = true;
- }
-
- public override Bytecode Bytecode { get; }
- }
-}
\ No newline at end of file
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 7e9a7bb09f..31e195034f 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
@@ -173,19 +173,6 @@ namespace Gremlin.Net.UnitTest.Structure.IO.GraphSON
Assert.Equal(expectedGraphSON, serializedGraphSON);
}
- [Theory, MemberData(nameof(Versions))]
- public void ShouldSerializeBinding(int version)
- {
- var writer = CreateGraphSONWriter(version);
- var binding = new Binding("theKey", 123);
-
- var graphSon = writer.WriteObject(binding);
-
- const string expected =
- "{\"@type\":\"g:Binding\",\"@value\":{\"value\":{\"@type\":\"g:Int32\",\"@value\":123},\"key\":\"theKey\"}}";
- Assert.Equal(expected, graphSon);
- }
-
[Fact]
public void ShouldSerializeWithCustomSerializerForNewType()
{
@@ -523,10 +510,7 @@ namespace Gremlin.Net.UnitTest.Structure.IO.GraphSON
var writer = CreateGraphSONWriter(version);
var readonlyStrategy = new SubgraphStrategy(vertices: __.HasLabel("person"));
- var graphSon = writer.WriteObject(readonlyStrategy);
-
- const string expected = "{\"@type\":\"g:SubgraphStrategy\",\"@value\":{\"fqcn\":\"org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.SubgraphStrategy\",\"conf\":{\"vertices\":{\"@type\":\"g:Bytecode\",\"@value\":{\"step\":[[\"hasLabel\",\"person\"]]}}}}}";
- Assert.Equal(expected, graphSon);
+ Assert.Throws<NotSupportedException>(() => writer.WriteObject(readonlyStrategy));
}
[Theory, MemberData(nameof(Versions))]
(tinkerpop) 02/04: Added missing strategies to gremlin-dotnet
Posted by xi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
xiazcy pushed a commit to branch dotnet-http
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git
commit 8154ab059a7f3a08a639fb5fd56b90060479c9b6
Author: Ken Hu <10...@users.noreply.github.com>
AuthorDate: Tue Jan 27 13:16:51 2026 -0800
Added missing strategies to gremlin-dotnet
---
gremlin-dotnet/build/generate.groovy | 1 +
.../Strategy/Decoration/HaltedTraverserStrategy.cs | 6 +++---
.../ComputerFinalizationStrategy.cs} | 25 ++++++++++------------
.../ProfileStrategy.cs} | 25 ++++++++++------------
.../ReferenceElementStrategy.cs} | 25 ++++++++++------------
.../ByModulatorOptimizationStrategy.cs} | 25 ++++++++++------------
.../MessagePassingReductionStrategy.cs} | 25 ++++++++++------------
.../ComputerVerificationStrategy.cs} | 25 ++++++++++------------
.../StandardVerificationStrategy.cs} | 25 ++++++++++------------
.../VertexProgramRestrictionStrategy.cs} | 25 ++++++++++------------
10 files changed, 92 insertions(+), 115 deletions(-)
diff --git a/gremlin-dotnet/build/generate.groovy b/gremlin-dotnet/build/generate.groovy
index 54d9aded7e..9a960303f5 100644
--- a/gremlin-dotnet/build/generate.groovy
+++ b/gremlin-dotnet/build/generate.groovy
@@ -65,6 +65,7 @@ radishGremlinFile.withWriter('UTF-8') { Writer writer ->
'using Gremlin.Net.Process.Traversal;\n' +
'using Gremlin.Net.Process.Traversal.Strategy.Optimization;\n' +
'using Gremlin.Net.Process.Traversal.Strategy.Verification;\n' +
+ 'using Gremlin.Net.Process.Traversal.Strategy.Finalization;\n' +
'using Gremlin.Net.Process.Traversal.Strategy.Decoration;\n')
writer.writeLine('namespace Gremlin.Net.IntegrationTest.Gherkin\n' +
'{\n' +
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Decoration/HaltedTraverserStrategy.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Decoration/HaltedTraverserStrategy.cs
index ffa38fcd9e..2eb3cbb49e 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Decoration/HaltedTraverserStrategy.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Decoration/HaltedTraverserStrategy.cs
@@ -32,11 +32,11 @@ namespace Gremlin.Net.Process.Traversal.Strategy.Decoration
{
}
- public HaltedTraverserStrategy(string? haltedTraverserFactoryName = null)
+ public HaltedTraverserStrategy(string? haltedTraverserFactory = null)
: this()
{
- if (haltedTraverserFactoryName != null)
- Configuration["haltedTraverserFactory"] = haltedTraverserFactoryName;
+ if (haltedTraverserFactory != null)
+ Configuration["haltedTraverserFactory"] = haltedTraverserFactory;
}
}
#pragma warning restore 1591
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Decoration/HaltedTraverserStrategy.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Finalization/ComputerFinalizationStrategy.cs
similarity index 58%
copy from gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Decoration/HaltedTraverserStrategy.cs
copy to gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Finalization/ComputerFinalizationStrategy.cs
index ffa38fcd9e..4ef57dc933 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Decoration/HaltedTraverserStrategy.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Finalization/ComputerFinalizationStrategy.cs
@@ -1,4 +1,4 @@
-#region License
+#region License
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -21,23 +21,20 @@
#endregion
-namespace Gremlin.Net.Process.Traversal.Strategy.Decoration
+namespace Gremlin.Net.Process.Traversal.Strategy.Optimization
{
-#pragma warning disable 1591
- public class HaltedTraverserStrategy : AbstractTraversalStrategy
+ /// <summary>
+ /// A strategy.
+ /// </summary>
+ public class ComputerFinalizationStrategy : AbstractTraversalStrategy
{
- private const string JavaFqcn = DecorationNamespace + nameof(HaltedTraverserStrategy);
+ private const string JavaFqcn = ComputerFinalizationNamespace + nameof(ComputerFinalizationStrategy);
- public HaltedTraverserStrategy() : base(JavaFqcn)
+ /// <summary>
+ /// Initializes a new instance of the <see cref="ComputerFinalizationStrategy" /> class.
+ /// </summary>
+ public ComputerFinalizationStrategy() : base(JavaFqcn)
{
}
-
- public HaltedTraverserStrategy(string? haltedTraverserFactoryName = null)
- : this()
- {
- if (haltedTraverserFactoryName != null)
- Configuration["haltedTraverserFactory"] = haltedTraverserFactoryName;
- }
}
-#pragma warning restore 1591
}
\ No newline at end of file
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Decoration/HaltedTraverserStrategy.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Finalization/ProfileStrategy.cs
similarity index 58%
copy from gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Decoration/HaltedTraverserStrategy.cs
copy to gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Finalization/ProfileStrategy.cs
index ffa38fcd9e..11b7bd6bb4 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Decoration/HaltedTraverserStrategy.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Finalization/ProfileStrategy.cs
@@ -1,4 +1,4 @@
-#region License
+#region License
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -21,23 +21,20 @@
#endregion
-namespace Gremlin.Net.Process.Traversal.Strategy.Decoration
+namespace Gremlin.Net.Process.Traversal.Strategy.Finalization
{
-#pragma warning disable 1591
- public class HaltedTraverserStrategy : AbstractTraversalStrategy
+ /// <summary>
+ /// A strategy.
+ /// </summary>
+ public class ProfileStrategy : AbstractTraversalStrategy
{
- private const string JavaFqcn = DecorationNamespace + nameof(HaltedTraverserStrategy);
+ private const string JavaFqcn = FinalizationNamespace + nameof(ProfileStrategy);
- public HaltedTraverserStrategy() : base(JavaFqcn)
+ /// <summary>
+ /// Initializes a new instance of the <see cref="ProfileStrategy" /> class.
+ /// </summary>
+ public ProfileStrategy() : base(JavaFqcn)
{
}
-
- public HaltedTraverserStrategy(string? haltedTraverserFactoryName = null)
- : this()
- {
- if (haltedTraverserFactoryName != null)
- Configuration["haltedTraverserFactory"] = haltedTraverserFactoryName;
- }
}
-#pragma warning restore 1591
}
\ No newline at end of file
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Decoration/HaltedTraverserStrategy.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Finalization/ReferenceElementStrategy.cs
similarity index 58%
copy from gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Decoration/HaltedTraverserStrategy.cs
copy to gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Finalization/ReferenceElementStrategy.cs
index ffa38fcd9e..61f78b7ab2 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Decoration/HaltedTraverserStrategy.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Finalization/ReferenceElementStrategy.cs
@@ -1,4 +1,4 @@
-#region License
+#region License
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -21,23 +21,20 @@
#endregion
-namespace Gremlin.Net.Process.Traversal.Strategy.Decoration
+namespace Gremlin.Net.Process.Traversal.Strategy.Finalization
{
-#pragma warning disable 1591
- public class HaltedTraverserStrategy : AbstractTraversalStrategy
+ /// <summary>
+ /// A strategy that detaches traversers with graph elements as references.
+ /// </summary>
+ public class ReferenceElementStrategy : AbstractTraversalStrategy
{
- private const string JavaFqcn = DecorationNamespace + nameof(HaltedTraverserStrategy);
+ private const string JavaFqcn = FinalizationNamespace + nameof(ReferenceElementStrategy);
- public HaltedTraverserStrategy() : base(JavaFqcn)
+ /// <summary>
+ /// Initializes a new instance of the <see cref="ReferenceElementStrategy" /> class.
+ /// </summary>
+ public ReferenceElementStrategy() : base(JavaFqcn)
{
}
-
- public HaltedTraverserStrategy(string? haltedTraverserFactoryName = null)
- : this()
- {
- if (haltedTraverserFactoryName != null)
- Configuration["haltedTraverserFactory"] = haltedTraverserFactoryName;
- }
}
-#pragma warning restore 1591
}
\ No newline at end of file
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Decoration/HaltedTraverserStrategy.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Optimization/ByModulatorOptimizationStrategy.cs
similarity index 58%
copy from gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Decoration/HaltedTraverserStrategy.cs
copy to gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Optimization/ByModulatorOptimizationStrategy.cs
index ffa38fcd9e..7020c1622c 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Decoration/HaltedTraverserStrategy.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Optimization/ByModulatorOptimizationStrategy.cs
@@ -1,4 +1,4 @@
-#region License
+#region License
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -21,23 +21,20 @@
#endregion
-namespace Gremlin.Net.Process.Traversal.Strategy.Decoration
+namespace Gremlin.Net.Process.Traversal.Strategy.Optimization
{
-#pragma warning disable 1591
- public class HaltedTraverserStrategy : AbstractTraversalStrategy
+ /// <summary>
+ /// Optimizes vertex- and value-emitting steps.
+ /// </summary>
+ public class ByModulatorOptimizationStrategy : AbstractTraversalStrategy
{
- private const string JavaFqcn = DecorationNamespace + nameof(HaltedTraverserStrategy);
+ private const string JavaFqcn = OptimizationNamespace + nameof(ByModulatorOptimizationStrategy);
- public HaltedTraverserStrategy() : base(JavaFqcn)
+ /// <summary>
+ /// Initializes a new instance of the <see cref="ByModulatorOptimizationStrategy" /> class.
+ /// </summary>
+ public ByModulatorOptimizationStrategy() : base(JavaFqcn)
{
}
-
- public HaltedTraverserStrategy(string? haltedTraverserFactoryName = null)
- : this()
- {
- if (haltedTraverserFactoryName != null)
- Configuration["haltedTraverserFactory"] = haltedTraverserFactoryName;
- }
}
-#pragma warning restore 1591
}
\ No newline at end of file
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Decoration/HaltedTraverserStrategy.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Optimization/MessagePassingReductionStrategy.cs
similarity index 58%
copy from gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Decoration/HaltedTraverserStrategy.cs
copy to gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Optimization/MessagePassingReductionStrategy.cs
index ffa38fcd9e..810e33ce22 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Decoration/HaltedTraverserStrategy.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Optimization/MessagePassingReductionStrategy.cs
@@ -1,4 +1,4 @@
-#region License
+#region License
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -21,23 +21,20 @@
#endregion
-namespace Gremlin.Net.Process.Traversal.Strategy.Decoration
+namespace Gremlin.Net.Process.Traversal.Strategy.Optimization
{
-#pragma warning disable 1591
- public class HaltedTraverserStrategy : AbstractTraversalStrategy
+ /// <summary>
+ /// A strategy.
+ /// </summary>
+ public class MessagePassingReductionStrategy : AbstractTraversalStrategy
{
- private const string JavaFqcn = DecorationNamespace + nameof(HaltedTraverserStrategy);
+ private const string JavaFqcn = ComputerOptimizationNamespace + nameof(MessagePassingReductionStrategy);
- public HaltedTraverserStrategy() : base(JavaFqcn)
+ /// <summary>
+ /// Initializes a new instance of the <see cref="MessagePassingReductionStrategy" /> class.
+ /// </summary>
+ public MessagePassingReductionStrategy() : base(JavaFqcn)
{
}
-
- public HaltedTraverserStrategy(string? haltedTraverserFactoryName = null)
- : this()
- {
- if (haltedTraverserFactoryName != null)
- Configuration["haltedTraverserFactory"] = haltedTraverserFactoryName;
- }
}
-#pragma warning restore 1591
}
\ No newline at end of file
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Decoration/HaltedTraverserStrategy.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Verification/ComputerVerificationStrategy.cs
similarity index 58%
copy from gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Decoration/HaltedTraverserStrategy.cs
copy to gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Verification/ComputerVerificationStrategy.cs
index ffa38fcd9e..fd7319cbbc 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Decoration/HaltedTraverserStrategy.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Verification/ComputerVerificationStrategy.cs
@@ -1,4 +1,4 @@
-#region License
+#region License
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -21,23 +21,20 @@
#endregion
-namespace Gremlin.Net.Process.Traversal.Strategy.Decoration
+namespace Gremlin.Net.Process.Traversal.Strategy.Verification
{
-#pragma warning disable 1591
- public class HaltedTraverserStrategy : AbstractTraversalStrategy
+ /// <summary>
+ /// A strategy.
+ /// </summary>
+ public class ComputerVerificationStrategy : AbstractTraversalStrategy
{
- private const string JavaFqcn = DecorationNamespace + nameof(HaltedTraverserStrategy);
+ private const string JavaFqcn = VerificationNamespace + nameof(ComputerVerificationStrategy);
- public HaltedTraverserStrategy() : base(JavaFqcn)
+ /// <summary>
+ /// Initializes a new instance of the <see cref="ComputerVerificationStrategy" /> class.
+ /// </summary>
+ public ComputerVerificationStrategy() : base(JavaFqcn)
{
}
-
- public HaltedTraverserStrategy(string? haltedTraverserFactoryName = null)
- : this()
- {
- if (haltedTraverserFactoryName != null)
- Configuration["haltedTraverserFactory"] = haltedTraverserFactoryName;
- }
}
-#pragma warning restore 1591
}
\ No newline at end of file
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Decoration/HaltedTraverserStrategy.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Verification/StandardVerificationStrategy.cs
similarity index 58%
copy from gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Decoration/HaltedTraverserStrategy.cs
copy to gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Verification/StandardVerificationStrategy.cs
index ffa38fcd9e..d3c07bb40f 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Decoration/HaltedTraverserStrategy.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Verification/StandardVerificationStrategy.cs
@@ -1,4 +1,4 @@
-#region License
+#region License
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -21,23 +21,20 @@
#endregion
-namespace Gremlin.Net.Process.Traversal.Strategy.Decoration
+namespace Gremlin.Net.Process.Traversal.Strategy.Verification
{
-#pragma warning disable 1591
- public class HaltedTraverserStrategy : AbstractTraversalStrategy
+ /// <summary>
+ /// A strategy
+ /// </summary>
+ public class StandardVerificationStrategy : AbstractTraversalStrategy
{
- private const string JavaFqcn = DecorationNamespace + nameof(HaltedTraverserStrategy);
+ private const string JavaFqcn = VerificationNamespace + nameof(StandardVerificationStrategy);
- public HaltedTraverserStrategy() : base(JavaFqcn)
+ /// <summary>
+ /// Initializes a new instance of the <see cref="StandardVerificationStrategy" /> class.
+ /// </summary>
+ public StandardVerificationStrategy() : base(JavaFqcn)
{
}
-
- public HaltedTraverserStrategy(string? haltedTraverserFactoryName = null)
- : this()
- {
- if (haltedTraverserFactoryName != null)
- Configuration["haltedTraverserFactory"] = haltedTraverserFactoryName;
- }
}
-#pragma warning restore 1591
}
\ No newline at end of file
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Decoration/HaltedTraverserStrategy.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Verification/VertexProgramRestrictionStrategy.cs
similarity index 58%
copy from gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Decoration/HaltedTraverserStrategy.cs
copy to gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Verification/VertexProgramRestrictionStrategy.cs
index ffa38fcd9e..4874cf5dd0 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Decoration/HaltedTraverserStrategy.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Verification/VertexProgramRestrictionStrategy.cs
@@ -1,4 +1,4 @@
-#region License
+#region License
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -21,23 +21,20 @@
#endregion
-namespace Gremlin.Net.Process.Traversal.Strategy.Decoration
+namespace Gremlin.Net.Process.Traversal.Strategy.Verification
{
-#pragma warning disable 1591
- public class HaltedTraverserStrategy : AbstractTraversalStrategy
+ /// <summary>
+ /// A strategy
+ /// </summary>
+ public class VertexProgramRestrictionStrategy : AbstractTraversalStrategy
{
- private const string JavaFqcn = DecorationNamespace + nameof(HaltedTraverserStrategy);
+ private const string JavaFqcn = ComputerVerificationNamespace + nameof(VertexProgramRestrictionStrategy);
- public HaltedTraverserStrategy() : base(JavaFqcn)
+ /// <summary>
+ /// Initializes a new instance of the <see cref="VertexProgramRestrictionStrategy" /> class.
+ /// </summary>
+ public VertexProgramRestrictionStrategy() : base(JavaFqcn)
{
}
-
- public HaltedTraverserStrategy(string? haltedTraverserFactoryName = null)
- : this()
- {
- if (haltedTraverserFactoryName != null)
- Configuration["haltedTraverserFactory"] = haltedTraverserFactoryName;
- }
}
-#pragma warning restore 1591
}
\ No newline at end of file
(tinkerpop) 04/04: Add GraphBinary4 type serializers to gremlin-dotnet (#3313)
Posted by xi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
xiazcy pushed a commit to branch dotnet-http
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git
commit 18b65cb2ebe4b7348139a243439089addf5cdaa1
Author: Ken Hu <10...@users.noreply.github.com>
AuthorDate: Tue Mar 10 15:54:34 2026 -0700
Add GraphBinary4 type serializers to gremlin-dotnet (#3313)
This is just the type serializers but not the message serializers which
will be implemented later. Uses the same style as GraphBinary1 despite
not having custom types.
---
.../Structure/IO/GraphBinary4/DataType.cs | 143 ++++
.../Structure/IO/GraphBinary4/GraphBinaryReader.cs | 96 +++
.../Structure/IO/GraphBinary4/GraphBinaryWriter.cs | 139 ++++
.../Structure/IO/GraphBinary4/ITypeSerializer.cs | 102 +++
.../Structure/IO/GraphBinary4/Marker.cs | 86 +++
.../Structure/IO/GraphBinary4/StreamExtensions.cs | 281 ++++++++
.../IO/GraphBinary4/TypeSerializerRegistry.cs | 219 ++++++
.../IO/GraphBinary4/Types/ArraySerializer.cs | 65 ++
.../IO/GraphBinary4/Types/BigDecimalSerializer.cs | 95 +++
.../IO/GraphBinary4/Types/BigIntegerSerializer.cs | 62 ++
.../IO/GraphBinary4/Types/BinarySerializer.cs | 61 ++
.../IO/GraphBinary4/Types/CharSerializer.cs | 87 +++
.../IO/GraphBinary4/Types/DateTimeSerializer.cs | 78 ++
.../IO/GraphBinary4/Types/DurationSerializer.cs | 63 ++
.../IO/GraphBinary4/Types/EdgeSerializer.cs | 89 +++
.../IO/GraphBinary4/Types/EnumSerializer.cs | 93 +++
.../IO/GraphBinary4/Types/ListSerializer.cs | 95 +++
.../IO/GraphBinary4/Types/MapSerializer.cs | 76 ++
.../IO/GraphBinary4/Types/PathSerializer.cs | 74 ++
.../IO/GraphBinary4/Types/PropertySerializer.cs | 68 ++
.../IO/GraphBinary4/Types/SetSerializer.cs | 77 ++
.../IO/GraphBinary4/Types/SimpleTypeSerializer.cs | 143 ++++
.../IO/GraphBinary4/Types/SingleTypeSerializer.cs | 133 ++++
.../IO/GraphBinary4/Types/StringSerializer.cs | 62 ++
.../IO/GraphBinary4/Types/UuidSerializer.cs | 111 +++
.../GraphBinary4/Types/VertexPropertySerializer.cs | 78 ++
.../IO/GraphBinary4/Types/VertexSerializer.cs | 68 ++
.../Structure/IO/GraphBinary4/GraphBinary4Tests.cs | 794 +++++++++++++++++++++
.../Structure/IO/GraphBinary4/Model.cs | 210 ++++++
.../Structure/IO/GraphBinary4/RoundTripTests.cs | 364 ++++++++++
30 files changed, 4112 insertions(+)
diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphBinary4/DataType.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphBinary4/DataType.cs
new file mode 100644
index 0000000000..9490a34302
--- /dev/null
+++ b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphBinary4/DataType.cs
@@ -0,0 +1,143 @@
+#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;
+
+namespace Gremlin.Net.Structure.IO.GraphBinary4
+{
+ /// <summary>
+ /// Represents a GraphBinary 4.0 data type.
+ /// </summary>
+ public class DataType : IEquatable<DataType>
+ {
+#pragma warning disable 1591
+ public static readonly DataType Int = new DataType(0x01);
+ public static readonly DataType Long = new DataType(0x02);
+ public static readonly DataType String = new DataType(0x03);
+ public static readonly DataType DateTime = new DataType(0x04);
+ public static readonly DataType Double = new DataType(0x07);
+ public static readonly DataType Float = new DataType(0x08);
+ public static readonly DataType List = new DataType(0x09);
+ public static readonly DataType Map = new DataType(0x0A);
+ public static readonly DataType Set = new DataType(0x0B);
+ public static readonly DataType Uuid = new DataType(0x0C);
+ public static readonly DataType Edge = new DataType(0x0D);
+ public static readonly DataType Path = new DataType(0x0E);
+ public static readonly DataType Property = new DataType(0x0F);
+ // Not yet implemented
+ // public static readonly DataType Graph = new DataType(0x10);
+ public static readonly DataType Vertex = new DataType(0x11);
+ public static readonly DataType VertexProperty = new DataType(0x12);
+ public static readonly DataType Direction = new DataType(0x18);
+ public static readonly DataType T = new DataType(0x20);
+ public static readonly DataType BigDecimal = new DataType(0x22);
+ public static readonly DataType BigInteger = new DataType(0x23);
+ public static readonly DataType Byte = new DataType(0x24);
+ public static readonly DataType Binary = new DataType(0x25);
+ public static readonly DataType Short = new DataType(0x26);
+ public static readonly DataType Boolean = new DataType(0x27);
+ // Not yet implemented
+ // public static readonly DataType Tree = new DataType(0x2B);
+ public static readonly DataType Merge = new DataType(0x2E);
+ // Not yet implemented
+ // public static readonly DataType CompositePDT = new DataType(0xF0);
+ // public static readonly DataType PrimitivePDT = new DataType(0xF1);
+ public static readonly DataType Char = new DataType(0x80);
+ public static readonly DataType Duration = new DataType(0x81);
+ public static readonly DataType Marker = new DataType(0xFD);
+#pragma warning restore 1591
+
+ /// <summary>
+ /// A null value for an unspecified Object value.
+ /// </summary>
+ public static readonly DataType UnspecifiedNull = new DataType(0xFE);
+
+ private DataType(int code)
+ {
+ TypeCode = (byte) code;
+ }
+
+ /// <summary>
+ /// Gets the type code of this data type.
+ /// </summary>
+ public byte TypeCode { get; }
+
+ /// <summary>
+ /// Creates a new <see cref="DataType"/> instance for the given type code.
+ /// </summary>
+ public static DataType FromTypeCode(int code)
+ {
+ return new DataType(code);
+ }
+
+ /// <inheritdoc />
+ public bool Equals(DataType? other)
+ {
+ if (ReferenceEquals(null, other)) return false;
+ if (ReferenceEquals(this, other)) return true;
+ return TypeCode == other.TypeCode;
+ }
+
+ /// <inheritdoc />
+ public override bool Equals(object? obj)
+ {
+ if (ReferenceEquals(null, obj)) return false;
+ if (ReferenceEquals(this, obj)) return true;
+ if (obj.GetType() != GetType()) return false;
+ return Equals((DataType) obj);
+ }
+
+ /// <inheritdoc />
+ public override int GetHashCode()
+ {
+ return TypeCode.GetHashCode();
+ }
+
+ /// <summary>
+ /// Determines whether two specified <see cref="DataType"/> have the same values.
+ /// </summary>
+ public static bool operator ==(DataType? first, DataType? second)
+ {
+ if (ReferenceEquals(null, first))
+ {
+ return ReferenceEquals(null, second);
+ }
+
+ return first.Equals(second);
+ }
+
+ /// <summary>
+ /// Determines whether two specified <see cref="DataType"/> have different values.
+ /// </summary>
+ public static bool operator !=(DataType? first, DataType? second)
+ {
+ return !(first == second);
+ }
+
+ /// <inheritdoc />
+ public override string ToString()
+ {
+ return $"DataType{{ TypeCode = {TypeCode} }}";
+ }
+ }
+}
diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphBinary4/GraphBinaryReader.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphBinary4/GraphBinaryReader.cs
new file mode 100644
index 0000000000..ffe9f08f97
--- /dev/null
+++ b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphBinary4/GraphBinaryReader.cs
@@ -0,0 +1,96 @@
+#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.IO;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace Gremlin.Net.Structure.IO.GraphBinary4
+{
+ /// <summary>
+ /// Allows to deserialize objects from GraphBinary v4.
+ /// </summary>
+ public class GraphBinaryReader
+ {
+ private readonly TypeSerializerRegistry _registry;
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="GraphBinaryReader" /> class.
+ /// </summary>
+ /// <param name="registry">The <see cref="TypeSerializerRegistry"/> to use for deserialization.</param>
+ public GraphBinaryReader(TypeSerializerRegistry? registry = null)
+ {
+ _registry = registry ?? TypeSerializerRegistry.Instance;
+ }
+
+ /// <summary>
+ /// Reads only the value for a specific type <typeparamref name="T"/>.
+ /// </summary>
+ /// <param name="stream">The GraphBinary data to parse.</param>
+ /// <param name="cancellationToken">The token to cancel the operation. The default value is None.</param>
+ /// <typeparam name="T">The type of the object to read.</typeparam>
+ /// <returns>The read value.</returns>
+ public async Task<object?> ReadNullableValueAsync<T>(Stream stream,
+ CancellationToken cancellationToken = default)
+ {
+ var typedSerializer = _registry.GetSerializerFor(typeof(T));
+ return await typedSerializer.ReadNullableValueAsync(stream, this, cancellationToken)
+ .ConfigureAwait(false);
+ }
+
+ /// <summary>
+ /// Reads only the value for a specific type <typeparamref name="T"/>.
+ /// </summary>
+ /// <param name="stream">The GraphBinary data to parse.</param>
+ /// <param name="cancellationToken">The token to cancel the operation. The default value is None.</param>
+ /// <typeparam name="T">The type of the object to read.</typeparam>
+ /// <returns>The read value.</returns>
+ public async Task<object> ReadNonNullableValueAsync<T>(Stream stream,
+ CancellationToken cancellationToken = default)
+ {
+ var typedSerializer = _registry.GetSerializerFor(typeof(T));
+ return await typedSerializer.ReadNonNullableValueAsync(stream, this, cancellationToken)
+ .ConfigureAwait(false);
+ }
+
+ /// <summary>
+ /// Reads the type code, information and value with fully-qualified format.
+ /// </summary>
+ /// <param name="stream">The GraphBinary data to parse.</param>
+ /// <param name="cancellationToken">The token to cancel the operation. The default value is None.</param>
+ /// <returns>The read value.</returns>
+ public async Task<object?> ReadAsync(Stream stream, CancellationToken cancellationToken = default)
+ {
+ var type = DataType.FromTypeCode(await stream.ReadByteAsync(cancellationToken).ConfigureAwait(false));
+
+ if (type == DataType.UnspecifiedNull)
+ {
+ await stream.ReadByteAsync(cancellationToken).ConfigureAwait(false); // read value byte to advance the index
+ return null;
+ }
+
+ var typeSerializer = _registry.GetSerializerFor(type);
+ return await typeSerializer.ReadAsync(stream, this, cancellationToken).ConfigureAwait(false);
+ }
+ }
+}
\ No newline at end of file
diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphBinary4/GraphBinaryWriter.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphBinary4/GraphBinaryWriter.cs
new file mode 100644
index 0000000000..c5c4fc6a7d
--- /dev/null
+++ b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphBinary4/GraphBinaryWriter.cs
@@ -0,0 +1,139 @@
+#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.IO;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace Gremlin.Net.Structure.IO.GraphBinary4
+{
+ /// <summary>
+ /// Allows to serialize objects to GraphBinary v4.
+ /// </summary>
+ public class GraphBinaryWriter
+ {
+ private const byte ValueFlagNull = 1;
+ private const byte ValueFlagNone = 0;
+
+ /// <summary>
+ /// A <see cref="byte"/> representing the version of the GraphBinary v4 specification.
+ /// </summary>
+ public const byte VersionByte = 0x84;
+
+ private static readonly byte[] UnspecifiedNullBytes = {DataType.UnspecifiedNull.TypeCode, 0x01};
+
+ private readonly TypeSerializerRegistry _registry;
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="GraphBinaryWriter" /> class.
+ /// </summary>
+ /// <param name="registry">The <see cref="TypeSerializerRegistry"/> to use for serialization.</param>
+ public GraphBinaryWriter(TypeSerializerRegistry? registry = null)
+ {
+ _registry = registry ?? TypeSerializerRegistry.Instance;
+ }
+
+ /// <summary>
+ /// Writes a nullable value without including type information.
+ /// </summary>
+ /// <param name="value">The value to write.</param>
+ /// <param name="stream">The stream to write to.</param>
+ /// <param name="cancellationToken">The token to cancel the operation. The default value is None.</param>
+ /// <returns>A task that represents the asynchronous write operation.</returns>
+ public async Task WriteNullableValueAsync(object? value, Stream stream,
+ CancellationToken cancellationToken = default)
+ {
+ if (value == null)
+ {
+ await WriteValueFlagNullAsync(stream, cancellationToken).ConfigureAwait(false);
+ return;
+ }
+
+ var valueType = value.GetType();
+ var serializer = _registry.GetSerializerFor(valueType);
+ await serializer.WriteNullableValueAsync(value, stream, this, cancellationToken).ConfigureAwait(false);
+ }
+
+ /// <summary>
+ /// Writes a non-nullable value without including type information.
+ /// </summary>
+ /// <param name="value">The value to write.</param>
+ /// <param name="stream">The stream to write to.</param>
+ /// <param name="cancellationToken">The token to cancel the operation. The default value is None.</param>
+ /// <returns>A task that represents the asynchronous write operation.</returns>
+ public async Task WriteNonNullableValueAsync(object value, Stream stream,
+ CancellationToken cancellationToken = default)
+ {
+ if (value == null) throw new IOException($"{nameof(value)} cannot be null");
+ var valueType = value.GetType();
+ var serializer = _registry.GetSerializerFor(valueType);
+ await serializer.WriteNonNullableValueAsync(value, stream, this, cancellationToken).ConfigureAwait(false);
+ }
+
+ /// <summary>
+ /// Writes an object in fully-qualified format, containing {type_code}{type_info}{value_flag}{value}.
+ /// </summary>
+ /// <param name="value">The value to write.</param>
+ /// <param name="stream">The stream to write to.</param>
+ /// <param name="cancellationToken">The token to cancel the operation. The default value is None.</param>
+ /// <returns>A task that represents the asynchronous write operation.</returns>
+ public async Task WriteAsync(object? value, Stream stream, CancellationToken cancellationToken = default)
+ {
+ if (value == null)
+ {
+ await stream.WriteAsync(UnspecifiedNullBytes, cancellationToken).ConfigureAwait(false);
+ return;
+ }
+
+ var valueType = value.GetType();
+ var serializer = _registry.GetSerializerFor(valueType);
+
+ await stream.WriteByteAsync(serializer.DataType.TypeCode, cancellationToken).ConfigureAwait(false);
+ await serializer.WriteAsync(value, stream, this, cancellationToken).ConfigureAwait(false);
+ }
+
+ /// <summary>
+ /// Writes a single byte representing the null value_flag.
+ /// </summary>
+ /// <param name="stream">The stream to write to.</param>
+ /// <param name="cancellationToken">The token to cancel the operation. The default value is None.</param>
+ /// <returns>A task that represents the asynchronous write operation.</returns>
+ public async Task WriteValueFlagNullAsync(Stream stream, CancellationToken cancellationToken = default)
+ {
+ await stream.WriteByteAsync(ValueFlagNull, cancellationToken).ConfigureAwait(false);
+ }
+
+ /// <summary>
+ /// Writes a single byte with value 0, representing an unset value_flag.
+ /// </summary>
+ /// <param name="stream">The stream to write to.</param>
+ /// <param name="cancellationToken">The token to cancel the operation. The default value is None.</param>
+ /// <returns>A task that represents the asynchronous write operation.</returns>
+ public async Task WriteValueFlagNoneAsync(Stream stream, CancellationToken cancellationToken = default) {
+ await stream.WriteByteAsync(ValueFlagNone, cancellationToken).ConfigureAwait(false);
+ }
+
+
+ }
+}
\ No newline at end of file
diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphBinary4/ITypeSerializer.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphBinary4/ITypeSerializer.cs
new file mode 100644
index 0000000000..9a195ef812
--- /dev/null
+++ b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphBinary4/ITypeSerializer.cs
@@ -0,0 +1,102 @@
+#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.IO;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace Gremlin.Net.Structure.IO.GraphBinary4
+{
+ /// <summary>
+ /// Represents a serializer for a certain type.
+ /// </summary>
+ public interface ITypeSerializer
+ {
+ /// <summary>
+ /// Gets the <see cref="DataType"/> that supported by this serializer.
+ /// </summary>
+ DataType DataType { get; }
+
+ /// <summary>
+ /// Writes the type code, information and value to a stream.
+ /// </summary>
+ /// <param name="value">The value to write.</param>
+ /// <param name="stream">The stream to write to.</param>
+ /// <param name="writer">A <see cref="GraphBinaryWriter"/> that can be used to write nested values.</param>
+ /// <param name="cancellationToken">The token to cancel the operation. The default value is None.</param>
+ /// <returns>A task that represents the asynchronous write operation.</returns>
+ Task WriteAsync(object value, Stream stream, GraphBinaryWriter writer,
+ CancellationToken cancellationToken = default);
+
+ /// <summary>
+ /// Writes the nullable value to a stream, composed by the value flag and the sequence of bytes.
+ /// </summary>
+ /// <param name="value">The value to write.</param>
+ /// <param name="stream">The stream to write to.</param>
+ /// <param name="writer">A <see cref="GraphBinaryWriter"/> that can be used to write nested values.</param>
+ /// <param name="cancellationToken">The token to cancel the operation. The default value is None.</param>
+ /// <returns>A task that represents the asynchronous write operation.</returns>
+ Task WriteNullableValueAsync(object? value, Stream stream, GraphBinaryWriter writer,
+ CancellationToken cancellationToken = default);
+
+ /// <summary>
+ /// Writes the non-nullable value to a stream, composed by the value flag and the sequence of bytes.
+ /// </summary>
+ /// <param name="value">The value to write.</param>
+ /// <param name="stream">The stream to write to.</param>
+ /// <param name="writer">A <see cref="GraphBinaryWriter"/> that can be used to write nested values.</param>
+ /// <param name="cancellationToken">The token to cancel the operation. The default value is None.</param>
+ /// <returns>A task that represents the asynchronous write operation.</returns>
+ Task WriteNonNullableValueAsync(object value, Stream stream, GraphBinaryWriter writer,
+ CancellationToken cancellationToken = default);
+
+ /// <summary>
+ /// Reads the type information and value from the stream.
+ /// </summary>
+ /// <param name="stream">The GraphBinary data to parse.</param>
+ /// <param name="reader">A <see cref="GraphBinaryReader"/> that can be used to read nested values.</param>
+ /// <param name="cancellationToken">The token to cancel the operation. The default value is None.</param>
+ /// <returns>The read value.</returns>
+ Task<object?> ReadAsync(Stream stream, GraphBinaryReader reader, CancellationToken cancellationToken = default);
+
+ /// <summary>
+ /// Reads the value from the stream (not the type information).
+ /// </summary>
+ /// <param name="stream">The GraphBinary data to parse.</param>
+ /// <param name="reader">A <see cref="GraphBinaryReader"/> that can be used to read nested values.</param>
+ /// <param name="cancellationToken">The token to cancel the operation. The default value is None.</param>
+ /// <returns>The read value.</returns>
+ Task<object?> ReadNullableValueAsync(Stream stream, GraphBinaryReader reader,
+ CancellationToken cancellationToken = default);
+
+ /// <summary>
+ /// Reads the value from the stream (not the type information).
+ /// </summary>
+ /// <param name="stream">The GraphBinary data to parse.</param>
+ /// <param name="reader">A <see cref="GraphBinaryReader"/> that can be used to read nested values.</param>
+ /// <param name="cancellationToken">The token to cancel the operation. The default value is None.</param>
+ /// <returns>The read value.</returns>
+ Task<object> ReadNonNullableValueAsync(Stream stream, GraphBinaryReader reader,
+ CancellationToken cancellationToken = default);
+ }
+}
\ No newline at end of file
diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphBinary4/Marker.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphBinary4/Marker.cs
new file mode 100644
index 0000000000..d13f1d3fbb
--- /dev/null
+++ b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphBinary4/Marker.cs
@@ -0,0 +1,86 @@
+#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;
+
+namespace Gremlin.Net.Structure.IO.GraphBinary4
+{
+ /// <summary>
+ /// Represents a special marker type for stream boundaries in GraphBinary 4.0 serialization.
+ /// </summary>
+ /// <remarks>
+ /// Markers are used to indicate stream boundaries in GraphBinary 4.0 responses.
+ /// The <see cref="EndOfStream"/> marker indicates the end of result data in a response,
+ /// signaling that the footer (status code, message, exception) follows.
+ /// </remarks>
+ public sealed class Marker
+ {
+ /// <summary>
+ /// Marker indicating the end of the result stream.
+ /// </summary>
+ /// <remarks>
+ /// In GraphBinary 4.0 response format, this marker (type code 0xFD with value 0x00)
+ /// separates the result data from the response footer.
+ /// </remarks>
+ public static readonly Marker EndOfStream = new Marker(0);
+
+ /// <summary>
+ /// Gets the byte value of this marker as used on the wire.
+ /// </summary>
+ public byte Value { get; }
+
+ private Marker(byte value)
+ {
+ Value = value;
+ }
+
+ /// <summary>
+ /// Returns the <see cref="Marker"/> instance for the given byte value.
+ /// </summary>
+ /// <param name="value">The marker byte value.</param>
+ /// <returns>The corresponding <see cref="Marker"/> instance.</returns>
+ /// <exception cref="ArgumentException">Thrown if the value is not a known marker.</exception>
+ public static Marker Of(byte value)
+ {
+ if (value != 0)
+ {
+ throw new ArgumentException($"Unknown marker value: {value}", nameof(value));
+ }
+ return EndOfStream;
+ }
+
+ /// <inheritdoc />
+ public override string ToString() => $"Marker({Value})";
+
+ /// <inheritdoc />
+ public override bool Equals(object? obj)
+ {
+ if (obj is null) return false;
+ if (ReferenceEquals(this, obj)) return true;
+ return obj is Marker other && Value == other.Value;
+ }
+
+ /// <inheritdoc />
+ public override int GetHashCode() => Value.GetHashCode();
+ }
+}
diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphBinary4/StreamExtensions.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphBinary4/StreamExtensions.cs
new file mode 100644
index 0000000000..e85767289f
--- /dev/null
+++ b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphBinary4/StreamExtensions.cs
@@ -0,0 +1,281 @@
+#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.IO;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace Gremlin.Net.Structure.IO.GraphBinary4
+{
+ /// <summary>
+ /// Provides extension methods for <see cref="Stream" /> that are mostly useful when implementing GraphBinary
+ /// serializers.
+ /// </summary>
+ public static class StreamExtensions
+ {
+ /// <summary>
+ /// Asynchronously writes a <see cref="byte"/> to a <see cref="Stream"/>.
+ /// </summary>
+ /// <param name="stream">The <see cref="Stream"/> to write the <see cref="byte"/> to.</param>
+ /// <param name="value">The <see cref="byte"/> to write.</param>
+ /// <param name="cancellationToken">The token to cancel the operation. The default value is None.</param>
+ public static async Task WriteByteAsync(this Stream stream, byte value,
+ CancellationToken cancellationToken = default)
+ {
+ await stream.WriteAsync(new[] {value}, 0, 1, cancellationToken).ConfigureAwait(false);
+ }
+
+ /// <summary>
+ /// Asynchronously reads a <see cref="byte"/> from a <see cref="Stream"/>.
+ /// </summary>
+ /// <param name="stream">The <see cref="Stream"/> to read from.</param>
+ /// <param name="cancellationToken">The token to cancel the operation. The default value is None.</param>
+ /// <returns>The read <see cref="byte"/>.</returns>
+ public static async Task<byte> ReadByteAsync(this Stream stream, CancellationToken cancellationToken = default)
+ {
+ var readBuffer = new byte[1];
+ await stream.ReadAsync(readBuffer, 0, 1, cancellationToken).ConfigureAwait(false);
+ return readBuffer[0];
+ }
+
+ /// <summary>
+ /// Asynchronously writes a <see cref="sbyte"/> to a <see cref="Stream"/>.
+ /// </summary>
+ /// <param name="stream">The <see cref="Stream"/> to write the <see cref="sbyte"/> to.</param>
+ /// <param name="value">The <see cref="sbyte"/> to write.</param>
+ /// <param name="cancellationToken">The token to cancel the operation. The default value is None.</param>
+ public static async Task WriteSByteAsync(this Stream stream, sbyte value,
+ CancellationToken cancellationToken = default)
+ {
+ await stream.WriteByteAsync((byte)value, cancellationToken).ConfigureAwait(false);
+ }
+
+ /// <summary>
+ /// Asynchronously reads a <see cref="sbyte"/> from a <see cref="Stream"/>.
+ /// </summary>
+ /// <param name="stream">The <see cref="Stream"/> to read from.</param>
+ /// <param name="cancellationToken">The token to cancel the operation. The default value is None.</param>
+ /// <returns>The read <see cref="sbyte"/>.</returns>
+ public static async Task<sbyte> ReadSByteAsync(this Stream stream, CancellationToken cancellationToken = default)
+ {
+ return (sbyte)await stream.ReadByteAsync(cancellationToken).ConfigureAwait(false);
+ }
+
+ /// <summary>
+ /// Asynchronously writes an <see cref="int"/> to a <see cref="Stream"/>.
+ /// </summary>
+ /// <param name="stream">The <see cref="Stream"/> to write the <see cref="int"/> to.</param>
+ /// <param name="value">The <see cref="int"/> to write.</param>
+ /// <param name="cancellationToken">The token to cancel the operation. The default value is None.</param>
+ public static async Task WriteIntAsync(this Stream stream, int value,
+ CancellationToken cancellationToken = default)
+ {
+ var bytes = BitConverter.GetBytes(value);
+ await stream.WriteAsync(new[] { bytes[3], bytes[2], bytes[1], bytes[0] }, 0, 4, cancellationToken).ConfigureAwait(false);
+ }
+
+ /// <summary>
+ /// Asynchronously reads an <see cref="int"/> from a <see cref="Stream"/>.
+ /// </summary>
+ /// <param name="stream">The <see cref="Stream"/> to read from.</param>
+ /// <param name="cancellationToken">The token to cancel the operation. The default value is None.</param>
+ /// <returns>The read <see cref="int"/>.</returns>
+ public static async Task<int> ReadIntAsync(this Stream stream, CancellationToken cancellationToken = default)
+ {
+ var bytes = new byte[4];
+ await stream.ReadAsync(bytes, 0, 4, cancellationToken).ConfigureAwait(false);
+ return BitConverter.ToInt32(new []{bytes[3], bytes[2], bytes[1], bytes[0]}, 0);
+ }
+
+ /// <summary>
+ /// Asynchronously writes a <see cref="long"/> to a <see cref="Stream"/>.
+ /// </summary>
+ /// <param name="stream">The <see cref="Stream"/> to write the <see cref="long"/> to.</param>
+ /// <param name="value">The <see cref="long"/> to write.</param>
+ /// <param name="cancellationToken">The token to cancel the operation. The default value is None.</param>
+ public static async Task WriteLongAsync(this Stream stream, long value,
+ CancellationToken cancellationToken = default)
+ {
+ var bytes = BitConverter.GetBytes(value);
+ await stream
+ .WriteAsync(new[] { bytes[7], bytes[6], bytes[5], bytes[4], bytes[3], bytes[2], bytes[1], bytes[0] }, 0,
+ 8, cancellationToken).ConfigureAwait(false);
+ }
+
+ /// <summary>
+ /// Asynchronously reads a <see cref="long"/> from a <see cref="Stream"/>.
+ /// </summary>
+ /// <param name="stream">The <see cref="Stream"/> to read from.</param>
+ /// <param name="cancellationToken">The token to cancel the operation. The default value is None.</param>
+ /// <returns>The read <see cref="long"/>.</returns>
+ public static async Task<long> ReadLongAsync(this Stream stream, CancellationToken cancellationToken = default)
+ {
+ var bytes = new byte[8];
+ await stream.ReadAsync(bytes, 0, 8, cancellationToken).ConfigureAwait(false);
+ return BitConverter.ToInt64(
+ new[] {bytes[7], bytes[6], bytes[5], bytes[4], bytes[3], bytes[2], bytes[1], bytes[0]}, 0);
+ }
+
+ /// <summary>
+ /// Asynchronously writes a <see cref="float"/> to a <see cref="Stream"/>.
+ /// </summary>
+ /// <param name="stream">The <see cref="Stream"/> to write the <see cref="float"/> to.</param>
+ /// <param name="value">The <see cref="float"/> to write.</param>
+ /// <param name="cancellationToken">The token to cancel the operation. The default value is None.</param>
+ public static async Task WriteFloatAsync(this Stream stream, float value,
+ CancellationToken cancellationToken = default)
+ {
+ var bytes = BitConverter.GetBytes(value);
+ await stream.WriteAsync(new[] { bytes[3], bytes[2], bytes[1], bytes[0] }, 0, 4, cancellationToken)
+ .ConfigureAwait(false);
+ }
+
+ /// <summary>
+ /// Asynchronously reads a <see cref="float"/> from a <see cref="Stream"/>.
+ /// </summary>
+ /// <param name="stream">The <see cref="Stream"/> to read from.</param>
+ /// <param name="cancellationToken">The token to cancel the operation. The default value is None.</param>
+ /// <returns>The read <see cref="float"/>.</returns>
+ public static async Task<float> ReadFloatAsync(this Stream stream,
+ CancellationToken cancellationToken = default)
+ {
+ var bytes = new byte[4];
+ await stream.ReadAsync(bytes, 0, 4, cancellationToken).ConfigureAwait(false);
+ return BitConverter.ToSingle(new []{bytes[3], bytes[2], bytes[1], bytes[0]}, 0);
+ }
+
+ /// <summary>
+ /// Asynchronously writes a <see cref="double"/> to a <see cref="Stream"/>.
+ /// </summary>
+ /// <param name="stream">The <see cref="Stream"/> to write the <see cref="double"/> to.</param>
+ /// <param name="value">The <see cref="double"/> to write.</param>
+ /// <param name="cancellationToken">The token to cancel the operation. The default value is None.</param>
+ public static async Task WriteDoubleAsync(this Stream stream, double value,
+ CancellationToken cancellationToken = default)
+ {
+ var bytes = BitConverter.GetBytes(value);
+ await stream
+ .WriteAsync(new[] {bytes[7], bytes[6], bytes[5], bytes[4], bytes[3], bytes[2], bytes[1], bytes[0]}, 0,
+ 8, cancellationToken).ConfigureAwait(false);
+ }
+
+ /// <summary>
+ /// Asynchronously reads a <see cref="double"/> from a <see cref="Stream"/>.
+ /// </summary>
+ /// <param name="stream">The <see cref="Stream"/> to read from.</param>
+ /// <param name="cancellationToken">The token to cancel the operation. The default value is None.</param>
+ /// <returns>The read <see cref="double"/>.</returns>
+ public static async Task<double> ReadDoubleAsync(this Stream stream,
+ CancellationToken cancellationToken = default)
+ {
+ var bytes = new byte[8];
+ await stream.ReadAsync(bytes, 0, 8, cancellationToken).ConfigureAwait(false);
+ return BitConverter.ToDouble(
+ new[] {bytes[7], bytes[6], bytes[5], bytes[4], bytes[3], bytes[2], bytes[1], bytes[0]}, 0);
+ }
+
+ /// <summary>
+ /// Asynchronously writes a <see cref="short"/> to a <see cref="Stream"/>.
+ /// </summary>
+ /// <param name="stream">The <see cref="Stream"/> to write the <see cref="short"/> to.</param>
+ /// <param name="value">The <see cref="short"/> to write.</param>
+ /// <param name="cancellationToken">The token to cancel the operation. The default value is None.</param>
+ public static async Task WriteShortAsync(this Stream stream, short value,
+ CancellationToken cancellationToken = default)
+ {
+ var bytes = BitConverter.GetBytes(value);
+ await stream.WriteAsync(new[] { bytes[1], bytes[0] }, 0, 2, cancellationToken).ConfigureAwait(false);
+ }
+
+ /// <summary>
+ /// Asynchronously reads a <see cref="short"/> from a <see cref="Stream"/>.
+ /// </summary>
+ /// <param name="stream">The <see cref="Stream"/> to read from.</param>
+ /// <param name="cancellationToken">The token to cancel the operation. The default value is None.</param>
+ /// <returns>The read <see cref="short"/>.</returns>
+ public static async Task<short> ReadShortAsync(this Stream stream,
+ CancellationToken cancellationToken = default)
+ {
+ var bytes = new byte[2];
+ await stream.ReadAsync(bytes, 0, 2, cancellationToken).ConfigureAwait(false);
+ return BitConverter.ToInt16(new []{bytes[1], bytes[0]}, 0);
+ }
+
+ /// <summary>
+ /// Asynchronously writes a <see cref="bool"/> to a <see cref="Stream"/>.
+ /// </summary>
+ /// <param name="stream">The <see cref="Stream"/> to write the <see cref="bool"/> to.</param>
+ /// <param name="value">The <see cref="bool"/> to write.</param>
+ /// <param name="cancellationToken">The token to cancel the operation. The default value is None.</param>
+ public static async Task WriteBoolAsync(this Stream stream, bool value,
+ CancellationToken cancellationToken = default)
+ {
+ await stream.WriteByteAsync((byte)(value ? 1 : 0), cancellationToken).ConfigureAwait(false);
+ }
+
+ /// <summary>
+ /// Asynchronously reads a <see cref="bool"/> from a <see cref="Stream"/>.
+ /// </summary>
+ /// <param name="stream">The <see cref="Stream"/> to read from.</param>
+ /// <param name="cancellationToken">The token to cancel the operation. The default value is None.</param>
+ /// <returns>The read <see cref="bool"/>.</returns>
+ public static async Task<bool> ReadBoolAsync(this Stream stream, CancellationToken cancellationToken = default)
+ {
+ var b = await stream.ReadByteAsync(cancellationToken).ConfigureAwait(false);
+ return b switch
+ {
+ 1 => true,
+ 0 => false,
+ _ => throw new IOException($"Cannot read byte {b} as a boolean.")
+ };
+ }
+
+ /// <summary>
+ /// Asynchronously writes a <see cref="T:byte[]"/> to a <see cref="Stream"/>.
+ /// </summary>
+ /// <param name="stream">The <see cref="Stream"/> to write the <see cref="T:byte[]"/> to.</param>
+ /// <param name="value">The <see cref="T:byte[]"/> to write.</param>
+ /// <param name="cancellationToken">The token to cancel the operation. The default value is None.</param>
+ public static async Task WriteAsync(this Stream stream, byte[] value,
+ CancellationToken cancellationToken = default)
+ {
+ await stream.WriteAsync(value, 0, value.Length, cancellationToken).ConfigureAwait(false);
+ }
+
+ /// <summary>
+ /// Asynchronously reads a <see cref="T:byte[]"/> from a <see cref="Stream"/> into a buffer.
+ /// </summary>
+ /// <param name="stream">The <see cref="Stream"/> to read from.</param>
+ /// <param name="count">The number of bytes to read.</param>
+ /// <param name="cancellationToken">The token to cancel the operation. The default value is None.</param>
+ /// <returns>The read <see cref="T:byte[]"/>.</returns>
+ public static async Task<byte[]> ReadAsync(this Stream stream, int count,
+ CancellationToken cancellationToken = default)
+ {
+ var buffer = new byte[count];
+ await stream.ReadAsync(buffer, 0, count, cancellationToken).ConfigureAwait(false);
+ return buffer;
+ }
+ }
+}
\ No newline at end of file
diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphBinary4/TypeSerializerRegistry.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphBinary4/TypeSerializerRegistry.cs
new file mode 100644
index 0000000000..82421f14a1
--- /dev/null
+++ b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphBinary4/TypeSerializerRegistry.cs
@@ -0,0 +1,219 @@
+#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;
+using System.Diagnostics.CodeAnalysis;
+using System.IO;
+using System.Linq;
+using System.Numerics;
+using Gremlin.Net.Process.Traversal;
+using Gremlin.Net.Structure.IO.GraphBinary4.Types;
+
+namespace Gremlin.Net.Structure.IO.GraphBinary4
+{
+ /// <summary>
+ /// Provides GraphBinary 4.0 serializers for different types.
+ /// </summary>
+ public class TypeSerializerRegistry
+ {
+ private readonly Dictionary<Type, ITypeSerializer> _serializerByType =
+ new Dictionary<Type, ITypeSerializer>
+ {
+ {typeof(int), SingleTypeSerializers.IntSerializer},
+ {typeof(long), SingleTypeSerializers.LongSerializer},
+ {typeof(string), new StringSerializer()},
+ {typeof(DateTimeOffset), new DateTimeSerializer()},
+ {typeof(double), SingleTypeSerializers.DoubleSerializer},
+ {typeof(float), SingleTypeSerializers.FloatSerializer},
+ {typeof(Guid), new UuidSerializer()},
+ {typeof(Edge), new EdgeSerializer()},
+ {typeof(Path), new PathSerializer()},
+ {typeof(Property), new PropertySerializer()},
+ {typeof(Vertex), new VertexSerializer()},
+ {typeof(VertexProperty), new VertexPropertySerializer()},
+ {typeof(Direction), EnumSerializers.DirectionSerializer},
+ {typeof(Merge), EnumSerializers.MergeSerializer},
+ {typeof(T), EnumSerializers.TSerializer},
+ {typeof(decimal), new BigDecimalSerializer()},
+ {typeof(BigInteger), new BigIntegerSerializer()},
+ {typeof(sbyte), SingleTypeSerializers.ByteSerializer},
+ {typeof(byte[]), new BinarySerializer()},
+ {typeof(short), SingleTypeSerializers.ShortSerializer},
+ {typeof(bool), SingleTypeSerializers.BooleanSerializer},
+ {typeof(char), new CharSerializer()},
+ {typeof(TimeSpan), new DurationSerializer()},
+ {typeof(Marker), SingleTypeSerializers.MarkerSerializer},
+ };
+
+ private readonly Dictionary<DataType, ITypeSerializer> _serializerByDataType =
+ new Dictionary<DataType, ITypeSerializer>
+ {
+ {DataType.Int, SingleTypeSerializers.IntSerializer},
+ {DataType.Long, SingleTypeSerializers.LongSerializer},
+ {DataType.String, new StringSerializer()},
+ {DataType.DateTime, new DateTimeSerializer()},
+ {DataType.Double, SingleTypeSerializers.DoubleSerializer},
+ {DataType.Float, SingleTypeSerializers.FloatSerializer},
+ {DataType.List, new ListSerializer<object>()},
+ {DataType.Map, new MapSerializer<object, object>()},
+ {DataType.Set, new SetSerializer<HashSet<object?>, object>()},
+ {DataType.Uuid, new UuidSerializer()},
+ {DataType.Edge, new EdgeSerializer()},
+ {DataType.Path, new PathSerializer()},
+ {DataType.Property, new PropertySerializer()},
+ {DataType.Vertex, new VertexSerializer()},
+ {DataType.VertexProperty, new VertexPropertySerializer()},
+ {DataType.Direction, EnumSerializers.DirectionSerializer},
+ {DataType.Merge, EnumSerializers.MergeSerializer},
+ {DataType.T, EnumSerializers.TSerializer},
+ {DataType.BigDecimal, new BigDecimalSerializer()},
+ {DataType.BigInteger, new BigIntegerSerializer()},
+ {DataType.Byte, SingleTypeSerializers.ByteSerializer},
+ {DataType.Binary, new BinarySerializer()},
+ {DataType.Short, SingleTypeSerializers.ShortSerializer},
+ {DataType.Boolean, SingleTypeSerializers.BooleanSerializer},
+ {DataType.Char, new CharSerializer()},
+ {DataType.Duration, new DurationSerializer()},
+ {DataType.Marker, SingleTypeSerializers.MarkerSerializer},
+ };
+
+ /// <summary>
+ /// Provides a default <see cref="TypeSerializerRegistry"/> instance.
+ /// </summary>
+ public static readonly TypeSerializerRegistry Instance = new TypeSerializerRegistry();
+
+ /// <summary>
+ /// Gets a serializer for the given type of the value to be serialized.
+ /// </summary>
+ /// <param name="valueType">Type of the value to be serialized.</param>
+ /// <returns>A serializer for the provided type.</returns>
+ /// <exception cref="InvalidOperationException">Thrown when no serializer can be found for the type.</exception>
+ public ITypeSerializer GetSerializerFor(Type valueType)
+ {
+ if (_serializerByType.TryGetValue(valueType, out var serializerForType))
+ {
+ return serializerForType;
+ }
+
+ if (IsDictionaryType(valueType, out var dictKeyType, out var dictValueType))
+ {
+ var serializerType = typeof(MapSerializer<,>).MakeGenericType(dictKeyType, dictValueType);
+ var serializer = (ITypeSerializer?) Activator.CreateInstance(serializerType);
+ _serializerByType[valueType] = serializer ??
+ throw new IOException(
+ $"Cannot create a serializer for the dictionary type {valueType}.");
+ return serializer;
+ }
+
+ if (IsSetType(valueType))
+ {
+ var memberType = valueType.GetGenericArguments()[0];
+ var serializerType = typeof(SetSerializer<,>).MakeGenericType(valueType, memberType);
+ var serializer = (ITypeSerializer?) Activator.CreateInstance(serializerType);
+ _serializerByType[valueType] = serializer ??
+ throw new IOException(
+ $"Cannot create a serializer for the set type {valueType}.");
+ return serializer;
+ }
+
+ if (valueType.IsArray)
+ {
+ var memberType = valueType.GetElementType();
+ var serializerType = typeof(ArraySerializer<>).MakeGenericType(memberType!);
+ var serializer = (ITypeSerializer?) Activator.CreateInstance(serializerType);
+ _serializerByType[valueType] = serializer ??
+ throw new IOException(
+ $"Cannot create a serializer for the array type {valueType}.");
+ return serializer;
+ }
+
+ if (IsListType(valueType))
+ {
+ var memberType = valueType.GetGenericArguments()[0];
+ var serializerType = typeof(ListSerializer<>).MakeGenericType(memberType);
+ var serializer = (ITypeSerializer?) Activator.CreateInstance(serializerType);
+ _serializerByType[valueType] = serializer ??
+ throw new IOException(
+ $"Cannot create a serializer for the list type {valueType}.");
+ return serializer;
+ }
+
+ foreach (var supportedType in new List<Type>(_serializerByType.Keys))
+ {
+ if (supportedType.IsAssignableFrom(valueType))
+ {
+ var serializer = _serializerByType[supportedType];
+ _serializerByType[valueType] = serializer;
+ return serializer;
+ }
+ }
+
+ throw new InvalidOperationException($"No serializer found for type '{valueType}'.");
+ }
+
+ /// <summary>
+ /// Gets a serializer for the given GraphBinary 4.0 data type code.
+ /// </summary>
+ /// <param name="dataType">The GraphBinary 4.0 data type.</param>
+ /// <returns>A serializer for the provided data type.</returns>
+ public ITypeSerializer GetSerializerFor(DataType dataType)
+ {
+ return _serializerByDataType[dataType];
+ }
+
+ private static bool IsDictionaryType(Type type, [NotNullWhen(returnValue: true)] out Type? keyType,
+ [NotNullWhen(returnValue: true)] out Type? valueType)
+ {
+ var maybeInterfaceType = type
+ .GetInterfaces()
+ .FirstOrDefault(implementedInterfaceType => implementedInterfaceType.IsConstructedGenericType && implementedInterfaceType.GetGenericTypeDefinition() == typeof(IDictionary<,>));
+
+ if (maybeInterfaceType is { } interfaceType)
+ {
+ keyType = interfaceType.GetGenericArguments()[0];
+ valueType = interfaceType.GetGenericArguments()[1];
+ return true;
+ }
+
+ keyType = null;
+ valueType = null;
+ return false;
+ }
+
+ private static bool IsSetType(Type type)
+ {
+ return type.GetInterfaces().Any(implementedInterface => implementedInterface.IsConstructedGenericType &&
+ implementedInterface.GetGenericTypeDefinition() ==
+ typeof(ISet<>));
+ }
+
+ private static bool IsListType(Type type)
+ {
+ return type.GetInterfaces().Any(implementedInterface => implementedInterface.IsConstructedGenericType &&
+ implementedInterface.GetGenericTypeDefinition() ==
+ typeof(IList<>));
+ }
+
+ }
+}
diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphBinary4/Types/ArraySerializer.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphBinary4/Types/ArraySerializer.cs
new file mode 100644
index 0000000000..c4f939b516
--- /dev/null
+++ b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphBinary4/Types/ArraySerializer.cs
@@ -0,0 +1,65 @@
+#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.IO;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace Gremlin.Net.Structure.IO.GraphBinary4.Types
+{
+ /// <summary>
+ /// A serializer that serializes .NET arrays to GraphBinary4 lists.
+ /// </summary>
+ /// <typeparam name="TMember">The type of elements in the array.</typeparam>
+ public class ArraySerializer<TMember> : SimpleTypeSerializer<TMember[]>
+ {
+ /// <summary>
+ /// Initializes a new instance of the <see cref="ArraySerializer{TMember}" /> class.
+ /// </summary>
+ public ArraySerializer() : base(DataType.List)
+ {
+ }
+
+ /// <inheritdoc />
+ protected override async Task WriteValueAsync(TMember[] value, Stream stream, GraphBinaryWriter writer,
+ CancellationToken cancellationToken = default)
+ {
+ await writer.WriteNonNullableValueAsync(value.Length, stream, cancellationToken).ConfigureAwait(false);
+
+ foreach (var item in value)
+ {
+ await writer.WriteAsync(item, stream, cancellationToken).ConfigureAwait(false);
+ }
+ }
+
+ /// <summary>
+ /// Currently not supported as GraphBinary has no array data type.
+ /// </summary>
+ protected override Task<TMember[]> ReadValueAsync(Stream stream, GraphBinaryReader reader,
+ CancellationToken cancellationToken = default)
+ {
+ throw new NotImplementedException("Reading an array is not supported");
+ }
+ }
+}
\ No newline at end of file
diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphBinary4/Types/BigDecimalSerializer.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphBinary4/Types/BigDecimalSerializer.cs
new file mode 100644
index 0000000000..e5bf0c7905
--- /dev/null
+++ b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphBinary4/Types/BigDecimalSerializer.cs
@@ -0,0 +1,95 @@
+#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.IO;
+using System.Numerics;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace Gremlin.Net.Structure.IO.GraphBinary4.Types
+{
+ /// <summary>
+ /// A serializer that serializes <see cref="decimal"/> values as BigDecimal in GraphBinary4.
+ /// </summary>
+ public class BigDecimalSerializer : SimpleTypeSerializer<decimal>
+ {
+ /// <summary>
+ /// Initializes a new instance of the <see cref="BigDecimalSerializer" /> class.
+ /// </summary>
+ public BigDecimalSerializer() : base(DataType.BigDecimal)
+ {
+ }
+
+ /// <inheritdoc />
+ protected override async Task WriteValueAsync(decimal value, Stream stream, GraphBinaryWriter writer,
+ CancellationToken cancellationToken = default)
+ {
+ var (unscaledValue, scale) = GetUnscaledValueAndScale(value);
+ await writer.WriteNonNullableValueAsync(scale, stream, cancellationToken).ConfigureAwait(false);
+ await writer.WriteNonNullableValueAsync(unscaledValue, stream, cancellationToken).ConfigureAwait(false);
+ }
+
+ private static (BigInteger, int) GetUnscaledValueAndScale(decimal input)
+ {
+ var parts = decimal.GetBits(input);
+
+ var sign = (parts[3] & 0x80000000) != 0;
+
+ var scale = (parts[3] >> 16) & 0x7F;
+
+ var lowBytes = BitConverter.GetBytes(parts[0]);
+ var middleBytes = BitConverter.GetBytes(parts[1]);
+ var highBytes = BitConverter.GetBytes(parts[2]);
+ var valueBytes = new byte[12];
+ lowBytes.CopyTo(valueBytes, 0);
+ middleBytes.CopyTo(valueBytes, 4);
+ highBytes.CopyTo(valueBytes, 8);
+ var bigInt = new BigInteger(valueBytes);
+
+ if (sign)
+ {
+ bigInt = -bigInt;
+ }
+
+ return (bigInt, scale);
+ }
+
+ /// <inheritdoc />
+ protected override async Task<decimal> ReadValueAsync(Stream stream, GraphBinaryReader reader,
+ CancellationToken cancellationToken = default)
+ {
+ var scale = (int)await reader.ReadNonNullableValueAsync<int>(stream, cancellationToken)
+ .ConfigureAwait(false);
+ var unscaled = (BigInteger)await reader.ReadNonNullableValueAsync<BigInteger>(stream, cancellationToken)
+ .ConfigureAwait(false);
+
+ return ConvertScaleAndUnscaledValue(scale, unscaled);
+ }
+
+ private static decimal ConvertScaleAndUnscaledValue(int scale, BigInteger unscaledValue)
+ {
+ return (decimal) unscaledValue * (decimal) Math.Pow(10, -scale);
+ }
+ }
+}
\ No newline at end of file
diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphBinary4/Types/BigIntegerSerializer.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphBinary4/Types/BigIntegerSerializer.cs
new file mode 100644
index 0000000000..4a555a0fad
--- /dev/null
+++ b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphBinary4/Types/BigIntegerSerializer.cs
@@ -0,0 +1,62 @@
+#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.IO;
+using System.Linq;
+using System.Numerics;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace Gremlin.Net.Structure.IO.GraphBinary4.Types
+{
+ /// <summary>
+ /// A serializer for <see cref="BigInteger"/> values.
+ /// </summary>
+ public class BigIntegerSerializer : SimpleTypeSerializer<BigInteger>
+ {
+ /// <summary>
+ /// Initializes a new instance of the <see cref="BigIntegerSerializer" /> class.
+ /// </summary>
+ public BigIntegerSerializer() : base(DataType.BigInteger)
+ {
+ }
+
+ /// <inheritdoc />
+ protected override async Task WriteValueAsync(BigInteger value, Stream stream, GraphBinaryWriter writer,
+ CancellationToken cancellationToken = default)
+ {
+ var bytes = value.ToByteArray().Reverse().ToArray();
+ await writer.WriteNonNullableValueAsync(bytes.Length, stream, cancellationToken).ConfigureAwait(false);
+ await stream.WriteAsync(bytes, cancellationToken).ConfigureAwait(false);
+ }
+
+ /// <inheritdoc />
+ protected override async Task<BigInteger> ReadValueAsync(Stream stream, GraphBinaryReader reader,
+ CancellationToken cancellationToken = default)
+ {
+ var length = (int)await reader.ReadNonNullableValueAsync<int>(stream, cancellationToken).ConfigureAwait(false);
+ var bytes = await stream.ReadAsync(length, cancellationToken).ConfigureAwait(false);
+ return new BigInteger(bytes.Reverse().ToArray());
+ }
+ }
+}
\ No newline at end of file
diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphBinary4/Types/BinarySerializer.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphBinary4/Types/BinarySerializer.cs
new file mode 100644
index 0000000000..58723e77a2
--- /dev/null
+++ b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphBinary4/Types/BinarySerializer.cs
@@ -0,0 +1,61 @@
+#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.IO;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace Gremlin.Net.Structure.IO.GraphBinary4.Types
+{
+
+ /// <summary>
+ /// A serializer for byte[].
+ /// </summary>
+ public class BinarySerializer : SimpleTypeSerializer<byte[]>
+ {
+ /// <summary>
+ /// Initializes a new instance of the <see cref="BinarySerializer" /> class.
+ /// </summary>
+ public BinarySerializer() : base(DataType.Binary)
+ {
+ }
+
+ /// <inheritdoc />
+ protected override async Task WriteValueAsync(byte[] value, Stream stream, GraphBinaryWriter writer,
+ CancellationToken cancellationToken = default)
+ {
+ await writer.WriteNonNullableValueAsync(value.Length, stream, cancellationToken).ConfigureAwait(false);
+ await stream.WriteAsync(value, 0, value.Length, cancellationToken).ConfigureAwait(false);
+ }
+
+ /// <inheritdoc />
+ protected override async Task<byte[]> ReadValueAsync(Stream stream, GraphBinaryReader reader,
+ CancellationToken cancellationToken = default)
+ {
+ var length = (int)await reader.ReadNonNullableValueAsync<int>(stream, cancellationToken).ConfigureAwait(false);
+ var buffer = new byte[length];
+ await stream.ReadAsync(buffer, 0, length, cancellationToken).ConfigureAwait(false);
+ return buffer;
+ }
+ }
+}
diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphBinary4/Types/CharSerializer.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphBinary4/Types/CharSerializer.cs
new file mode 100644
index 0000000000..7ea3cb5cc5
--- /dev/null
+++ b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphBinary4/Types/CharSerializer.cs
@@ -0,0 +1,87 @@
+#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.IO;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace Gremlin.Net.Structure.IO.GraphBinary4.Types
+{
+ /// <summary>
+ /// A <see cref="char"/> serializer.
+ /// </summary>
+ public class CharSerializer : SimpleTypeSerializer<char>
+ {
+ /// <summary>
+ /// Initializes a new instance of the <see cref="CharSerializer" /> class.
+ /// </summary>
+ public CharSerializer() : base(DataType.Char)
+ {
+ }
+
+ /// <inheritdoc />
+ protected override async Task WriteValueAsync(char value, Stream stream, GraphBinaryWriter writer,
+ CancellationToken cancellationToken = default)
+ {
+ var bytes = Encoding.UTF8.GetBytes(value.ToString());
+ await stream.WriteAsync(bytes, cancellationToken).ConfigureAwait(false);
+ }
+
+ /// <inheritdoc />
+ protected override async Task<char> ReadValueAsync(Stream stream, GraphBinaryReader reader,
+ CancellationToken cancellationToken = default)
+ {
+ var firstByte = await stream.ReadByteAsync(cancellationToken).ConfigureAwait(false);
+ var byteLength = 1;
+ // A byte with the first byte ON (10000000) signals that more bytes are needed to represent the UTF-8 char
+ if ((firstByte & 0x80) > 0)
+ {
+ if ((firstByte & 0xf0) == 0xf0)
+ { // 0xf0 = 11110000
+ byteLength = 4;
+ } else if ((firstByte & 0xe0) == 0xe0)
+ { //11100000
+ byteLength = 3;
+ } else if ((firstByte & 0xc0) == 0xc0)
+ { //11000000
+ byteLength = 2;
+ }
+ }
+
+ byte[] bytes;
+ if (byteLength == 1)
+ {
+ bytes = new[] {firstByte};
+ }
+ else
+ {
+ bytes = new byte[byteLength];
+ bytes[0] = firstByte;
+ await stream.ReadAsync(bytes, 1, byteLength - 1, cancellationToken).ConfigureAwait(false);
+ }
+
+ return Encoding.UTF8.GetChars(bytes)[0];
+ }
+ }
+}
\ No newline at end of file
diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphBinary4/Types/DateTimeSerializer.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphBinary4/Types/DateTimeSerializer.cs
new file mode 100644
index 0000000000..b5fc932af6
--- /dev/null
+++ b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphBinary4/Types/DateTimeSerializer.cs
@@ -0,0 +1,78 @@
+#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.IO;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace Gremlin.Net.Structure.IO.GraphBinary4.Types
+{
+ /// <summary>
+ /// A serializer for <see cref="DateTimeOffset"/> values in GraphBinary 4.0.
+ /// </summary>
+ public class DateTimeSerializer : SimpleTypeSerializer<DateTimeOffset>
+ {
+ /// <summary>
+ /// Initializes a new instance of the <see cref="DateTimeSerializer" /> class.
+ /// </summary>
+ public DateTimeSerializer() : base(DataType.DateTime)
+ {
+ }
+
+ /// <inheritdoc />
+ protected override async Task WriteValueAsync(DateTimeOffset value, Stream stream, GraphBinaryWriter writer,
+ CancellationToken cancellationToken = default)
+ {
+ await stream.WriteIntAsync(value.Year, cancellationToken).ConfigureAwait(false);
+ await stream.WriteByteAsync((byte)value.Month, cancellationToken).ConfigureAwait(false);
+ await stream.WriteByteAsync((byte)value.Day, cancellationToken).ConfigureAwait(false);
+
+ // time as Long nanoseconds since midnight
+ var timeNanos = (value.Hour * 3600L + value.Minute * 60L + value.Second) * 1_000_000_000L +
+ value.Millisecond * 1_000_000L +
+ (value.Ticks % TimeSpan.TicksPerMillisecond) * 100L;
+ await stream.WriteLongAsync(timeNanos, cancellationToken).ConfigureAwait(false);
+
+ await stream.WriteIntAsync((int)value.Offset.TotalSeconds, cancellationToken).ConfigureAwait(false);
+ }
+
+ /// <inheritdoc />
+ protected override async Task<DateTimeOffset> ReadValueAsync(Stream stream, GraphBinaryReader reader,
+ CancellationToken cancellationToken = default)
+ {
+ var year = await stream.ReadIntAsync(cancellationToken).ConfigureAwait(false);
+ var month = await stream.ReadByteAsync(cancellationToken).ConfigureAwait(false);
+ var day = await stream.ReadByteAsync(cancellationToken).ConfigureAwait(false);
+ var timeNanos = await stream.ReadLongAsync(cancellationToken).ConfigureAwait(false);
+ var offsetSeconds = await stream.ReadIntAsync(cancellationToken).ConfigureAwait(false);
+
+ // Convert nanoseconds to TimeSpan (100 nanoseconds per tick)
+ var timeSpan = TimeSpan.FromTicks(timeNanos / 100);
+ var offset = TimeSpan.FromSeconds(offsetSeconds);
+
+ return new DateTimeOffset(year, month, day, timeSpan.Hours, timeSpan.Minutes, timeSpan.Seconds,
+ timeSpan.Milliseconds, offset).AddTicks(timeSpan.Ticks % TimeSpan.TicksPerMillisecond);
+ }
+ }
+}
diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphBinary4/Types/DurationSerializer.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphBinary4/Types/DurationSerializer.cs
new file mode 100644
index 0000000000..0b6e8d59a0
--- /dev/null
+++ b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphBinary4/Types/DurationSerializer.cs
@@ -0,0 +1,63 @@
+#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.IO;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace Gremlin.Net.Structure.IO.GraphBinary4.Types
+{
+ /// <summary>
+ /// A serializer that serializes <see cref="TimeSpan"/> values as Duration in GraphBinary.
+ /// </summary>
+ public class DurationSerializer : SimpleTypeSerializer<TimeSpan>
+ {
+ /// <summary>
+ /// Initializes a new instance of the <see cref="DurationSerializer" /> class.
+ /// </summary>
+ public DurationSerializer() : base(DataType.Duration)
+ {
+ }
+
+ /// <inheritdoc />
+ protected override async Task WriteValueAsync(TimeSpan value, Stream stream, GraphBinaryWriter writer,
+ CancellationToken cancellationToken = default)
+ {
+ await stream.WriteLongAsync((long)value.TotalSeconds, cancellationToken).ConfigureAwait(false);
+ // Get sub-second ticks and convert to nanoseconds (1 tick = 100 nanoseconds)
+ await stream.WriteIntAsync((int)(value.Ticks % TimeSpan.TicksPerSecond * 100), cancellationToken).ConfigureAwait(false);
+ }
+
+ /// <inheritdoc />
+ protected override async Task<TimeSpan> ReadValueAsync(Stream stream, GraphBinaryReader reader,
+ CancellationToken cancellationToken = default)
+ {
+ var seconds = await stream.ReadLongAsync(cancellationToken).ConfigureAwait(false);
+ var nanoseconds = await stream.ReadIntAsync(cancellationToken).ConfigureAwait(false);
+
+ // Convert nanoseconds to ticks (1 tick = 100 nanoseconds)
+ return TimeSpan.FromSeconds(seconds) + TimeSpan.FromTicks(nanoseconds / 100);
+ }
+ }
+}
\ No newline at end of file
diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphBinary4/Types/EdgeSerializer.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphBinary4/Types/EdgeSerializer.cs
new file mode 100644
index 0000000000..b3a8097de5
--- /dev/null
+++ b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphBinary4/Types/EdgeSerializer.cs
@@ -0,0 +1,89 @@
+#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;
+using System.IO;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace Gremlin.Net.Structure.IO.GraphBinary4.Types
+{
+ /// <summary>
+ /// An <see cref="Edge"/> serializer for GraphBinary 4.0.
+ /// In v4, labels are serialized as List of Strings instead of a single String.
+ /// </summary>
+ public class EdgeSerializer : SimpleTypeSerializer<Edge>
+ {
+ /// <summary>
+ /// Initializes a new instance of the <see cref="EdgeSerializer" /> class.
+ /// </summary>
+ public EdgeSerializer() : base(DataType.Edge)
+ {
+ }
+
+ /// <inheritdoc />
+ protected override async Task WriteValueAsync(Edge value, Stream stream, GraphBinaryWriter writer,
+ CancellationToken cancellationToken = default)
+ {
+ await writer.WriteAsync(value.Id, stream, cancellationToken).ConfigureAwait(false);
+ await writer.WriteNonNullableValueAsync(new List<string> { value.Label }, stream, cancellationToken).ConfigureAwait(false);
+
+ await writer.WriteAsync(value.InV.Id, stream, cancellationToken).ConfigureAwait(false);
+ await writer.WriteNonNullableValueAsync(new List<string> { value.InV.Label }, stream, cancellationToken).ConfigureAwait(false);
+ await writer.WriteAsync(value.OutV.Id, stream, cancellationToken).ConfigureAwait(false);
+ await writer.WriteNonNullableValueAsync(new List<string> { value.OutV.Label }, stream, cancellationToken).ConfigureAwait(false);
+
+ // Placeholder for the parent vertex
+ await writer.WriteAsync(null, stream, cancellationToken).ConfigureAwait(false);
+
+ // placeholder for the properties
+ await writer.WriteAsync(null, stream, cancellationToken).ConfigureAwait(false);
+ }
+
+ /// <inheritdoc />
+ protected override async Task<Edge> ReadValueAsync(Stream stream, GraphBinaryReader reader,
+ CancellationToken cancellationToken = default)
+ {
+ var id = await reader.ReadAsync(stream, cancellationToken).ConfigureAwait(false);
+ var labelList = (List<string?>)await reader.ReadNonNullableValueAsync<List<string?>>(stream, cancellationToken).ConfigureAwait(false);
+ var label = labelList.Count > 0 ? labelList[0] ?? "" : "";
+
+ var inVId = await reader.ReadAsync(stream, cancellationToken).ConfigureAwait(false);
+ var inVLabelList = (List<string?>)await reader.ReadNonNullableValueAsync<List<string?>>(stream, cancellationToken).ConfigureAwait(false);
+ var inV = new Vertex(inVId, inVLabelList.Count > 0 ? inVLabelList[0] ?? "" : "");
+
+ var outVId = await reader.ReadAsync(stream, cancellationToken).ConfigureAwait(false);
+ var outVLabelList = (List<string?>)await reader.ReadNonNullableValueAsync<List<string?>>(stream, cancellationToken).ConfigureAwait(false);
+ var outV = new Vertex(outVId, outVLabelList.Count > 0 ? outVLabelList[0] ?? "" : "");
+
+ // discard possible parent vertex
+ await reader.ReadAsync(stream, cancellationToken).ConfigureAwait(false);
+
+ var properties = await reader.ReadAsync(stream, cancellationToken).ConfigureAwait(false);
+ var propertiesAsArray = null == properties ? Array.Empty<object>() : (properties as List<object>)?.ToArray();
+
+ return new Edge(id, outV, label, inV, propertiesAsArray);
+ }
+ }
+}
diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphBinary4/Types/EnumSerializer.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphBinary4/Types/EnumSerializer.cs
new file mode 100644
index 0000000000..c885c97bf9
--- /dev/null
+++ b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphBinary4/Types/EnumSerializer.cs
@@ -0,0 +1,93 @@
+#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.IO;
+using System.Threading;
+using System.Threading.Tasks;
+using Gremlin.Net.Process.Traversal;
+
+namespace Gremlin.Net.Structure.IO.GraphBinary4.Types
+{
+ /// <summary>
+ /// Provides serializers for enum types supported in GraphBinary 4.0.
+ /// </summary>
+ /// <remarks>
+ /// GraphBinary 4.0 only supports Direction, T, and Merge enum types.
+ /// The following types were removed in v4: Barrier, Cardinality, Column, DT, GType,
+ /// Operator, Order, Pick, Pop, Scope.
+ /// </remarks>
+ public static class EnumSerializers
+ {
+ /// <summary>
+ /// A serializer for <see cref="Direction"/> values.
+ /// </summary>
+ public static readonly EnumSerializer<Direction> DirectionSerializer =
+ new EnumSerializer<Direction>(DataType.Direction, Direction.GetByValue);
+
+ /// <summary>
+ /// A serializer for <see cref="Merge"/> values.
+ /// </summary>
+ public static readonly EnumSerializer<Merge> MergeSerializer =
+ new EnumSerializer<Merge>(DataType.Merge, Merge.GetByValue);
+
+ /// <summary>
+ /// A serializer for <see cref="T"/> values.
+ /// </summary>
+ public static readonly EnumSerializer<T> TSerializer =
+ new EnumSerializer<T>(DataType.T, T.GetByValue);
+ }
+
+ /// <summary>
+ /// Generalized serializer for enum types.
+ /// </summary>
+ /// <typeparam name="TEnum">The type of the enum to serialize.</typeparam>
+ public class EnumSerializer<TEnum> : SimpleTypeSerializer<TEnum>
+ where TEnum : EnumWrapper
+ {
+ private readonly Func<string, TEnum> _readFunc;
+
+ internal EnumSerializer(DataType dataType, Func<string, TEnum> readFunc) : base(dataType)
+ {
+ _readFunc = readFunc;
+ }
+
+ /// <inheritdoc />
+ protected override async Task WriteValueAsync(TEnum value, Stream stream, GraphBinaryWriter writer,
+ CancellationToken cancellationToken = default)
+ {
+ await writer.WriteAsync(value.EnumValue, stream, cancellationToken).ConfigureAwait(false);
+ }
+
+ /// <inheritdoc />
+ protected override async Task<TEnum> ReadValueAsync(Stream stream, GraphBinaryReader reader,
+ CancellationToken cancellationToken = default)
+ {
+ // This should probably be `reader.ReadNonNullableValueAsync<string>(stream, cancellationToken)` instead,
+ // but it's the same in other GLVs and changing this would be a breaking change for the GraphBinary format.
+ var enumValue = (string?) await reader.ReadAsync(stream, cancellationToken).ConfigureAwait(false);
+ if (enumValue == null) throw new IOException($"Read null as a value for {DataType}");
+ return _readFunc.Invoke(enumValue);
+ }
+ }
+}
\ No newline at end of file
diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphBinary4/Types/ListSerializer.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphBinary4/Types/ListSerializer.cs
new file mode 100644
index 0000000000..73c4179fac
--- /dev/null
+++ b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphBinary4/Types/ListSerializer.cs
@@ -0,0 +1,95 @@
+#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.Collections.Generic;
+using System.IO;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace Gremlin.Net.Structure.IO.GraphBinary4.Types
+{
+ /// <summary>
+ /// A generic list serializer for GraphBinary 4.0.
+ /// </summary>
+ /// <typeparam name="TMember">The type of elements in the list.</typeparam>
+ public class ListSerializer<TMember> : SimpleTypeSerializer<IList<TMember?>>
+ {
+ private const byte ValueFlagBulked = 0x02;
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="ListSerializer{TList}" /> class.
+ /// </summary>
+ public ListSerializer() : base(DataType.List)
+ {
+ }
+
+ /// <inheritdoc />
+ protected override async Task WriteValueAsync(IList<TMember?> value, Stream stream, GraphBinaryWriter writer,
+ CancellationToken cancellationToken = default)
+ {
+ await writer.WriteNonNullableValueAsync(value.Count, stream, cancellationToken).ConfigureAwait(false);
+
+ foreach (var item in value)
+ {
+ await writer.WriteAsync(item, stream, cancellationToken).ConfigureAwait(false);
+ }
+ }
+
+ /// <inheritdoc />
+ protected override Task<IList<TMember?>> ReadValueAsync(Stream stream, GraphBinaryReader reader,
+ CancellationToken cancellationToken = default)
+ {
+ // Default to standard format (valueFlag = 0x00)
+ return ReadValueAsync(stream, reader, 0x00, cancellationToken);
+ }
+
+ /// <inheritdoc />
+ protected override async Task<IList<TMember?>> ReadValueAsync(Stream stream, GraphBinaryReader reader,
+ byte valueFlag, CancellationToken cancellationToken = default)
+ {
+ var length = (int)await reader.ReadNonNullableValueAsync<int>(stream, cancellationToken).ConfigureAwait(false);
+ var result = new List<TMember?>();
+ var isBulked = (valueFlag & ValueFlagBulked) != 0;
+
+ for (var i = 0; i < length; i++)
+ {
+ var item = (TMember?)await reader.ReadAsync(stream, cancellationToken).ConfigureAwait(false);
+
+ if (isBulked)
+ {
+ var bulk = await stream.ReadLongAsync(cancellationToken).ConfigureAwait(false);
+ for (var j = 0; j < bulk; j++)
+ {
+ result.Add(item);
+ }
+ }
+ else
+ {
+ result.Add(item);
+ }
+ }
+
+ return result;
+ }
+ }
+}
diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphBinary4/Types/MapSerializer.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphBinary4/Types/MapSerializer.cs
new file mode 100644
index 0000000000..f8e9172d14
--- /dev/null
+++ b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphBinary4/Types/MapSerializer.cs
@@ -0,0 +1,76 @@
+#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.Collections.Generic;
+using System.IO;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace Gremlin.Net.Structure.IO.GraphBinary4.Types
+{
+ /// <summary>
+ /// A generic dictionary serializer for GraphBinary 4.0.
+ /// </summary>
+ /// <typeparam name="TKey">The type of keys in the dictionary.</typeparam>
+ /// <typeparam name="TValue">The type of values in the dictionary.</typeparam>
+ public class MapSerializer<TKey, TValue> : SimpleTypeSerializer<IDictionary<TKey, TValue?>> where TKey : notnull
+ {
+ /// <summary>
+ /// Initializes a new instance of the <see cref="MapSerializer{TKey, TValue}" /> class.
+ /// </summary>
+ public MapSerializer() : base(DataType.Map)
+ {
+ }
+
+ /// <inheritdoc />
+ protected override async Task WriteValueAsync(IDictionary<TKey, TValue?> value, Stream stream,
+ GraphBinaryWriter writer, CancellationToken cancellationToken = default)
+ {
+ await writer.WriteNonNullableValueAsync(value.Count, stream, cancellationToken).ConfigureAwait(false);
+
+ foreach (var key in value.Keys)
+ {
+ await writer.WriteAsync(key, stream, cancellationToken).ConfigureAwait(false);
+ await writer.WriteAsync(value[key], stream, cancellationToken).ConfigureAwait(false);
+ }
+ }
+
+ /// <inheritdoc />
+ protected override async Task<IDictionary<TKey, TValue?>> ReadValueAsync(Stream stream, GraphBinaryReader reader,
+ CancellationToken cancellationToken = default)
+ {
+ var length = await stream.ReadIntAsync(cancellationToken).ConfigureAwait(false);
+ var result = new Dictionary<TKey, TValue?>(length);
+
+ for (var i = 0; i < length; i++)
+ {
+ var key = (TKey?) await reader.ReadAsync(stream, cancellationToken).ConfigureAwait(false);
+ if (key == null) throw new IOException("Read null as the key for a dictionary.");
+ var value = (TValue?) await reader.ReadAsync(stream, cancellationToken).ConfigureAwait(false);
+ result.Add(key, value);
+ }
+
+ return result;
+ }
+ }
+}
diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphBinary4/Types/PathSerializer.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphBinary4/Types/PathSerializer.cs
new file mode 100644
index 0000000000..03c6a26049
--- /dev/null
+++ b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphBinary4/Types/PathSerializer.cs
@@ -0,0 +1,74 @@
+#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.Collections.Generic;
+using System.IO;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace Gremlin.Net.Structure.IO.GraphBinary4.Types
+{
+ /// <summary>
+ /// A <see cref="Path"/> serializer.
+ /// </summary>
+ public class PathSerializer : SimpleTypeSerializer<Path>
+ {
+ /// <summary>
+ /// Initializes a new instance of the <see cref="PathSerializer" /> class.
+ /// </summary>
+ public PathSerializer() : base(DataType.Path)
+ {
+ }
+
+ /// <inheritdoc />
+ protected override async Task WriteValueAsync(Path value, Stream stream, GraphBinaryWriter writer,
+ CancellationToken cancellationToken = default)
+ {
+ await writer.WriteAsync(value.Labels, stream, cancellationToken).ConfigureAwait(false);
+ await writer.WriteAsync(value.Objects, stream, cancellationToken).ConfigureAwait(false);
+ }
+
+ /// <inheritdoc />
+ protected override async Task<Path> ReadValueAsync(Stream stream, GraphBinaryReader reader,
+ CancellationToken cancellationToken = default)
+ {
+ var readLabelObjects =
+ (List<object>?)await reader.ReadAsync(stream, cancellationToken).ConfigureAwait(false);
+ if (readLabelObjects == null) throw new IOException("Read null, but expected a list of labels");
+ var labels = new List<ISet<string>>();
+ foreach (var labelObjectList in readLabelObjects)
+ {
+ var labelSet = new HashSet<string>();
+ foreach (var labelObj in (HashSet<object>) labelObjectList)
+ {
+ labelSet.Add((string) labelObj);
+ }
+ labels.Add(labelSet);
+ }
+
+ var objects = (List<object?>?) await reader.ReadAsync(stream, cancellationToken).ConfigureAwait(false);
+ if (objects == null) throw new IOException("Read null, but expected a list of objects");
+ return new Path(labels, objects);
+ }
+ }
+}
\ No newline at end of file
diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphBinary4/Types/PropertySerializer.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphBinary4/Types/PropertySerializer.cs
new file mode 100644
index 0000000000..6eba38a2b6
--- /dev/null
+++ b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphBinary4/Types/PropertySerializer.cs
@@ -0,0 +1,68 @@
+#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.IO;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace Gremlin.Net.Structure.IO.GraphBinary4.Types
+{
+ /// <summary>
+ /// A <see cref="Property"/> serializer.
+ /// </summary>
+ public class
+ PropertySerializer : SimpleTypeSerializer<Property>
+ {
+ /// <summary>
+ /// Initializes a new instance of the <see cref="PropertySerializer" /> class.
+ /// </summary>
+ public PropertySerializer() : base(DataType.Property)
+ {
+ }
+
+ /// <inheritdoc />
+ protected override async Task WriteValueAsync(Property value, Stream stream, GraphBinaryWriter writer,
+ CancellationToken cancellationToken = default)
+ {
+ await writer.WriteNonNullableValueAsync(value.Key, stream, cancellationToken).ConfigureAwait(false);
+ await writer.WriteAsync(value.Value, stream, cancellationToken).ConfigureAwait(false);
+
+ // placeholder for the parent element
+ await writer.WriteAsync(null, stream, cancellationToken).ConfigureAwait(false);
+ }
+
+ /// <inheritdoc />
+ protected override async Task<Property> ReadValueAsync(Stream stream, GraphBinaryReader reader,
+ CancellationToken cancellationToken = default)
+ {
+ var p = new Property(
+ (string)await reader.ReadNonNullableValueAsync<string>(stream, cancellationToken).ConfigureAwait(false),
+ await reader.ReadAsync(stream, cancellationToken).ConfigureAwait(false));
+
+ // discard parent element
+ await reader.ReadAsync(stream, cancellationToken).ConfigureAwait(false);
+
+ return p;
+ }
+ }
+}
\ No newline at end of file
diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphBinary4/Types/SetSerializer.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphBinary4/Types/SetSerializer.cs
new file mode 100644
index 0000000000..c656ae706f
--- /dev/null
+++ b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphBinary4/Types/SetSerializer.cs
@@ -0,0 +1,77 @@
+#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.Collections;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace Gremlin.Net.Structure.IO.GraphBinary4.Types
+{
+ /// <summary>
+ /// A generic set serializer for GraphBinary 4.0.
+ /// </summary>
+ /// <typeparam name="TSet">The type of the set to serialize.</typeparam>
+ /// <typeparam name="TMember">The type of elements in the set.</typeparam>
+ public class SetSerializer<TSet, TMember> : SimpleTypeSerializer<TSet>
+ where TSet : ISet<TMember?>, new()
+ {
+ /// <summary>
+ /// Initializes a new instance of the <see cref="SetSerializer{TSet,TMember}" /> class.
+ /// </summary>
+ public SetSerializer() : base(DataType.Set)
+ {
+ }
+
+ /// <inheritdoc />
+ protected override async Task WriteValueAsync(TSet value, Stream stream, GraphBinaryWriter writer,
+ CancellationToken cancellationToken = default)
+ {
+ var enumerable = (IEnumerable) value;
+ var list = enumerable.Cast<object>().ToList();
+
+ await writer.WriteNonNullableValueAsync(list.Count, stream, cancellationToken).ConfigureAwait(false);
+
+ foreach (var item in list)
+ {
+ await writer.WriteAsync(item, stream, cancellationToken).ConfigureAwait(false);
+ }
+ }
+
+ /// <inheritdoc />
+ protected override async Task<TSet> ReadValueAsync(Stream stream, GraphBinaryReader reader,
+ CancellationToken cancellationToken = default)
+ {
+ var length = (int)await reader.ReadNonNullableValueAsync<int>(stream, cancellationToken).ConfigureAwait(false);
+ var result = new TSet();
+ for (var i = 0; i < length; i++)
+ {
+ result.Add((TMember?) await reader.ReadAsync(stream, cancellationToken).ConfigureAwait(false));
+ }
+
+ return result;
+ }
+ }
+}
diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphBinary4/Types/SimpleTypeSerializer.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphBinary4/Types/SimpleTypeSerializer.cs
new file mode 100644
index 0000000000..8115959560
--- /dev/null
+++ b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphBinary4/Types/SimpleTypeSerializer.cs
@@ -0,0 +1,143 @@
+#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.IO;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace Gremlin.Net.Structure.IO.GraphBinary4.Types
+{
+ /// <summary>
+ /// Base class for serialization of types that don't contain type specific information only {type_code},
+ /// {value_flag} and {value}.
+ /// </summary>
+ /// <typeparam name="T">The supported type.</typeparam>
+ public abstract class SimpleTypeSerializer<T> : ITypeSerializer
+ {
+ /// <summary>
+ /// Initializes a new instance of the <see cref="SimpleTypeSerializer{T}" /> class.
+ /// </summary>
+ protected SimpleTypeSerializer(DataType dataType)
+ {
+ DataType = dataType;
+ }
+
+ /// <inheritdoc />
+ public DataType DataType { get; }
+
+ /// <inheritdoc />
+ public async Task WriteAsync(object? value, Stream stream, GraphBinaryWriter writer,
+ CancellationToken cancellationToken = default)
+ {
+ await WriteNullableValueAsync((T?) value, stream, writer, cancellationToken).ConfigureAwait(false);
+ }
+
+ /// <inheritdoc />
+ public async Task WriteNullableValueAsync(object? value, Stream stream, GraphBinaryWriter writer,
+ CancellationToken cancellationToken = default)
+ {
+ if (value == null)
+ {
+ await writer.WriteValueFlagNullAsync(stream, cancellationToken).ConfigureAwait(false);
+ return;
+ }
+
+ await writer.WriteValueFlagNoneAsync(stream, cancellationToken).ConfigureAwait(false);
+
+ await WriteValueAsync((T) value, stream, writer, cancellationToken).ConfigureAwait(false);
+ }
+
+ /// <inheritdoc />
+ public async Task WriteNonNullableValueAsync(object value, Stream stream, GraphBinaryWriter writer,
+ CancellationToken cancellationToken = default)
+ {
+ await WriteValueAsync((T) value, stream, writer, cancellationToken).ConfigureAwait(false);
+ }
+
+ /// <summary>
+ /// Writes a non-nullable value into a stream.
+ /// </summary>
+ /// <param name="value">The value to write.</param>
+ /// <param name="stream">The stream to write to.</param>
+ /// <param name="writer">A <see cref="GraphBinaryWriter"/>.</param>
+ /// <param name="cancellationToken">The token to cancel the operation. The default value is None.</param>
+ /// <returns>A task that represents the asynchronous write operation.</returns>
+ protected abstract Task WriteValueAsync(T value, Stream stream, GraphBinaryWriter writer,
+ CancellationToken cancellationToken = default);
+
+ /// <inheritdoc />
+ public async Task<object?> ReadAsync(Stream stream, GraphBinaryReader reader,
+ CancellationToken cancellationToken = default)
+ {
+ return await ReadNullableValueAsync(stream, reader, cancellationToken).ConfigureAwait(false);
+ }
+
+ /// <inheritdoc />
+ public async Task<object?> ReadNullableValueAsync(Stream stream, GraphBinaryReader reader,
+ CancellationToken cancellationToken = default)
+ {
+ var valueFlag = await stream.ReadByteAsync(cancellationToken).ConfigureAwait(false);
+ if ((valueFlag & 1) == 1)
+ {
+ return null;
+ }
+
+ return await ReadValueAsync(stream, reader, valueFlag, cancellationToken).ConfigureAwait(false);
+ }
+
+ /// <inheritdoc />
+ public async Task<object> ReadNonNullableValueAsync(Stream stream, GraphBinaryReader reader,
+ CancellationToken cancellationToken = default)
+ {
+ return (await ReadValueAsync(stream, reader, cancellationToken).ConfigureAwait(false))!;
+ }
+
+ /// <summary>
+ /// Reads a non-nullable value according to the type format with the value flag.
+ /// </summary>
+ /// <param name="stream">The GraphBinary data to parse.</param>
+ /// <param name="reader">A <see cref="GraphBinaryReader"/>.</param>
+ /// <param name="valueFlag">The value flag byte that was read.</param>
+ /// <param name="cancellationToken">The token to cancel the operation. The default value is None.</param>
+ /// <returns>The read value.</returns>
+ /// <remarks>
+ /// Override this method to handle type-specific value flags (e.g., bulked format for List).
+ /// The default implementation delegates to <see cref="ReadValueAsync(Stream, GraphBinaryReader, CancellationToken)"/>.
+ /// </remarks>
+ protected virtual Task<T> ReadValueAsync(Stream stream, GraphBinaryReader reader, byte valueFlag,
+ CancellationToken cancellationToken = default)
+ {
+ return ReadValueAsync(stream, reader, cancellationToken);
+ }
+
+ /// <summary>
+ /// Reads a non-nullable value according to the type format.
+ /// </summary>
+ /// <param name="stream">The GraphBinary data to parse.</param>
+ /// <param name="reader">A <see cref="GraphBinaryReader"/>.</param>
+ /// <param name="cancellationToken">The token to cancel the operation. The default value is None.</param>
+ /// <returns>The read value.</returns>
+ protected abstract Task<T> ReadValueAsync(Stream stream, GraphBinaryReader reader,
+ CancellationToken cancellationToken = default);
+ }
+}
\ No newline at end of file
diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphBinary4/Types/SingleTypeSerializer.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphBinary4/Types/SingleTypeSerializer.cs
new file mode 100644
index 0000000000..6164581be5
--- /dev/null
+++ b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphBinary4/Types/SingleTypeSerializer.cs
@@ -0,0 +1,133 @@
+#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.IO;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace Gremlin.Net.Structure.IO.GraphBinary4.Types
+{
+ /// <summary>
+ /// Provides serializers for types that can be represented as a single value and that can be read and write in a
+ /// single operation.
+ /// </summary>
+ public static class SingleTypeSerializers
+ {
+ /// <summary>
+ /// A serializer for <see cref="int"/> values.
+ /// </summary>
+ public static readonly SingleTypeSerializer<int> IntSerializer = new SingleTypeSerializer<int>(DataType.Int,
+ (value, stream, cancellationToken) => stream.WriteIntAsync(value, cancellationToken),
+ (stream, cancellationToken) => stream.ReadIntAsync(cancellationToken));
+
+ /// <summary>
+ /// A serializer for <see cref="long"/> values.
+ /// </summary>
+ public static readonly SingleTypeSerializer<long> LongSerializer = new SingleTypeSerializer<long>(DataType.Long,
+ (value, stream, cancellationToken) => stream.WriteLongAsync(value, cancellationToken),
+ (stream, cancellationToken) => stream.ReadLongAsync(cancellationToken));
+
+ /// <summary>
+ /// A serializer for <see cref="double"/> values.
+ /// </summary>
+ public static readonly SingleTypeSerializer<double> DoubleSerializer =
+ new SingleTypeSerializer<double>(DataType.Double,
+ (value, stream, cancellationToken) => stream.WriteDoubleAsync(value, cancellationToken),
+ (stream, cancellationToken) => stream.ReadDoubleAsync(cancellationToken));
+
+ /// <summary>
+ /// A serializer for <see cref="float"/> values.
+ /// </summary>
+ public static readonly SingleTypeSerializer<float> FloatSerializer =
+ new SingleTypeSerializer<float>(DataType.Float,
+ (value, stream, cancellationToken) => stream.WriteFloatAsync(value, cancellationToken),
+ (stream, cancellationToken) => stream.ReadFloatAsync(cancellationToken));
+
+ /// <summary>
+ /// A serializer for <see cref="short"/> values.
+ /// </summary>
+ public static readonly SingleTypeSerializer<short> ShortSerializer =
+ new SingleTypeSerializer<short>(DataType.Short,
+ (value, stream, cancellationToken) => stream.WriteShortAsync(value, cancellationToken),
+ (stream, cancellationToken) => stream.ReadShortAsync(cancellationToken));
+
+ /// <summary>
+ /// A serializer for <see cref="bool"/> values.
+ /// </summary>
+ public static readonly SingleTypeSerializer<bool> BooleanSerializer =
+ new SingleTypeSerializer<bool>(DataType.Boolean,
+ (value, stream, cancellationToken) => stream.WriteBoolAsync(value, cancellationToken),
+ (stream, cancellationToken) => stream.ReadBoolAsync(cancellationToken));
+
+ /// <summary>
+ /// A serializer for <see cref="sbyte"/> values.
+ /// </summary>
+ public static readonly SingleTypeSerializer<sbyte> ByteSerializer = new SingleTypeSerializer<sbyte>(DataType.Byte,
+ (value, stream, cancellationToken) => stream.WriteSByteAsync(value, cancellationToken),
+ (stream, cancellationToken) => stream.ReadSByteAsync(cancellationToken));
+
+ /// <summary>
+ /// A serializer for <see cref="Marker"/> values.
+ /// </summary>
+ public static readonly SingleTypeSerializer<Marker> MarkerSerializer = new SingleTypeSerializer<Marker>(DataType.Marker,
+ (value, stream, cancellationToken) => stream.WriteByteAsync(value.Value, cancellationToken),
+ async (stream, cancellationToken) =>
+ {
+ var markerValue = await stream.ReadByteAsync(cancellationToken).ConfigureAwait(false);
+ return Marker.Of(markerValue);
+ });
+ }
+
+ /// <summary>
+ /// Represents a serializer for types that can be represented as a single value and that can be read and write in a
+ /// single operation.
+ /// </summary>
+ public class SingleTypeSerializer<T> : SimpleTypeSerializer<T>
+ {
+ private readonly Func<T, Stream, CancellationToken, Task> _writeFunc;
+ private readonly Func<Stream, CancellationToken, Task<T>> _readFunc;
+
+ internal SingleTypeSerializer(DataType dataType, Func<T, Stream, CancellationToken, Task> writeFunc,
+ Func<Stream, CancellationToken, Task<T>> readFunc)
+ : base(dataType)
+ {
+ _writeFunc = writeFunc;
+ _readFunc = readFunc;
+ }
+
+ /// <inheritdoc />
+ protected override async Task WriteValueAsync(T value, Stream stream, GraphBinaryWriter writer,
+ CancellationToken cancellationToken = default)
+ {
+ await _writeFunc.Invoke(value, stream, cancellationToken).ConfigureAwait(false);
+ }
+
+ /// <inheritdoc />
+ protected override async Task<T> ReadValueAsync(Stream stream, GraphBinaryReader reader,
+ CancellationToken cancellationToken = default)
+ {
+ return await _readFunc.Invoke(stream, cancellationToken).ConfigureAwait(false);
+ }
+ }
+}
\ No newline at end of file
diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphBinary4/Types/StringSerializer.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphBinary4/Types/StringSerializer.cs
new file mode 100644
index 0000000000..73cce54aa5
--- /dev/null
+++ b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphBinary4/Types/StringSerializer.cs
@@ -0,0 +1,62 @@
+#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.IO;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace Gremlin.Net.Structure.IO.GraphBinary4.Types
+{
+ /// <summary>
+ /// A <see cref="string"/> serializer.
+ /// </summary>
+ public class StringSerializer : SimpleTypeSerializer<string>
+ {
+ /// <summary>
+ /// Initializes a new instance of the <see cref="StringSerializer" /> class.
+ /// </summary>
+ public StringSerializer() : base(DataType.String)
+ {
+ }
+
+ /// <inheritdoc />
+ protected override async Task WriteValueAsync(string value, Stream stream, GraphBinaryWriter writer,
+ CancellationToken cancellationToken = default)
+ {
+ var bytes = Encoding.UTF8.GetBytes(value);
+ await writer.WriteNonNullableValueAsync(bytes.Length, stream, cancellationToken).ConfigureAwait(false);
+ await stream.WriteAsync(bytes, cancellationToken).ConfigureAwait(false);
+ }
+
+ /// <inheritdoc />
+ protected override async Task<string> ReadValueAsync(Stream stream, GraphBinaryReader reader,
+ CancellationToken cancellationToken = default)
+ {
+ var length = (int)await reader.ReadNonNullableValueAsync<int>(stream, cancellationToken).ConfigureAwait(false);
+ var bytes = new byte[length];
+ await stream.ReadAsync(bytes, 0, length, cancellationToken).ConfigureAwait(false);
+ return Encoding.UTF8.GetString(bytes);
+ }
+ }
+}
\ No newline at end of file
diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphBinary4/Types/UuidSerializer.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphBinary4/Types/UuidSerializer.cs
new file mode 100644
index 0000000000..dbecb30867
--- /dev/null
+++ b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphBinary4/Types/UuidSerializer.cs
@@ -0,0 +1,111 @@
+#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.IO;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace Gremlin.Net.Structure.IO.GraphBinary4.Types
+{
+ /// <summary>
+ /// A serializer that serializes <see cref="Guid"/> values as Uuid in GraphBinary.
+ /// </summary>
+ public class UuidSerializer : SimpleTypeSerializer<Guid>
+ {
+ /// <summary>
+ /// Initializes a new instance of the <see cref="UuidSerializer" /> class.
+ /// </summary>
+ public UuidSerializer() : base(DataType.Uuid)
+ {
+ }
+
+ /// <inheritdoc />
+ protected override async Task WriteValueAsync(Guid value, Stream stream, GraphBinaryWriter writer,
+ CancellationToken cancellationToken = default)
+ {
+ var bytes = value.ToByteArray();
+
+ // first 4 bytes in reverse order:
+ await stream.WriteByteAsync(bytes[3], cancellationToken).ConfigureAwait(false);
+ await stream.WriteByteAsync(bytes[2], cancellationToken).ConfigureAwait(false);
+ await stream.WriteByteAsync(bytes[1], cancellationToken).ConfigureAwait(false);
+ await stream.WriteByteAsync(bytes[0], cancellationToken).ConfigureAwait(false);
+
+ // 2 bytes in reverse order:
+ await stream.WriteByteAsync(bytes[5], cancellationToken).ConfigureAwait(false);
+ await stream.WriteByteAsync(bytes[4], cancellationToken).ConfigureAwait(false);
+
+ // 3 bytes in reverse order:
+ await stream.WriteByteAsync(bytes[7], cancellationToken).ConfigureAwait(false);
+ await stream.WriteByteAsync(bytes[6], cancellationToken).ConfigureAwait(false);
+
+ // 3 bytes:
+ await stream.WriteByteAsync(bytes[8], cancellationToken).ConfigureAwait(false);
+ await stream.WriteByteAsync(bytes[9], cancellationToken).ConfigureAwait(false);
+
+ // last 6 bytes:
+ await stream.WriteByteAsync(bytes[10], cancellationToken).ConfigureAwait(false);
+ await stream.WriteByteAsync(bytes[11], cancellationToken).ConfigureAwait(false);
+ await stream.WriteByteAsync(bytes[12], cancellationToken).ConfigureAwait(false);
+ await stream.WriteByteAsync(bytes[13], cancellationToken).ConfigureAwait(false);
+ await stream.WriteByteAsync(bytes[14], cancellationToken).ConfigureAwait(false);
+ await stream.WriteByteAsync(bytes[15], cancellationToken).ConfigureAwait(false);
+ }
+
+ /// <inheritdoc />
+ protected override async Task<Guid> ReadValueAsync(Stream stream, GraphBinaryReader reader,
+ CancellationToken cancellationToken = default)
+ {
+ var bytes = new byte[16];
+
+ // first 4 bytes in reverse order:
+ bytes[3] = await stream.ReadByteAsync(cancellationToken).ConfigureAwait(false);
+ bytes[2] = await stream.ReadByteAsync(cancellationToken).ConfigureAwait(false);
+ bytes[1] = await stream.ReadByteAsync(cancellationToken).ConfigureAwait(false);
+ bytes[0] = await stream.ReadByteAsync(cancellationToken).ConfigureAwait(false);
+
+ // 2 bytes in reverse order:
+ bytes[5] = await stream.ReadByteAsync(cancellationToken).ConfigureAwait(false);
+ bytes[4] = await stream.ReadByteAsync(cancellationToken).ConfigureAwait(false);
+
+ // 2 bytes in reverse order:
+ bytes[7] = await stream.ReadByteAsync(cancellationToken).ConfigureAwait(false);
+ bytes[6] = await stream.ReadByteAsync(cancellationToken).ConfigureAwait(false);
+
+ // 2 bytes:
+ bytes[8] = await stream.ReadByteAsync(cancellationToken).ConfigureAwait(false);
+ bytes[9] = await stream.ReadByteAsync(cancellationToken).ConfigureAwait(false);
+
+ // last 6 bytes:
+ bytes[10] = await stream.ReadByteAsync(cancellationToken).ConfigureAwait(false);
+ bytes[11] = await stream.ReadByteAsync(cancellationToken).ConfigureAwait(false);
+ bytes[12] = await stream.ReadByteAsync(cancellationToken).ConfigureAwait(false);
+ bytes[13] = await stream.ReadByteAsync(cancellationToken).ConfigureAwait(false);
+ bytes[14] = await stream.ReadByteAsync(cancellationToken).ConfigureAwait(false);
+ bytes[15] = await stream.ReadByteAsync(cancellationToken).ConfigureAwait(false);
+
+ return new Guid(bytes);
+ }
+ }
+}
\ No newline at end of file
diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphBinary4/Types/VertexPropertySerializer.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphBinary4/Types/VertexPropertySerializer.cs
new file mode 100644
index 0000000000..89f4acd767
--- /dev/null
+++ b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphBinary4/Types/VertexPropertySerializer.cs
@@ -0,0 +1,78 @@
+#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;
+using System.IO;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace Gremlin.Net.Structure.IO.GraphBinary4.Types
+{
+ /// <summary>
+ /// A <see cref="VertexProperty"/> serializer for GraphBinary 4.0.
+ /// In v4, labels are serialized as List of Strings instead of a single String.
+ /// </summary>
+ public class VertexPropertySerializer : SimpleTypeSerializer<VertexProperty>
+ {
+ /// <summary>
+ /// Initializes a new instance of the <see cref="VertexPropertySerializer" /> class.
+ /// </summary>
+ public VertexPropertySerializer() : base(DataType.VertexProperty)
+ {
+ }
+
+ /// <inheritdoc />
+ protected override async Task WriteValueAsync(VertexProperty value, Stream stream, GraphBinaryWriter writer,
+ CancellationToken cancellationToken = default)
+ {
+ await writer.WriteAsync(value.Id, stream, cancellationToken).ConfigureAwait(false);
+ await writer.WriteNonNullableValueAsync(new List<string> { value.Label }, stream, cancellationToken).ConfigureAwait(false);
+ await writer.WriteAsync(value.Value, stream, cancellationToken).ConfigureAwait(false);
+
+ // placeholder for the parent vertex
+ await writer.WriteAsync(null, stream, cancellationToken).ConfigureAwait(false);
+
+ // placeholder for properties
+ await writer.WriteAsync(null, stream, cancellationToken).ConfigureAwait(false);
+ }
+
+ /// <inheritdoc />
+ protected override async Task<VertexProperty> ReadValueAsync(Stream stream, GraphBinaryReader reader,
+ CancellationToken cancellationToken = default)
+ {
+ var id = await reader.ReadAsync(stream, cancellationToken).ConfigureAwait(false);
+ var labelList = (List<string?>)await reader.ReadNonNullableValueAsync<List<string?>>(stream, cancellationToken).ConfigureAwait(false);
+ var label = labelList.Count > 0 ? labelList[0] ?? "" : "";
+ var value = await reader.ReadAsync(stream, cancellationToken).ConfigureAwait(false);
+
+ // discard the parent vertex
+ await reader.ReadAsync(stream, cancellationToken).ConfigureAwait(false);
+
+ var properties = await reader.ReadAsync(stream, cancellationToken).ConfigureAwait(false);
+ var propertiesAsArray = null == properties ? Array.Empty<object>() : (properties as List<object>)?.ToArray();
+
+ return new VertexProperty(id, label, value, null, propertiesAsArray);
+ }
+ }
+}
diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphBinary4/Types/VertexSerializer.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphBinary4/Types/VertexSerializer.cs
new file mode 100644
index 0000000000..9bad7be2d7
--- /dev/null
+++ b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphBinary4/Types/VertexSerializer.cs
@@ -0,0 +1,68 @@
+#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;
+using System.IO;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace Gremlin.Net.Structure.IO.GraphBinary4.Types
+{
+ /// <summary>
+ /// A <see cref="Vertex"/> serializer for GraphBinary 4.0.
+ /// In v4, labels are serialized as List of Strings instead of a single String.
+ /// </summary>
+ public class VertexSerializer : SimpleTypeSerializer<Vertex>
+ {
+ /// <summary>
+ /// Initializes a new instance of the <see cref="VertexSerializer" /> class.
+ /// </summary>
+ public VertexSerializer() : base(DataType.Vertex)
+ {
+ }
+
+ /// <inheritdoc />
+ protected override async Task WriteValueAsync(Vertex value, Stream stream, GraphBinaryWriter writer,
+ CancellationToken cancellationToken = default)
+ {
+ await writer.WriteAsync(value.Id, stream, cancellationToken).ConfigureAwait(false);
+ await writer.WriteNonNullableValueAsync(new List<string> { value.Label }, stream, cancellationToken).ConfigureAwait(false);
+ await writer.WriteAsync(null, stream, cancellationToken).ConfigureAwait(false); // properties
+ }
+
+ /// <inheritdoc />
+ protected override async Task<Vertex> ReadValueAsync(Stream stream, GraphBinaryReader reader,
+ CancellationToken cancellationToken = default)
+ {
+ var id = await reader.ReadAsync(stream, cancellationToken).ConfigureAwait(false);
+ var labelList = (List<string?>)await reader.ReadNonNullableValueAsync<List<string?>>(stream, cancellationToken).ConfigureAwait(false);
+ var label = labelList.Count > 0 ? labelList[0] ?? "" : "";
+
+ var properties = await reader.ReadAsync(stream, cancellationToken).ConfigureAwait(false);
+ var propertiesAsArray = null == properties ? Array.Empty<object>() : (properties as List<object>)?.ToArray();
+
+ return new Vertex(id, label, propertiesAsArray);
+ }
+ }
+}
diff --git a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphBinary4/GraphBinary4Tests.cs b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphBinary4/GraphBinary4Tests.cs
new file mode 100644
index 0000000000..14d8a95e4d
--- /dev/null
+++ b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphBinary4/GraphBinary4Tests.cs
@@ -0,0 +1,794 @@
+#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;
+using System.Globalization;
+using System.IO;
+using System.Numerics;
+using System.Threading.Tasks;
+using Gremlin.Net.Process.Traversal;
+using Gremlin.Net.Structure;
+using Gremlin.Net.Structure.IO.GraphBinary4;
+using Xunit;
+using Path = Gremlin.Net.Structure.Path;
+
+namespace Gremlin.Net.UnitTest.Structure.IO.GraphBinary4
+{
+ public class GraphBinary4Tests
+ {
+ [Fact]
+ public async Task TestNull()
+ {
+ var writer = CreateGraphBinaryWriter();
+ var reader = CreateGraphBinaryReader();
+ var serializationStream = new MemoryStream();
+
+ await writer.WriteAsync(null, serializationStream);
+ serializationStream.Position = 0;
+ var actual = await reader.ReadAsync(serializationStream);
+
+ Assert.Null(actual);
+ }
+
+ [Fact]
+ public async Task TestInt()
+ {
+ const int expected = 100;
+ var writer = CreateGraphBinaryWriter();
+ var reader = CreateGraphBinaryReader();
+ var serializationStream = new MemoryStream();
+
+ await writer.WriteAsync(expected, serializationStream);
+ serializationStream.Position = 0;
+ var actual = await reader.ReadAsync(serializationStream);
+
+ Assert.Equal(expected, actual);
+ }
+
+ [Theory]
+ [InlineData(1, new byte[]{0x00, 0x00, 0x00, 0x01})]
+ [InlineData(257, new byte[]{0x00, 0x00, 0x01, 0x01})]
+ [InlineData(-1, new byte[]{0xFF, 0xFF, 0xFF, 0xFF})]
+ [InlineData(-2, new byte[]{0xFF, 0xFF, 0xFF, 0xFE})]
+ public async Task TestIntSpec(int value, byte[] expected)
+ {
+ var writer = CreateGraphBinaryWriter();
+ var serializationStream = new MemoryStream();
+
+ await writer.WriteNonNullableValueAsync(value, serializationStream);
+
+ var serBytes = serializationStream.ToArray();
+ Assert.Equal(expected, serBytes);
+ }
+
+ [Fact]
+ public async Task TestLong()
+ {
+ const long expected = 100;
+ var writer = CreateGraphBinaryWriter();
+ var reader = CreateGraphBinaryReader();
+ var serializationStream = new MemoryStream();
+
+ await writer.WriteAsync(expected, serializationStream);
+ serializationStream.Position = 0;
+ var actual = await reader.ReadAsync(serializationStream);
+
+ Assert.Equal(expected, actual);
+ }
+
+ [Theory]
+ [InlineData(100.01f)]
+ [InlineData(float.NaN)]
+ [InlineData(float.NegativeInfinity)]
+ [InlineData(float.PositiveInfinity)]
+ public async Task TestFloat(float expected)
+ {
+ var writer = CreateGraphBinaryWriter();
+ var reader = CreateGraphBinaryReader();
+ var serializationStream = new MemoryStream();
+
+ await writer.WriteAsync(expected, serializationStream);
+ serializationStream.Position = 0;
+ var actual = await reader.ReadAsync(serializationStream);
+
+ Assert.Equal(expected, actual);
+ }
+
+ [Fact]
+ public async Task TestDouble()
+ {
+ const double expected = 100.001;
+ var writer = CreateGraphBinaryWriter();
+ var reader = CreateGraphBinaryReader();
+ var serializationStream = new MemoryStream();
+
+ await writer.WriteAsync(expected, serializationStream);
+ serializationStream.Position = 0;
+ var actual = await reader.ReadAsync(serializationStream);
+
+ Assert.Equal(expected, actual);
+ }
+
+ [Fact]
+ public async Task TestShort()
+ {
+ const short expected = 100;
+ var writer = CreateGraphBinaryWriter();
+ var reader = CreateGraphBinaryReader();
+ var serializationStream = new MemoryStream();
+
+ await writer.WriteAsync(expected, serializationStream);
+ serializationStream.Position = 0;
+ var actual = await reader.ReadAsync(serializationStream);
+
+ Assert.Equal(expected, actual);
+ }
+
+ [Fact]
+ public async Task TestDateTime()
+ {
+ var expected = DateTimeOffset.ParseExact("2016-12-14 16:14:36.295000", "yyyy-MM-dd HH:mm:ss.ffffff",
+ CultureInfo.InvariantCulture);
+ var writer = CreateGraphBinaryWriter();
+ var reader = CreateGraphBinaryReader();
+ var serializationStream = new MemoryStream();
+
+ await writer.WriteAsync(expected, serializationStream);
+ serializationStream.Position = 0;
+ var actual = await reader.ReadAsync(serializationStream);
+
+ Assert.Equal(expected, actual);
+ }
+
+ [Fact]
+ public async Task TestDateTimeWithNonUtcOffset()
+ {
+ // 2007-12-03T10:15:30+01:00 — the example from the spec
+ var expected = new DateTimeOffset(2007, 12, 3, 10, 15, 30, TimeSpan.FromHours(1));
+ var writer = CreateGraphBinaryWriter();
+ var reader = CreateGraphBinaryReader();
+ var serializationStream = new MemoryStream();
+
+ await writer.WriteAsync(expected, serializationStream);
+ serializationStream.Position = 0;
+ var actual = await reader.ReadAsync(serializationStream);
+
+ Assert.Equal(expected, actual);
+ }
+
+ [Fact]
+ public async Task TestDateTimeWithNegativeOffset()
+ {
+ var expected = new DateTimeOffset(2024, 6, 15, 8, 30, 0, TimeSpan.FromHours(-5));
+ var writer = CreateGraphBinaryWriter();
+ var reader = CreateGraphBinaryReader();
+ var serializationStream = new MemoryStream();
+
+ await writer.WriteAsync(expected, serializationStream);
+ serializationStream.Position = 0;
+ var actual = await reader.ReadAsync(serializationStream);
+
+ Assert.Equal(expected, actual);
+ }
+
+ [Fact]
+ public async Task TestMarkerEndOfStream()
+ {
+ var expected = Marker.EndOfStream;
+ var writer = CreateGraphBinaryWriter();
+ var reader = CreateGraphBinaryReader();
+ var serializationStream = new MemoryStream();
+
+ await writer.WriteAsync(expected, serializationStream);
+ serializationStream.Position = 0;
+ var actual = await reader.ReadAsync(serializationStream);
+
+ Assert.Equal(expected, actual);
+ }
+
+ [Fact]
+ public async Task TestMarkerEndOfStreamSpec()
+ {
+ var writer = CreateGraphBinaryWriter();
+ var serializationStream = new MemoryStream();
+
+ await writer.WriteAsync(Marker.EndOfStream, serializationStream);
+
+ Assert.Equal(new byte[] { 0xFD, 0x00, 0x00 }, serializationStream.ToArray());
+ }
+
+ [Fact]
+ public async Task TestString()
+ {
+ const string expected = "serialize this!";
+ var writer = CreateGraphBinaryWriter();
+ var reader = CreateGraphBinaryReader();
+ var serializationStream = new MemoryStream();
+
+ await writer.WriteAsync(expected, serializationStream);
+ serializationStream.Position = 0;
+ var actual = await reader.ReadAsync(serializationStream);
+
+ Assert.Equal(expected, actual);
+ }
+
+ [Theory]
+ [InlineData("serialize this!", "serialize that!", "serialize that!", "stop telling me what to serialize")]
+ [InlineData(1, 2, 3, 4, 5)]
+ [InlineData(0.1, 1.1, 2.5, double.NaN)]
+ [InlineData(0.1f, 1.1f, 2.5f, float.NaN)]
+ public async Task TestHomogeneousList(params object[] listMembers)
+ {
+ var expected = new List<object>(listMembers);
+ var writer = CreateGraphBinaryWriter();
+ var reader = CreateGraphBinaryReader();
+ var serializationStream = new MemoryStream();
+
+ await writer.WriteAsync(expected, serializationStream);
+ serializationStream.Position = 0;
+ var actual = await reader.ReadAsync(serializationStream);
+
+ Assert.Equal(expected, actual);
+ }
+
+ [Fact]
+ public async Task TestHomogeneousTypeSafeList()
+ {
+ var expected = new List<string> {"test", "123"};
+ var writer = CreateGraphBinaryWriter();
+ var reader = CreateGraphBinaryReader();
+ var serializationStream = new MemoryStream();
+
+ await writer.WriteAsync(expected, serializationStream);
+ serializationStream.Position = 0;
+ var actual = await reader.ReadAsync(serializationStream);
+
+ Assert.Equal(expected, actual);
+ }
+
+ [Fact]
+ public async Task TestHeterogeneousList()
+ {
+ var expected = new List<object>
+ {"serialize this!", 0, "serialize that!", "serialize that!", 1, "stop telling me what to serialize", 2};
+ var writer = CreateGraphBinaryWriter();
+ var reader = CreateGraphBinaryReader();
+ var serializationStream = new MemoryStream();
+
+ await writer.WriteAsync(expected, serializationStream);
+ serializationStream.Position = 0;
+ var actual = await reader.ReadAsync(serializationStream);
+
+ Assert.Equal(expected, actual);
+ }
+
+ /// <summary>
+ /// Tests the bulked list format (value_flag=0x02) where each item is followed by a Long bulk count.
+ /// The writer doesn't produce this format, so we construct the bytes manually to test the reader.
+ /// </summary>
+ [Fact]
+ public async Task TestBulkedList()
+ {
+ // Manually construct: type=List(0x12), value_flag=0x02 (bulked), count=2 items
+ // item 1: String "a", bulk=2 → ["a", "a"]
+ // item 2: String "b", bulk=1 → ["b"]
+ var stream = new MemoryStream();
+ var writer = CreateGraphBinaryWriter();
+ // type code + bulked flag
+ stream.WriteByte(DataType.List.TypeCode);
+ stream.WriteByte(0x02); // ValueFlagBulk
+ await writer.WriteNonNullableValueAsync(2, stream);
+ await writer.WriteAsync("a", stream);
+ await writer.WriteNonNullableValueAsync(2L, stream);
+ await writer.WriteAsync("b", stream);
+ await writer.WriteNonNullableValueAsync(1L, stream);
+
+ stream.Position = 0;
+ var reader = CreateGraphBinaryReader();
+ var actual = (List<object?>) await reader.ReadAsync(stream);
+
+ Assert.Equal(new List<object?> { "a", "a", "b" }, actual);
+ }
+
+ [Fact]
+ public async Task TestArray()
+ {
+ var expected = new string[] {"hallo", "welt"};
+ var writer = CreateGraphBinaryWriter();
+ var reader = CreateGraphBinaryReader();
+ var serializationStream = new MemoryStream();
+
+ await writer.WriteAsync(expected, serializationStream);
+ serializationStream.Position = 0;
+ var actual = await reader.ReadAsync(serializationStream);
+
+ Assert.Equal(expected, actual);
+ }
+
+ [Theory]
+ [InlineData("serialize this!", "serialize that!", "serialize that!", "stop telling me what to serialize")]
+ [InlineData(1, 2, 3, 4, 5)]
+ [InlineData(0.1, 1.1, 2.5, double.NaN)]
+ [InlineData(0.1f, 1.1f, 2.5f, float.NaN)]
+ public async Task TestHomogeneousSet(params object[] listMembers)
+ {
+ var expected = new HashSet<object>(listMembers);
+ var writer = CreateGraphBinaryWriter();
+ var reader = CreateGraphBinaryReader();
+ var serializationStream = new MemoryStream();
+
+ await writer.WriteAsync(expected, serializationStream);
+ serializationStream.Position = 0;
+ var actual = await reader.ReadAsync(serializationStream);
+
+ Assert.Equal(expected, actual);
+ }
+
+ [Fact]
+ public async Task TestHomogeneousTypeSafeSet()
+ {
+ var expected = new HashSet<string> {"test", "123"};
+ var writer = CreateGraphBinaryWriter();
+ var reader = CreateGraphBinaryReader();
+ var serializationStream = new MemoryStream();
+
+ await writer.WriteNonNullableValueAsync(expected, serializationStream);
+ serializationStream.Position = 0;
+ var actual = await reader.ReadNonNullableValueAsync<HashSet<string>>(serializationStream);
+
+ Assert.Equal(expected, actual);
+ Assert.Equal(expected.GetType(), actual.GetType());
+ }
+
+ [Fact]
+ public async Task TestHeterogeneousSet()
+ {
+ var expected = new HashSet<object>
+ {"serialize this!", 0, "serialize that!", "serialize that!", 1, "stop telling me what to serialize", 2};
+ var writer = CreateGraphBinaryWriter();
+ var reader = CreateGraphBinaryReader();
+ var serializationStream = new MemoryStream();
+
+ await writer.WriteAsync(expected, serializationStream);
+ serializationStream.Position = 0;
+ var actual = await reader.ReadAsync(serializationStream);
+
+ Assert.Equal(expected, actual);
+ }
+
+ [Fact]
+ public async Task TestDictionary()
+ {
+ var expected = new Dictionary<object, object>
+ {
+ {"yo", "what"},
+ {"go", "no!"},
+ {"number", 123},
+ {321, "crazy with the number for a key"},
+ {987, new List<object> {"go", "deep", new Dictionary<object, object> {{"here", "!"}}}}
+ };
+ var writer = CreateGraphBinaryWriter();
+ var reader = CreateGraphBinaryReader();
+ var serializationStream = new MemoryStream();
+
+ await writer.WriteAsync(expected, serializationStream);
+ serializationStream.Position = 0;
+ var actual = await reader.ReadAsync(serializationStream);
+
+ Assert.Equal(expected, actual);
+ }
+
+ [Fact]
+ public async Task TestHomogeneousTypeSafeDictionary()
+ {
+ var expected = new Dictionary<string, int>
+ {
+ {"number", 123},
+ {"and", 456},
+ {"nothing else", 789}
+ };
+ var writer = CreateGraphBinaryWriter();
+ var reader = CreateGraphBinaryReader();
+ var serializationStream = new MemoryStream();
+
+ await writer.WriteAsync(expected, serializationStream);
+ serializationStream.Position = 0;
+ var actual = await reader.ReadAsync(serializationStream);
+
+ Assert.Equal(expected, actual);
+ }
+
+ [Fact]
+ public async Task TestHomogeneousTypeSafeDictionaryWithCorrectTyping()
+ {
+ var expected = new Dictionary<string, int>
+ {
+ {"number", 123},
+ {"and", 456},
+ {"nothing else", 789}
+ };
+ var writer = CreateGraphBinaryWriter();
+ var reader = CreateGraphBinaryReader();
+ var serializationStream = new MemoryStream();
+
+ await writer.WriteNonNullableValueAsync(expected, serializationStream);
+ serializationStream.Position = 0;
+ var actual = await reader.ReadNonNullableValueAsync<Dictionary<string, int>>(serializationStream);
+
+ Assert.Equal(expected, actual);
+ Assert.Equal(expected.GetType(), actual.GetType());
+ }
+
+ [Fact]
+ public async Task TestGuid()
+ {
+ var expected = Guid.Parse("41d2e28a-20a4-4ab0-b379-d810dede3786");
+ var writer = CreateGraphBinaryWriter();
+ var reader = CreateGraphBinaryReader();
+ var serializationStream = new MemoryStream();
+
+ await writer.WriteAsync(expected, serializationStream);
+ serializationStream.Position = 0;
+ var actual = await reader.ReadAsync(serializationStream);
+
+ Assert.Equal(expected, actual);
+ }
+
+ [Fact]
+ public async Task TestGuidSerialization()
+ {
+ var toSerialize = Guid.Parse("00112233-4455-6677-8899-aabbccddeeff");
+ var writer = CreateGraphBinaryWriter();
+ var serializationStream = new MemoryStream();
+
+ await writer.WriteNonNullableValueAsync(toSerialize, serializationStream);
+
+ var expected = new byte[]
+ {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff};
+ Assert.Equal(expected, serializationStream.ToArray());
+ }
+
+ [Fact]
+ public async Task TestVertex()
+ {
+ var expected = new Vertex(123, "person");
+ var writer = CreateGraphBinaryWriter();
+ var reader = CreateGraphBinaryReader();
+ var serializationStream = new MemoryStream();
+
+ await writer.WriteAsync(expected, serializationStream);
+ serializationStream.Position = 0;
+ var actual = await reader.ReadAsync(serializationStream);
+
+ Assert.Equal(expected, actual);
+ }
+
+ [Fact]
+ public async Task WriteNonNullableValueShouldThrowForNullValue()
+ {
+ var writer = CreateGraphBinaryWriter();
+ var serializationStream = new MemoryStream();
+
+ await Assert.ThrowsAsync<IOException>(() => writer.WriteNonNullableValueAsync(null!, serializationStream));
+ }
+
+ [Fact]
+ public async Task TestEdge()
+ {
+ var expected = new Edge(123, new Vertex(1, "person"), "developed", new Vertex(10, "software"));
+ var writer = CreateGraphBinaryWriter();
+ var reader = CreateGraphBinaryReader();
+ var serializationStream = new MemoryStream();
+
+ await writer.WriteAsync(expected, serializationStream);
+ serializationStream.Position = 0;
+ var actual = await reader.ReadAsync(serializationStream);
+
+ Assert.Equal(expected, actual);
+ }
+
+ [Fact]
+ public async Task TestPath()
+ {
+ var expected =
+ new Path(
+ new List<ISet<string>>
+ {new HashSet<string> {"a", "b"}, new HashSet<string> {"c", "d"}, new HashSet<string> {"e"}},
+ new List<object?> {1, 2, 3});
+ var writer = CreateGraphBinaryWriter();
+ var reader = CreateGraphBinaryReader();
+ var serializationStream = new MemoryStream();
+
+ await writer.WriteAsync(expected, serializationStream);
+ serializationStream.Position = 0;
+ var actual = await reader.ReadAsync(serializationStream);
+
+ Assert.Equal(expected, actual);
+ }
+
+ [Fact]
+ public async Task TestProperty()
+ {
+ var expected = new Property("name", "stephen", null);
+ var writer = CreateGraphBinaryWriter();
+ var reader = CreateGraphBinaryReader();
+ var serializationStream = new MemoryStream();
+
+ await writer.WriteAsync(expected, serializationStream);
+ serializationStream.Position = 0;
+ var actual = await reader.ReadAsync(serializationStream);
+
+ Assert.Equal(expected, actual);
+ }
+
+ [Fact]
+ public async Task TestVertexProperty()
+ {
+ var expected = new VertexProperty(123, "name", "stephen", null);
+ var writer = CreateGraphBinaryWriter();
+ var reader = CreateGraphBinaryReader();
+ var serializationStream = new MemoryStream();
+
+ await writer.WriteAsync(expected, serializationStream);
+ serializationStream.Position = 0;
+ var actual = await reader.ReadAsync(serializationStream);
+
+ Assert.Equal(expected, actual);
+ }
+
+ [Fact]
+ public async Task TestDirection()
+ {
+ var expected = Direction.Out;
+ var writer = CreateGraphBinaryWriter();
+ var reader = CreateGraphBinaryReader();
+ var serializationStream = new MemoryStream();
+
+ await writer.WriteAsync(expected, serializationStream);
+ serializationStream.Position = 0;
+ var actual = await reader.ReadAsync(serializationStream);
+
+ Assert.Equal(expected, actual);
+ }
+
+ [Fact]
+ public async Task TestMerge()
+ {
+ var expected = Merge.OnCreate;
+ var writer = CreateGraphBinaryWriter();
+ var reader = CreateGraphBinaryReader();
+ var serializationStream = new MemoryStream();
+
+ await writer.WriteAsync(expected, serializationStream);
+ serializationStream.Position = 0;
+ var actual = await reader.ReadAsync(serializationStream);
+
+ Assert.Equal(expected, actual);
+ }
+
+ [Fact]
+ public async Task TestT()
+ {
+ var expected = T.Label;
+ var writer = CreateGraphBinaryWriter();
+ var reader = CreateGraphBinaryReader();
+ var serializationStream = new MemoryStream();
+
+ await writer.WriteAsync(expected, serializationStream);
+ serializationStream.Position = 0;
+ var actual = await reader.ReadAsync(serializationStream);
+
+ Assert.Equal(expected, actual);
+ }
+
+ [Theory]
+ [InlineData(1)]
+ [InlineData(123)]
+ [InlineData(-1)]
+ [InlineData(-128)]
+ [InlineData(127)]
+ public async Task TestSByte(sbyte expected)
+ {
+ var writer = CreateGraphBinaryWriter();
+ var reader = CreateGraphBinaryReader();
+ var serializationStream = new MemoryStream();
+
+ await writer.WriteAsync(expected, serializationStream);
+ serializationStream.Position = 0;
+ var actual = await reader.ReadAsync(serializationStream);
+
+ Assert.Equal(expected, actual);
+ }
+
+ [Theory]
+ [InlineData((sbyte)0, new byte[] { 0x00 })]
+ [InlineData((sbyte)1, new byte[] { 0x01 })]
+ [InlineData((sbyte)127, new byte[] { 0x7F })]
+ [InlineData((sbyte)-1, new byte[] { 0xFF })]
+ [InlineData((sbyte)-128, new byte[] { 0x80 })]
+ public async Task TestSByteSerializationSpec(sbyte value, byte[] expected)
+ {
+ var writer = CreateGraphBinaryWriter();
+ var serializationStream = new MemoryStream();
+
+ await writer.WriteNonNullableValueAsync(value, serializationStream);
+
+ var serBytes = serializationStream.ToArray();
+ Assert.Equal(expected, serBytes);
+ }
+
+ [Theory]
+ [InlineData((sbyte)0)]
+ [InlineData((sbyte)1)]
+ [InlineData((sbyte)127)]
+ [InlineData((sbyte)-1)]
+ [InlineData((sbyte)-128)]
+ [InlineData((sbyte)42)]
+ [InlineData((sbyte)-42)]
+ public async Task TestSByteRoundTrip(sbyte expected)
+ {
+ var writer = CreateGraphBinaryWriter();
+ var reader = CreateGraphBinaryReader();
+ var serializationStream = new MemoryStream();
+
+ await writer.WriteAsync(expected, serializationStream);
+ serializationStream.Position = 0;
+ var actual = await reader.ReadAsync(serializationStream);
+
+ Assert.Equal(expected, actual);
+ Assert.IsType<sbyte>(actual);
+ }
+
+ [Fact]
+ public async Task TestSByteMinMaxValues()
+ {
+ var writer = CreateGraphBinaryWriter();
+ var reader = CreateGraphBinaryReader();
+
+ // Test minimum value
+ var minStream = new MemoryStream();
+ await writer.WriteAsync(sbyte.MinValue, minStream);
+ minStream.Position = 0;
+ var actualMin = await reader.ReadAsync(minStream);
+ Assert.Equal(sbyte.MinValue, actualMin);
+
+ // Test maximum value
+ var maxStream = new MemoryStream();
+ await writer.WriteAsync(sbyte.MaxValue, maxStream);
+ maxStream.Position = 0;
+ var actualMax = await reader.ReadAsync(maxStream);
+ Assert.Equal(sbyte.MaxValue, actualMax);
+ }
+
+ [Fact]
+ public async Task TestBinary()
+ {
+ var expected = new byte[] {1, 2, 3};
+ var writer = CreateGraphBinaryWriter();
+ var reader = CreateGraphBinaryReader();
+ var serializationStream = new MemoryStream();
+
+ await writer.WriteAsync(expected, serializationStream);
+ serializationStream.Position = 0;
+ var actual = await reader.ReadAsync(serializationStream);
+
+ Assert.Equal(expected, actual);
+ }
+
+ [Theory]
+ [InlineData(true)]
+ [InlineData(false)]
+ public async Task TestBoolean(bool expected)
+ {
+ var writer = CreateGraphBinaryWriter();
+ var reader = CreateGraphBinaryReader();
+ var serializationStream = new MemoryStream();
+
+ await writer.WriteAsync(expected, serializationStream);
+ serializationStream.Position = 0;
+ var actual = await reader.ReadAsync(serializationStream);
+
+ Assert.Equal(expected, actual);
+ }
+
+ [Theory]
+ [InlineData('a')]
+ [InlineData('0')]
+ [InlineData('¢')]
+ [InlineData('€')]
+ public async Task TestChar(char expected)
+ {
+ var writer = CreateGraphBinaryWriter();
+ var reader = CreateGraphBinaryReader();
+ var serializationStream = new MemoryStream();
+
+ await writer.WriteAsync(expected, serializationStream);
+ serializationStream.Position = 0;
+ var actual = await reader.ReadAsync(serializationStream);
+
+ Assert.Equal(expected, actual);
+ }
+
+ [Fact]
+ public async Task TestDuration()
+ {
+ var expected = new TimeSpan(1, 2, 3, 4, 5);
+ var writer = CreateGraphBinaryWriter();
+ var reader = CreateGraphBinaryReader();
+ var serializationStream = new MemoryStream();
+
+ await writer.WriteAsync(expected, serializationStream);
+ serializationStream.Position = 0;
+ var actual = await reader.ReadAsync(serializationStream);
+
+ Assert.Equal(expected, actual);
+ }
+
+ [Fact]
+ public async Task TestBigInteger()
+ {
+ var expected = BigInteger.Parse("123456789987654321123456789987654321");
+ var writer = CreateGraphBinaryWriter();
+ var reader = CreateGraphBinaryReader();
+ var serializationStream = new MemoryStream();
+
+ await writer.WriteAsync(expected, serializationStream);
+ serializationStream.Position = 0;
+ var actual = await reader.ReadAsync(serializationStream);
+
+ Assert.Equal(expected, actual);
+ }
+
+ [Theory]
+ [InlineData("190.035")]
+ [InlineData("0.19")]
+ [InlineData("1900")]
+ [InlineData("-1900")]
+ [InlineData("100000000000000")]
+ [InlineData("100000000000000000000000000")]
+ public async Task TestBigDecimal(string decimalValue)
+ {
+ var expected = Decimal.Parse(decimalValue);
+ var writer = CreateGraphBinaryWriter();
+ var reader = CreateGraphBinaryReader();
+ var serializationStream = new MemoryStream();
+
+ await writer.WriteAsync(expected, serializationStream);
+ serializationStream.Position = 0;
+ var actual = await reader.ReadAsync(serializationStream);
+
+ Assert.Equal(expected, actual);
+ }
+
+ private static GraphBinaryWriter CreateGraphBinaryWriter()
+ {
+ return new GraphBinaryWriter();
+ }
+
+ private static GraphBinaryReader CreateGraphBinaryReader()
+ {
+ return new GraphBinaryReader();
+ }
+ }
+}
\ No newline at end of file
diff --git a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphBinary4/Model.cs b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphBinary4/Model.cs
new file mode 100644
index 0000000000..d749d6624e
--- /dev/null
+++ b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphBinary4/Model.cs
@@ -0,0 +1,210 @@
+#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;
+using System.Numerics;
+using Gremlin.Net.Process.Traversal;
+using Gremlin.Net.Structure;
+
+namespace Gremlin.Net.UnitTest.Structure.IO.GraphBinary4
+{
+ /// <summary>
+ /// Defines the supported types for GraphBinary 4.0 IO and provides test entries for round-trip testing.
+ ///
+ /// The following models aren't supported:
+ /// tinker-graph Graph type not implemented
+ /// traversal-tree Tree type not implemented
+ /// max-offsetdatetime DateTimeOffset.MaxValue exceeds serialization range
+ /// min-offsetdatetime DateTimeOffset.MinValue exceeds serialization range
+ /// forever-duration TimeSpan cannot represent Duration.FOREVER
+ /// pos-bigdecimal Java BigDecimal precision (33 digits) exceeds C# decimal (28-29 digits)
+ /// neg-bigdecimal Java BigDecimal precision (33 digits) exceeds C# decimal (28-29 digits)
+ /// var-type-map Dictionary doesn't support null key
+ /// </summary>
+ public static class Model
+ {
+ private static readonly Property SinceProperty = new("since", 2009, null);
+ private static readonly Property StartTime2005 = new("startTime", 2005, null);
+ private static readonly Property EndTime2005 = new("endTime", 2005, null);
+ private static readonly Property StartTime2001 = new("startTime", 2001, null);
+ private static readonly Property EndTime2004 = new("endTime", 2004, null);
+ private static readonly Property StartTime1997 = new("startTime", 1997, null);
+ private static readonly Property EndTime2001 = new("endTime", 2001, null);
+ private static readonly Property PropertyAB = new("a", "b", null);
+
+ private static readonly VertexProperty SantaFe = new(9, "location", "santa fe", null,
+ new dynamic[] { new Property("startTime", 2005, null) });
+ private static readonly VertexProperty Brussels = new(8, "location", "brussels", null,
+ new dynamic[] { StartTime2005, EndTime2005 });
+ private static readonly VertexProperty SantaCruz = new(7, "location", "santa cruz", null,
+ new dynamic[] { StartTime2001, EndTime2004 });
+ private static readonly VertexProperty SanDiego = new(6, "location", "san diego", null,
+ new dynamic[] { StartTime1997, EndTime2001 });
+ private static readonly VertexProperty NameMarko = new(0, "name", "marko", null);
+
+ public static Dictionary<string, object?> Entries { get; } = new()
+ {
+ // BigInteger
+ ["pos-biginteger"] = BigInteger.Parse("123456789987654321123456789987654321"),
+ ["neg-biginteger"] = BigInteger.Parse("-123456789987654321123456789987654321"),
+
+ // Byte (sbyte in C#)
+ ["min-byte"] = sbyte.MinValue, // -128
+ ["max-byte"] = sbyte.MaxValue, // 127
+
+ // Binary (byte[])
+ ["empty-binary"] = Array.Empty<byte>(),
+ ["str-binary"] = System.Text.Encoding.UTF8.GetBytes("some bytes for you"),
+
+ // Double
+ ["max-double"] = double.MaxValue,
+ ["min-double"] = double.Epsilon,
+ ["neg-max-double"] = -double.MaxValue,
+ ["neg-min-double"] = -double.Epsilon,
+ ["nan-double"] = double.NaN,
+ ["pos-inf-double"] = double.PositiveInfinity,
+ ["neg-inf-double"] = double.NegativeInfinity,
+ ["neg-zero-double"] = -0.0,
+
+ // Float
+ // Note: Java's Float.MIN_VALUE is the smallest positive float (equivalent to C#'s float.Epsilon),
+ // not the most negative float.
+ ["max-float"] = float.MaxValue,
+ ["min-float"] = float.Epsilon, // Java Float.MIN_VALUE = smallest positive float
+ ["neg-max-float"] = -float.MaxValue,
+ ["neg-min-float"] = -float.Epsilon, // negated Java Float.MIN_VALUE
+ ["nan-float"] = float.NaN,
+ ["pos-inf-float"] = float.PositiveInfinity,
+ ["neg-inf-float"] = float.NegativeInfinity,
+ ["neg-zero-float"] = -0.0f,
+
+ // Char
+ ["single-byte-char"] = 'a',
+ ["multi-byte-char"] = '\u03A9', // Greek capital letter Omega
+
+ // Null
+ ["unspecified-null"] = null,
+
+ // Boolean
+ ["true-boolean"] = true,
+ ["false-boolean"] = false,
+
+ // String
+ ["single-byte-string"] = "abc",
+ ["mixed-string"] = "abc\u0391\u0392\u0393", // abc + Greek letters Alpha, Beta, Gamma
+
+ // BulkSet (represented as List with duplicates)
+ ["var-bulklist"] = new List<object?> { "marko", "josh", "josh" },
+ ["empty-bulklist"] = new List<object?>(),
+
+ // Duration (TimeSpan)
+ ["zero-duration"] = TimeSpan.Zero,
+
+ // Edge
+ ["traversal-edge"] = new Edge(13, new Vertex(1, "person"), "develops", new Vertex(10, "software"),
+ new dynamic[] { SinceProperty }),
+ ["no-prop-edge"] = new Edge(13, new Vertex(1, "person"), "develops", new Vertex(10, "software")),
+
+ // Int
+ ["max-int"] = int.MaxValue,
+ ["min-int"] = int.MinValue,
+
+ // Long
+ ["max-long"] = long.MaxValue,
+ ["min-long"] = long.MinValue,
+
+ // List
+ ["var-type-list"] = new List<object?> { 1, "person", true, null },
+ ["empty-list"] = new List<object?>(),
+
+ // Map
+ ["var-type-map"] = new Dictionary<object, object?>
+ {
+ { "test", 123 },
+ { DateTimeOffset.FromUnixTimeMilliseconds(1481295), "red" },
+ { new List<object?> { 1, 2, 3 }, DateTimeOffset.FromUnixTimeMilliseconds(1481295) },
+ // Note: null key not supported in C# Dictionary
+ },
+ ["empty-map"] = new Dictionary<object, object?>(),
+
+ // Path
+ ["traversal-path"] = new Path(
+ new List<ISet<string>> { new HashSet<string>(), new HashSet<string>(), new HashSet<string>() },
+ new List<object?> { new Vertex(1, "person"), new Vertex(10, "software"), new Vertex(11, "software") }),
+ ["empty-path"] = new Path(new List<ISet<string>>(), new List<object?>()),
+ ["prop-path"] = new Path(
+ new List<ISet<string>> { new HashSet<string>(), new HashSet<string>(), new HashSet<string>() },
+ new List<object?>
+ {
+ new Vertex(1, "person", new dynamic[]
+ {
+ new VertexProperty(123, "name", "stephen", null, new dynamic[]
+ {
+ new VertexProperty(0, "name", "marko", null),
+ new VertexProperty(6, "location", new List<object?>(), null)
+ })
+ }),
+ new Vertex(10, "software"),
+ new Vertex(11, "software")
+ }),
+
+ // Property
+ ["edge-property"] = new Property("since", 2009, null),
+ ["null-property"] = new Property("", null, null),
+
+ // Set
+ ["var-type-set"] = new HashSet<object?> { 2, "person", true, null },
+ ["empty-set"] = new HashSet<object?>(),
+
+ // Short
+ ["max-short"] = short.MaxValue,
+ ["min-short"] = short.MinValue,
+
+ // UUID (Guid)
+ ["specified-uuid"] = Guid.Parse("41d2e28a-20a4-4ab0-b379-d810dede3786"),
+ ["nil-uuid"] = Guid.Empty,
+
+ // Vertex
+ ["no-prop-vertex"] = new Vertex(1, "person"),
+ ["traversal-vertex"] = new Vertex(1, "person", new dynamic[]
+ {
+ new Property("name", NameMarko, null),
+ new Property("location", new List<object?> { SanDiego, SantaCruz, Brussels, SantaFe }, null)
+ }),
+
+ // VertexProperty
+ ["traversal-vertexproperty"] = new VertexProperty(0L, "name", "marko", null),
+ ["meta-vertexproperty"] = new VertexProperty(1, "person", "stephen", null,
+ new dynamic[] { PropertyAB }),
+ ["set-cardinality-vertexproperty"] = new VertexProperty(1, "person",
+ new HashSet<object?> { "stephen", "marko" }, null, new dynamic[] { PropertyAB }),
+
+ // T enum
+ ["id-t"] = T.Id,
+
+ // Direction enum
+ ["out-direction"] = Direction.Out,
+ };
+ }
+}
diff --git a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphBinary4/RoundTripTests.cs b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphBinary4/RoundTripTests.cs
new file mode 100644
index 0000000000..c270105fa2
--- /dev/null
+++ b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphBinary4/RoundTripTests.cs
@@ -0,0 +1,364 @@
+#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.IO;
+using System.Threading.Tasks;
+using Gremlin.Net.Structure.IO.GraphBinary4;
+using Xunit;
+
+namespace Gremlin.Net.UnitTest.Structure.IO.GraphBinary4
+{
+ /// <summary>
+ /// Round trip testing of GraphBinary 4.0 compared to a correct "model".
+ /// Set the IO_TEST_DIRECTORY environment variable to the directory where
+ /// the .gbin files that represent the serialized "model" are located.
+ /// </summary>
+ public class RoundTripTests
+ {
+ private const string GremlinTestDir = "gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphbinary/";
+ private const string DirectorySearchPattern = "gremlin-dotnet";
+
+ private static readonly string TestResourceDirectory;
+ private static readonly GraphBinaryWriter Writer = new();
+ private static readonly GraphBinaryReader Reader = new();
+
+ static RoundTripTests()
+ {
+ var envDir = Environment.GetEnvironmentVariable("IO_TEST_DIRECTORY");
+ if (!string.IsNullOrEmpty(envDir))
+ {
+ TestResourceDirectory = envDir;
+ }
+ else
+ {
+ // Find the root directory by searching for gremlin-dotnet in the current path
+ var currentDir = AppDomain.CurrentDomain.BaseDirectory;
+ var index = currentDir.IndexOf(DirectorySearchPattern, StringComparison.Ordinal);
+ var defaultDir = index >= 0 ? currentDir[..index] : currentDir;
+ TestResourceDirectory = Path.Combine(defaultDir, GremlinTestDir);
+ }
+ }
+
+ private static object? GetEntry(string title) => Model.Entries[title];
+
+ private static byte[] ReadFileByName(string resourceName)
+ {
+ var fullName = Path.Combine(TestResourceDirectory, $"{resourceName}-v4.gbin");
+ return File.ReadAllBytes(fullName);
+ }
+
+ /// <summary>
+ /// Runs the regular set of tests for the type:
+ /// 1. model to deserialized object
+ /// 2. written bytes to read bytes
+ /// 3. round tripped (read then written) bytes to read bytes
+ /// </summary>
+ private async Task Run(string resourceName, Func<object?, object?, bool>? comparator = null)
+ {
+ var resourceBytes = ReadFileByName(resourceName);
+ var model = GetEntry(resourceName);
+
+ using var readStream = new MemoryStream(resourceBytes);
+ var read = await Reader.ReadAsync(readStream);
+
+ if (comparator != null)
+ Assert.True(comparator(model, read));
+ else
+ Assert.Equal(model, read);
+
+ using var writeStream = new MemoryStream();
+ await Writer.WriteAsync(model, writeStream);
+ Assert.Equal(resourceBytes, writeStream.ToArray());
+
+ using var roundTripReadStream = new MemoryStream(resourceBytes);
+ var roundTripRead = await Reader.ReadAsync(roundTripReadStream);
+ using var roundTripWriteStream = new MemoryStream();
+ await Writer.WriteAsync(roundTripRead, roundTripWriteStream);
+ Assert.Equal(resourceBytes, roundTripWriteStream.ToArray());
+ }
+
+ /// <summary>
+ /// Runs the read test which compares the model to deserialized object.
+ /// This should only be used in cases where there is only a deserializer
+ /// but no serializer for the same type.
+ /// </summary>
+ private async Task RunRead(string resourceName, Func<object?, object?, bool>? comparator = null)
+ {
+ var resourceBytes = ReadFileByName(resourceName);
+ var model = GetEntry(resourceName);
+
+ using var readStream = new MemoryStream(resourceBytes);
+ var read = await Reader.ReadAsync(readStream);
+
+ if (comparator != null)
+ Assert.True(comparator(model, read));
+ else
+ Assert.Equal(model, read);
+ }
+
+ /// <summary>
+ /// Runs a reduced set of tests for the type:
+ /// 1. model to deserialized object
+ /// 2. model to round tripped (written then read) object
+ /// Use this in cases where the regular Run() function is too stringent.
+ /// E.g. when ordering doesn't matter like for sets.
+ /// </summary>
+ private async Task RunWriteRead(string resourceName, Func<object?, object?, bool>? comparator = null)
+ {
+ var resourceBytes = ReadFileByName(resourceName);
+ var model = GetEntry(resourceName);
+
+ using var readStream = new MemoryStream(resourceBytes);
+ var read = await Reader.ReadAsync(readStream);
+
+ using var writeStream = new MemoryStream();
+ await Writer.WriteAsync(model, writeStream);
+ using var roundTripStream = new MemoryStream(writeStream.ToArray());
+ var roundTripped = await Reader.ReadAsync(roundTripStream);
+
+ if (comparator != null)
+ {
+ Assert.True(comparator(model, read));
+ Assert.True(comparator(model, roundTripped));
+ }
+ else
+ {
+ Assert.Equal(model, read);
+ Assert.Equal(model, roundTripped);
+ }
+ }
+
+ private static bool NanComparator(object? x, object? y)
+ {
+ return x switch
+ {
+ double dx when y is double dy => double.IsNaN(dx) && double.IsNaN(dy),
+ float fx when y is float fy => float.IsNaN(fx) && float.IsNaN(fy),
+ _ => false
+ };
+ }
+
+ // BigInteger tests
+ [Fact]
+ public Task TestPosBigInteger() => Run("pos-biginteger");
+
+ [Fact]
+ public Task TestNegBigInteger() => Run("neg-biginteger");
+
+ // Byte tests
+ [Fact]
+ public Task TestMinByte() => Run("min-byte");
+
+ [Fact]
+ public Task TestMaxByte() => Run("max-byte");
+
+ // Binary tests
+ [Fact]
+ public Task TestEmptyBinary() => Run("empty-binary");
+
+ [Fact]
+ public Task TestStrBinary() => Run("str-binary");
+
+ // Double tests
+ [Fact]
+ public Task TestMaxDouble() => Run("max-double");
+
+ [Fact]
+ public Task TestMinDouble() => Run("min-double");
+
+ [Fact]
+ public Task TestNegMaxDouble() => Run("neg-max-double");
+
+ [Fact]
+ public Task TestNegMinDouble() => Run("neg-min-double");
+
+ [Fact]
+ public Task TestNanDouble() => RunWriteRead("nan-double", NanComparator); // C# has different NaN representation
+
+ [Fact]
+ public Task TestPosInfDouble() => Run("pos-inf-double");
+
+ [Fact]
+ public Task TestNegInfDouble() => Run("neg-inf-double");
+
+ [Fact]
+ public Task TestNegZeroDouble() => Run("neg-zero-double");
+
+ // Float tests
+ [Fact]
+ public Task TestMaxFloat() => Run("max-float");
+
+ [Fact]
+ public Task TestMinFloat() => Run("min-float");
+
+ [Fact]
+ public Task TestNegMaxFloat() => Run("neg-max-float");
+
+ [Fact]
+ public Task TestNegMinFloat() => Run("neg-min-float");
+
+ [Fact]
+ public Task TestNanFloat() => RunWriteRead("nan-float", NanComparator); // C# has different NaN representation
+
+ [Fact]
+ public Task TestPosInfFloat() => Run("pos-inf-float");
+
+ [Fact]
+ public Task TestNegInfFloat() => Run("neg-inf-float");
+
+ [Fact]
+ public Task TestNegZeroFloat() => Run("neg-zero-float");
+
+ // Char tests
+ [Fact]
+ public Task TestSingleByteChar() => Run("single-byte-char");
+
+ [Fact]
+ public Task TestMultiByteChar() => Run("multi-byte-char");
+
+ // Null test
+ [Fact]
+ public Task TestUnspecifiedNull() => Run("unspecified-null");
+
+ // Boolean tests
+ [Fact]
+ public Task TestTrueBoolean() => Run("true-boolean");
+
+ [Fact]
+ public Task TestFalseBoolean() => Run("false-boolean");
+
+ // String tests
+ [Fact]
+ public Task TestSingleByteString() => Run("single-byte-string");
+
+ [Fact]
+ public Task TestMixedString() => Run("mixed-string");
+
+ // BulkSet tests (read only - BulkSet deserialized as List)
+ [Fact]
+ public Task TestVarBulkList() => RunRead("var-bulklist");
+
+ [Fact]
+ public Task TestEmptyBulkList() => RunRead("empty-bulklist");
+
+ // Duration tests
+ [Fact]
+ public Task TestZeroDuration() => Run("zero-duration");
+
+ // Edge tests
+ [Fact]
+ public Task TestTraversalEdge() => RunWriteRead("traversal-edge"); // properties aren't serialized
+
+ [Fact]
+ public Task TestNoPropEdge() => RunWriteRead("no-prop-edge"); // properties written as null not empty list
+
+ // Int tests
+ [Fact]
+ public Task TestMaxInt() => Run("max-int");
+
+ [Fact]
+ public Task TestMinInt() => Run("min-int");
+
+ // Long tests
+ [Fact]
+ public Task TestMaxLong() => Run("max-long");
+
+ [Fact]
+ public Task TestMinLong() => Run("min-long");
+
+ // List tests
+ [Fact]
+ public Task TestVarTypeList() => Run("var-type-list");
+
+ [Fact]
+ public Task TestEmptyList() => Run("empty-list");
+
+ // Map tests
+ [Fact]
+ public Task TestEmptyMap() => Run("empty-map");
+
+ // Path tests
+ [Fact]
+ public Task TestTraversalPath() => RunWriteRead("traversal-path"); // properties written as null not empty list
+
+ [Fact]
+ public Task TestEmptyPath() => Run("empty-path");
+
+ [Fact]
+ public Task TestPropPath() => RunWriteRead("prop-path"); // properties aren't serialized
+
+ // Property tests
+ [Fact]
+ public Task TestEdgeProperty() => Run("edge-property");
+
+ [Fact]
+ public Task TestNullProperty() => Run("null-property");
+
+ // Set tests
+ [Fact]
+ public Task TestVarTypeSet() => RunWriteRead("var-type-set"); // order not guaranteed in HashSet
+
+ [Fact]
+ public Task TestEmptySet() => Run("empty-set");
+
+ // Short tests
+ [Fact]
+ public Task TestMaxShort() => Run("max-short");
+
+ [Fact]
+ public Task TestMinShort() => Run("min-short");
+
+ // UUID tests
+ [Fact]
+ public Task TestSpecifiedUuid() => Run("specified-uuid");
+
+ [Fact]
+ public Task TestNilUuid() => Run("nil-uuid");
+
+ // Vertex tests
+ [Fact]
+ public Task TestNoPropVertex() => RunWriteRead("no-prop-vertex"); // properties written as null not empty list
+
+ [Fact]
+ public Task TestTraversalVertex() => RunWriteRead("traversal-vertex"); // properties aren't serialized
+
+ // VertexProperty tests
+ [Fact]
+ public Task TestTraversalVertexProperty() => RunWriteRead("traversal-vertexproperty"); // properties aren't serialized
+
+ [Fact]
+ public Task TestMetaVertexProperty() => RunWriteRead("meta-vertexproperty"); // properties aren't serialized
+
+ [Fact]
+ public Task TestSetCardinalityVertexProperty() => RunWriteRead("set-cardinality-vertexproperty"); // properties aren't serialized
+
+ // T enum test
+ [Fact]
+ public Task TestIdT() => Run("id-t");
+
+ // Direction enum test
+ [Fact]
+ public Task TestOutDirection() => Run("out-direction");
+ }
+}