This is an automated email from the ASF dual-hosted git repository. florianhockmann pushed a commit to branch TINKERPOP-2348-nullable-in-tests in repository https://gitbox.apache.org/repos/asf/tinkerpop.git
commit d921c050613e6131057f6aa9ebba3e0a02e05e24 Author: Florian Hockmann <[email protected]> AuthorDate: Wed Nov 23 15:56:51 2022 +0100 TINKERPOP-2348 Add nullable annotations also to tests Only the generated Gherkin test traversals are missing as we would have to let the Java `DotNetTranslator` produce C# code with nullable annotations. I think we should do that at some point in the future as nullable annotations are only enabled since .NET 6 by default and only for new projects. So, many users are probably still not using them. Adding the annotations also in tests revealed two (well actually three) more places where `null` should be allowed in Gremlin.Net itself: In `Traversal.Equals()` and in the `From()`/`To()` steps if the argument is a `Vertex`. While `null` is still not really allowed there, Gremlin throws a more meaningful exception message if it gets `null` and we might change that in the future to somehow allow `null` maybe. --- gremlin-dotnet/build/generate.groovy | 4 +- .../Process/Traversal/GraphTraversal.cs | 4 +- .../src/Gremlin.Net/Process/Traversal/Traverser.cs | 2 +- .../Gremlin.Net.Benchmarks.csproj | 1 + .../MessageSerializerBenchmarks.cs | 8 +- .../Docs/Reference/IntroTests.cs | 2 +- .../Driver/ConnectionPoolTests.cs | 2 +- .../Driver/DriverRemoteConnectionTests.cs | 2 +- .../Driver/GremlinClientAuthenticationTests.cs | 12 +-- .../Driver/GremlinClientTests.cs | 8 +- .../Driver/MessagesTests.cs | 4 +- .../Driver/MockedLoggerExtensions.cs | 6 +- .../Gherkin/CommonSteps.cs | 87 +++++++++++----------- .../Gherkin/GherkinTestRunner.cs | 16 ++-- .../Gremlin.Net.IntegrationTest/Gherkin/Gremlin.cs | 3 + .../Gherkin/IgnoreException.cs | 2 +- .../Gherkin/ScenarioData.cs | 10 +-- .../Gremlin.Net.IntegrationTest.csproj | 1 + .../Process/Remote/RemoteStrategyTests.cs | 2 +- .../BytecodeGeneration/BytecodeGenerationTests.cs | 2 +- .../BytecodeGeneration/StrategiesTests.cs | 13 ++-- .../DriverRemoteConnection/GraphTraversalTests.cs | 4 +- .../RemoteConnectionFactory.cs | 4 +- .../Gremlin.Net.Template.IntegrationTest.csproj | 1 + .../ServiceTests.cs | 4 +- .../Driver/ConnectionPoolTests.cs | 4 +- .../Gremlin.Net.UnitTest/Driver/ConnectionTests.cs | 9 ++- .../Driver/DriverRemoteConnectionTests.cs | 2 +- .../Driver/GraphSONMessageSerializerTests.cs | 2 +- .../Gremlin.Net.UnitTest.csproj | 1 + .../Process/Traversal/BytecodeTests.cs | 16 ++-- .../Process/Traversal/GraphTraversalSourceTests.cs | 5 +- .../Process/Traversal/TestTraversal.cs | 6 +- .../Traversal/Translator/GroovyTranslatorTests.cs | 2 +- .../Process/Traversal/TraversalTests.cs | 28 +++---- .../GraphBinaryMessageSerializerTests.cs | 2 +- .../Structure/IO/GraphBinary/GraphBinaryTests.cs | 32 ++++---- .../IO/GraphBinary/Types/Sample/SamplePerson.cs | 4 +- .../Types/Sample/SamplePersonSerializer.cs | 4 +- .../Types/Sample/SamplePersonSerializerTests.cs | 4 +- .../IO/GraphSON/GraphSON3MessageSerializerTests.cs | 2 +- .../Structure/IO/GraphSON/GraphSONReaderTests.cs | 32 ++++---- .../Structure/IO/GraphSON/GraphSONWriterTests.cs | 4 +- .../Structure/IO/GraphSON/TestClass.cs | 2 +- .../Gremlin.Net.UnitTest/Structure/PathTests.cs | 64 ++++++++-------- 45 files changed, 223 insertions(+), 206 deletions(-) diff --git a/gremlin-dotnet/build/generate.groovy b/gremlin-dotnet/build/generate.groovy index 6360c3a9fb..6be4c572a6 100644 --- a/gremlin-dotnet/build/generate.groovy +++ b/gremlin-dotnet/build/generate.groovy @@ -89,7 +89,8 @@ radishGremlinFile.withWriter('UTF-8') { Writer writer -> writer.writeLine("\n\n//********************************************************************************") writer.writeLine("//* Do NOT edit this file directly - generated by build/generate.groovy") - writer.writeLine("//********************************************************************************\n\n") + writer.writeLine("//********************************************************************************\n") + writer.writeLine("#nullable disable\n") writer.writeLine('using System;\n' + 'using System.Collections.Generic;\n' + @@ -174,6 +175,7 @@ radishGremlinFile.withWriter('UTF-8') { Writer writer -> ' }\n' + ' }\n' + '}\n') + writer.writeLine("#nullable restore\n") } diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs index f4ffb36ecd..2d1633697c 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs @@ -732,7 +732,7 @@ namespace Gremlin.Net.Process.Traversal /// <summary> /// Adds the from step to this <see cref="GraphTraversal{SType, EType}" />. /// </summary> - public GraphTraversal<TStart, TEnd> From (Vertex fromVertex) + public GraphTraversal<TStart, TEnd> From (Vertex? fromVertex) { Bytecode.AddStep("from", fromVertex); return Wrap<TStart, TEnd>(this); @@ -1883,7 +1883,7 @@ namespace Gremlin.Net.Process.Traversal /// <summary> /// Adds the to step to this <see cref="GraphTraversal{SType, EType}" />. /// </summary> - public GraphTraversal<TStart, TEnd> To (Vertex toVertex) + public GraphTraversal<TStart, TEnd> To (Vertex? toVertex) { Bytecode.AddStep("to", toVertex); return Wrap<TStart, TEnd>(this); diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Traverser.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Traverser.cs index e00644ebdb..6c241ef787 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Traverser.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Traverser.cs @@ -50,7 +50,7 @@ namespace Gremlin.Net.Process.Traversal public long Bulk { get; internal set; } /// <inheritdoc /> - public bool Equals(Traverser other) + public bool Equals(Traverser? other) { if (ReferenceEquals(null, other)) return false; if (ReferenceEquals(this, other)) return true; diff --git a/gremlin-dotnet/test/Gremlin.Net.Benchmarks/Gremlin.Net.Benchmarks.csproj b/gremlin-dotnet/test/Gremlin.Net.Benchmarks/Gremlin.Net.Benchmarks.csproj index 6be47d5458..79c3e1b835 100644 --- a/gremlin-dotnet/test/Gremlin.Net.Benchmarks/Gremlin.Net.Benchmarks.csproj +++ b/gremlin-dotnet/test/Gremlin.Net.Benchmarks/Gremlin.Net.Benchmarks.csproj @@ -3,6 +3,7 @@ <PropertyGroup> <OutputType>Exe</OutputType> <TargetFramework>net6.0</TargetFramework> + <Nullable>enable</Nullable> </PropertyGroup> <ItemGroup> diff --git a/gremlin-dotnet/test/Gremlin.Net.Benchmarks/MessageSerializerBenchmarks.cs b/gremlin-dotnet/test/Gremlin.Net.Benchmarks/MessageSerializerBenchmarks.cs index 500929acfb..45be90eb66 100644 --- a/gremlin-dotnet/test/Gremlin.Net.Benchmarks/MessageSerializerBenchmarks.cs +++ b/gremlin-dotnet/test/Gremlin.Net.Benchmarks/MessageSerializerBenchmarks.cs @@ -86,22 +86,22 @@ namespace Gremlin.Net.Benchmarks .ConfigureAwait(false); [Benchmark] - public async Task<ResponseMessage<List<object>>> TestReadSmallResponseMessageBinary() => + public async Task<ResponseMessage<List<object>>?> TestReadSmallResponseMessageBinary() => await BinaryMessageSerializer.DeserializeMessageAsync(TestMessages.SmallBinaryResponseMessageBytes) .ConfigureAwait(false); [Benchmark] - public async Task<ResponseMessage<List<object>>> TestReadSmallResponseMessageGraphSON3() => + public async Task<ResponseMessage<List<object>>?> TestReadSmallResponseMessageGraphSON3() => await GraphSON3MessageSerializer.DeserializeMessageAsync(TestMessages.SmallGraphSON3ResponseMessageBytes) .ConfigureAwait(false); [Benchmark] - public async Task<ResponseMessage<List<object>>> TestReadBigResponseMessageBinary() => + public async Task<ResponseMessage<List<object>>?> TestReadBigResponseMessageBinary() => await BinaryMessageSerializer.DeserializeMessageAsync(TestMessages.BigBinaryResponseMessageBytes) .ConfigureAwait(false); [Benchmark] - public async Task<ResponseMessage<List<object>>> TestReadBigResponseMessageGraphSON3() => + public async Task<ResponseMessage<List<object>>?> TestReadBigResponseMessageGraphSON3() => await GraphSON3MessageSerializer.DeserializeMessageAsync(TestMessages.BigGraphSON3ResponseMessageBytes) .ConfigureAwait(false); } diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Docs/Reference/IntroTests.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Docs/Reference/IntroTests.cs index 1d45514842..f360c75619 100644 --- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Docs/Reference/IntroTests.cs +++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Docs/Reference/IntroTests.cs @@ -62,7 +62,7 @@ var marko = g.V().Has("person", "name", "marko").Next(); var peopleMarkoKnows = g.V().Has("person", "name", "marko").Out("knows").ToList(); // end::basicGremlinMarkoKnows[] - Assert.Equal("person", marko.Label); + Assert.Equal("person", marko!.Label); Assert.Equal(2, peopleMarkoKnows.Count); } } diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Driver/ConnectionPoolTests.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Driver/ConnectionPoolTests.cs index c4f5f7c980..d35c3e36ec 100644 --- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Driver/ConnectionPoolTests.cs +++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Driver/ConnectionPoolTests.cs @@ -34,7 +34,7 @@ namespace Gremlin.Net.IntegrationTest.Driver public class ConnectionPoolTests { private readonly RequestMessageProvider _requestMessageProvider = new RequestMessageProvider(); - private static readonly string TestHost = ConfigProvider.Configuration["TestServerIpAddress"]; + private static readonly string TestHost = ConfigProvider.Configuration["TestServerIpAddress"]!; private static readonly int TestPort = Convert.ToInt32(ConfigProvider.Configuration["TestServerPort"]); private async Task ExecuteMultipleLongRunningRequestsInParallel(IGremlinClient gremlinClient, int nrRequests, diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Driver/DriverRemoteConnectionTests.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Driver/DriverRemoteConnectionTests.cs index 74730c4958..f0461c14be 100644 --- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Driver/DriverRemoteConnectionTests.cs +++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Driver/DriverRemoteConnectionTests.cs @@ -34,7 +34,7 @@ namespace Gremlin.Net.IntegrationTest.Driver; public class DriverRemoteConnectionTests { - private static readonly string TestHost = ConfigProvider.Configuration["TestServerIpAddress"]; + private static readonly string TestHost = ConfigProvider.Configuration["TestServerIpAddress"]!; private static readonly int TestPort = Convert.ToInt32(ConfigProvider.Configuration["TestServerPort"]); [Fact] diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Driver/GremlinClientAuthenticationTests.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Driver/GremlinClientAuthenticationTests.cs index e56e282248..978e5e2d0d 100644 --- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Driver/GremlinClientAuthenticationTests.cs +++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Driver/GremlinClientAuthenticationTests.cs @@ -35,14 +35,14 @@ namespace Gremlin.Net.IntegrationTest.Driver { public class GremlinClientAuthenticationTests { - private static readonly string TestHost = ConfigProvider.Configuration["TestServerIpAddress"]; + private static readonly string TestHost = ConfigProvider.Configuration["TestServerIpAddress"]!; private static readonly int TestPort = Convert.ToInt32(ConfigProvider.Configuration["TestSecureServerPort"]); private readonly RequestMessageProvider _requestMessageProvider = new RequestMessageProvider(); public static bool IgnoreCertificateValidationLiveDangerouslyWheeeeeeee( object sender, - X509Certificate certificate, - X509Chain chain, + X509Certificate? certificate, + X509Chain? chain, SslPolicyErrors sslPolicyErrors) { return true; @@ -51,7 +51,7 @@ namespace Gremlin.Net.IntegrationTest.Driver [Fact] public async Task ShouldThrowForMissingCredentials() { - ClientWebSocketOptions optionsSet = null; + ClientWebSocketOptions? optionsSet = null; var webSocketConfiguration = new Action<ClientWebSocketOptions>(options => { @@ -75,7 +75,7 @@ namespace Gremlin.Net.IntegrationTest.Driver [InlineData("stephen", "wrongPassword")] public async Task ShouldThrowForWrongCredentials(string username, string password) { - ClientWebSocketOptions optionsSet = null; + ClientWebSocketOptions? optionsSet = null; var webSocketConfiguration = new Action<ClientWebSocketOptions>(options => { @@ -98,7 +98,7 @@ namespace Gremlin.Net.IntegrationTest.Driver public async Task ScriptShouldBeEvaluatedAndResultReturnedForCorrectCredentials(string requestMsg, string expectedResponse) { - ClientWebSocketOptions optionsSet = null; + ClientWebSocketOptions? optionsSet = null; var webSocketConfiguration = new Action<ClientWebSocketOptions>(options => { diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Driver/GremlinClientTests.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Driver/GremlinClientTests.cs index 454f837d55..b7223eca23 100644 --- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Driver/GremlinClientTests.cs +++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Driver/GremlinClientTests.cs @@ -38,8 +38,8 @@ namespace Gremlin.Net.IntegrationTest.Driver { public class GremlinClientTests { - private readonly RequestMessageProvider _requestMessageProvider = new RequestMessageProvider(); - private static readonly string TestHost = ConfigProvider.Configuration["TestServerIpAddress"]; + private readonly RequestMessageProvider _requestMessageProvider = new(); + private static readonly string TestHost = ConfigProvider.Configuration["TestServerIpAddress"]!; private static readonly int TestPort = Convert.ToInt32(ConfigProvider.Configuration["TestServerPort"]); [Theory] @@ -67,7 +67,7 @@ namespace Gremlin.Net.IntegrationTest.Driver var response = await gremlinClient.SubmitWithSingleResultAsync<string>(requestMsg); - Assert.Equal(responseMsgSize, response.Length); + Assert.Equal(responseMsgSize, response!.Length); } } @@ -246,7 +246,7 @@ namespace Gremlin.Net.IntegrationTest.Driver public async Task ShouldConfigureWebSocketOptionsAsSpecified() { var gremlinServer = new GremlinServer(TestHost, TestPort); - ClientWebSocketOptions optionsSet = null; + ClientWebSocketOptions? optionsSet = null; var expectedKeepAliveInterval = TimeSpan.FromMilliseconds(11); var webSocketConfiguration = new Action<ClientWebSocketOptions>(options => diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Driver/MessagesTests.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Driver/MessagesTests.cs index 6d6ca72614..5a39b7dfec 100644 --- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Driver/MessagesTests.cs +++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Driver/MessagesTests.cs @@ -35,8 +35,8 @@ namespace Gremlin.Net.IntegrationTest.Driver { public class MessagesTests { - private readonly RequestMessageProvider _requestMessageProvider = new RequestMessageProvider(); - private static readonly string TestHost = ConfigProvider.Configuration["TestServerIpAddress"]; + private readonly RequestMessageProvider _requestMessageProvider = new(); + private static readonly string TestHost = ConfigProvider.Configuration["TestServerIpAddress"]!; private static readonly int TestPort = Convert.ToInt32(ConfigProvider.Configuration["TestServerPort"]); [Fact] diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Driver/MockedLoggerExtensions.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Driver/MockedLoggerExtensions.cs index e9668768be..6cad68c8d2 100644 --- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Driver/MockedLoggerExtensions.cs +++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Driver/MockedLoggerExtensions.cs @@ -34,14 +34,14 @@ public static class MockedLoggerExtensions { mockedLogger.Verify( m => m.Log(expectedLogLevel, It.IsAny<EventId>(), - It.Is<It.IsAnyType>((o, _) => o.ToString().Contains(logMessagePart)), null, - It.IsAny<Func<It.IsAnyType, Exception, string>>()), Times.Once); + It.Is<It.IsAnyType>((o, _) => o.ToString()!.Contains(logMessagePart)), null, + It.IsAny<Func<It.IsAnyType, Exception?, string>>()), Times.Once); } public static void VerifyNothingWasLogged(this Mock<ILogger> mockedLogger) { mockedLogger.Verify( m => m.Log(It.IsAny<LogLevel>(), It.IsAny<EventId>(), It.IsAny<It.IsAnyType>(), It.IsAny<Exception>(), - It.IsAny<Func<It.IsAnyType, Exception, string>>()), Times.Never); + It.IsAny<Func<It.IsAnyType, Exception?, string>>()), Times.Never); } } \ No newline at end of file diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/CommonSteps.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/CommonSteps.cs index fc6bcebc5b..cef4caec5f 100644 --- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/CommonSteps.cs +++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/CommonSteps.cs @@ -42,30 +42,30 @@ namespace Gremlin.Net.IntegrationTest.Gherkin { internal class CommonSteps : StepDefinition { - private GraphTraversalSource _g; - private string _graphName; - private readonly IDictionary<string, object> _parameters = new Dictionary<string, object>(); - private ITraversal _traversal; - private object[] _result; - private Exception _error = null; + private GraphTraversalSource? _g; + private string? _graphName; + private readonly IDictionary<string, object?> _parameters = new Dictionary<string, object?>(); + private ITraversal? _traversal; + private object?[]? _result; + private Exception? _error; private static readonly JsonSerializerOptions JsonDeserializingOptions = new() { PropertyNamingPolicy = JsonNamingPolicy.CamelCase }; public static ScenarioData ScenarioData { get; set; } = new ScenarioData(new GraphSON3MessageSerializer()); - private static readonly IDictionary<Regex, Func<string, string, object>> Parsers = - new Dictionary<string, Func<string, string, object>> + private static readonly IDictionary<Regex, Func<string, string, object?>> Parsers = + new Dictionary<string, Func<string, string, object?>> { {@"vp\[(.+)\]", ToVertexProperty}, {@"d\[(.*)\]\.([bsilfdmn])", ToNumber}, {@"D\[(.+)\]", ToDirection}, {@"v\[(.+)\]", ToVertex}, {@"v\[(.+)\]\.id", (x, graphName) => ToVertex(x, graphName).Id}, - {@"v\[(.+)\]\.sid", (x, graphName) => ToVertex(x, graphName).Id.ToString()}, + {@"v\[(.+)\]\.sid", (x, graphName) => ToVertex(x, graphName).Id!.ToString()}, {@"e\[(.+)\]", ToEdge}, {@"e\[(.+)\].id", (x, graphName) => ToEdge(x, graphName).Id}, - {@"e\[(.+)\].sid", (x, graphName) => ToEdge(x, graphName).Id.ToString()}, + {@"e\[(.+)\].sid", (x, graphName) => ToEdge(x, graphName).Id!.ToString()}, {@"p\[(.+)\]", ToPath}, {@"l\[(.*)\]", ToList}, {@"s\[(.*)\]", ToSet}, @@ -108,14 +108,14 @@ namespace Gremlin.Net.IntegrationTest.Gherkin [Given("using the parameter (\\w+) defined as \"(.*)\"")] public void UsingParameter(string name, string value) { - var parsedValue = ParseValue(value.Replace("\\\"", "\""), _graphName); + var parsedValue = ParseValue(value.Replace("\\\"", "\""), _graphName!); _parameters.Add(name, parsedValue); } [Given("using the parameter (\\w+) of P.(\\w+)\\(\"(.*)\"\\)")] public void UsingParameterP(string name, string pval, string value) { - var parsedValue = ParseValue(value.Replace("\\\"", "\""), _graphName); + var parsedValue = ParseValue(value.Replace("\\\"", "\""), _graphName!); _parameters.Add(name, new P(pval, parsedValue)); } @@ -127,20 +127,20 @@ namespace Gremlin.Net.IntegrationTest.Gherkin throw new InvalidOperationException("g should be a traversal source"); } - if (ScenarioData.CurrentFeature.Tags.Select(t => t.Name).ToList().Contains("@GraphComputerOnly")) + if (ScenarioData.CurrentFeature!.Tags.Select(t => t.Name).ToList().Contains("@GraphComputerOnly")) { _g = _g.WithComputer(); } _traversal = - Gremlin.UseTraversal(ScenarioData.CurrentScenario.Name, _g, _parameters); + Gremlin.UseTraversal(ScenarioData.CurrentScenario!.Name, _g, _parameters); } [Given("the graph initializer of")] public void InitTraversal(string traversalText) { var traversal = - Gremlin.UseTraversal(ScenarioData.CurrentScenario.Name, _g, _parameters); + Gremlin.UseTraversal(ScenarioData.CurrentScenario!.Name, _g, _parameters); traversal.Iterate(); // We may have modified the so-called `empty` graph @@ -226,13 +226,13 @@ namespace Gremlin.Net.IntegrationTest.Gherkin switch (comparison) { case "containing": - Assert.Equal(true, _error.Message.Contains(expectedMessage)); + Assert.Contains(expectedMessage, _error.Message); break; case "starting": - Assert.Equal(true, _error.Message.StartsWith(expectedMessage)); + Assert.StartsWith(expectedMessage, _error.Message); break; case "ending": - Assert.Equal(true, _error.Message.EndsWith(expectedMessage)); + Assert.EndsWith(expectedMessage, _error.Message); break; default: throw new NotSupportedException( @@ -244,15 +244,15 @@ namespace Gremlin.Net.IntegrationTest.Gherkin } [Then("the result should be (\\w+)")] - public void AssertResult(string characterizedAs, DataTable table = null) + public void AssertResult(string characterizedAs, DataTable? table = null) { - assertThatNoErrorWasThrown(); + AssertThatNoErrorWasThrown(); var ordered = characterizedAs == "ordered"; switch (characterizedAs) { case "empty": - Assert.Empty(_result); + Assert.Empty(_result!); return; case "ordered": case "unordered": @@ -260,16 +260,16 @@ namespace Gremlin.Net.IntegrationTest.Gherkin Assert.NotNull(table); var rows = table.Rows.ToArray(); Assert.Equal("result", rows[0].Cells.First().Value); - var expected = rows.Skip(1).Select(x => ParseValue(x.Cells.First().Value, _graphName)); + var expected = rows.Skip(1).Select(x => ParseValue(x.Cells.First().Value, _graphName!)); if (ordered) { - Assert.Equal(expected, _result); + Assert.Equal(expected, _result!); } else { var expectedArray = expected.ToArray(); - foreach (var resultItem in _result) + foreach (var resultItem in _result!) { if (resultItem is Dictionary<object, object> resultItemDict) { @@ -284,7 +284,7 @@ namespace Gremlin.Net.IntegrationTest.Gherkin Assert.True(expectedArrayContainsResultDictionary); } else if (resultItem is double resultItemDouble && - expectedArray.Select(e => e.GetType()).Any(t => t == typeof(decimal))) + expectedArray.Select(e => e!.GetType()).Any(t => t == typeof(decimal))) { // Java seems to use BigDecimal by default sometimes where .NET uses double, but we only // care for the value not its type here. So we just convert these to decimal (equivalent @@ -310,15 +310,15 @@ namespace Gremlin.Net.IntegrationTest.Gherkin [Then("the result should have a count of (\\d+)")] public void AssertCount(int count) { - assertThatNoErrorWasThrown(); + AssertThatNoErrorWasThrown(); - Assert.Equal(count, _result.Length); + Assert.Equal(count, _result!.Length); } [Then("the graph should return (\\d+) for count of (.+)")] public void AssertTraversalCount(int expectedCount, string traversalText) { - assertThatNoErrorWasThrown(); + AssertThatNoErrorWasThrown(); if (traversalText.StartsWith("\"")) { @@ -326,7 +326,7 @@ namespace Gremlin.Net.IntegrationTest.Gherkin } var traversal = - Gremlin.UseTraversal(ScenarioData.CurrentScenario.Name, _g, _parameters); + Gremlin.UseTraversal(ScenarioData.CurrentScenario!.Name, _g, _parameters); var count = 0; while (traversal.MoveNext()) @@ -342,7 +342,7 @@ namespace Gremlin.Net.IntegrationTest.Gherkin } - private void assertThatNoErrorWasThrown() + private void AssertThatNoErrorWasThrown() { if (_error != null) throw _error; } @@ -350,7 +350,7 @@ namespace Gremlin.Net.IntegrationTest.Gherkin private static object ToMap(string stringMap, string graphName) { var jsonMap = JsonSerializer.Deserialize<JsonElement>(stringMap, JsonDeserializingOptions); - return ParseMapValue(jsonMap, graphName); + return ParseMapValue(jsonMap, graphName)!; } private static object ToLambda(string stringLambda, string graphName) @@ -374,13 +374,13 @@ namespace Gremlin.Net.IntegrationTest.Gherkin stringNumber.Substring(0, stringNumber.Length - 1)); } - private static object ParseMapValue(JsonElement value, string graphName) + private static object? ParseMapValue(JsonElement value, string graphName) { switch (value.ValueKind) { case JsonValueKind.Object: { - return value.EnumerateObject().ToDictionary(property => ParseValue(property.Name, graphName), + return value.EnumerateObject().ToDictionary(property => ParseValue(property.Name, graphName)!, property => ParseMapValue(property.Value, graphName)); } case JsonValueKind.Array: @@ -402,7 +402,7 @@ namespace Gremlin.Net.IntegrationTest.Gherkin throw new ArgumentOutOfRangeException(nameof(value), value, "Not a supported number type"); } case JsonValueKind.String: - return ParseValue(value.GetString(), graphName); + return ParseValue(value.GetString()!, graphName); case JsonValueKind.True: return true; case JsonValueKind.False: @@ -415,16 +415,16 @@ namespace Gremlin.Net.IntegrationTest.Gherkin } } - private static ISet<object> ToSet(string stringSet, string graphName) + private static ISet<object?> ToSet(string stringSet, string graphName) { - return new HashSet<object>(ToList(stringSet, graphName)); + return new HashSet<object?>(ToList(stringSet, graphName)); } - private static IList<object> ToList(string stringList, string graphName) + private static IList<object?> ToList(string stringList, string graphName) { if (stringList == "") { - return new List<object>(0); + return new List<object?>(0); } return stringList.Split(',').Select(x => ParseValue(x, graphName)).ToList(); } @@ -453,13 +453,14 @@ namespace Gremlin.Net.IntegrationTest.Gherkin private static Path ToPath(string value, string graphName) { - return new Path(new List<ISet<string>>(0), value.Split(',').Select(x => ParseValue(x, graphName)).ToList()); + return new Path(new List<ISet<string>>(0), + value.Split(',').Select(x => ParseValue(x, graphName)).ToList()); } - private static object ParseValue(string stringValue, string graphName) + private static object? ParseValue(string stringValue, string graphName) { - Func<string, string, object> parser = null; - string extractedValue = null; + Func<string, string, object?>? parser = null; + string? extractedValue = null; foreach (var kv in Parsers) { var match = kv.Key.Match(stringValue); @@ -474,7 +475,7 @@ namespace Gremlin.Net.IntegrationTest.Gherkin break; } } - return parser != null ? parser(extractedValue, graphName) : stringValue; + return parser != null ? parser(extractedValue!, graphName) : stringValue; } } } \ No newline at end of file diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/GherkinTestRunner.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/GherkinTestRunner.cs index 2bdd7f1540..f6b811139c 100644 --- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/GherkinTestRunner.cs +++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/GherkinTestRunner.cs @@ -119,7 +119,7 @@ namespace Gremlin.Net.IntegrationTest.Gherkin } StepBlock? currentStep = null; - StepDefinition stepDefinition = null; + StepDefinition? stepDefinition = null; foreach (var step in scenario.Steps) { var previousStep = currentStep; @@ -243,13 +243,13 @@ namespace Gremlin.Net.IntegrationTest.Gherkin } } - private Exception ExecuteStep(StepDefinition instance, StepBlock stepBlock, Step step) + private Exception? ExecuteStep(StepDefinition instance, StepBlock stepBlock, Step step) { var attribute = Attributes[stepBlock]; var methodAndParameters = instance.GetType().GetMethods() .Select(m => { - var attr = (BddAttribute) m.GetCustomAttribute(attribute); + var attr = (BddAttribute?) m.GetCustomAttribute(attribute); if (attr == null) { @@ -260,7 +260,7 @@ namespace Gremlin.Net.IntegrationTest.Gherkin { return null; } - var parameters = new List<object>(); + var parameters = new List<object?>(); for (var i = 1; i < match.Groups.Count; i++) { parameters.Add(match.Groups[i].Value); @@ -363,7 +363,7 @@ namespace Gremlin.Net.IntegrationTest.Gherkin { throw new InvalidOperationException($"No step definition class matches Given '{stepText}'"); } - return (StepDefinition) Activator.CreateInstance(type); + return (StepDefinition) Activator.CreateInstance(type)!; } private ICollection<Type> GetStepDefinitionTypes() @@ -396,9 +396,9 @@ namespace Gremlin.Net.IntegrationTest.Gherkin { var codeBaseUrl = new Uri(GetType().GetTypeInfo().Assembly.Location); var codeBasePath = Uri.UnescapeDataString(codeBaseUrl.AbsolutePath); - DirectoryInfo rootDir = null; - for (var dir = Directory.GetParent(Path.GetDirectoryName(codeBasePath)); - dir.Parent != null; + DirectoryInfo? rootDir = null; + for (var dir = Directory.GetParent(Path.GetDirectoryName(codeBasePath)!); + dir!.Parent != null; dir = dir.Parent) { if (dir.Name == "gremlin-dotnet" && dir.GetFiles("pom.xml").Length == 1) diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/Gremlin.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/Gremlin.cs index 20f298d7e9..b7c3c84cb6 100644 --- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/Gremlin.cs +++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/Gremlin.cs @@ -27,6 +27,7 @@ //* Do NOT edit this file directly - generated by build/generate.groovy //******************************************************************************** +#nullable disable using System; using System.Collections.Generic; @@ -1137,3 +1138,5 @@ namespace Gremlin.Net.IntegrationTest.Gherkin } } +#nullable restore + diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/IgnoreException.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/IgnoreException.cs index a2a0d488ca..8b6f94ff11 100644 --- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/IgnoreException.cs +++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/IgnoreException.cs @@ -37,7 +37,7 @@ namespace Gremlin.Net.IntegrationTest.Gherkin private static string GetMessage(IgnoreReason reason) { - string reasonSuffix = null; + string? reasonSuffix = null; switch (reason) { case IgnoreReason.NoReason: diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/ScenarioData.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/ScenarioData.cs index b7660c32b6..1c8be14a92 100644 --- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/ScenarioData.cs +++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/ScenarioData.cs @@ -52,8 +52,8 @@ namespace Gremlin.Net.IntegrationTest.Gherkin private readonly RemoteConnectionFactory _connectionFactory; - public Scenario CurrentScenario; - public Feature CurrentFeature; + public Scenario? CurrentScenario; + public Feature? CurrentFeature; public ScenarioDataPerGraph GetByGraphName(string name) { @@ -109,7 +109,7 @@ namespace Gremlin.Net.IntegrationTest.Gherkin // Property name might not exist and C# doesn't support "null" keys in Dictionary if (g.V().Count().Next() == g.V().Has("name").Count().Next()) { - return g.V().Group<string, object>().By("name").By(__.Tail<Vertex>()).Next() + return g.V().Group<string, object>().By("name").By(__.Tail<Vertex>()).Next()! .ToDictionary(kv => kv.Key, kv => (Vertex) kv.Value); } else @@ -128,7 +128,7 @@ namespace Gremlin.Net.IntegrationTest.Gherkin return g.E().Group<string, Edge>() .By(lambda) .By(__.Tail<object>()) - .Next(); + .Next()!; } catch (ResponseException) { @@ -191,7 +191,7 @@ namespace Gremlin.Net.IntegrationTest.Gherkin return g.V().Properties<VertexProperty>().Group<string, VertexProperty>() .By(lambda) .By(__.Tail<object>()) - .Next(); + .Next()!; } catch (ResponseException) { diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gremlin.Net.IntegrationTest.csproj b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gremlin.Net.IntegrationTest.csproj index 43cccfbb97..47fcfe8321 100644 --- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gremlin.Net.IntegrationTest.csproj +++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gremlin.Net.IntegrationTest.csproj @@ -1,6 +1,7 @@ <Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <TargetFramework>net6.0</TargetFramework> + <Nullable>enable</Nullable> </PropertyGroup> <ItemGroup> <None Update="appsettings.json"> 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 ca363191c2..33b4ab4889 100644 --- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Remote/RemoteStrategyTests.cs +++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Remote/RemoteStrategyTests.cs @@ -34,7 +34,7 @@ namespace Gremlin.Net.IntegrationTest.Process.Remote { public class RemoteStrategyTests { - private static readonly string TestHost = ConfigProvider.Configuration["TestServerIpAddress"]; + private static readonly string TestHost = ConfigProvider.Configuration["TestServerIpAddress"]!; private static readonly int TestPort = Convert.ToInt32(ConfigProvider.Configuration["TestServerPort"]); [Fact] diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/BytecodeGeneration/BytecodeGenerationTests.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/BytecodeGeneration/BytecodeGenerationTests.cs index adac06b2a2..cea8e231cc 100644 --- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/BytecodeGeneration/BytecodeGenerationTests.cs +++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/BytecodeGeneration/BytecodeGenerationTests.cs @@ -110,7 +110,7 @@ namespace Gremlin.Net.IntegrationTest.Process.Traversal.BytecodeGeneration [Fact] public void AnonymousTraversal_OutXnullX() { - Assert.Throws<ArgumentNullException>(() => __.Out(null)); + Assert.Throws<ArgumentNullException>(() => __.Out(null!)); } } } \ No newline at end of file diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/BytecodeGeneration/StrategiesTests.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/BytecodeGeneration/StrategiesTests.cs index 3a76a84423..24c5e631fe 100644 --- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/BytecodeGeneration/StrategiesTests.cs +++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/BytecodeGeneration/StrategiesTests.cs @@ -90,7 +90,7 @@ namespace Gremlin.Net.IntegrationTest.Process.Traversal.BytecodeGeneration Assert.Equal("withStrategies", bytecode.SourceInstructions[0].OperatorName); Assert.Equal(new MatchAlgorithmStrategy(), bytecode.SourceInstructions[0].Arguments[0]); Assert.Contains("greedy", - ((MatchAlgorithmStrategy) bytecode.SourceInstructions[0].Arguments[0]).Configuration.Values); + ((MatchAlgorithmStrategy) bytecode.SourceInstructions[0].Arguments[0]!).Configuration.Values); } [Fact] @@ -118,8 +118,9 @@ namespace Gremlin.Net.IntegrationTest.Process.Traversal.BytecodeGeneration Assert.Single(bytecode.SourceInstructions[0].Arguments); Assert.Equal("withStrategies", bytecode.SourceInstructions[0].OperatorName); Assert.Equal(new ReadOnlyStrategy(), bytecode.SourceInstructions[0].Arguments[0]); - Assert.Equal("ReadOnlyStrategy", bytecode.SourceInstructions[0].Arguments[0].ToString()); - Assert.Equal(new ReadOnlyStrategy().GetHashCode(), bytecode.SourceInstructions[0].Arguments[0].GetHashCode()); + Assert.Equal("ReadOnlyStrategy", bytecode.SourceInstructions[0].Arguments[0]!.ToString()); + Assert.Equal(new ReadOnlyStrategy().GetHashCode(), + bytecode.SourceInstructions[0].Arguments[0]!.GetHashCode()); Assert.Equal(0, g.TraversalStrategies.Count); } @@ -150,9 +151,9 @@ namespace Gremlin.Net.IntegrationTest.Process.Traversal.BytecodeGeneration Assert.Single(bytecode.SourceInstructions[0].Arguments); Assert.Equal("withStrategies", bytecode.SourceInstructions[0].OperatorName); Assert.Equal(new SubgraphStrategy(), bytecode.SourceInstructions[0].Arguments[0]); - SubgraphStrategy strategy = bytecode.SourceInstructions[0].Arguments[0]; - Assert.Equal(typeof(GraphTraversal<object, object>), strategy.Configuration["vertices"].GetType()); - ITraversal traversal = strategy.Configuration["vertices"]; + SubgraphStrategy strategy = bytecode.SourceInstructions[0].Arguments[0]!; + Assert.Equal(typeof(GraphTraversal<object, object>), strategy.Configuration["vertices"]!.GetType()); + ITraversal traversal = strategy.Configuration["vertices"]!; Assert.Equal("has", traversal.Bytecode.StepInstructions[0].OperatorName); Assert.Equal(new List<string> {"name", "marko"}, traversal.Bytecode.StepInstructions[0].Arguments); Assert.Equal(false, strategy.Configuration["checkAdjacentVertices"]); diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/DriverRemoteConnection/GraphTraversalTests.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/DriverRemoteConnection/GraphTraversalTests.cs index 262ffeabca..73cbff3dd9 100644 --- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/DriverRemoteConnection/GraphTraversalTests.cs +++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/DriverRemoteConnection/GraphTraversalTests.cs @@ -84,7 +84,7 @@ namespace Gremlin.Net.IntegrationTest.Process.Traversal.DriverRemoteConnection var vertex = g.V(1).Next(); Assert.Equal(new Vertex(1), vertex); - Assert.Equal(1, vertex.Id); + Assert.Equal(1, vertex!.Id); } [Fact] @@ -143,7 +143,7 @@ namespace Gremlin.Net.IntegrationTest.Process.Traversal.DriverRemoteConnection var shortestPath = g.V(5).Repeat(__.Both().SimplePath()).Until(__.HasId(6)).Limit<Vertex>(1).Path().Next(); - Assert.Equal(4, shortestPath.Count); + Assert.Equal(4, shortestPath!.Count); Assert.Equal(new Vertex(6), shortestPath[3]); } diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/DriverRemoteConnection/RemoteConnectionFactory.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/DriverRemoteConnection/RemoteConnectionFactory.cs index 8fe6c2e7cd..f5aa498a1a 100644 --- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/DriverRemoteConnection/RemoteConnectionFactory.cs +++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/DriverRemoteConnection/RemoteConnectionFactory.cs @@ -32,13 +32,13 @@ namespace Gremlin.Net.IntegrationTest.Process.Traversal.DriverRemoteConnection { internal class RemoteConnectionFactory : IDisposable { - private static readonly string TestHost = ConfigProvider.Configuration["TestServerIpAddress"]; + private static readonly string TestHost = ConfigProvider.Configuration["TestServerIpAddress"]!; private static readonly int TestPort = Convert.ToInt32(ConfigProvider.Configuration["TestServerPort"]); private readonly IList<DriverRemoteConnectionImpl> _connections = new List<DriverRemoteConnectionImpl>(); private readonly IMessageSerializer _messageSerializer; - public RemoteConnectionFactory(IMessageSerializer messageSerializer = null) + public RemoteConnectionFactory(IMessageSerializer? messageSerializer = null) { _messageSerializer = messageSerializer ?? new GraphSON3MessageSerializer(); } diff --git a/gremlin-dotnet/test/Gremlin.Net.Template.IntegrationTest/Gremlin.Net.Template.IntegrationTest.csproj b/gremlin-dotnet/test/Gremlin.Net.Template.IntegrationTest/Gremlin.Net.Template.IntegrationTest.csproj index b7eba8da81..2f38cff24b 100644 --- a/gremlin-dotnet/test/Gremlin.Net.Template.IntegrationTest/Gremlin.Net.Template.IntegrationTest.csproj +++ b/gremlin-dotnet/test/Gremlin.Net.Template.IntegrationTest/Gremlin.Net.Template.IntegrationTest.csproj @@ -2,6 +2,7 @@ <PropertyGroup> <TargetFramework>net6.0</TargetFramework> + <Nullable>enable</Nullable> </PropertyGroup> <ItemGroup> diff --git a/gremlin-dotnet/test/Gremlin.Net.Template.IntegrationTest/ServiceTests.cs b/gremlin-dotnet/test/Gremlin.Net.Template.IntegrationTest/ServiceTests.cs index 1faa0b8cc7..faef08e0b8 100644 --- a/gremlin-dotnet/test/Gremlin.Net.Template.IntegrationTest/ServiceTests.cs +++ b/gremlin-dotnet/test/Gremlin.Net.Template.IntegrationTest/ServiceTests.cs @@ -34,7 +34,7 @@ namespace Gremlin.Net.Template.IntegrationTest { public class ServiceTests { - private static readonly string TestHost = ConfigProvider.Configuration["TestServerIpAddress"]; + private static readonly string TestHost = ConfigProvider.Configuration["TestServerIpAddress"]!; private static readonly int TestPort = Convert.ToInt32(ConfigProvider.Configuration["TestServerPort"]); private const string TestTraversalSource = "gmodern"; @@ -48,7 +48,7 @@ namespace Gremlin.Net.Template.IntegrationTest var creators = service.FindCreatorsOfSoftware("lop"); - Assert.Equal(new List<string> {"marko", "josh", "peter"}, creators); + Assert.Equal(new List<string?> {"marko", "josh", "peter"}, creators); } } diff --git a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Driver/ConnectionPoolTests.cs b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Driver/ConnectionPoolTests.cs index 0fbc02aadb..e5711b047d 100644 --- a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Driver/ConnectionPoolTests.cs +++ b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Driver/ConnectionPoolTests.cs @@ -27,6 +27,7 @@ using System.Threading; using System.Threading.Tasks; using Gremlin.Net.Driver; using Gremlin.Net.Driver.Exceptions; +using Gremlin.Net.Driver.Messages; using Microsoft.Extensions.Logging.Abstractions; using Moq; using Xunit; @@ -188,7 +189,8 @@ namespace Gremlin.Net.UnitTest.Driver fakedConnection.Setup(f => f.IsOpen).Returns(false); mockedConnectionFactory.Setup(m => m.CreateConnection()).Returns(OpenConnection); - await returnedConnection.SubmitAsync<bool>(null, CancellationToken.None); + await returnedConnection.SubmitAsync<bool>(RequestMessage.Build(string.Empty).Create(), + CancellationToken.None); returnedConnection.Dispose(); Assert.Equal(1, pool.NrConnections); diff --git a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Driver/ConnectionTests.cs b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Driver/ConnectionTests.cs index f912f6a8fb..26e483a5db 100644 --- a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Driver/ConnectionTests.cs +++ b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Driver/ConnectionTests.cs @@ -314,14 +314,14 @@ namespace Gremlin.Net.UnitTest.Driver } private static Connection GetConnection(IMock<IClientWebSocket> mockedClientWebSocket, - IMessageSerializer messageSerializer = null, Uri uri = null) + IMessageSerializer? messageSerializer = null, Uri? uri = null) { return GetConnection(new WebSocketConnection(mockedClientWebSocket.Object, new WebSocketSettings()), messageSerializer, uri); } private static Connection GetConnection(IWebSocketConnection webSocketConnection, - IMessageSerializer messageSerializer = null, Uri uri = null) + IMessageSerializer? messageSerializer = null, Uri? uri = null) { uri ??= new Uri("wss://localhost:8182"); messageSerializer ??= new GraphBinaryMessageSerializer(); @@ -334,9 +334,10 @@ namespace Gremlin.Net.UnitTest.Driver sessionId: null); } - private static async Task AssertExpectedConnectionClosedException(WebSocketCloseStatus? expectedCloseStatus, string expectedCloseDescription, Func<Task> func) + private static async Task AssertExpectedConnectionClosedException(WebSocketCloseStatus? expectedCloseStatus, + string? expectedCloseDescription, Func<Task> func) { - ConnectionClosedException exception = await Assert.ThrowsAsync<ConnectionClosedException>(func); + var exception = await Assert.ThrowsAsync<ConnectionClosedException>(func); Assert.Equal(expectedCloseStatus, exception.Status); Assert.Equal(expectedCloseDescription, exception.Description); } diff --git a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Driver/DriverRemoteConnectionTests.cs b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Driver/DriverRemoteConnectionTests.cs index 7ed9c96fef..8780cf9bae 100644 --- a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Driver/DriverRemoteConnectionTests.cs +++ b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Driver/DriverRemoteConnectionTests.cs @@ -45,7 +45,7 @@ namespace Gremlin.Net.UnitTest.Driver [Fact] public void ShouldThrowWhenGivenNullAsGremlinClient() { - Assert.Throws<ArgumentNullException>(() => new DriverRemoteConnection(null)); + Assert.Throws<ArgumentNullException>(() => new DriverRemoteConnection(null!)); } } } \ No newline at end of file diff --git a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Driver/GraphSONMessageSerializerTests.cs b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Driver/GraphSONMessageSerializerTests.cs index 6b7951ff21..6aae17518d 100644 --- a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Driver/GraphSONMessageSerializerTests.cs +++ b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Driver/GraphSONMessageSerializerTests.cs @@ -36,7 +36,7 @@ namespace Gremlin.Net.UnitTest.Driver { var sut = CreateMessageSerializer(); - await Assert.ThrowsAsync<ArgumentNullException>(()=> sut.DeserializeMessageAsync(null)); + await Assert.ThrowsAsync<ArgumentNullException>(()=> sut.DeserializeMessageAsync(null!)); } [Fact] diff --git a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Gremlin.Net.UnitTest.csproj b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Gremlin.Net.UnitTest.csproj index 4c2934e4ac..1bb0371987 100644 --- a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Gremlin.Net.UnitTest.csproj +++ b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Gremlin.Net.UnitTest.csproj @@ -2,6 +2,7 @@ <PropertyGroup> <TargetFramework>net6.0</TargetFramework> + <Nullable>enable</Nullable> <AssemblyOriginatorKeyFile>../../build/tinkerpop.snk</AssemblyOriginatorKeyFile> <SignAssembly>true</SignAssembly> <PublicSign Condition="'$(OS)' != 'Windows_NT'">true</PublicSign> diff --git a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/BytecodeTests.cs b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/BytecodeTests.cs index d9ab4a7e69..1f91af649a 100644 --- a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/BytecodeTests.cs +++ b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/BytecodeTests.cs @@ -62,7 +62,7 @@ namespace Gremlin.Net.UnitTest.Process.Traversal bytecode.AddStep("someStep", new Dictionary<string, object> {{"someKey", b.Of("valVariable", "valValue")}}); var arg = bytecode.StepInstructions[0].Arguments[0] as IDictionary; - Assert.Equal(new Binding("valVariable", "valValue"), arg["someKey"]); + Assert.Equal(new Binding("valVariable", "valValue"), arg!["someKey"]); } [Fact] @@ -74,7 +74,7 @@ namespace Gremlin.Net.UnitTest.Process.Traversal bytecode.AddStep("someStep", new Dictionary<string, object> {{b.Of("keyVariable", "keyValue"), 1234}}); var arg = bytecode.StepInstructions[0].Arguments[0]; - var binding = ((Dictionary<object, object>) arg).Keys.First() as Binding; + var binding = ((Dictionary<object, object>) arg!).Keys.First() as Binding; Assert.Equal(new Binding("keyVariable", "keyValue"), binding); } @@ -87,7 +87,7 @@ namespace Gremlin.Net.UnitTest.Process.Traversal bytecode.AddStep("someStep", new List<string> {"test", b.Of("listVariable", "listValue")}); var arg = bytecode.StepInstructions[0].Arguments[0] as IList; - Assert.Equal(new Binding("listVariable", "listValue"), arg[1]); + Assert.Equal(new Binding("listVariable", "listValue"), arg![1]); } [Fact] @@ -99,7 +99,7 @@ namespace Gremlin.Net.UnitTest.Process.Traversal bytecode.AddStep("someStep", new HashSet<string> { "test", b.Of("setVariable", "setValue") }); var arg = bytecode.StepInstructions[0].Arguments[0] as ISet<object>; - Assert.Equal(new Binding("setVariable", "setValue"), arg.ToList()[1]); + Assert.Equal(new Binding("setVariable", "setValue"), arg!.ToList()[1]); } [Fact] @@ -133,7 +133,7 @@ namespace Gremlin.Net.UnitTest.Process.Traversal bytecode.AddSource("someSource", new Dictionary<string, object> { { "someKey", b.Of("valVariable", "valValue") } }); var arg = bytecode.SourceInstructions[0].Arguments[0] as IDictionary; - Assert.Equal(new Binding("valVariable", "valValue"), arg["someKey"]); + Assert.Equal(new Binding("valVariable", "valValue"), arg!["someKey"]); } [Fact] @@ -145,7 +145,7 @@ namespace Gremlin.Net.UnitTest.Process.Traversal bytecode.AddSource("someSource", new Dictionary<string, object> { { b.Of("keyVariable", "keyValue"), 1234 } }); var arg = bytecode.SourceInstructions[0].Arguments[0]; - var binding = ((Dictionary<object, object>)arg).Keys.First() as Binding; + var binding = ((Dictionary<object, object>)arg!).Keys.First() as Binding; Assert.Equal(new Binding("keyVariable", "keyValue"), binding); } @@ -158,7 +158,7 @@ namespace Gremlin.Net.UnitTest.Process.Traversal bytecode.AddSource("someSource", new List<string> { "test", b.Of("listVariable", "listValue") }); var arg = bytecode.SourceInstructions[0].Arguments[0] as IList; - Assert.Equal(new Binding("listVariable", "listValue"), arg[1]); + Assert.Equal(new Binding("listVariable", "listValue"), arg![1]); } [Fact] @@ -170,7 +170,7 @@ namespace Gremlin.Net.UnitTest.Process.Traversal bytecode.AddSource("someSource", new HashSet<string> { "test", b.Of("setVariable", "setValue") }); var arg = bytecode.SourceInstructions[0].Arguments[0] as ISet<object>; - Assert.Equal(new Binding("setVariable", "setValue"), arg.ToList()[1]); + Assert.Equal(new Binding("setVariable", "setValue"), arg!.ToList()[1]); } [Fact] diff --git a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/GraphTraversalSourceTests.cs b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/GraphTraversalSourceTests.cs index b08cf6fb1a..98a5fce606 100644 --- a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/GraphTraversalSourceTests.cs +++ b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/GraphTraversalSourceTests.cs @@ -22,7 +22,10 @@ #endregion using System; +using Gremlin.Net.Driver.Remote; +using Gremlin.Net.Process.Remote; using Gremlin.Net.Process.Traversal; +using Moq; using Xunit; namespace Gremlin.Net.UnitTest.Process.Traversal @@ -57,7 +60,7 @@ namespace Gremlin.Net.UnitTest.Process.Traversal { var gLocal = AnonymousTraversalSource.Traversal(); - var gRemote = gLocal.WithRemote(null); + var gRemote = gLocal.WithRemote(Mock.Of<IRemoteConnection>()); Assert.Equal(0, gLocal.TraversalStrategies.Count); Assert.Equal(1, gRemote.TraversalStrategies.Count); 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 0356ff4db7..d618aec1d0 100644 --- a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/TestTraversal.cs +++ b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/TestTraversal.cs @@ -29,7 +29,7 @@ namespace Gremlin.Net.UnitTest.Process.Traversal { public class TestTraversal : DefaultTraversal<object, object> { - public TestTraversal(List<object> traverserObjs) + public TestTraversal(List<object?> traverserObjs) { var traversers = new List<Traverser>(traverserObjs.Count); traverserObjs.ForEach(o => traversers.Add(new Traverser(o))); @@ -37,7 +37,7 @@ namespace Gremlin.Net.UnitTest.Process.Traversal Bytecode = new Bytecode(); } - public TestTraversal(IReadOnlyList<object> traverserObjs, IReadOnlyList<long> traverserBulks) + public TestTraversal(IReadOnlyList<object?> traverserObjs, IReadOnlyList<long> traverserBulks) { var traversers = new List<Traverser>(traverserObjs.Count); traversers.AddRange(traverserObjs.Select((t, i) => new Traverser(t, traverserBulks[i]))); @@ -50,6 +50,6 @@ namespace Gremlin.Net.UnitTest.Process.Traversal TraversalStrategies = traversalStrategies; } - public override Bytecode Bytecode { get; } + public override Bytecode Bytecode { get; } = new(); } } \ No newline at end of file diff --git a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/Translator/GroovyTranslatorTests.cs b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/Translator/GroovyTranslatorTests.cs index bf1d4f1675..057e4f507f 100644 --- a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/Translator/GroovyTranslatorTests.cs +++ b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/Translator/GroovyTranslatorTests.cs @@ -486,7 +486,7 @@ public class GroovyTranslatorTests } } - private void AssertTranslation(string expectedTranslation, params object[] objs) + private void AssertTranslation(string expectedTranslation, params object?[]? objs) { AssertTraversalTranslation($"g.inject({expectedTranslation})", _g.Inject(objs)); } diff --git a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/TraversalTests.cs b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/TraversalTests.cs index 5f87dffd06..0ed745b0c1 100644 --- a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/TraversalTests.cs +++ b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/TraversalTests.cs @@ -36,7 +36,7 @@ namespace Gremlin.Net.UnitTest.Process.Traversal [InlineData("test")] public void ShouldReturnAvailableTraverserObjWhenNextIsCalled(object traverserObj) { - var traversal = new TestTraversal(new List<object> {traverserObj}); + var traversal = new TestTraversal(new List<object?> {traverserObj}); var actualObj = traversal.Next(); @@ -49,7 +49,7 @@ namespace Gremlin.Net.UnitTest.Process.Traversal [InlineData("test")] public void ShouldCheckHasNext(object traverserObj) { - var traversal = new TestTraversal(new List<object> {traverserObj}); + var traversal = new TestTraversal(new List<object?> {traverserObj}); Assert.True(traversal.HasNext()); Assert.True(traversal.HasNext()); @@ -66,7 +66,7 @@ namespace Gremlin.Net.UnitTest.Process.Traversal [InlineData(10)] public void ShouldReturnCorrectNrOfResultObjsWhenNextIsCalledWithAmountArgument(int nrOfResults) { - var objs = new List<object>(20); + var objs = new List<object?>(20); for (var i = 0; i < 20; i++) objs.Add(i); var traversal = new TestTraversal(objs); @@ -79,9 +79,9 @@ namespace Gremlin.Net.UnitTest.Process.Traversal Assert.Equal(objs[i], traversedObjsList[i]); } - private List<object> UnfoldBulks(IReadOnlyList<object> objs, IReadOnlyList<long> bulks) + private List<object?> UnfoldBulks(IReadOnlyList<object?> objs, IReadOnlyList<long> bulks) { - var unfoldedObjs = new List<object>(); + var unfoldedObjs = new List<object?>(); for (var traverserIdx = 0; traverserIdx < objs.Count; traverserIdx++) for (var currentBulkObjIdx = 0; currentBulkObjIdx < bulks[traverserIdx]; currentBulkObjIdx++) unfoldedObjs.Add(objs[traverserIdx]); @@ -91,7 +91,7 @@ namespace Gremlin.Net.UnitTest.Process.Traversal [Fact] public void ShouldDrainAllTraversersWhenIterateIsCalled() { - var someObjs = new List<object> {1, 2, 3}; + var someObjs = new List<object?> {1, 2, 3}; var traversal = new TestTraversal(someObjs); var drainedTraversal = traversal.Iterate(); @@ -103,7 +103,7 @@ namespace Gremlin.Net.UnitTest.Process.Traversal public void ShouldReturnNullWhenNextIsCalledAndNoTraverserIsAvailable() { var expectedFirstObj = 1; - var traversal = new TestTraversal(new List<object> {expectedFirstObj}); + var traversal = new TestTraversal(new List<object?> {expectedFirstObj}); var actualFirstObj = traversal.Next(); var actualSecondObj = traversal.Next(); @@ -115,18 +115,18 @@ namespace Gremlin.Net.UnitTest.Process.Traversal [Fact] public void ShouldReturnTraversalsTraverserWhenNextTraverserIsCalled() { - var someObjs = new List<object> {1, 2, 3}; + var someObjs = new List<object?> {1, 2, 3}; var traversal = new TestTraversal(someObjs); var traverser = traversal.NextTraverser(); - Assert.Equal(traversal.Traversers.First(), traverser); + Assert.Equal(traversal.Traversers!.First(), traverser); } [Fact] public void ShouldThrowNotSupportedExceptionWhenResetIsCalled() { - var someObjs = new List<object> {1, 2, 3}; + var someObjs = new List<object?> {1, 2, 3}; var traversal = new TestTraversal(someObjs); Assert.Throws<NotSupportedException>(() => traversal.Reset()); @@ -135,7 +135,7 @@ namespace Gremlin.Net.UnitTest.Process.Traversal [Fact] public void ShouldReturnAllTraverserObjsWhenToListIsCalled() { - var expectedObjs = new List<object> {1, 2, 3}; + var expectedObjs = new List<object?> {1, 2, 3}; var traversal = new TestTraversal(expectedObjs); var traversedObjs = traversal.ToList(); @@ -146,13 +146,13 @@ namespace Gremlin.Net.UnitTest.Process.Traversal [Fact] public void ShouldReturnAllTraverserObjWithoutDuplicatesWhenToSetIsCalled() { - var traverserObjs = new List<object> {1, 1, 2, 3}; + var traverserObjs = new List<object?> {1, 1, 2, 3}; var traversal = new TestTraversal(traverserObjs); var traversedObjSet = traversal.ToSet(); Assert.Equal(3, traversedObjSet.Count); - Assert.Equal(new HashSet<object>(traverserObjs), traversedObjSet); + Assert.Equal(new HashSet<object?>(traverserObjs), traversedObjSet); } [Fact] @@ -170,7 +170,7 @@ namespace Gremlin.Net.UnitTest.Process.Traversal [Fact] public void ShouldBeUnfoldTraverserBulksWhenToListIsCalled() { - var objs = new List<object> {1, 2, 3}; + var objs = new List<object?> {1, 2, 3}; var bulks = new List<long> {3, 2, 1}; var traversal = new TestTraversal(objs, bulks); diff --git a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphBinary/GraphBinaryMessageSerializerTests.cs b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphBinary/GraphBinaryMessageSerializerTests.cs index 5510678f01..e175300d3a 100644 --- a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphBinary/GraphBinaryMessageSerializerTests.cs +++ b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphBinary/GraphBinaryMessageSerializerTests.cs @@ -77,7 +77,7 @@ namespace Gremlin.Net.UnitTest.Structure.IO.GraphBinary var serializer = CreateMessageSerializer(); await Assert.ThrowsAsync<TaskCanceledException>(async () => - await serializer.SerializeMessageAsync(RequestMessage.Build(default).Create(), + await serializer.SerializeMessageAsync(RequestMessage.Build(string.Empty).Create(), new CancellationToken(true))); } diff --git a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphBinary/GraphBinaryTests.cs b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphBinary/GraphBinaryTests.cs index d50c82e303..47a190b500 100644 --- a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphBinary/GraphBinaryTests.cs +++ b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphBinary/GraphBinaryTests.cs @@ -409,7 +409,7 @@ namespace Gremlin.Net.UnitTest.Structure.IO.GraphBinary var writer = CreateGraphBinaryWriter(); var serializationStream = new MemoryStream(); - await Assert.ThrowsAsync<IOException>(() => writer.WriteNonNullableValueAsync(null, serializationStream)); + await Assert.ThrowsAsync<IOException>(() => writer.WriteNonNullableValueAsync(null!, serializationStream)); } [Fact] @@ -434,7 +434,7 @@ namespace Gremlin.Net.UnitTest.Structure.IO.GraphBinary new Path( new List<ISet<string>> {new HashSet<string> {"a", "b"}, new HashSet<string> {"c", "d"}, new HashSet<string> {"e"}}, - new List<object> {1, 2, 3}); + new List<object?> {1, 2, 3}); var writer = CreateGraphBinaryWriter(); var reader = CreateGraphBinaryReader(); var serializationStream = new MemoryStream(); @@ -669,9 +669,9 @@ namespace Gremlin.Net.UnitTest.Structure.IO.GraphBinary await writer.WriteAsync(expected, serializationStream); serializationStream.Position = 0; - var actual = (Bytecode) await reader.ReadAsync(serializationStream); + var actual = (Bytecode?) await reader.ReadAsync(serializationStream); - Assert.Equal(expected.SourceInstructions, actual.SourceInstructions); + Assert.Equal(expected.SourceInstructions, actual!.SourceInstructions); Assert.Equal(expected.StepInstructions, actual.StepInstructions); } @@ -801,9 +801,9 @@ namespace Gremlin.Net.UnitTest.Structure.IO.GraphBinary await writer.WriteAsync(expected, serializationStream); serializationStream.Position = 0; - var actual = (StringBasedLambda) await reader.ReadAsync(serializationStream); + var actual = (StringBasedLambda?) await reader.ReadAsync(serializationStream); - Assert.Equal(expected.Language, actual.Language); + Assert.Equal(expected.Language, actual!.Language); Assert.Equal(expected.LambdaExpression, actual.LambdaExpression); Assert.Equal(expected.Arguments, actual.Arguments); } @@ -818,9 +818,9 @@ namespace Gremlin.Net.UnitTest.Structure.IO.GraphBinary await writer.WriteAsync(expected, serializationStream); serializationStream.Position = 0; - var actual = (P) await reader.ReadAsync(serializationStream); + var actual = (P?) await reader.ReadAsync(serializationStream); - Assert.Equal(expected.OperatorName, actual.OperatorName); + Assert.Equal(expected.OperatorName, actual!.OperatorName); Assert.Equal(expected.Other, actual.Other); Assert.Equal(expected.Value, actual.Value); } @@ -835,9 +835,9 @@ namespace Gremlin.Net.UnitTest.Structure.IO.GraphBinary await writer.WriteAsync(expected, serializationStream); serializationStream.Position = 0; - var actual = (P) await reader.ReadAsync(serializationStream); + var actual = (P?) await reader.ReadAsync(serializationStream); - Assert.Equal(expected.OperatorName, actual.OperatorName); + Assert.Equal(expected.OperatorName, actual!.OperatorName); Assert.Equal(expected.Other, actual.Other); Assert.Equal(expected.Value, actual.Value); } @@ -852,9 +852,9 @@ namespace Gremlin.Net.UnitTest.Structure.IO.GraphBinary await writer.WriteAsync(expected, serializationStream); serializationStream.Position = 0; - var actual = (P) await reader.ReadAsync(serializationStream); + var actual = (P?) await reader.ReadAsync(serializationStream); - Assert.Equal(expected.ToString(), actual.ToString()); + Assert.Equal(expected.ToString(), actual!.ToString()); } [Fact] @@ -867,9 +867,9 @@ namespace Gremlin.Net.UnitTest.Structure.IO.GraphBinary await writer.WriteAsync(expected, serializationStream); serializationStream.Position = 0; - var actual = (TextP) await reader.ReadAsync(serializationStream); + var actual = (TextP?) await reader.ReadAsync(serializationStream); - Assert.Equal(expected.OperatorName, actual.OperatorName); + Assert.Equal(expected.OperatorName, actual!.OperatorName); Assert.Equal(expected.Other, actual.Other); Assert.Equal(expected.Value, actual.Value); } @@ -884,9 +884,9 @@ namespace Gremlin.Net.UnitTest.Structure.IO.GraphBinary await writer.WriteAsync(expected, serializationStream); serializationStream.Position = 0; - var actual = (Traverser) await reader.ReadAsync(serializationStream); + var actual = (Traverser?) await reader.ReadAsync(serializationStream); - Assert.Equal(expected.Object, actual.Object); + Assert.Equal(expected.Object, actual!.Object); Assert.Equal(expected.Bulk, actual.Bulk); } diff --git a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphBinary/Types/Sample/SamplePerson.cs b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphBinary/Types/Sample/SamplePerson.cs index e474f30158..40627c8ba6 100644 --- a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphBinary/Types/Sample/SamplePerson.cs +++ b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphBinary/Types/Sample/SamplePerson.cs @@ -36,14 +36,14 @@ namespace Gremlin.Net.UnitTest.Structure.IO.GraphBinary.Types.Sample public string Name { get; } public DateTimeOffset BirthDate { get; } - public bool Equals(SamplePerson other) + public bool Equals(SamplePerson? other) { if (ReferenceEquals(null, other)) return false; if (ReferenceEquals(this, other)) return true; return Name == other.Name && BirthDate.Equals(other.BirthDate); } - 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/test/Gremlin.Net.UnitTest/Structure/IO/GraphBinary/Types/Sample/SamplePersonSerializer.cs b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphBinary/Types/Sample/SamplePersonSerializer.cs index 6145f6d23b..172d167b07 100644 --- a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphBinary/Types/Sample/SamplePersonSerializer.cs +++ b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphBinary/Types/Sample/SamplePersonSerializer.cs @@ -86,7 +86,7 @@ namespace Gremlin.Net.UnitTest.Structure.IO.GraphBinary.Types.Sample .ConfigureAwait(false); } - public override async Task<object> ReadAsync(Stream stream, GraphBinaryReader reader, + public override async Task<object?> ReadAsync(Stream stream, GraphBinaryReader reader, CancellationToken cancellationToken = default) { // {custom type info}, {value_flag} and {value} @@ -99,7 +99,7 @@ namespace Gremlin.Net.UnitTest.Structure.IO.GraphBinary.Types.Sample return await ReadNullableValueAsync(stream, reader, cancellationToken).ConfigureAwait(false); } - public override async Task<object> ReadNullableValueAsync(Stream stream, GraphBinaryReader reader, + public override async Task<object?> ReadNullableValueAsync(Stream stream, GraphBinaryReader reader, CancellationToken cancellationToken = default) { var valueFlag = await stream.ReadByteAsync(cancellationToken).ConfigureAwait(false); diff --git a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphBinary/Types/Sample/SamplePersonSerializerTests.cs b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphBinary/Types/Sample/SamplePersonSerializerTests.cs index 908e03f90d..e023a9188a 100644 --- a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphBinary/Types/Sample/SamplePersonSerializerTests.cs +++ b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphBinary/Types/Sample/SamplePersonSerializerTests.cs @@ -43,7 +43,7 @@ namespace Gremlin.Net.UnitTest.Structure.IO.GraphBinary.Types.Sample await writer.WriteAsync(expected, serializationStream); serializationStream.Position = 0; - var actual = (SamplePerson) await reader.ReadAsync(serializationStream); + var actual = (SamplePerson?) await reader.ReadAsync(serializationStream); Assert.Equal(expected, actual); } @@ -60,7 +60,7 @@ namespace Gremlin.Net.UnitTest.Structure.IO.GraphBinary.Types.Sample await writer.WriteNullableValueAsync(expected, serializationStream).ConfigureAwait(false); serializationStream.Position = 0; - var actual = (SamplePerson)await reader.ReadNullableValueAsync<SamplePerson>(serializationStream) + var actual = (SamplePerson?)await reader.ReadNullableValueAsync<SamplePerson>(serializationStream) .ConfigureAwait(false); Assert.Equal(expected, actual); diff --git a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/GraphSON3MessageSerializerTests.cs b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/GraphSON3MessageSerializerTests.cs index df75dc2db8..d1b593b06a 100644 --- a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/GraphSON3MessageSerializerTests.cs +++ b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/GraphSON3MessageSerializerTests.cs @@ -38,7 +38,7 @@ public class GraphSON3MessageSerializerTests var serializer = CreateMessageSerializer(); await Assert.ThrowsAsync<OperationCanceledException>(async () => - await serializer.SerializeMessageAsync(RequestMessage.Build(default).Create(), + await serializer.SerializeMessageAsync(RequestMessage.Build(string.Empty).Create(), new CancellationToken(true))); } diff --git a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/GraphSONReaderTests.cs b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/GraphSONReaderTests.cs index 2c33a1e034..82aeeb02f6 100644 --- a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/GraphSONReaderTests.cs +++ b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/GraphSONReaderTests.cs @@ -74,7 +74,7 @@ namespace Gremlin.Net.UnitTest.Structure.IO.GraphSON var jsonElement = JsonSerializer.Deserialize<JsonElement>(graphSON); var deserializedValue = reader.ToObject(jsonElement); - Assert.Equal("test", deserializedValue.Value); + Assert.Equal("test", deserializedValue!.Value); } [Fact] @@ -118,7 +118,7 @@ namespace Gremlin.Net.UnitTest.Structure.IO.GraphSON var jsonElement = JsonSerializer.Deserialize<JsonElement>(serializedDict); var deserializedValue = reader.ToObject(jsonElement); - var expectedDict = new Dictionary<string, dynamic> + var expectedDict = new Dictionary<string, dynamic?> { {"age", new List<object> {29}}, {"name", new List<object> {"marko"}}, @@ -136,7 +136,7 @@ namespace Gremlin.Net.UnitTest.Structure.IO.GraphSON var reader = CreateStandardGraphSONReader(version); var jsonElement = JsonSerializer.Deserialize<JsonElement>(graphSon); - Edge readEdge = reader.ToObject(jsonElement); + Edge readEdge = reader.ToObject(jsonElement)!; Assert.Equal((long) 17, readEdge.Id); Assert.Equal("knows", readEdge.Label); @@ -286,7 +286,7 @@ namespace Gremlin.Net.UnitTest.Structure.IO.GraphSON var jsonElement = JsonSerializer.Deserialize<JsonElement>(serializedValue); var deserializedValue = reader.ToObject(jsonElement); - Assert.Equal(new List<object> {5, 6, null}, deserializedValue); + Assert.Equal(new List<object?> {5, 6, null}, deserializedValue); } [Theory, MemberData(nameof(Versions))] @@ -296,7 +296,7 @@ namespace Gremlin.Net.UnitTest.Structure.IO.GraphSON var reader = CreateStandardGraphSONReader(version); var jsonElement = JsonSerializer.Deserialize<JsonElement>(graphSon); - T readT = reader.ToObject(jsonElement); + T readT = reader.ToObject(jsonElement)!; Assert.Equal(T.Label, readT); } @@ -333,7 +333,7 @@ namespace Gremlin.Net.UnitTest.Structure.IO.GraphSON var reader = CreateStandardGraphSONReader(2); var jsonElement = JsonSerializer.Deserialize<JsonElement>(graphSon); - Path readPath = reader.ToObject(jsonElement); + Path readPath = reader.ToObject(jsonElement)!; Assert.Equal("path[v[1], v[3], lop]", readPath.ToString()); Assert.Equal(new Vertex(1), readPath[0]); @@ -351,7 +351,7 @@ namespace Gremlin.Net.UnitTest.Structure.IO.GraphSON var reader = CreateStandardGraphSONReader(3); var jsonElement = JsonSerializer.Deserialize<JsonElement>(graphSon); - Path readPath = reader.ToObject(jsonElement); + Path readPath = reader.ToObject(jsonElement)!; Assert.Equal("path[v[5]]", readPath.ToString()); Assert.Equal(new Vertex(5L), readPath[0]); @@ -370,13 +370,13 @@ namespace Gremlin.Net.UnitTest.Structure.IO.GraphSON var reader = CreateStandardGraphSONReader(version); var jsonElement = JsonSerializer.Deserialize<JsonElement>(graphSon); - Property readProperty = reader.ToObject(jsonElement); + Property readProperty = reader.ToObject(jsonElement)!; Assert.Equal("aKey", readProperty.Key); Assert.Equal((long) 17, readProperty.Value); - Assert.Equal(typeof(Edge), readProperty.Element.GetType()); + Assert.Equal(typeof(Edge), readProperty.Element!.GetType()); var edge = readProperty.Element as Edge; - Assert.Equal((long) 122, edge.Id); + Assert.Equal((long) 122, edge!.Id); Assert.Equal("knows", edge.Label); Assert.Equal("x", edge.InV.Id); Assert.Equal("y", edge.OutV.Id); @@ -415,7 +415,7 @@ namespace Gremlin.Net.UnitTest.Structure.IO.GraphSON var reader = CreateStandardGraphSONReader(version); var jsonElement = JsonSerializer.Deserialize<JsonElement>(graphSon); - VertexProperty readVertexProperty = reader.ToObject(jsonElement); + VertexProperty readVertexProperty = reader.ToObject(jsonElement)!; Assert.Equal("anId", readVertexProperty.Id); Assert.Equal("aKey", readVertexProperty.Label); @@ -431,7 +431,7 @@ namespace Gremlin.Net.UnitTest.Structure.IO.GraphSON var reader = CreateStandardGraphSONReader(version); var jsonElement = JsonSerializer.Deserialize<JsonElement>(graphSon); - VertexProperty readVertexProperty = reader.ToObject(jsonElement); + VertexProperty readVertexProperty = reader.ToObject(jsonElement)!; Assert.Equal(1, readVertexProperty.Id); Assert.Equal("name", readVertexProperty.Label); @@ -460,7 +460,7 @@ namespace Gremlin.Net.UnitTest.Structure.IO.GraphSON var reader = CreateStandardGraphSONReader(version); var jsonElement = JsonSerializer.Deserialize<JsonElement>(graphSon); - Vertex deserializedValue = reader.ToObject(jsonElement); + Vertex deserializedValue = reader.ToObject(jsonElement)!; Assert.Equal("person", deserializedValue.Label); } @@ -473,11 +473,11 @@ namespace Gremlin.Net.UnitTest.Structure.IO.GraphSON var reader = CreateStandardGraphSONReader(version); var jsonElement = JsonSerializer.Deserialize<JsonElement>(graphSon); - Vertex readVertex = reader.ToObject(jsonElement); + Vertex readVertex = reader.ToObject(jsonElement)!; Assert.Equal(new Vertex(1), readVertex); Assert.Equal("person", readVertex.Label); - Assert.Equal(typeof(int), readVertex.Id.GetType()); + Assert.Equal(typeof(int), readVertex.Id!.GetType()); } [Theory, MemberData(nameof(VersionsSupportingCollections))] @@ -576,7 +576,7 @@ namespace Gremlin.Net.UnitTest.Structure.IO.GraphSON var reader = CreateStandardGraphSONReader(version); var jsonElement = JsonSerializer.Deserialize<JsonElement>(json); - Traverser deserializedValue = reader.ToObject(jsonElement); + Traverser deserializedValue = reader.ToObject(jsonElement)!; Assert.Equal(10, deserializedValue.Bulk); Assert.Equal(1, deserializedValue.Object); diff --git a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/GraphSONWriterTests.cs b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/GraphSONWriterTests.cs index 92478318ac..3a4282366a 100644 --- a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/GraphSONWriterTests.cs +++ b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/GraphSONWriterTests.cs @@ -295,7 +295,7 @@ namespace Gremlin.Net.UnitTest.Structure.IO.GraphSON public void ShouldSerializeGList(int version) { var writer = CreateGraphSONWriter(version); - var list = new List<object> {5, 6, null}; + var list = new List<object?> {5, 6, null}; var serializedGraphSON = writer.WriteObject(list); @@ -552,7 +552,7 @@ namespace Gremlin.Net.UnitTest.Structure.IO.GraphSON internal class TestGraphSONSerializer : IGraphSONSerializer { - public string TestNamespace { get; set; } + public string? TestNamespace { get; set; } public Dictionary<string, dynamic> Dictify(dynamic objectData, GraphSONWriter writer) { diff --git a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/TestClass.cs b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/TestClass.cs index 13d1bca9e7..1fba9434a1 100644 --- a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/TestClass.cs +++ b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/TestClass.cs @@ -25,6 +25,6 @@ namespace Gremlin.Net.UnitTest.Structure.IO.GraphSON { internal class TestClass { - public dynamic Value { get; set; } + public dynamic? Value { get; set; } } } \ No newline at end of file diff --git a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/PathTests.cs b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/PathTests.cs index 6df92bac73..a996df124b 100644 --- a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/PathTests.cs +++ b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/PathTests.cs @@ -40,7 +40,7 @@ namespace Gremlin.Net.UnitTest.Structure new HashSet<string> {"c", "b"}, new HashSet<string>() }; - var objects = new List<object> {1, new Vertex(1), "hello"}; + var objects = new List<object?> {1, new Vertex(1), "hello"}; var path = new Path(labels, objects); @@ -57,7 +57,7 @@ namespace Gremlin.Net.UnitTest.Structure new HashSet<string> {"c", "b"}, new HashSet<string>() }; - var path = new Path(labels, new List<object>()); + var path = new Path(labels, new List<object?>()); var containsKey = path.ContainsKey("c"); @@ -73,7 +73,7 @@ namespace Gremlin.Net.UnitTest.Structure new HashSet<string> {"c", "b"}, new HashSet<string>() }; - var path = new Path(labels, new List<object>()); + var path = new Path(labels, new List<object?>()); var containsKey = path.ContainsKey("z"); @@ -83,7 +83,7 @@ namespace Gremlin.Net.UnitTest.Structure [Fact] public void ShouldReturnCountOfObjectsForCountProperty() { - var objects = new List<object> {1, new Vertex(1), "hello"}; + var objects = new List<object?> {1, new Vertex(1), "hello"}; var path = new Path(new List<ISet<string>>(), objects); var count = path.Count; @@ -94,7 +94,7 @@ namespace Gremlin.Net.UnitTest.Structure [Fact] public void ShouldEnumeratorObjectsIntoListWhenToListIsCalled() { - var objects = new List<object> {1, new Vertex(1), "hello"}; + var objects = new List<object?> {1, new Vertex(1), "hello"}; var path = new Path(new List<ISet<string>>(), objects); var enumeratedObj = path.ToList(); @@ -112,7 +112,7 @@ namespace Gremlin.Net.UnitTest.Structure new HashSet<string> {"a", "b"}, new HashSet<string> {"c", "b"}, new HashSet<string>() - }, new List<object> {1, new Vertex(1), "hello"}); + }, new List<object?> {1, new Vertex(1), "hello"}); var secondPath = new Path( new List<ISet<string>> @@ -120,7 +120,7 @@ namespace Gremlin.Net.UnitTest.Structure new HashSet<string> {"a", "b"}, new HashSet<string> {"c", "b"}, new HashSet<string>() - }, new List<object> {1, new Vertex(1), "hello"}); + }, new List<object?> {1, new Vertex(1), "hello"}); var equals = firstPath.Equals(secondPath); @@ -137,7 +137,7 @@ namespace Gremlin.Net.UnitTest.Structure new HashSet<string> {"a", "b"}, new HashSet<string> {"c", "b"}, new HashSet<string>() - }, new List<object> {1, new Vertex(1), "hello"}); + }, new List<object?> {1, new Vertex(1), "hello"}); var secondPath = new Path( new List<ISet<string>> @@ -145,7 +145,7 @@ namespace Gremlin.Net.UnitTest.Structure new HashSet<string> {"a"}, new HashSet<string> {"c", "b"}, new HashSet<string>() - }, new List<object> {1, new Vertex(1), "hello"}); + }, new List<object?> {1, new Vertex(1), "hello"}); var equals = firstPath.Equals(secondPath); @@ -162,7 +162,7 @@ namespace Gremlin.Net.UnitTest.Structure new HashSet<string> {"a", "b"}, new HashSet<string> {"c", "b"}, new HashSet<string>() - }, new List<object> {1, new Vertex(1), "hello"}); + }, new List<object?> {1, new Vertex(1), "hello"}); var secondPath = new Path( new List<ISet<string>> @@ -170,7 +170,7 @@ namespace Gremlin.Net.UnitTest.Structure new HashSet<string> {"a", "b"}, new HashSet<string> {"c", "b"}, new HashSet<string>() - }, new List<object> {3, new Vertex(1), "hello"}); + }, new List<object?> {3, new Vertex(1), "hello"}); var equals = firstPath.Equals(secondPath); @@ -187,7 +187,7 @@ namespace Gremlin.Net.UnitTest.Structure new HashSet<string> {"a", "b"}, new HashSet<string> {"c", "b"}, new HashSet<string>() - }, new List<object> { 1, new Vertex(1), "hello" }); + }, new List<object?> { 1, new Vertex(1), "hello" }); object secondPath = new Path( new List<ISet<string>> @@ -195,7 +195,7 @@ namespace Gremlin.Net.UnitTest.Structure new HashSet<string> {"a", "b"}, new HashSet<string> {"c", "b"}, new HashSet<string>() - }, new List<object> { 1, new Vertex(1), "hello" }); + }, new List<object?> { 1, new Vertex(1), "hello" }); var equals = firstPath.Equals(secondPath); @@ -212,7 +212,7 @@ namespace Gremlin.Net.UnitTest.Structure new HashSet<string> {"a", "b"}, new HashSet<string> {"c", "b"}, new HashSet<string>() - }, new List<object> { 1, new Vertex(1), "hello" }); + }, new List<object?> { 1, new Vertex(1), "hello" }); object secondPath = new Path( new List<ISet<string>> @@ -220,7 +220,7 @@ namespace Gremlin.Net.UnitTest.Structure new HashSet<string> {"a"}, new HashSet<string> {"c", "b"}, new HashSet<string>() - }, new List<object> { 1, new Vertex(1), "hello" }); + }, new List<object?> { 1, new Vertex(1), "hello" }); var equals = firstPath.Equals(secondPath); @@ -237,7 +237,7 @@ namespace Gremlin.Net.UnitTest.Structure new HashSet<string> {"a", "b"}, new HashSet<string> {"c", "b"}, new HashSet<string>() - }, new List<object> { 1, new Vertex(1), "hello" }); + }, new List<object?> { 1, new Vertex(1), "hello" }); object secondPath = new Path( new List<ISet<string>> @@ -245,7 +245,7 @@ namespace Gremlin.Net.UnitTest.Structure new HashSet<string> {"a", "b"}, new HashSet<string> {"c", "b"}, new HashSet<string>() - }, new List<object> { 3, new Vertex(1), "hello" }); + }, new List<object?> { 3, new Vertex(1), "hello" }); var equals = firstPath.Equals(secondPath); @@ -255,7 +255,7 @@ namespace Gremlin.Net.UnitTest.Structure [Fact] public void ShouldReturnFalseForEqualsWhereOtherIsNull() { - var path = new Path(new List<ISet<string>> {new HashSet<string> {"a", "b"},}, new List<object> {1}); + var path = new Path(new List<ISet<string>> { new HashSet<string> { "a", "b" }, }, new List<object?> { 1 }); var equals = path.Equals(null); @@ -272,7 +272,7 @@ namespace Gremlin.Net.UnitTest.Structure new HashSet<string> {"a", "b"}, new HashSet<string> {"c", "b"}, new HashSet<string>() - }, new List<object> { 1, new Vertex(1), "hello" }); + }, new List<object?> { 1, new Vertex(1), "hello" }); var secondPath = new Path( new List<ISet<string>> @@ -280,7 +280,7 @@ namespace Gremlin.Net.UnitTest.Structure new HashSet<string> {"a", "b"}, new HashSet<string> {"c", "b"}, new HashSet<string>() - }, new List<object> { 1, new Vertex(1), "hello" }); + }, new List<object?> { 1, new Vertex(1), "hello" }); var firstHashCode = firstPath.GetHashCode(); var secondHashCode = secondPath.GetHashCode(); @@ -291,7 +291,7 @@ namespace Gremlin.Net.UnitTest.Structure [Fact] public void ShouldThrowWhenInvalidIndexIsAccessed() { - var objects = new List<object> {1, new Vertex(1), "hello"}; + var objects = new List<object?> {1, new Vertex(1), "hello"}; var path = new Path(new List<ISet<string>>(), objects); Assert.Throws<ArgumentOutOfRangeException>(() => path[3]); @@ -300,7 +300,7 @@ namespace Gremlin.Net.UnitTest.Structure [Fact] public void ShouldReturnObjectsByTheirIndex() { - var objects = new List<object> {1, new Vertex(1), "hello"}; + var objects = new List<object?> {1, new Vertex(1), "hello"}; var path = new Path(new List<ISet<string>>(), objects); Assert.Equal(1, path[0]); @@ -317,7 +317,7 @@ namespace Gremlin.Net.UnitTest.Structure new HashSet<string> {"c", "b"}, new HashSet<string>() }; - var objects = new List<object> {1, new Vertex(1), "hello"}; + var objects = new List<object?> {1, new Vertex(1), "hello"}; var path = new Path(labels, objects); var bObjects = path["b"]; @@ -334,7 +334,7 @@ namespace Gremlin.Net.UnitTest.Structure new HashSet<string> {"c", "b"}, new HashSet<string>() }; - var objects = new List<object> {1, new Vertex(1), "hello"}; + var objects = new List<object?> {1, new Vertex(1), "hello"}; var path = new Path(labels, objects); Assert.Equal(1, path["a"]); @@ -345,7 +345,7 @@ namespace Gremlin.Net.UnitTest.Structure [Fact] public void ShouldThrowWhenUnknownKeyIsAccessed() { - var path = new Path(new List<ISet<string>>(), new List<object>()); + var path = new Path(new List<ISet<string>>(), new List<object?>()); Assert.Throws<KeyNotFoundException>(() => path["unknownKey"]); } @@ -359,7 +359,7 @@ namespace Gremlin.Net.UnitTest.Structure new HashSet<string> {"c", "b"}, new HashSet<string>() }; - var objects = new List<object> {1, new Vertex(1), "hello"}; + var objects = new List<object?> {1, new Vertex(1), "hello"}; var path = new Path(labels, objects); var pathStr = path.ToString(); @@ -376,10 +376,10 @@ namespace Gremlin.Net.UnitTest.Structure new HashSet<string> {"c", "b"}, new HashSet<string>() }; - var objects = new List<object> {1, new Vertex(1), "hello"}; + var objects = new List<object?> {1, new Vertex(1), "hello"}; var path = new Path(labels, objects); - var success = path.TryGetValue("b", out object actualObj); + var success = path.TryGetValue("b", out object? actualObj); Assert.True(success); Assert.Equal(new List<object> {1, new Vertex(1)}, actualObj); @@ -394,10 +394,10 @@ namespace Gremlin.Net.UnitTest.Structure new HashSet<string> {"c", "b"}, new HashSet<string>() }; - var objects = new List<object> {1, new Vertex(1), "hello"}; + var objects = new List<object?> {1, new Vertex(1), "hello"}; var path = new Path(labels, objects); - var success = path.TryGetValue("b", out object actualObj); + var success = path.TryGetValue("b", out var actualObj); Assert.True(success); Assert.Equal(new Vertex(1), actualObj); @@ -406,9 +406,9 @@ namespace Gremlin.Net.UnitTest.Structure [Fact] public void ShouldReturnFalseForTryGetWhenUnknownKeyIsProvided() { - var path = new Path(new List<ISet<string>>(), new List<object>()); + var path = new Path(new List<ISet<string>>(), new List<object?>()); - var success = path.TryGetValue("unknownKey", out object _); + var success = path.TryGetValue("unknownKey", out _); Assert.False(success); }
