This is an automated email from the ASF dual-hosted git repository.

colegreer pushed a commit to branch 3.7-dev
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git


The following commit(s) were added to refs/heads/3.7-dev by this push:
     new e8446d2c0a Integrate .NET driver examples into automated build process 
(#3293)
e8446d2c0a is described below

commit e8446d2c0aecadda80e6f22ab3d20d2296359900
Author: kirill-stepanishin <[email protected]>
AuthorDate: Fri Jan 23 09:39:48 2026 -0800

    Integrate .NET driver examples into automated build process (#3293)
---
 .../Examples/BasicGremlin/BasicGremlin.cs          | 16 ++++++++------
 gremlin-dotnet/Examples/Connections/Connections.cs | 25 +++++++++++-----------
 .../Examples/ModernTraversals/ModernTraversals.cs  | 10 +++++++--
 gremlin-dotnet/docker-compose.yml                  | 11 +++++++++-
 .../gremlin-dotnet/BasicGremlin/BasicGremlin.cs    | 16 ++++++++------
 .../gremlin-dotnet/Connections/Connections.cs      | 25 +++++++++++-----------
 .../ModernTraversals/ModernTraversals.cs           |  5 ++++-
 7 files changed, 68 insertions(+), 40 deletions(-)

diff --git a/gremlin-dotnet/Examples/BasicGremlin/BasicGremlin.cs 
b/gremlin-dotnet/Examples/BasicGremlin/BasicGremlin.cs
index 91820bfe09..7a5f373133 100644
--- a/gremlin-dotnet/Examples/BasicGremlin/BasicGremlin.cs
+++ b/gremlin-dotnet/Examples/BasicGremlin/BasicGremlin.cs
@@ -23,16 +23,20 @@ using static 
Gremlin.Net.Process.Traversal.AnonymousTraversalSource;
 
 public class BasicGremlinExample
 {
+    static readonly string ServerHost = 
Environment.GetEnvironmentVariable("GREMLIN_SERVER_HOST") ?? "localhost";
+    static readonly int ServerPort = 
int.Parse(Environment.GetEnvironmentVariable("GREMLIN_SERVER_PORT") ?? "8182");
+    static readonly string VertexLabel = 
Environment.GetEnvironmentVariable("VERTEX_LABEL") ?? "person";
+
     static async Task Main()
     {
-        var server = new GremlinServer("localhost", 8182);
+        var server = new GremlinServer(ServerHost, ServerPort);
         using var remoteConnection = new DriverRemoteConnection(new 
GremlinClient(server), "g");
         var g = Traversal().WithRemote(remoteConnection);
 
         // Basic Gremlin: adding and retrieving data
-        var v1 = g.AddV("person").Property("name", "marko").Next();
-        var v2 = g.AddV("person").Property("name", "stephen").Next();
-        var v3 = g.AddV("person").Property("name", "vadas").Next();
+        var v1 = g.AddV(VertexLabel).Property("name", "marko").Next();
+        var v2 = g.AddV(VertexLabel).Property("name", "stephen").Next();
+        var v3 = g.AddV(VertexLabel).Property("name", "vadas").Next();
 
         // Be sure to use a terminating step like Next() or Iterate() so that 
the traversal "executes"
         // Iterate() does not return any data and is used to just generate 
side-effects (i.e. write data to the database)
@@ -40,11 +44,11 @@ public class BasicGremlinExample
         g.V(v1).AddE("knows").To(v3).Property("weight", 0.75).Iterate();
 
         // Retrieve the data from the "marko" vertex
-        var marko = await g.V().Has("person", "name", 
"marko").Values<string>("name").Promise(t => t.Next());
+        var marko = await g.V().Has(VertexLabel, "name", 
"marko").Values<string>("name").Promise(t => t.Next());
         Console.WriteLine("name: " + marko);
 
         // Find the "marko" vertex and then traverse to the people he "knows" 
and return their data
-        var peopleMarkoKnows = await g.V().Has("person", "name", 
"marko").Out("knows").Values<string>("name").Promise(t => t.ToList());
+        var peopleMarkoKnows = await g.V().Has(VertexLabel, "name", 
"marko").Out("knows").Values<string>("name").Promise(t => t.ToList());
         foreach (var person in peopleMarkoKnows)
         {
             Console.WriteLine("marko knows " + person);
diff --git a/gremlin-dotnet/Examples/Connections/Connections.cs 
b/gremlin-dotnet/Examples/Connections/Connections.cs
index 940cc05990..d0cfdc0783 100644
--- a/gremlin-dotnet/Examples/Connections/Connections.cs
+++ b/gremlin-dotnet/Examples/Connections/Connections.cs
@@ -24,6 +24,10 @@ using static 
Gremlin.Net.Process.Traversal.AnonymousTraversalSource;
 
 public class ConnectionExample
 {
+    static readonly string ServerHost = 
Environment.GetEnvironmentVariable("GREMLIN_SERVER_HOST") ?? "localhost";
+    static readonly int ServerPort = 
int.Parse(Environment.GetEnvironmentVariable("GREMLIN_SERVER_PORT") ?? "8182");
+    static readonly string VertexLabel = 
Environment.GetEnvironmentVariable("VERTEX_LABEL") ?? "connection";
+
     static void Main()
     {
         WithRemote();
@@ -34,16 +38,13 @@ public class ConnectionExample
     // Connecting to the server
     static void WithRemote()
     {
-        var server = new GremlinServer("localhost", 8182);
+        var server = new GremlinServer(ServerHost, ServerPort);
         using var remoteConnection = new DriverRemoteConnection(new 
GremlinClient(server), "g");
         var g = Traversal().WithRemote(remoteConnection);
 
-        // Drop existing vertices
-        g.V().Drop().Iterate();
-
         // Simple query to verify connection
-        var v = g.AddV().Iterate();
-        var count = g.V().Count().Next();
+        var v = g.AddV(VertexLabel).Iterate();
+        var count = g.V().HasLabel(VertexLabel).Count().Next();
         Console.WriteLine("Vertex count: " + count);
     }
 
@@ -51,24 +52,24 @@ public class ConnectionExample
     static void WithConf()
     {
         using var remoteConnection = new DriverRemoteConnection(new 
GremlinClient(
-        new GremlinServer(hostname: "localhost", port: 8182, enableSsl: false, 
username: "", password: "")), "g");
+        new GremlinServer(hostname: ServerHost, port: ServerPort, enableSsl: 
false, username: "", password: "")), "g");
         var g = Traversal().WithRemote(remoteConnection);
 
-        var v = g.AddV().Iterate();
-        var count = g.V().Count().Next();
+        var v = g.AddV(VertexLabel).Iterate();
+        var count = g.V().HasLabel(VertexLabel).Count().Next();
         Console.WriteLine("Vertex count: " + count);
     }
 
     // Specifying a serializer
     static void WithSerializer()
     {
-        var server = new GremlinServer("localhost", 8182);
+        var server = new GremlinServer(ServerHost, ServerPort);
         var client = new GremlinClient(server, new 
GraphSON3MessageSerializer());
         using var remoteConnection = new DriverRemoteConnection(client, "g");
         var g = Traversal().WithRemote(remoteConnection);
 
-        var v = g.AddV().Iterate();
-        var count = g.V().Count().Next();
+        var v = g.AddV(VertexLabel).Iterate();
+        var count = g.V().HasLabel(VertexLabel).Count().Next();
         Console.WriteLine("Vertex count: " + count);
     }
 }
diff --git a/gremlin-dotnet/Examples/ModernTraversals/ModernTraversals.cs 
b/gremlin-dotnet/Examples/ModernTraversals/ModernTraversals.cs
index fab7073530..a7d608ddbb 100644
--- a/gremlin-dotnet/Examples/ModernTraversals/ModernTraversals.cs
+++ b/gremlin-dotnet/Examples/ModernTraversals/ModernTraversals.cs
@@ -26,10 +26,16 @@ using static Gremlin.Net.Process.Traversal.P;
 
 public class ModernTraversalExample
 {
+    static readonly string ServerHost = 
Environment.GetEnvironmentVariable("GREMLIN_SERVER_HOST") ?? "localhost";
+    static readonly int ServerPort = 
int.Parse(Environment.GetEnvironmentVariable("GREMLIN_SERVER_PORT") ?? "8182");
+    static readonly bool IsDocker = 
Environment.GetEnvironmentVariable("DOCKER_ENVIRONMENT") == "true";
+
     static void Main()
     {
-        var server = new GremlinServer("localhost", 8182);
-        using var remoteConnection = new DriverRemoteConnection(new 
GremlinClient(server), "g");
+        var server = new GremlinServer(ServerHost, ServerPort);
+        // Use gmodern in CI environment, default connection locally
+        var traversalSource = IsDocker ? "gmodern" : "g";
+        using var remoteConnection = new DriverRemoteConnection(new 
GremlinClient(server), traversalSource);
         var g = Traversal().WithRemote(remoteConnection);
 
         /*
diff --git a/gremlin-dotnet/docker-compose.yml 
b/gremlin-dotnet/docker-compose.yml
index 5cb2363150..3a34ed27bd 100644
--- a/gremlin-dotnet/docker-compose.yml
+++ b/gremlin-dotnet/docker-compose.yml
@@ -53,10 +53,19 @@ services:
       - 
../gremlin-tools/gremlin-socket-server/conf:/gremlin-dotnet/gremlin-socket-server/conf/
     environment:
       - DOCKER_ENVIRONMENT=true
+      - GREMLIN_SERVER_HOST=gremlin-server-test-dotnet
+      - GREMLIN_SERVER_PORT=45940
+      - VERTEX_LABEL=dotnet-example
     working_dir: /gremlin-dotnet
     command: >
       bash -c "dotnet tool update -g dotnet-trx; dotnet test ./Gremlin.Net.sln 
-c Release --logger trx; /root/.dotnet/tools/trx;
-      EXIT_CODE=$$?; chown -R `stat -c "%u:%g" .` .; exit $$EXIT_CODE"
+      EXIT_CODE=$$?;
+      echo 'Running examples...';
+      dotnet run --project Examples/BasicGremlin/BasicGremlin.csproj;
+      dotnet run --project Examples/Connections/Connections.csproj;
+      dotnet run --project Examples/ModernTraversals/ModernTraversals.csproj;
+      echo 'All examples completed successfully';
+      chown -R `stat -c \"%u:%g\" .` .; exit $$EXIT_CODE"
     depends_on:
       gremlin-server-test-dotnet:
         condition: service_healthy
diff --git a/gremlin-examples/gremlin-dotnet/BasicGremlin/BasicGremlin.cs 
b/gremlin-examples/gremlin-dotnet/BasicGremlin/BasicGremlin.cs
index 91820bfe09..a9b79273dd 100644
--- a/gremlin-examples/gremlin-dotnet/BasicGremlin/BasicGremlin.cs
+++ b/gremlin-examples/gremlin-dotnet/BasicGremlin/BasicGremlin.cs
@@ -23,16 +23,20 @@ using static 
Gremlin.Net.Process.Traversal.AnonymousTraversalSource;
 
 public class BasicGremlinExample
 {
+    static readonly string ServerHost = "localhost";
+    static readonly int ServerPort = 8182;
+    static readonly string VertexLabel = "person";
+
     static async Task Main()
     {
-        var server = new GremlinServer("localhost", 8182);
+        var server = new GremlinServer(ServerHost, ServerPort);
         using var remoteConnection = new DriverRemoteConnection(new 
GremlinClient(server), "g");
         var g = Traversal().WithRemote(remoteConnection);
 
         // Basic Gremlin: adding and retrieving data
-        var v1 = g.AddV("person").Property("name", "marko").Next();
-        var v2 = g.AddV("person").Property("name", "stephen").Next();
-        var v3 = g.AddV("person").Property("name", "vadas").Next();
+        var v1 = g.AddV(VertexLabel).Property("name", "marko").Next();
+        var v2 = g.AddV(VertexLabel).Property("name", "stephen").Next();
+        var v3 = g.AddV(VertexLabel).Property("name", "vadas").Next();
 
         // Be sure to use a terminating step like Next() or Iterate() so that 
the traversal "executes"
         // Iterate() does not return any data and is used to just generate 
side-effects (i.e. write data to the database)
@@ -40,11 +44,11 @@ public class BasicGremlinExample
         g.V(v1).AddE("knows").To(v3).Property("weight", 0.75).Iterate();
 
         // Retrieve the data from the "marko" vertex
-        var marko = await g.V().Has("person", "name", 
"marko").Values<string>("name").Promise(t => t.Next());
+        var marko = await g.V().Has(VertexLabel, "name", 
"marko").Values<string>("name").Promise(t => t.Next());
         Console.WriteLine("name: " + marko);
 
         // Find the "marko" vertex and then traverse to the people he "knows" 
and return their data
-        var peopleMarkoKnows = await g.V().Has("person", "name", 
"marko").Out("knows").Values<string>("name").Promise(t => t.ToList());
+        var peopleMarkoKnows = await g.V().Has(VertexLabel, "name", 
"marko").Out("knows").Values<string>("name").Promise(t => t.ToList());
         foreach (var person in peopleMarkoKnows)
         {
             Console.WriteLine("marko knows " + person);
diff --git a/gremlin-examples/gremlin-dotnet/Connections/Connections.cs 
b/gremlin-examples/gremlin-dotnet/Connections/Connections.cs
index 940cc05990..e22b78ec20 100644
--- a/gremlin-examples/gremlin-dotnet/Connections/Connections.cs
+++ b/gremlin-examples/gremlin-dotnet/Connections/Connections.cs
@@ -24,6 +24,10 @@ using static 
Gremlin.Net.Process.Traversal.AnonymousTraversalSource;
 
 public class ConnectionExample
 {
+    static readonly string ServerHost = "localhost";
+    static readonly int ServerPort = 8182;
+    static readonly string VertexLabel = "connection";
+
     static void Main()
     {
         WithRemote();
@@ -34,16 +38,13 @@ public class ConnectionExample
     // Connecting to the server
     static void WithRemote()
     {
-        var server = new GremlinServer("localhost", 8182);
+        var server = new GremlinServer(ServerHost, ServerPort);
         using var remoteConnection = new DriverRemoteConnection(new 
GremlinClient(server), "g");
         var g = Traversal().WithRemote(remoteConnection);
 
-        // Drop existing vertices
-        g.V().Drop().Iterate();
-
         // Simple query to verify connection
-        var v = g.AddV().Iterate();
-        var count = g.V().Count().Next();
+        var v = g.AddV(VertexLabel).Iterate();
+        var count = g.V().HasLabel(VertexLabel).Count().Next();
         Console.WriteLine("Vertex count: " + count);
     }
 
@@ -51,24 +52,24 @@ public class ConnectionExample
     static void WithConf()
     {
         using var remoteConnection = new DriverRemoteConnection(new 
GremlinClient(
-        new GremlinServer(hostname: "localhost", port: 8182, enableSsl: false, 
username: "", password: "")), "g");
+        new GremlinServer(hostname: ServerHost, port: ServerPort, enableSsl: 
false, username: "", password: "")), "g");
         var g = Traversal().WithRemote(remoteConnection);
 
-        var v = g.AddV().Iterate();
-        var count = g.V().Count().Next();
+        var v = g.AddV(VertexLabel).Iterate();
+        var count = g.V().HasLabel(VertexLabel).Count().Next();
         Console.WriteLine("Vertex count: " + count);
     }
 
     // Specifying a serializer
     static void WithSerializer()
     {
-        var server = new GremlinServer("localhost", 8182);
+        var server = new GremlinServer(ServerHost, ServerPort);
         var client = new GremlinClient(server, new 
GraphSON3MessageSerializer());
         using var remoteConnection = new DriverRemoteConnection(client, "g");
         var g = Traversal().WithRemote(remoteConnection);
 
-        var v = g.AddV().Iterate();
-        var count = g.V().Count().Next();
+        var v = g.AddV(VertexLabel).Iterate();
+        var count = g.V().HasLabel(VertexLabel).Count().Next();
         Console.WriteLine("Vertex count: " + count);
     }
 }
diff --git 
a/gremlin-examples/gremlin-dotnet/ModernTraversals/ModernTraversals.cs 
b/gremlin-examples/gremlin-dotnet/ModernTraversals/ModernTraversals.cs
index fab7073530..94688df048 100644
--- a/gremlin-examples/gremlin-dotnet/ModernTraversals/ModernTraversals.cs
+++ b/gremlin-examples/gremlin-dotnet/ModernTraversals/ModernTraversals.cs
@@ -26,9 +26,12 @@ using static Gremlin.Net.Process.Traversal.P;
 
 public class ModernTraversalExample
 {
+    static readonly string ServerHost = "localhost";
+    static readonly int ServerPort = 8182;
+
     static void Main()
     {
-        var server = new GremlinServer("localhost", 8182);
+        var server = new GremlinServer(ServerHost, ServerPort);
         using var remoteConnection = new DriverRemoteConnection(new 
GremlinClient(server), "g");
         var g = Traversal().WithRemote(remoteConnection);
 

Reply via email to