You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by fl...@apache.org on 2021/04/28 14:19:49 UTC
[tinkerpop] 03/03: Enable nullable warnings for traversal types
This is an automated email from the ASF dual-hosted git repository.
florianhockmann pushed a commit to branch TINKERPOP-2348
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git
commit a100bc76231eb7369055554ad7f60d55b4415f6a
Author: Florian Hockmann <fh...@florian-hockmann.de>
AuthorDate: Wed Apr 28 16:19:04 2021 +0200
Enable nullable warnings for traversal types
---
.../Process/Traversal/DefaultTraversal.cs | 2 +-
.../Process/Traversal/GraphTraversal.cs | 77 ++++++++++++----------
.../Process/Traversal/GraphTraversalSource.cs | 43 ++++++------
.../Strategy/AbstractTraversalStrategy.cs | 8 ++-
.../Strategy/Decoration/OptionsStrategy.cs | 2 +
.../Strategy/Decoration/VertexProgramStrategy.cs | 8 ++-
.../src/Gremlin.Net/Process/Traversal/__.cs | 23 ++++---
.../Process/Remote/RemoteStrategyTests.cs | 2 +
.../Process/Traversal/TestTraversal.cs | 2 +
.../IO/GraphSON/BytecodeGraphSONSerializerTests.cs | 2 +
10 files changed, 99 insertions(+), 70 deletions(-)
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/DefaultTraversal.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/DefaultTraversal.cs
index 8348035..61c0b14 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/DefaultTraversal.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/DefaultTraversal.cs
@@ -42,7 +42,7 @@ namespace Gremlin.Net.Process.Traversal
/// <summary>
/// Gets the <see cref="Traversal.Bytecode" /> representation of this traversal.
/// </summary>
- public virtual Bytecode Bytecode { get; protected set; } = null!;
+ public abstract Bytecode Bytecode { get; }
/// <summary>
/// Determines if this traversal was spawned anonymously or not.
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs
index 8f6df56..93bf326 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs
@@ -21,6 +21,8 @@
#endregion
+#nullable enable warnings
+
using System.Collections.Generic;
using System.Linq;
using Gremlin.Net.Structure;
@@ -62,12 +64,15 @@ namespace Gremlin.Net.Process.Traversal
Bytecode = bytecode;
IsAnonymous = anonymous;
}
+
+ /// <inheritdoc />
+ public override Bytecode Bytecode { get; }
private static GraphTraversal<S2, E2> Wrap<S2, E2>(GraphTraversal<S, E> traversal)
{
if (typeof(S2) == typeof(S) && typeof(E2) == typeof(E))
{
- return traversal as GraphTraversal<S2, E2>;
+ return (traversal as GraphTraversal<S2, E2>)!;
}
// New wrapper
return new GraphTraversal<S2, E2>(traversal.TraversalStrategies, traversal.Bytecode, traversal.IsAnonymous);
@@ -77,9 +82,9 @@ namespace Gremlin.Net.Process.Traversal
/// <summary>
/// Adds the V step to this <see cref="GraphTraversal{SType, EType}" />.
/// </summary>
- public GraphTraversal<S, Vertex> V (params object[] vertexIdsOrElements)
+ public GraphTraversal<S, Vertex> V (params object?[] vertexIdsOrElements)
{
- var args = new List<object>(0 + vertexIdsOrElements.Length) {};
+ var args = new List<object?>(0 + vertexIdsOrElements.Length);
args.AddRange(vertexIdsOrElements);
Bytecode.AddStep("V", args.ToArray());
return Wrap<S, Vertex>(this);
@@ -502,7 +507,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<S, IDictionary<object, E2>> ElementMap<E2> (params string[] propertyKeys)
{
- var args = new List<object>(0 + propertyKeys.Length) {};
+ var args = new List<object>(0 + propertyKeys.Length);
args.AddRange(propertyKeys);
Bytecode.AddStep("elementMap", args.ToArray());
return Wrap<S, IDictionary<object, E2>>(this);
@@ -664,7 +669,7 @@ namespace Gremlin.Net.Process.Traversal
/// <summary>
/// Adds the has step to this <see cref="GraphTraversal{SType, EType}" />.
/// </summary>
- public GraphTraversal<S, E> Has (string propertyKey, object value)
+ public GraphTraversal<S, E> Has (string propertyKey, object? value)
{
Bytecode.AddStep("has", propertyKey, value);
return Wrap<S, E>(this);
@@ -682,7 +687,7 @@ namespace Gremlin.Net.Process.Traversal
/// <summary>
/// Adds the has step to this <see cref="GraphTraversal{SType, EType}" />.
/// </summary>
- public GraphTraversal<S, E> Has (string label, string propertyKey, object value)
+ public GraphTraversal<S, E> Has (string label, string propertyKey, object? value)
{
Bytecode.AddStep("has", label, propertyKey, value);
return Wrap<S, E>(this);
@@ -709,7 +714,7 @@ namespace Gremlin.Net.Process.Traversal
/// <summary>
/// Adds the has step to this <see cref="GraphTraversal{SType, EType}" />.
/// </summary>
- public GraphTraversal<S, E> Has (T accessor, object value)
+ public GraphTraversal<S, E> Has (T accessor, object? value)
{
Bytecode.AddStep("has", accessor, value);
return Wrap<S, E>(this);
@@ -736,9 +741,9 @@ namespace Gremlin.Net.Process.Traversal
/// <summary>
/// Adds the hasId step to this <see cref="GraphTraversal{SType, EType}" />.
/// </summary>
- public GraphTraversal<S, E> HasId (object id, params object[] otherIds)
+ public GraphTraversal<S, E> HasId (object? id, params object?[] otherIds)
{
- var args = new List<object>(1 + otherIds.Length) {id};
+ var args = new List<object?>(1 + otherIds.Length) {id};
args.AddRange(otherIds);
Bytecode.AddStep("hasId", args.ToArray());
return Wrap<S, E>(this);
@@ -805,9 +810,9 @@ namespace Gremlin.Net.Process.Traversal
/// <summary>
/// Adds the hasValue step to this <see cref="GraphTraversal{SType, EType}" />.
/// </summary>
- public GraphTraversal<S, E> HasValue (object value, params object[] otherValues)
+ public GraphTraversal<S, E> HasValue (object? value, params object?[] otherValues)
{
- var args = new List<object>(1 + otherValues.Length) {value};
+ var args = new List<object?>(1 + otherValues.Length) {value};
args.AddRange(otherValues);
Bytecode.AddStep("hasValue", args.ToArray());
return Wrap<S, E>(this);
@@ -825,10 +830,10 @@ namespace Gremlin.Net.Process.Traversal
/// <summary>
/// Adds the id step to this <see cref="GraphTraversal{SType, EType}" />.
/// </summary>
- public GraphTraversal<S, object> Id ()
+ public GraphTraversal<S, object?> Id ()
{
Bytecode.AddStep("id");
- return Wrap<S, object>(this);
+ return Wrap<S, object?>(this);
}
/// <summary>
@@ -845,7 +850,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<S, Vertex> In (params string[] edgeLabels)
{
- var args = new List<object>(0 + edgeLabels.Length) {};
+ var args = new List<object>(0 + edgeLabels.Length);
args.AddRange(edgeLabels);
Bytecode.AddStep("in", args.ToArray());
return Wrap<S, Vertex>(this);
@@ -856,7 +861,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<S, Edge> InE (params string[] edgeLabels)
{
- var args = new List<object>(0 + edgeLabels.Length) {};
+ var args = new List<object>(0 + edgeLabels.Length);
args.AddRange(edgeLabels);
Bytecode.AddStep("inE", args.ToArray());
return Wrap<S, Edge>(this);
@@ -885,7 +890,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<S, E> Inject (params E[] injections)
{
- var args = new List<object>(0 + injections.Length) {};
+ var args = new List<object>(0 + injections.Length);
args.AddRange(injections.Cast<object>());
Bytecode.AddStep("inject", args.ToArray());
return Wrap<S, E>(this);
@@ -894,7 +899,7 @@ namespace Gremlin.Net.Process.Traversal
/// <summary>
/// Adds the is step to this <see cref="GraphTraversal{SType, EType}" />.
/// </summary>
- public GraphTraversal<S, E> Is (object value)
+ public GraphTraversal<S, E> Is (object? value)
{
Bytecode.AddStep("is", value);
return Wrap<S, E>(this);
@@ -995,7 +1000,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<S, IDictionary<string, E2>> Match<E2> (params ITraversal[] matchTraversals)
{
- var args = new List<object>(0 + matchTraversals.Length) {};
+ var args = new List<object>(0 + matchTraversals.Length);
args.AddRange(matchTraversals);
Bytecode.AddStep("match", args.ToArray());
return Wrap<S, IDictionary<string, E2>>(this);
@@ -1114,7 +1119,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<S, E> Or (params ITraversal[] orTraversals)
{
- var args = new List<object>(0 + orTraversals.Length) {};
+ var args = new List<object>(0 + orTraversals.Length);
args.AddRange(orTraversals);
Bytecode.AddStep("or", args.ToArray());
return Wrap<S, E>(this);
@@ -1152,7 +1157,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<S, Vertex> Out (params string[] edgeLabels)
{
- var args = new List<object>(0 + edgeLabels.Length) {};
+ var args = new List<object>(0 + edgeLabels.Length);
args.AddRange(edgeLabels);
Bytecode.AddStep("out", args.ToArray());
return Wrap<S, Vertex>(this);
@@ -1163,7 +1168,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<S, Edge> OutE (params string[] edgeLabels)
{
- var args = new List<object>(0 + edgeLabels.Length) {};
+ var args = new List<object>(0 + edgeLabels.Length);
args.AddRange(edgeLabels);
Bytecode.AddStep("outE", args.ToArray());
return Wrap<S, Edge>(this);
@@ -1257,7 +1262,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<S, E2> Properties<E2> (params string[] propertyKeys)
{
- var args = new List<object>(0 + propertyKeys.Length) {};
+ var args = new List<object>(0 + propertyKeys.Length);
args.AddRange(propertyKeys);
Bytecode.AddStep("properties", args.ToArray());
return Wrap<S, E2>(this);
@@ -1266,9 +1271,10 @@ namespace Gremlin.Net.Process.Traversal
/// <summary>
/// Adds the property step to this <see cref="GraphTraversal{SType, EType}" />.
/// </summary>
- public GraphTraversal<S, E> Property (Cardinality cardinality, object key, object value, params object[] keyValues)
+ public GraphTraversal<S, E> Property(Cardinality cardinality, object key, object? value,
+ params object?[] keyValues)
{
- var args = new List<object>(3 + keyValues.Length) {cardinality, key, value};
+ var args = new List<object?>(3 + keyValues.Length) {cardinality, key, value};
args.AddRange(keyValues);
Bytecode.AddStep("property", args.ToArray());
return Wrap<S, E>(this);
@@ -1277,9 +1283,9 @@ namespace Gremlin.Net.Process.Traversal
/// <summary>
/// Adds the property step to this <see cref="GraphTraversal{SType, EType}" />.
/// </summary>
- public GraphTraversal<S, E> Property (object key, object value, params object[] keyValues)
+ public GraphTraversal<S, E> Property (object key, object? value, params object?[] keyValues)
{
- var args = new List<object>(2 + keyValues.Length) {key, value};
+ var args = new List<object?>(2 + keyValues.Length) {key, value};
args.AddRange(keyValues);
Bytecode.AddStep("property", args.ToArray());
return Wrap<S, E>(this);
@@ -1290,7 +1296,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<S, IDictionary<string, E2>> PropertyMap<E2> (params string[] propertyKeys)
{
- var args = new List<object>(0 + propertyKeys.Length) {};
+ var args = new List<object>(0 + propertyKeys.Length);
args.AddRange(propertyKeys);
Bytecode.AddStep("propertyMap", args.ToArray());
return Wrap<S, IDictionary<string, E2>>(this);
@@ -1398,7 +1404,8 @@ namespace Gremlin.Net.Process.Traversal
/// <summary>
/// Adds the select step to this <see cref="GraphTraversal{SType, EType}" />.
/// </summary>
- public GraphTraversal<S, IDictionary<string, E2>> Select<E2> (Pop pop, string selectKey1, string selectKey2, params string[] otherSelectKeys)
+ public GraphTraversal<S, IDictionary<string, E2>> Select<E2>(Pop pop, string selectKey1, string selectKey2,
+ params string[] otherSelectKeys)
{
var args = new List<object>(3 + otherSelectKeys.Length) {pop, selectKey1, selectKey2};
args.AddRange(otherSelectKeys);
@@ -1427,7 +1434,8 @@ namespace Gremlin.Net.Process.Traversal
/// <summary>
/// Adds the select step to this <see cref="GraphTraversal{SType, EType}" />.
/// </summary>
- public GraphTraversal<S, IDictionary<string, E2>> Select<E2> (string selectKey1, string selectKey2, params string[] otherSelectKeys)
+ public GraphTraversal<S, IDictionary<string, E2>> Select<E2>(string selectKey1, string selectKey2,
+ params string[] otherSelectKeys)
{
var args = new List<object>(2 + otherSelectKeys.Length) {selectKey1, selectKey2};
args.AddRange(otherSelectKeys);
@@ -1678,7 +1686,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<S, E2> Union<E2> (params ITraversal[] unionTraversals)
{
- var args = new List<object>(0 + unionTraversals.Length) {};
+ var args = new List<object>(0 + unionTraversals.Length);
args.AddRange(unionTraversals);
Bytecode.AddStep("union", args.ToArray());
return Wrap<S, E2>(this);
@@ -1716,7 +1724,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<S, IDictionary<TKey, TValue>> ValueMap<TKey, TValue> (params string[] propertyKeys)
{
- var args = new List<object>(0 + propertyKeys.Length) {};
+ var args = new List<object>(0 + propertyKeys.Length);
args.AddRange(propertyKeys);
Bytecode.AddStep("valueMap", args.ToArray());
return Wrap<S, IDictionary<TKey, TValue>>(this);
@@ -1725,7 +1733,8 @@ namespace Gremlin.Net.Process.Traversal
/// <summary>
/// Adds the valueMap step to this <see cref="GraphTraversal{SType, EType}" />.
/// </summary>
- public GraphTraversal<S, IDictionary<TKey, TValue>> ValueMap<TKey, TValue> (bool includeTokens, params string[] propertyKeys)
+ public GraphTraversal<S, IDictionary<TKey, TValue>> ValueMap<TKey, TValue>(bool includeTokens,
+ params string[] propertyKeys)
{
var args = new List<object>(1 + propertyKeys.Length) {includeTokens};
args.AddRange(propertyKeys);
@@ -1738,7 +1747,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<S, E2> Values<E2> (params string[] propertyKeys)
{
- var args = new List<object>(0 + propertyKeys.Length) {};
+ var args = new List<object>(0 + propertyKeys.Length);
args.AddRange(propertyKeys);
Bytecode.AddStep("values", args.ToArray());
return Wrap<S, E2>(this);
@@ -1804,7 +1813,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public GraphTraversal<S, E> Clone()
{
- return new GraphTraversal<S, E>(TraversalStrategies, new Bytecode(Bytecode));
+ return new(TraversalStrategies, new Bytecode(Bytecode));
}
}
}
\ 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 db4c521..21b2295 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversalSource.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversalSource.cs
@@ -21,6 +21,8 @@
#endregion
+#nullable enable warnings
+
using System;
using System.Collections.Generic;
using System.Linq;
@@ -89,7 +91,7 @@ namespace Gremlin.Net.Process.Traversal
return WithStrategies(optionsStrategy);
}
- optionsStrategy = optionsStrategyInst.Arguments[0];
+ optionsStrategy = optionsStrategyInst.Arguments[0]!;
optionsStrategy.Configuration[key] = value;
return new GraphTraversalSource(new List<ITraversalStrategy>(TraversalStrategies),
new Bytecode(Bytecode));
@@ -112,7 +114,7 @@ namespace Gremlin.Net.Process.Traversal
return source;
}
- public GraphTraversalSource WithSack(object initialValue)
+ public GraphTraversalSource WithSack(object? initialValue)
{
var source = new GraphTraversalSource(new List<ITraversalStrategy>(TraversalStrategies),
new Bytecode(Bytecode));
@@ -120,7 +122,7 @@ namespace Gremlin.Net.Process.Traversal
return source;
}
- public GraphTraversalSource WithSack(object initialValue, IBinaryOperator mergeOperator)
+ public GraphTraversalSource WithSack(object? initialValue, IBinaryOperator mergeOperator)
{
var source = new GraphTraversalSource(new List<ITraversalStrategy>(TraversalStrategies),
new Bytecode(Bytecode));
@@ -128,7 +130,7 @@ namespace Gremlin.Net.Process.Traversal
return source;
}
- public GraphTraversalSource WithSack(object initialValue, IUnaryOperator splitOperator)
+ public GraphTraversalSource WithSack(object? initialValue, IUnaryOperator splitOperator)
{
var source = new GraphTraversalSource(new List<ITraversalStrategy>(TraversalStrategies),
new Bytecode(Bytecode));
@@ -136,7 +138,8 @@ namespace Gremlin.Net.Process.Traversal
return source;
}
- public GraphTraversalSource WithSack(object initialValue, IUnaryOperator splitOperator, IBinaryOperator mergeOperator)
+ public GraphTraversalSource WithSack(object? initialValue, IUnaryOperator splitOperator,
+ IBinaryOperator mergeOperator)
{
var source = new GraphTraversalSource(new List<ITraversalStrategy>(TraversalStrategies),
new Bytecode(Bytecode));
@@ -168,7 +171,8 @@ namespace Gremlin.Net.Process.Traversal
return source;
}
- public GraphTraversalSource WithSack(ISupplier initialValue, IUnaryOperator splitOperator, IBinaryOperator mergeOperator)
+ public GraphTraversalSource WithSack(ISupplier initialValue, IUnaryOperator splitOperator,
+ IBinaryOperator mergeOperator)
{
var source = new GraphTraversalSource(new List<ITraversalStrategy>(TraversalStrategies),
new Bytecode(Bytecode));
@@ -176,7 +180,7 @@ namespace Gremlin.Net.Process.Traversal
return source;
}
- public GraphTraversalSource WithSideEffect(string key, object initialValue)
+ public GraphTraversalSource WithSideEffect(string key, object? initialValue)
{
var source = new GraphTraversalSource(new List<ITraversalStrategy>(TraversalStrategies),
new Bytecode(Bytecode));
@@ -184,7 +188,7 @@ namespace Gremlin.Net.Process.Traversal
return source;
}
- public GraphTraversalSource WithSideEffect(string key, object initialValue, IBinaryOperator reducer)
+ public GraphTraversalSource WithSideEffect(string key, object? initialValue, IBinaryOperator reducer)
{
var source = new GraphTraversalSource(new List<ITraversalStrategy>(TraversalStrategies),
new Bytecode(Bytecode));
@@ -212,7 +216,7 @@ namespace Gremlin.Net.Process.Traversal
{
var source = new GraphTraversalSource(new List<ITraversalStrategy>(TraversalStrategies),
new Bytecode(Bytecode));
- var args = new List<object>(0 + traversalStrategies.Length) {};
+ var args = new List<object>(0 + traversalStrategies.Length);
args.AddRange(traversalStrategies);
source.Bytecode.AddSource("withStrategies", args.ToArray());
return source;
@@ -222,7 +226,7 @@ namespace Gremlin.Net.Process.Traversal
{
var source = new GraphTraversalSource(new List<ITraversalStrategy>(TraversalStrategies),
new Bytecode(Bytecode));
- var args = new List<object>(0 + traversalStrategyClasses.Length) {};
+ var args = new List<object>(0 + traversalStrategyClasses.Length);
args.AddRange(traversalStrategyClasses);
source.Bytecode.AddSource("withoutStrategies", args.ToArray());
return source;
@@ -255,11 +259,12 @@ namespace Gremlin.Net.Process.Traversal
/// Add a GraphComputer class used to execute the traversal.
/// This adds a <see cref="VertexProgramStrategy" /> to the strategies.
/// </summary>
- public GraphTraversalSource WithComputer(string graphComputer = null, int? workers = null, string persist = null,
- string result = null, ITraversal vertices = null, ITraversal edges = null,
- Dictionary<string, dynamic> configuration = null)
+ public GraphTraversalSource WithComputer(string? graphComputer = null, int? workers = null,
+ string? persist = null, string? result = null, ITraversal? vertices = null, ITraversal? edges = null,
+ Dictionary<string, dynamic>? configuration = null)
{
- return WithStrategies(new VertexProgramStrategy(graphComputer, workers, persist, result, vertices, edges, configuration));
+ return WithStrategies(new VertexProgramStrategy(graphComputer, workers, persist, result, vertices, edges,
+ configuration));
}
@@ -267,10 +272,10 @@ namespace Gremlin.Net.Process.Traversal
/// Spawns a <see cref="GraphTraversal{SType, EType}" /> off this graph traversal source and adds the E step to that
/// traversal.
/// </summary>
- public GraphTraversal<Edge, Edge> E(params object[] edgesIds)
+ public GraphTraversal<Edge, Edge> E(params object?[] edgesIds)
{
var traversal = new GraphTraversal<Edge, Edge>(TraversalStrategies, new Bytecode(Bytecode));
- var args = new List<object>(0 + edgesIds.Length) {};
+ var args = new List<object?>(0 + edgesIds.Length);
args.AddRange(edgesIds);
traversal.Bytecode.AddStep("E", args.ToArray());
return traversal;
@@ -280,10 +285,10 @@ namespace Gremlin.Net.Process.Traversal
/// Spawns a <see cref="GraphTraversal{SType, EType}" /> off this graph traversal source and adds the V step to that
/// traversal.
/// </summary>
- public GraphTraversal<Vertex, Vertex> V(params object[] vertexIds)
+ public GraphTraversal<Vertex, Vertex> V(params object?[] vertexIds)
{
var traversal = new GraphTraversal<Vertex, Vertex>(TraversalStrategies, new Bytecode(Bytecode));
- var args = new List<object>(0 + vertexIds.Length) {};
+ var args = new List<object?>(0 + vertexIds.Length) {};
args.AddRange(vertexIds);
traversal.Bytecode.AddStep("V", args.ToArray());
return traversal;
@@ -351,7 +356,7 @@ namespace Gremlin.Net.Process.Traversal
public GraphTraversal<S, S> Inject<S>(params S[] starts)
{
var traversal = new GraphTraversal<S, S>(TraversalStrategies, new Bytecode(Bytecode));
- var args = new List<object>(0 + starts.Length) {};
+ var args = new List<object>(0 + starts.Length);
args.AddRange(starts.Cast<object>());
traversal.Bytecode.AddStep("inject", args.ToArray());
return traversal;
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 418ac7e..c0d853c 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/AbstractTraversalStrategy.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/AbstractTraversalStrategy.cs
@@ -21,6 +21,8 @@
#endregion
+#nullable enable warnings
+
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
@@ -83,10 +85,10 @@ namespace Gremlin.Net.Process.Traversal.Strategy
/// <summary>
/// Gets the configuration of the strategy.
/// </summary>
- public Dictionary<string, dynamic> Configuration { get; } = new Dictionary<string, dynamic>();
+ public Dictionary<string, dynamic> Configuration { get; } = new();
/// <inheritdoc />
- public bool Equals(AbstractTraversalStrategy other)
+ public bool Equals(AbstractTraversalStrategy? other)
{
if (ReferenceEquals(null, other)) return false;
if (ReferenceEquals(this, other)) return true;
@@ -105,7 +107,7 @@ namespace Gremlin.Net.Process.Traversal.Strategy
}
/// <inheritdoc />
- public override bool Equals(object obj)
+ public override bool Equals(object? obj)
{
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Decoration/OptionsStrategy.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Decoration/OptionsStrategy.cs
index aee9118..2d9854f 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Decoration/OptionsStrategy.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Decoration/OptionsStrategy.cs
@@ -21,6 +21,8 @@
#endregion
+#nullable enable warnings
+
using System.Collections.Generic;
namespace Gremlin.Net.Process.Traversal.Strategy.Decoration
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Decoration/VertexProgramStrategy.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Decoration/VertexProgramStrategy.cs
index 17bfbaa..2850b8c 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Decoration/VertexProgramStrategy.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Decoration/VertexProgramStrategy.cs
@@ -21,6 +21,8 @@
#endregion
+#nullable enable warnings
+
using System.Collections.Generic;
using System.Linq;
@@ -35,9 +37,9 @@ namespace Gremlin.Net.Process.Traversal.Strategy.Decoration
{
}
- public VertexProgramStrategy(string graphComputer = null, int? workers = null, string persist = null,
- string result = null, ITraversal vertices = null, ITraversal edges = null,
- Dictionary<string, dynamic> configuration = null)
+ public VertexProgramStrategy(string? graphComputer = null, int? workers = null, string? persist = null,
+ string? result = null, ITraversal? vertices = null, ITraversal? edges = null,
+ Dictionary<string, dynamic>? configuration = null)
: this()
{
if (graphComputer != null)
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/__.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/__.cs
index fa1c027..9827d30 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/__.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/__.cs
@@ -21,6 +21,8 @@
#endregion
+#nullable enable warnings
+
using System.Collections.Generic;
using Gremlin.Net.Structure;
@@ -36,7 +38,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public static GraphTraversal<object, object> Start()
{
- return new GraphTraversal<object, object>();
+ return new();
}
/// <summary>
@@ -454,7 +456,7 @@ namespace Gremlin.Net.Process.Traversal
/// <summary>
/// Spawns a <see cref="GraphTraversal{SType, EType}" /> and adds the has step to that traversal.
/// </summary>
- public static GraphTraversal<object, object> Has(string propertyKey, object value)
+ public static GraphTraversal<object, object> Has(string propertyKey, object? value)
{
return new GraphTraversal<object, object>().Has(propertyKey, value);
}
@@ -470,7 +472,7 @@ namespace Gremlin.Net.Process.Traversal
/// <summary>
/// Spawns a <see cref="GraphTraversal{SType, EType}" /> and adds the has step to that traversal.
/// </summary>
- public static GraphTraversal<object, object> Has(string label, string propertyKey, object value)
+ public static GraphTraversal<object, object> Has(string label, string propertyKey, object? value)
{
return new GraphTraversal<object, object>().Has(label, propertyKey, value);
}
@@ -494,7 +496,7 @@ namespace Gremlin.Net.Process.Traversal
/// <summary>
/// Spawns a <see cref="GraphTraversal{SType, EType}" /> and adds the has step to that traversal.
/// </summary>
- public static GraphTraversal<object, object> Has(T accessor, object value)
+ public static GraphTraversal<object, object> Has(T accessor, object? value)
{
return new GraphTraversal<object, object>().Has(accessor, value);
}
@@ -518,7 +520,7 @@ namespace Gremlin.Net.Process.Traversal
/// <summary>
/// Spawns a <see cref="GraphTraversal{SType, EType}" /> and adds the hasId step to that traversal.
/// </summary>
- public static GraphTraversal<object, object> HasId(object id, params object[] otherIds)
+ public static GraphTraversal<object, object> HasId(object? id, params object?[] otherIds)
{
return otherIds.Length == 0
? new GraphTraversal<object, object>().HasId(id)
@@ -580,7 +582,7 @@ namespace Gremlin.Net.Process.Traversal
/// <summary>
/// Spawns a <see cref="GraphTraversal{SType, EType}" /> and adds the hasValue step to that traversal.
/// </summary>
- public static GraphTraversal<object, object> HasValue(object value, params object[] values)
+ public static GraphTraversal<object, object> HasValue(object? value, params object?[] values)
{
return values.Length == 0
? new GraphTraversal<object, object>().HasValue(value)
@@ -598,7 +600,7 @@ namespace Gremlin.Net.Process.Traversal
/// <summary>
/// Spawns a <see cref="GraphTraversal{SType, EType}" /> and adds the id step to that traversal.
/// </summary>
- public static GraphTraversal<object, object> Id()
+ public static GraphTraversal<object, object?> Id()
{
return new GraphTraversal<object, object>().Id();
}
@@ -660,7 +662,7 @@ namespace Gremlin.Net.Process.Traversal
/// <summary>
/// Spawns a <see cref="GraphTraversal{SType, EType}" /> and adds the is step to that traversal.
/// </summary>
- public static GraphTraversal<object, object> Is(object value)
+ public static GraphTraversal<object, object> Is(object? value)
{
return new GraphTraversal<object, object>().Is(value);
}
@@ -920,7 +922,8 @@ namespace Gremlin.Net.Process.Traversal
/// <summary>
/// Spawns a <see cref="GraphTraversal{SType, EType}" /> and adds the property step to that traversal.
/// </summary>
- public static GraphTraversal<object, object> Property(Cardinality cardinality, object key, object value, params object[] keyValues)
+ public static GraphTraversal<object, object> Property(Cardinality cardinality, object key, object? value,
+ params object?[] keyValues)
{
return keyValues.Length == 0
? new GraphTraversal<object, object>().Property(cardinality, key, value)
@@ -930,7 +933,7 @@ namespace Gremlin.Net.Process.Traversal
/// <summary>
/// Spawns a <see cref="GraphTraversal{SType, EType}" /> and adds the property step to that traversal.
/// </summary>
- public static GraphTraversal<object, object> Property(object key, object value, params object[] keyValues)
+ public static GraphTraversal<object, object> Property(object key, object? value, params object?[] keyValues)
{
return keyValues.Length == 0
? new GraphTraversal<object, object>().Property(key, value)
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 5c24346..2e8839a 100644
--- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Remote/RemoteStrategyTests.cs
+++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Remote/RemoteStrategyTests.cs
@@ -93,5 +93,7 @@ namespace Gremlin.Net.IntegrationTest.Process.Remote
TraversalStrategies.Add(traversalStrategy);
Bytecode = bytecode;
}
+
+ public override Bytecode Bytecode { get; }
}
}
\ No newline at end of file
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 c1b87a0..e7cfa3d 100644
--- a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/TestTraversal.cs
+++ b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/TestTraversal.cs
@@ -49,5 +49,7 @@ namespace Gremlin.Net.UnitTest.Process.Traversal
{
TraversalStrategies = traversalStrategies;
}
+
+ public override Bytecode Bytecode { get; }
}
}
\ No newline at end of file
diff --git a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/BytecodeGraphSONSerializerTests.cs b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/BytecodeGraphSONSerializerTests.cs
index ad78334..da6a6a7 100644
--- a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/BytecodeGraphSONSerializerTests.cs
+++ b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/BytecodeGraphSONSerializerTests.cs
@@ -163,5 +163,7 @@ namespace Gremlin.Net.UnitTest.Structure.IO.GraphSON
Bytecode = bytecode;
IsAnonymous = true;
}
+
+ public override Bytecode Bytecode { get; }
}
}
\ No newline at end of file