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:48 UTC
[tinkerpop] 02/03: Enable nullable warnings for most types in
Process
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 5aa418cbb9fa8214e1de711c2843b06e930e5712
Author: Florian Hockmann <fh...@florian-hockmann.de>
AuthorDate: Wed Apr 28 15:33:07 2021 +0200
Enable nullable warnings for most types in Process
---
.../Driver/Remote/DriverRemoteConnection.cs | 4 +-
.../Driver/Remote/DriverRemoteTraversal.cs | 3 +
.../Process/Remote/IRemoteConnection.cs | 2 +
.../Gremlin.Net/Process/Remote/RemoteStrategy.cs | 2 +
.../src/Gremlin.Net/Process/Traversal/Barrier.cs | 4 +-
.../src/Gremlin.Net/Process/Traversal/Bindings.cs | 11 ++-
.../src/Gremlin.Net/Process/Traversal/Bytecode.cs | 21 +++--
.../Gremlin.Net/Process/Traversal/Cardinality.cs | 8 +-
.../src/Gremlin.Net/Process/Traversal/Column.cs | 6 +-
.../Process/Traversal/ConnectedComponent.cs | 12 +--
.../Process/Traversal/DefaultTraversal.cs | 56 ++++++++-----
.../src/Gremlin.Net/Process/Traversal/Direction.cs | 8 +-
.../Gremlin.Net/Process/Traversal/EnumWrapper.cs | 9 ++-
.../Process/Traversal/GraphSONVersion.cs | 8 +-
.../Gremlin.Net/Process/Traversal/GryoVersion.cs | 6 +-
.../Gremlin.Net/Process/Traversal/IBiFunction.cs | 2 +
.../Process/Traversal/IBinaryOperator.cs | 2 +
.../Gremlin.Net/Process/Traversal/IComparator.cs | 2 +
.../src/Gremlin.Net/Process/Traversal/IConsumer.cs | 2 +
.../src/Gremlin.Net/Process/Traversal/IFunction.cs | 2 +
.../src/Gremlin.Net/Process/Traversal/IO.cs | 14 ++--
.../Gremlin.Net/Process/Traversal/IPredicate.cs | 2 +
.../src/Gremlin.Net/Process/Traversal/ISupplier.cs | 2 +
.../Gremlin.Net/Process/Traversal/ITraversal.cs | 14 ++--
.../Process/Traversal/ITraversalStrategy.cs | 2 +
.../Process/Traversal/IUnaryOperator.cs | 2 +
.../Gremlin.Net/Process/Traversal/Instruction.cs | 23 +++---
.../src/Gremlin.Net/Process/Traversal/Lambda.cs | 2 +
.../Process/Traversal/NamingConversions.cs | 91 ----------------------
.../src/Gremlin.Net/Process/Traversal/Operator.cs | 24 +++---
.../src/Gremlin.Net/Process/Traversal/Order.cs | 8 +-
.../src/Gremlin.Net/Process/Traversal/PageRank.cs | 12 +--
.../Gremlin.Net/Process/Traversal/PeerPressure.cs | 12 +--
.../src/Gremlin.Net/Process/Traversal/Pick.cs | 6 +-
.../src/Gremlin.Net/Process/Traversal/Pop.cs | 10 ++-
.../src/Gremlin.Net/Process/Traversal/Scope.cs | 6 +-
.../Gremlin.Net/Process/Traversal/ShortestPath.cs | 16 ++--
.../Process/Traversal/StringBasedLambda.cs | 2 +
.../src/Gremlin.Net/Process/Traversal/T.cs | 10 ++-
.../Gremlin.Net/Process/Traversal/WithOptions.cs | 8 +-
gremlin-dotnet/src/Gremlin.Net/Process/Utils.cs | 4 +-
.../Process/Traversal/GraphTraversalTests.cs} | 14 ++--
42 files changed, 213 insertions(+), 241 deletions(-)
diff --git a/gremlin-dotnet/src/Gremlin.Net/Driver/Remote/DriverRemoteConnection.cs b/gremlin-dotnet/src/Gremlin.Net/Driver/Remote/DriverRemoteConnection.cs
index 30ff97b..c433a7f 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Driver/Remote/DriverRemoteConnection.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Driver/Remote/DriverRemoteConnection.cs
@@ -98,7 +98,7 @@ namespace Gremlin.Net.Driver.Remote
s => s.OperatorName == "withStrategies" && s.Arguments[0] is OptionsStrategy);
if (optionsStrategyInst != null)
{
- OptionsStrategy optionsStrategy = optionsStrategyInst.Arguments[0];
+ OptionsStrategy optionsStrategy = optionsStrategyInst.Arguments[0]!;
foreach (var pair in optionsStrategy.Configuration)
{
if (_allowedKeys.Contains(pair.Key))
@@ -107,7 +107,7 @@ namespace Gremlin.Net.Driver.Remote
}
}
}
-
+
return await _client.SubmitAsync<Traverser>(requestMsg.Create()).ConfigureAwait(false);
}
diff --git a/gremlin-dotnet/src/Gremlin.Net/Driver/Remote/DriverRemoteTraversal.cs b/gremlin-dotnet/src/Gremlin.Net/Driver/Remote/DriverRemoteTraversal.cs
index ea375bd..c3954d8 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Driver/Remote/DriverRemoteTraversal.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Driver/Remote/DriverRemoteTraversal.cs
@@ -21,6 +21,7 @@
#endregion
+using System;
using System.Collections.Generic;
using Gremlin.Net.Process.Traversal;
@@ -32,5 +33,7 @@ namespace Gremlin.Net.Driver.Remote
{
Traversers = traversers;
}
+
+ public override Bytecode Bytecode => throw new NotSupportedException("Remote traversals do not have Bytecode");
}
}
\ No newline at end of file
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Remote/IRemoteConnection.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Remote/IRemoteConnection.cs
index 5393bcb..29bbe29 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Remote/IRemoteConnection.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Remote/IRemoteConnection.cs
@@ -21,6 +21,8 @@
#endregion
+#nullable enable warnings
+
using System.Threading.Tasks;
using Gremlin.Net.Process.Traversal;
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Remote/RemoteStrategy.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Remote/RemoteStrategy.cs
index d361ac4..e5efa31 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Remote/RemoteStrategy.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Remote/RemoteStrategy.cs
@@ -21,6 +21,8 @@
#endregion
+#nullable enable warnings
+
using System.Threading.Tasks;
using Gremlin.Net.Process.Traversal;
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Barrier.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Barrier.cs
index c65994b..0aa6e14 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Barrier.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Barrier.cs
@@ -21,6 +21,8 @@
#endregion
+#nullable enable warnings
+
using System;
using System.Collections.Generic;
@@ -35,7 +37,7 @@ namespace Gremlin.Net.Process.Traversal
{
}
- public static Barrier NormSack => new Barrier("normSack");
+ public static Barrier NormSack => new("normSack");
private static readonly IDictionary<string, Barrier> Properties = new Dictionary<string, Barrier>
{
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Bindings.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Bindings.cs
index a6e13b9..b25a7fc 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Bindings.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Bindings.cs
@@ -21,6 +21,8 @@
#endregion
+#nullable enable warnings
+
using System.Collections.Generic;
using System.Threading;
@@ -34,10 +36,9 @@ namespace Gremlin.Net.Process.Traversal
/// <summary>
/// Gets an instance of the <see cref="Bindings" /> class.
/// </summary>
- public static Bindings Instance { get; } = new Bindings();
+ public static Bindings Instance { get; } = new();
- private static readonly ThreadLocal<Dictionary<object, string>> BoundVariableByValue =
- new ThreadLocal<Dictionary<object, string>>();
+ private static readonly ThreadLocal<Dictionary<object, string>> BoundVariableByValue = new();
/// <summary>
/// Binds the variable to the specified value.
@@ -46,6 +47,7 @@ namespace Gremlin.Net.Process.Traversal
/// <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)
@@ -57,7 +59,8 @@ namespace Gremlin.Net.Process.Traversal
return value;
}
- internal static string GetBoundVariable<TV>(TV value)
+ internal static string? GetBoundVariable<TV>(TV value)
+ where TV : notnull
{
var dict = BoundVariableByValue.Value;
if (dict == null)
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Bytecode.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Bytecode.cs
index f4e44f4..f0035fd 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Bytecode.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Bytecode.cs
@@ -21,9 +21,12 @@
#endregion
+#nullable enable warnings
+
using System;
using System.Collections;
using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
using System.Linq;
namespace Gremlin.Net.Process.Traversal
@@ -89,14 +92,14 @@ namespace Gremlin.Net.Process.Traversal
Bindings.Clear();
}
- private object[] FlattenArguments(object[] arguments)
+ private object?[] FlattenArguments(object?[] arguments)
{
if (arguments.Length == 0)
return EmptyArray;
- var flatArguments = new List<object>();
+ var flatArguments = new List<object?>();
foreach (var arg in arguments)
{
- if (arg is object[] objects)
+ if (arg is object?[] objects)
{
flatArguments.AddRange(objects.Select(nestObject => ConvertArgument(nestObject, true)));
}
@@ -108,6 +111,7 @@ namespace Gremlin.Net.Process.Traversal
return flatArguments.ToArray();
}
+ [return: NotNullIfNotNull("argument")]
private object? ConvertArgument(object? argument, bool searchBindings)
{
if (null == argument)
@@ -122,29 +126,30 @@ namespace Gremlin.Net.Process.Traversal
return new Binding(variable, ConvertArgument(argument, false));
}
- if (argument is ITraversal traversal && !traversal.IsAnonymous)
+ if (argument is ITraversal {IsAnonymous: false} traversal)
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>();
+ var dict = new Dictionary<object, object?>();
foreach (DictionaryEntry item in (IDictionary)argument)
{
- dict[ConvertArgument(item.Key, true)] = ConvertArgument(item.Value, true);
+ var key = ConvertArgument(item.Key, true);
+ dict[key] = ConvertArgument(item.Value, true);
}
return dict;
}
if (IsListType(argument.GetType()))
{
- var list = new List<object>(((IList) argument).Count);
+ 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>();
+ var set = new HashSet<object?>();
foreach (var item in (IEnumerable)argument)
{
set.Add(ConvertArgument(item, true));
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Cardinality.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Cardinality.cs
index 65663d6..a7eda50 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Cardinality.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Cardinality.cs
@@ -21,6 +21,8 @@
#endregion
+#nullable enable warnings
+
using System;
using System.Collections.Generic;
@@ -35,11 +37,11 @@ namespace Gremlin.Net.Process.Traversal
{
}
- public static Cardinality List => new Cardinality("list");
+ public static Cardinality List => new("list");
- public static Cardinality Set => new Cardinality("set");
+ public static Cardinality Set => new("set");
- public static Cardinality Single => new Cardinality("single");
+ public static Cardinality Single => new("single");
private static readonly IDictionary<string, Cardinality> Properties = new Dictionary<string, Cardinality>
{
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Column.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Column.cs
index 66a6edd..cfe42df 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Column.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Column.cs
@@ -21,6 +21,8 @@
#endregion
+#nullable enable warnings
+
using System;
using System.Collections.Generic;
@@ -35,9 +37,9 @@ namespace Gremlin.Net.Process.Traversal
{
}
- public static Column Keys => new Column("keys");
+ public static Column Keys => new("keys");
- public static Column Values => new Column("values");
+ public static Column Values => new("values");
private static readonly IDictionary<string, Column> Properties = new Dictionary<string, Column>
{
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/ConnectedComponent.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/ConnectedComponent.cs
index 860e87a..c8d010f 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/ConnectedComponent.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/ConnectedComponent.cs
@@ -21,11 +21,7 @@
#endregion
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Linq;
-using System.Reflection;
+#nullable enable warnings
namespace Gremlin.Net.Process.Traversal
{
@@ -34,11 +30,11 @@ namespace Gremlin.Net.Process.Traversal
public class ConnectedComponent
{
- public const String component = "gremlin.connectedComponentVertexProgram.component";
+ public const string component = "gremlin.connectedComponentVertexProgram.component";
- public const String edges = "~tinkerpop.connectedComponent.edges";
+ public const string edges = "~tinkerpop.connectedComponent.edges";
- public const String propertyName = "~tinkerpop.connectedComponent.propertyName";
+ public const string propertyName = "~tinkerpop.connectedComponent.propertyName";
}
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/DefaultTraversal.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/DefaultTraversal.cs
index 38e031c..8348035 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/DefaultTraversal.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/DefaultTraversal.cs
@@ -21,9 +21,12 @@
#endregion
+#nullable enable warnings
+
using System;
using System.Collections;
using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
using System.Reflection;
using System.Threading.Tasks;
@@ -34,12 +37,12 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public abstract class DefaultTraversal<S, E> : ITraversal<S, E>
{
- private IEnumerator<Traverser> _traverserEnumerator;
+ private IEnumerator<Traverser>? _traverserEnumerator;
/// <summary>
/// Gets the <see cref="Traversal.Bytecode" /> representation of this traversal.
/// </summary>
- public Bytecode Bytecode { get; protected set; }
+ public virtual Bytecode Bytecode { get; protected set; } = null!;
/// <summary>
/// Determines if this traversal was spawned anonymously or not.
@@ -49,7 +52,7 @@ namespace Gremlin.Net.Process.Traversal
/// <summary>
/// Gets or sets the <see cref="Traverser" />'s of this traversal that hold the results of the traversal.
/// </summary>
- public IEnumerable<Traverser> Traversers { get; set; }
+ public IEnumerable<Traverser>? Traversers { get; set; }
ITraversal ITraversal.Iterate()
{
@@ -61,8 +64,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
protected ICollection<ITraversalStrategy> TraversalStrategies { get; set; } = new List<ITraversalStrategy>();
- private IEnumerator<Traverser> TraverserEnumerator
- => _traverserEnumerator ?? (_traverserEnumerator = GetTraverserEnumerator());
+ private IEnumerator<Traverser> TraverserEnumerator => _traverserEnumerator ??= GetTraverserEnumerator();
private bool _nextAvailable;
private bool _fetchedNext;
@@ -108,23 +110,23 @@ namespace Gremlin.Net.Process.Traversal
}
/// <inheritdoc />
- public E Current => GetCurrent<E>();
+ public E? Current => GetCurrent<E>();
- object IEnumerator.Current => GetCurrent();
+ object? IEnumerator.Current => GetCurrent();
- private TReturn GetCurrent<TReturn>()
+ private TReturn? GetCurrent<TReturn>()
{
var value = GetCurrent();
var returnType = typeof(TReturn);
if (value == null || value.GetType() == returnType)
{
// Avoid evaluating type comparisons
- return (TReturn) value;
+ return (TReturn?) value;
}
- return (TReturn) GetValue(returnType, value);
+ return (TReturn?) GetValue(returnType, value);
}
- private object GetCurrent()
+ private object? GetCurrent()
{
// Use dynamic to object to prevent runtime dynamic conversion evaluation
return TraverserEnumerator.Current?.Object;
@@ -133,7 +135,8 @@ namespace Gremlin.Net.Process.Traversal
/// <summary>
/// Gets the value, converting to the expected type when necessary and supported.
/// </summary>
- private static object GetValue(Type type, object value)
+ [return: NotNullIfNotNull("value")]
+ private static object? GetValue(Type type, object? value)
{
var genericType = type.GetTypeInfo().IsGenericType
? type.GetTypeInfo().GetGenericTypeDefinition()
@@ -143,7 +146,11 @@ namespace Gremlin.Net.Process.Traversal
var keyType = type.GenericTypeArguments[0];
var valueType = type.GenericTypeArguments[1];
var mapType = typeof(Dictionary<,>).MakeGenericType(keyType, valueType);
- var result = (IDictionary) Activator.CreateInstance(mapType);
+ var result = (IDictionary?) Activator.CreateInstance(mapType);
+ if (result == null)
+ {
+ throw new InvalidOperationException($"Cannot convert value {value} to a Dictionary.");
+ }
foreach (DictionaryEntry kv in dictValue)
{
result.Add(GetValue(keyType, kv.Key), GetValue(valueType, kv.Value));
@@ -154,7 +161,11 @@ namespace Gremlin.Net.Process.Traversal
{
var childType = type.GenericTypeArguments[0];
var listType = typeof(List<>).MakeGenericType(childType);
- var result = (IList) Activator.CreateInstance(listType);
+ var result = (IList?) Activator.CreateInstance(listType);
+ if (result == null)
+ {
+ throw new InvalidOperationException($"Cannot convert value {value} to a list.");
+ }
foreach (var itemValue in enumerableValue)
{
result.Add(itemValue);
@@ -168,6 +179,11 @@ namespace Gremlin.Net.Process.Traversal
{
if (Traversers == null)
ApplyStrategies();
+ if (Traversers == null)
+ {
+ throw new InvalidOperationException(
+ $"Cannot enumerate the traversal as there are no {nameof(Traversers)}. Maybe a strategy needs to be added.");
+ }
return Traversers.GetEnumerator();
}
@@ -195,7 +211,7 @@ namespace Gremlin.Net.Process.Traversal
/// Gets the next result from the traversal.
/// </summary>
/// <returns>The result.</returns>
- public E Next()
+ public E? Next()
{
MoveNext();
return Current;
@@ -206,7 +222,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
/// <param name="amount">The number of results to get.</param>
/// <returns>The n-results.</returns>
- public IEnumerable<E> Next(int amount)
+ public IEnumerable<E?> Next(int amount)
{
for (var i = 0; i < amount; i++)
yield return Next();
@@ -239,9 +255,9 @@ namespace Gremlin.Net.Process.Traversal
/// Puts all the results into a <see cref="List{T}" />.
/// </summary>
/// <returns>The results in a list.</returns>
- public IList<E> ToList()
+ public IList<E?> ToList()
{
- var objs = new List<E>();
+ var objs = new List<E?>();
while (MoveNext())
objs.Add(Current);
return objs;
@@ -251,9 +267,9 @@ namespace Gremlin.Net.Process.Traversal
/// Puts all the results into a <see cref="HashSet{T}" />.
/// </summary>
/// <returns>The results in a set.</returns>
- public ISet<E> ToSet()
+ public ISet<E?> ToSet()
{
- var objs = new HashSet<E>();
+ var objs = new HashSet<E?>();
while (MoveNext())
objs.Add(Current);
return objs;
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Direction.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Direction.cs
index 8c3ed4a..10cbb20 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Direction.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Direction.cs
@@ -21,6 +21,8 @@
#endregion
+#nullable enable warnings
+
using System;
using System.Collections.Generic;
@@ -35,11 +37,11 @@ namespace Gremlin.Net.Process.Traversal
{
}
- public static Direction Both => new Direction("BOTH");
+ public static Direction Both => new("BOTH");
- public static Direction In => new Direction("IN");
+ public static Direction In => new("IN");
- public static Direction Out => new Direction("OUT");
+ public static Direction Out => new("OUT");
private static readonly IDictionary<string, Direction> Properties = new Dictionary<string, Direction>
{
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/EnumWrapper.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/EnumWrapper.cs
index 20a0348..e783e7e 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/EnumWrapper.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/EnumWrapper.cs
@@ -21,6 +21,8 @@
#endregion
+#nullable enable warnings
+
using System;
namespace Gremlin.Net.Process.Traversal
@@ -52,7 +54,7 @@ namespace Gremlin.Net.Process.Traversal
}
/// <inheritdoc />
- public bool Equals(EnumWrapper other)
+ public bool Equals(EnumWrapper? other)
{
if (ReferenceEquals(null, other)) return false;
if (ReferenceEquals(this, other)) return true;
@@ -60,7 +62,7 @@ namespace Gremlin.Net.Process.Traversal
}
/// <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;
@@ -73,8 +75,7 @@ namespace Gremlin.Net.Process.Traversal
{
unchecked
{
- return ((EnumName != null ? EnumName.GetHashCode() : 0) * 397) ^
- (EnumValue != null ? EnumValue.GetHashCode() : 0);
+ return (EnumName.GetHashCode() * 397) ^ EnumValue.GetHashCode();
}
}
}
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphSONVersion.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphSONVersion.cs
index e79c86e..1563a34 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphSONVersion.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphSONVersion.cs
@@ -21,6 +21,8 @@
#endregion
+#nullable enable warnings
+
using System;
using System.Collections.Generic;
@@ -35,11 +37,11 @@ namespace Gremlin.Net.Process.Traversal
{
}
- public static GraphSONVersion V1_0 => new GraphSONVersion("V1_0");
+ public static GraphSONVersion V1_0 => new("V1_0");
- public static GraphSONVersion V2_0 => new GraphSONVersion("V2_0");
+ public static GraphSONVersion V2_0 => new("V2_0");
- public static GraphSONVersion V3_0 => new GraphSONVersion("V3_0");
+ public static GraphSONVersion V3_0 => new("V3_0");
private static readonly IDictionary<string, GraphSONVersion> Properties = new Dictionary<string, GraphSONVersion>
{
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GryoVersion.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GryoVersion.cs
index e34c7b3..c1405c7 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GryoVersion.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GryoVersion.cs
@@ -21,6 +21,8 @@
#endregion
+#nullable enable warnings
+
using System;
using System.Collections.Generic;
@@ -35,9 +37,9 @@ namespace Gremlin.Net.Process.Traversal
{
}
- public static GryoVersion V1_0 => new GryoVersion("V1_0");
+ public static GryoVersion V1_0 => new("V1_0");
- public static GryoVersion V3_0 => new GryoVersion("V3_0");
+ public static GryoVersion V3_0 => new("V3_0");
private static readonly IDictionary<string, GryoVersion> Properties = new Dictionary<string, GryoVersion>
{
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/IBiFunction.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/IBiFunction.cs
index 15c9f91..babb85e 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/IBiFunction.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/IBiFunction.cs
@@ -21,6 +21,8 @@
#endregion
+#nullable enable warnings
+
namespace Gremlin.Net.Process.Traversal
{
/// <summary>
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/IBinaryOperator.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/IBinaryOperator.cs
index dcd7aed..92c2b97 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/IBinaryOperator.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/IBinaryOperator.cs
@@ -21,6 +21,8 @@
#endregion
+#nullable enable warnings
+
namespace Gremlin.Net.Process.Traversal
{
/// <summary>
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/IComparator.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/IComparator.cs
index b7a48e0..65e8d90 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/IComparator.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/IComparator.cs
@@ -21,6 +21,8 @@
#endregion
+#nullable enable warnings
+
namespace Gremlin.Net.Process.Traversal
{
/// <summary>
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/IConsumer.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/IConsumer.cs
index 7eed5e2..4eb40c8 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/IConsumer.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/IConsumer.cs
@@ -21,6 +21,8 @@
#endregion
+#nullable enable warnings
+
namespace Gremlin.Net.Process.Traversal
{
/// <summary>
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/IFunction.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/IFunction.cs
index 075154a..9e38377 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/IFunction.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/IFunction.cs
@@ -21,6 +21,8 @@
#endregion
+#nullable enable warnings
+
namespace Gremlin.Net.Process.Traversal
{
/// <summary>
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/IO.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/IO.cs
index b9e0fdd..0fe1f2c 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/IO.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/IO.cs
@@ -21,6 +21,8 @@
#endregion
+#nullable enable warnings
+
using System;
using System.Collections;
using System.Collections.Generic;
@@ -34,17 +36,17 @@ namespace Gremlin.Net.Process.Traversal
public class IO
{
- public const String graphml = "graphml";
+ public const string graphml = "graphml";
- public const String graphson = "graphson";
+ public const string graphson = "graphson";
- public const String gryo = "gryo";
+ public const string gryo = "gryo";
- public const String reader = "~tinkerpop.io.reader";
+ public const string reader = "~tinkerpop.io.reader";
- public const String registry = "~tinkerpop.io.registry";
+ public const string registry = "~tinkerpop.io.registry";
- public const String writer = "~tinkerpop.io.writer";
+ public const string writer = "~tinkerpop.io.writer";
}
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/IPredicate.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/IPredicate.cs
index a7e5e3d..1d5932c 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/IPredicate.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/IPredicate.cs
@@ -21,6 +21,8 @@
#endregion
+#nullable enable warnings
+
namespace Gremlin.Net.Process.Traversal
{
/// <summary>
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/ISupplier.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/ISupplier.cs
index b1dda13..61b4b7e 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/ISupplier.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/ISupplier.cs
@@ -21,6 +21,8 @@
#endregion
+#nullable enable warnings
+
namespace Gremlin.Net.Process.Traversal
{
/// <summary>
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/ITraversal.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/ITraversal.cs
index 95cbb74..e2b2884 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/ITraversal.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/ITraversal.cs
@@ -21,6 +21,8 @@
#endregion
+#nullable enable warnings
+
using System;
using System.Collections;
using System.Collections.Generic;
@@ -47,7 +49,7 @@ namespace Gremlin.Net.Process.Traversal
/// <summary>
/// Gets or sets the <see cref="Traverser" />'s of this traversal that hold the results of the traversal.
/// </summary>
- IEnumerable<Traverser> Traversers { get; set; }
+ IEnumerable<Traverser>? Traversers { get; set; }
/// <summary>
/// Iterates all <see cref="Traverser" /> instances in the traversal.
@@ -59,13 +61,13 @@ namespace Gremlin.Net.Process.Traversal
/// <summary>
/// A traversal represents a directed walk over a graph.
/// </summary>
- public interface ITraversal<S, E> : ITraversal, IEnumerator<E>
+ public interface ITraversal<S, E> : ITraversal, IEnumerator<E?>
{
/// <summary>
/// Gets the next result from the traversal.
/// </summary>
/// <returns>The result.</returns>
- E Next();
+ E? Next();
/// <summary>
/// Determines if the traversal contains any additional results for iteration.
@@ -78,7 +80,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
/// <param name="amount">The number of results to get.</param>
/// <returns>The n-results.</returns>
- IEnumerable<E> Next(int amount);
+ IEnumerable<E?> Next(int amount);
/// <summary>
/// Iterates all <see cref="Traverser" /> instances in the traversal.
@@ -96,13 +98,13 @@ namespace Gremlin.Net.Process.Traversal
/// Puts all the results into a <see cref="IList{T}" />.
/// </summary>
/// <returns>The results in a list.</returns>
- IList<E> ToList();
+ IList<E?> ToList();
/// <summary>
/// Puts all the results into a <see cref="ISet{T}" />.
/// </summary>
/// <returns>The results in a set.</returns>
- ISet<E> ToSet();
+ ISet<E?> ToSet();
/// <summary>
/// Starts a promise to execute a function on the current traversal that will be completed in the future.
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/ITraversalStrategy.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/ITraversalStrategy.cs
index 013d62a..d246287 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/ITraversalStrategy.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/ITraversalStrategy.cs
@@ -23,6 +23,8 @@
using System.Threading.Tasks;
+#nullable enable warnings
+
namespace Gremlin.Net.Process.Traversal
{
/// <summary>
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/IUnaryOperator.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/IUnaryOperator.cs
index b57be02..eaee14f 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/IUnaryOperator.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/IUnaryOperator.cs
@@ -21,6 +21,8 @@
#endregion
+#nullable enable warnings
+
namespace Gremlin.Net.Process.Traversal
{
/// <summary>
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Instruction.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Instruction.cs
index 1063b33..0b44a12 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Instruction.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Instruction.cs
@@ -21,6 +21,8 @@
#endregion
+#nullable enable warnings
+
using System;
using System.Linq;
@@ -36,7 +38,7 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
/// <param name="operatorName">The name of the operator.</param>
/// <param name="arguments">The arguments.</param>
- public Instruction(string operatorName, params dynamic[] arguments)
+ public Instruction(string operatorName, params dynamic?[] arguments)
{
OperatorName = operatorName;
Arguments = arguments;
@@ -50,18 +52,18 @@ namespace Gremlin.Net.Process.Traversal
/// <summary>
/// Gets the arguments.
/// </summary>
- public dynamic[] Arguments { get; }
+ public dynamic?[] Arguments { get; }
/// <summary>
/// String representation of the <see cref="Instruction"/>.
/// </summary>
public override string ToString()
{
- return OperatorName + " [" + String.Join(",", Arguments) + "]";
+ return OperatorName + " [" + string.Join(",", Arguments) + "]";
}
/// <inheritdoc />
- public bool Equals(Instruction other)
+ public bool Equals(Instruction? other)
{
if (ReferenceEquals(null, other)) return false;
if (ReferenceEquals(this, other)) return true;
@@ -69,7 +71,7 @@ namespace Gremlin.Net.Process.Traversal
}
/// <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;
@@ -83,15 +85,10 @@ namespace Gremlin.Net.Process.Traversal
unchecked
{
var hash = 19;
- if (OperatorName != null)
- {
- hash = hash * 397 + OperatorName.GetHashCode();
- }
+ hash = hash * 397 + OperatorName.GetHashCode();
- if (Arguments != null)
- {
- hash = Arguments.Aggregate(hash, (current, value) => current * 31 + value.GetHashCode());
- }
+ hash = Arguments.Aggregate(hash,
+ (current, value) => current * 31 + (value == null ? 0 : value.GetHashCode()));
return hash;
}
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Lambda.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Lambda.cs
index 01bdbc6..99a4248 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Lambda.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Lambda.cs
@@ -21,6 +21,8 @@
#endregion
+#nullable enable warnings
+
namespace Gremlin.Net.Process.Traversal
{
/// <summary>
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/NamingConversions.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/NamingConversions.cs
deleted file mode 100644
index a650dc5..0000000
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/NamingConversions.cs
+++ /dev/null
@@ -1,91 +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;
-
-namespace Gremlin.Net.Process.Traversal
-{
- internal static class NamingConversions
- {
- /// <summary>
- /// Gets the Java name equivalent for a given enum value
- /// </summary>
- internal static string GetEnumJavaName(string typeName, string value)
- {
- var key = $"{typeName}.{value}";
- string javaName;
- if (!CSharpToJavaEnums.TryGetValue(key, out javaName))
- {
- throw new KeyNotFoundException($"Java name for {key} not found");
- }
- return javaName;
- }
-
- internal static readonly IDictionary<string, string> CSharpToJavaEnums = new Dictionary<string, string>
- {
- {"Barrier.NormSack", "normSack"},
- {"Cardinality.List", "list"},
- {"Cardinality.Set", "set"},
- {"Cardinality.Single", "single"},
- {"Column.Keys", "keys"},
- {"Column.Values", "values"},
- {"Direction.Both", "BOTH"},
- {"Direction.In", "IN"},
- {"Direction.Out", "OUT"},
- {"GraphSONVersion.V1_0", "V1_0"},
- {"GraphSONVersion.V2_0", "V2_0"},
- {"GraphSONVersion.V3_0", "V3_0"},
- {"GryoVersion.V1_0", "V1_0"},
- {"GryoVersion.V3_0", "V3_0"},
- {"Operator.AddAll", "addAll"},
- {"Operator.And", "and"},
- {"Operator.Assign", "assign"},
- {"Operator.Div", "div"},
- {"Operator.Max", "max"},
- {"Operator.Min", "min"},
- {"Operator.Minus", "minus"},
- {"Operator.Mult", "mult"},
- {"Operator.Or", "or"},
- {"Operator.Sum", "sum"},
- {"Operator.SumLong", "sumLong"},
- {"Order.Decr", "decr"},
- {"Order.Incr", "incr"},
- {"Order.Shuffle", "shuffle"},
- {"Order.Asc", "asc"},
- {"Order.Desc", "desc"},
- {"Pick.Any", "any"},
- {"Pick.None", "none"},
- {"Pop.All", "all"},
- {"Pop.First", "first"},
- {"Pop.Last", "last"},
- {"Pop.Mixed", "mixed"},
- {"Scope.Global", "global"},
- {"Scope.Local", "local"},
- {"T.Id", "id"},
- {"T.Key", "key"},
- {"T.Label", "label"},
- {"T.Value", "value"}
-
- };
- }
-}
\ No newline at end of file
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Operator.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Operator.cs
index ce33569..38703df 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Operator.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Operator.cs
@@ -21,6 +21,8 @@
#endregion
+#nullable enable warnings
+
using System;
using System.Collections.Generic;
@@ -35,27 +37,27 @@ namespace Gremlin.Net.Process.Traversal
{
}
- public static Operator AddAll => new Operator("addAll");
+ public static Operator AddAll => new("addAll");
- public static Operator And => new Operator("and");
+ public static Operator And => new("and");
- public static Operator Assign => new Operator("assign");
+ public static Operator Assign => new("assign");
- public static Operator Div => new Operator("div");
+ public static Operator Div => new("div");
- public static Operator Max => new Operator("max");
+ public static Operator Max => new("max");
- public static Operator Min => new Operator("min");
+ public static Operator Min => new("min");
- public static Operator Minus => new Operator("minus");
+ public static Operator Minus => new("minus");
- public static Operator Mult => new Operator("mult");
+ public static Operator Mult => new("mult");
- public static Operator Or => new Operator("or");
+ public static Operator Or => new("or");
- public static Operator Sum => new Operator("sum");
+ public static Operator Sum => new("sum");
- public static Operator SumLong => new Operator("sumLong");
+ public static Operator SumLong => new("sumLong");
private static readonly IDictionary<string, Operator> Properties = new Dictionary<string, Operator>
{
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Order.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Order.cs
index fca67ab..eb65b43 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Order.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Order.cs
@@ -21,6 +21,8 @@
#endregion
+#nullable enable warnings
+
using System;
using System.Collections.Generic;
@@ -35,11 +37,11 @@ namespace Gremlin.Net.Process.Traversal
{
}
- public static Order Asc => new Order("asc");
+ public static Order Asc => new("asc");
- public static Order Desc => new Order("desc");
+ public static Order Desc => new("desc");
- public static Order Shuffle => new Order("shuffle");
+ public static Order Shuffle => new("shuffle");
private static readonly IDictionary<string, Order> Properties = new Dictionary<string, Order>
{
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/PageRank.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/PageRank.cs
index 5c2ade9..c674149 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/PageRank.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/PageRank.cs
@@ -21,11 +21,7 @@
#endregion
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Linq;
-using System.Reflection;
+#nullable enable warnings
namespace Gremlin.Net.Process.Traversal
{
@@ -34,11 +30,11 @@ namespace Gremlin.Net.Process.Traversal
public class PageRank
{
- public const String edges = "~tinkerpop.pageRank.edges";
+ public const string edges = "~tinkerpop.pageRank.edges";
- public const String propertyName = "~tinkerpop.pageRank.propertyName";
+ public const string propertyName = "~tinkerpop.pageRank.propertyName";
- public const String times = "~tinkerpop.pageRank.times";
+ public const string times = "~tinkerpop.pageRank.times";
}
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/PeerPressure.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/PeerPressure.cs
index fde3b41..4e02427 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/PeerPressure.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/PeerPressure.cs
@@ -21,11 +21,7 @@
#endregion
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Linq;
-using System.Reflection;
+#nullable enable warnings
namespace Gremlin.Net.Process.Traversal
{
@@ -34,11 +30,11 @@ namespace Gremlin.Net.Process.Traversal
public class PeerPressure
{
- public const String edges = "~tinkerpop.peerPressure.edges";
+ public const string edges = "~tinkerpop.peerPressure.edges";
- public const String propertyName = "~tinkerpop.peerPressure.propertyName";
+ public const string propertyName = "~tinkerpop.peerPressure.propertyName";
- public const String times = "~tinkerpop.peerPressure.times";
+ public const string times = "~tinkerpop.peerPressure.times";
}
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Pick.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Pick.cs
index f0312a3..6cc4a17 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Pick.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Pick.cs
@@ -21,6 +21,8 @@
#endregion
+#nullable enable warnings
+
using System;
using System.Collections.Generic;
@@ -35,9 +37,9 @@ namespace Gremlin.Net.Process.Traversal
{
}
- public static Pick Any => new Pick("any");
+ public static Pick Any => new("any");
- public static Pick None => new Pick("none");
+ public static Pick None => new("none");
private static readonly IDictionary<string, Pick> Properties = new Dictionary<string, Pick>
{
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Pop.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Pop.cs
index 196ce01..1ff98d0 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Pop.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Pop.cs
@@ -21,6 +21,8 @@
#endregion
+#nullable enable warnings
+
using System;
using System.Collections.Generic;
@@ -35,13 +37,13 @@ namespace Gremlin.Net.Process.Traversal
{
}
- public static Pop All => new Pop("all");
+ public static Pop All => new("all");
- public static Pop First => new Pop("first");
+ public static Pop First => new("first");
- public static Pop Last => new Pop("last");
+ public static Pop Last => new("last");
- public static Pop Mixed => new Pop("mixed");
+ public static Pop Mixed => new("mixed");
private static readonly IDictionary<string, Pop> Properties = new Dictionary<string, Pop>
{
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Scope.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Scope.cs
index ff70069..43a3f5c 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Scope.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Scope.cs
@@ -21,6 +21,8 @@
#endregion
+#nullable enable warnings
+
using System;
using System.Collections.Generic;
@@ -35,9 +37,9 @@ namespace Gremlin.Net.Process.Traversal
{
}
- public static Scope Global => new Scope("global");
+ public static Scope Global => new("global");
- public static Scope Local => new Scope("local");
+ public static Scope Local => new("local");
private static readonly IDictionary<string, Scope> Properties = new Dictionary<string, Scope>
{
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/ShortestPath.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/ShortestPath.cs
index 238a5e7..bd26a84 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/ShortestPath.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/ShortestPath.cs
@@ -21,11 +21,7 @@
#endregion
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Linq;
-using System.Reflection;
+#nullable enable warnings
namespace Gremlin.Net.Process.Traversal
{
@@ -34,15 +30,15 @@ namespace Gremlin.Net.Process.Traversal
public class ShortestPath
{
- public const String distance = "~tinkerpop.shortestPath.distance";
+ public const string distance = "~tinkerpop.shortestPath.distance";
- public const String edges = "~tinkerpop.shortestPath.edges";
+ public const string edges = "~tinkerpop.shortestPath.edges";
- public const String includeEdges = "~tinkerpop.shortestPath.includeEdges";
+ public const string includeEdges = "~tinkerpop.shortestPath.includeEdges";
- public const String maxDistance = "~tinkerpop.shortestPath.maxDistance";
+ public const string maxDistance = "~tinkerpop.shortestPath.maxDistance";
- public const String target = "~tinkerpop.shortestPath.target";
+ public const string target = "~tinkerpop.shortestPath.target";
}
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/StringBasedLambda.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/StringBasedLambda.cs
index 69f8030..1299df5 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/StringBasedLambda.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/StringBasedLambda.cs
@@ -21,6 +21,8 @@
#endregion
+#nullable enable warnings
+
using System;
namespace Gremlin.Net.Process.Traversal
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/T.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/T.cs
index e688e8d..1411983 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/T.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/T.cs
@@ -21,6 +21,8 @@
#endregion
+#nullable enable warnings
+
using System;
using System.Collections.Generic;
@@ -35,13 +37,13 @@ namespace Gremlin.Net.Process.Traversal
{
}
- public static T Id => new T("id");
+ public static T Id => new("id");
- public static T Key => new T("key");
+ public static T Key => new("key");
- public static T Label => new T("label");
+ public static T Label => new("label");
- public static T Value => new T("value");
+ public static T Value => new("value");
private static readonly IDictionary<string, T> Properties = new Dictionary<string, T>
{
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/WithOptions.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/WithOptions.cs
index 0229d4c..1d0d132 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/WithOptions.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/WithOptions.cs
@@ -21,11 +21,7 @@
#endregion
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Linq;
-using System.Reflection;
+#nullable enable warnings
namespace Gremlin.Net.Process.Traversal.Step.Util
{
@@ -36,8 +32,6 @@ namespace Gremlin.Net.Process.Traversal.Step.Util
/// </summary>
public class WithOptions
{
-
-
public static readonly string Tokens = "~tinkerpop.valueMap.tokens";
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Utils.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Utils.cs
index 27d5de1..78e741e 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Utils.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Utils.cs
@@ -21,6 +21,8 @@
#endregion
+#nullable enable warnings
+
using System;
using System.Runtime.ExceptionServices;
using System.Threading.Tasks;
@@ -44,7 +46,7 @@ namespace Gremlin.Net.Process
}
catch (AggregateException ex)
{
- if (ex.InnerExceptions.Count == 1)
+ if (ex.InnerException != null)
{
ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
}
diff --git a/gremlin-dotnet/src/Gremlin.Net/Driver/Remote/DriverRemoteTraversal.cs b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/GraphTraversalTests.cs
similarity index 73%
copy from gremlin-dotnet/src/Gremlin.Net/Driver/Remote/DriverRemoteTraversal.cs
copy to gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/GraphTraversalTests.cs
index ea375bd..52df33c 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Driver/Remote/DriverRemoteTraversal.cs
+++ b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/GraphTraversalTests.cs
@@ -21,16 +21,20 @@
#endregion
-using System.Collections.Generic;
+using System;
using Gremlin.Net.Process.Traversal;
+using Xunit;
-namespace Gremlin.Net.Driver.Remote
+namespace Gremlin.Net.UnitTest.Process.Traversal
{
- internal class DriverRemoteTraversal<S, E> : DefaultTraversal<S, E>
+ public class GraphTraversalTests
{
- public DriverRemoteTraversal(IEnumerable<Traverser> traversers)
+ [Fact]
+ public void ShouldThrowOnIterationIfNoStrategiesConfigured()
{
- Traversers = traversers;
+ var g = AnonymousTraversalSource.Traversal();
+
+ Assert.Throws<InvalidOperationException>(() => g.V().Next());
}
}
}
\ No newline at end of file