diff --git a/src/Apache.Arrow/Arrays/LargeStringArray.cs b/src/Apache.Arrow/Arrays/LargeStringArray.cs index e97683f..a12bae6 100644 --- a/src/Apache.Arrow/Arrays/LargeStringArray.cs +++ b/src/Apache.Arrow/Arrays/LargeStringArray.cs @@ -81,7 +81,7 @@ IEnumerator IEnumerable.GetEnumerator() for (int index = 0; index < Length; index++) { yield return GetString(index); - }; + } } IEnumerator IEnumerable.GetEnumerator() => ((IEnumerable)this).GetEnumerator(); diff --git a/src/Apache.Arrow/Arrays/StringArray.cs b/src/Apache.Arrow/Arrays/StringArray.cs index 6df1011..918f828 100644 --- a/src/Apache.Arrow/Arrays/StringArray.cs +++ b/src/Apache.Arrow/Arrays/StringArray.cs @@ -160,7 +160,7 @@ IEnumerator IEnumerable.GetEnumerator() for (int index = 0; index < Length; index++) { yield return GetString(index); - }; + } } IEnumerator IEnumerable.GetEnumerator() => ((IEnumerable)this).GetEnumerator(); diff --git a/src/Apache.Arrow/Arrays/StringViewArray.cs b/src/Apache.Arrow/Arrays/StringViewArray.cs index 96eeb19..5411d6b 100644 --- a/src/Apache.Arrow/Arrays/StringViewArray.cs +++ b/src/Apache.Arrow/Arrays/StringViewArray.cs @@ -102,7 +102,7 @@ IEnumerator IEnumerable.GetEnumerator() for (int index = 0; index < Length; index++) { yield return GetString(index); - }; + } } IEnumerator IEnumerable.GetEnumerator() => ((IEnumerable)this).GetEnumerator(); diff --git a/src/Apache.Arrow/Arrays/TimestampArray.cs b/src/Apache.Arrow/Arrays/TimestampArray.cs index ffc6471..28aa1d1 100644 --- a/src/Apache.Arrow/Arrays/TimestampArray.cs +++ b/src/Apache.Arrow/Arrays/TimestampArray.cs @@ -156,7 +156,7 @@ public DateTimeOffset GetTimestampUnchecked(int index) for (int index = 0; index < Length; index++) { yield return GetTimestamp(index); - }; + } } int ICollection.Count => Length; diff --git a/src/Apache.Arrow/C/CArrowSchemaExporter.cs b/src/Apache.Arrow/C/CArrowSchemaExporter.cs index 1cf6dc7..4258174 100644 --- a/src/Apache.Arrow/C/CArrowSchemaExporter.cs +++ b/src/Apache.Arrow/C/CArrowSchemaExporter.cs @@ -253,7 +253,7 @@ private static long GetFlags(IArrowType datatype, bool nullable = true) if (numFields == 0) { throw new NotSupportedException("Exporting nested data types with zero children."); - }; + } var pointerList = (CArrowSchema**)Marshal.AllocHGlobal(numFields * IntPtr.Size); diff --git a/src/Apache.Arrow/Ipc/ArrowStreamReaderImplementation.cs b/src/Apache.Arrow/Ipc/ArrowStreamReaderImplementation.cs index c1daae9..0b9de1d 100644 --- a/src/Apache.Arrow/Ipc/ArrowStreamReaderImplementation.cs +++ b/src/Apache.Arrow/Ipc/ArrowStreamReaderImplementation.cs @@ -240,7 +240,7 @@ private async ValueTask ReadMessageLengthAsync(bool throwOnFullRead, bool r messageLength = BitUtility.ReadInt32(lengthBuffer); } - }; + } return messageLength; } diff --git a/test/Apache.Arrow.Flight.IntegrationTest/Apache.Arrow.Flight.IntegrationTest.csproj b/test/Apache.Arrow.Flight.IntegrationTest/Apache.Arrow.Flight.IntegrationTest.csproj index 3403062..93d5b62 100644 --- a/test/Apache.Arrow.Flight.IntegrationTest/Apache.Arrow.Flight.IntegrationTest.csproj +++ b/test/Apache.Arrow.Flight.IntegrationTest/Apache.Arrow.Flight.IntegrationTest.csproj @@ -8,7 +8,7 @@ - + diff --git a/test/Apache.Arrow.Flight.IntegrationTest/Program.cs b/test/Apache.Arrow.Flight.IntegrationTest/Program.cs index 24d39de..97a0d1c 100644 --- a/test/Apache.Arrow.Flight.IntegrationTest/Program.cs +++ b/test/Apache.Arrow.Flight.IntegrationTest/Program.cs @@ -13,7 +13,9 @@ // See the License for the specific language governing permissions and // limitations under the License. +using System; using System.CommandLine; +using System.CommandLine.Parsing; using System.IO; using System.Threading.Tasks; @@ -23,18 +25,18 @@ public static class Program { public static async Task Main(string[] args) { - var portOption = new Option( - new[] { "--port", "-p" }, - description: "Port the Flight server is listening on"); - var scenarioOption = new Option( - new[] { "--scenario", "-s" }, - "The name of the scenario to run"); - var pathOption = new Option( - new[] { "--path", "-j" }, - "Path to a JSON file of test data"); - - var rootCommand = new RootCommand( - "Integration test application for Apache.Arrow .NET Flight."); + var portOption = new Option("--port", "-p") + { + Description = "Port the Flight server is listening on", + }; + var scenarioOption = new Option("--scenario", "-s") + { + Description = "The name of the scenario to run", + }; + var pathOption = new Option("--path", "-j") + { + Description = "Path to a JSON file of test data", + }; var clientCommand = new Command("client", "Run the Flight client") { @@ -42,26 +44,42 @@ public static async Task Main(string[] args) scenarioOption, pathOption, }; - rootCommand.AddCommand(clientCommand); - - clientCommand.SetHandler(async (port, scenario, jsonFile) => + clientCommand.SetAction(async (parseResult, cancellationToken) => { - var command = new FlightClientCommand(port, scenario, jsonFile); + var command = new FlightClientCommand( + parseResult.GetValue(portOption), + parseResult.GetValue(scenarioOption), + parseResult.GetValue(pathOption)); await command.Execute().ConfigureAwait(false); - }, portOption, scenarioOption, pathOption); + }); var serverCommand = new Command("server", "Run the Flight server") { scenarioOption, }; - rootCommand.AddCommand(serverCommand); - - serverCommand.SetHandler(async scenario => + serverCommand.SetAction(async (parseResult, cancellationToken) => { - var command = new FlightServerCommand(scenario); + var command = new FlightServerCommand( + parseResult.GetValue(scenarioOption)); await command.Execute().ConfigureAwait(false); - }, scenarioOption); + }); + + var rootCommand = new RootCommand("Integration test application for Apache.Arrow .NET Flight.") + { + clientCommand, + serverCommand, + }; - return await rootCommand.InvokeAsync(args).ConfigureAwait(false); + ParseResult parseResult = rootCommand.Parse(args); + if (parseResult.Errors.Count == 0) + { + return await parseResult.InvokeAsync(); + } + + foreach (ParseError parseError in parseResult.Errors) + { + Console.Error.WriteLine(parseError.Message); + } + return 1; } } diff --git a/test/Apache.Arrow.IntegrationTest/Apache.Arrow.IntegrationTest.csproj b/test/Apache.Arrow.IntegrationTest/Apache.Arrow.IntegrationTest.csproj index 2445151..b883ad5 100644 --- a/test/Apache.Arrow.IntegrationTest/Apache.Arrow.IntegrationTest.csproj +++ b/test/Apache.Arrow.IntegrationTest/Apache.Arrow.IntegrationTest.csproj @@ -8,7 +8,7 @@ - + diff --git a/test/Apache.Arrow.IntegrationTest/Program.cs b/test/Apache.Arrow.IntegrationTest/Program.cs index 8dedd60..bf993b2 100644 --- a/test/Apache.Arrow.IntegrationTest/Program.cs +++ b/test/Apache.Arrow.IntegrationTest/Program.cs @@ -14,13 +14,10 @@ // limitations under the License. using System; -using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; +using System.CommandLine.Parsing; using System.IO; -using System.Linq; using System.Threading.Tasks; -using Apache.Arrow.Types; namespace Apache.Arrow.IntegrationTest { @@ -28,27 +25,39 @@ public class Program { public static async Task Main(string[] args) { - var integrationTestCommand = new RootCommand + var modeOption = new Option("--mode") { - new Option( - "--mode", - description: "Which command to run"), - new Option( - new[] { "--json-file", "-j" }, - "The JSON file to interact with"), - new Option( - new[] { "--arrow-file", "-a" }, - "The arrow file to interact with") + Description = "Which command to run", + }; + var jsonFileOption = new Option("--json-file", "-j") + { + Description = "The JSON file to interact with", + }; + var arrowFileOption = new Option("--arrow-file", "-a") + { + Description = "The arrow file to interact with", }; - integrationTestCommand.Description = "Integration test app for Apache.Arrow .NET Library."; + var integrationTestCommand = new RootCommand("Integration test app for Apache.Arrow .NET Library.") + { + modeOption, jsonFileOption, arrowFileOption + }; + + ParseResult parseResult = integrationTestCommand.Parse(args); + if (parseResult.Errors.Count == 0) + { + var integrationCommand = new IntegrationCommand( + parseResult.GetValue(modeOption), + parseResult.GetValue(jsonFileOption), + parseResult.GetValue(arrowFileOption)); + return await integrationCommand.Execute(); + } - integrationTestCommand.Handler = CommandHandler.Create(async (mode, j, a) => + foreach (ParseError parseError in parseResult.Errors) { - var integrationCommand = new IntegrationCommand(mode, j, a); - await integrationCommand.Execute(); - }); - return await integrationTestCommand.InvokeAsync(args); + Console.Error.WriteLine(parseError.Message); + } + return 1; } } }