diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 8527556332..05c1bd2619 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -131,6 +131,13 @@ repos:
pass_filenames: true
files: '(^\.pre-commit-config\.yaml$)|(^\.github/workflows/.*\.(yml|yaml)$)'
entry: "./ci/scripts/run_pre_commit_pin.py"
+ - id: dotnet-format
+ name: C# Format
+ language: system
+ entry: |
+ dotnet format csharp/Apache.Arrow.Adbc.sln --verify-no-changes
+ always_run: true
+ pass_filenames: false
- repo: https://github.com/doublify/pre-commit-rust
rev: eeee35a89e69d5772bdee97db1a6a898467b686e # v1.0
hooks:
diff --git a/csharp/src/Apache.Arrow.Adbc/Extensions/IArrowArrayExtensions.cs b/csharp/src/Apache.Arrow.Adbc/Extensions/IArrowArrayExtensions.cs
index 2eaf75a9c8..acdf80e75f 100644
--- a/csharp/src/Apache.Arrow.Adbc/Extensions/IArrowArrayExtensions.cs
+++ b/csharp/src/Apache.Arrow.Adbc/Extensions/IArrowArrayExtensions.cs
@@ -238,7 +238,7 @@ public static class IArrowArrayExtensions
((Decimal256Array)array).GetString(index) :
((StringArray)array).GetString(index);
case ArrowTypeId.LargeString:
- return (array, index) =>((LargeStringArray)array).GetString(index);
+ return (array, index) => ((LargeStringArray)array).GetString(index);
#if NET6_0_OR_GREATER
case ArrowTypeId.Time32:
return (array, index) => ((Time32Array)array).GetTime(index);
diff --git a/csharp/src/Apache.Arrow.Adbc/Tracing/ActivityTrace.cs b/csharp/src/Apache.Arrow.Adbc/Tracing/ActivityTrace.cs
index 273fa930cd..a261cd2c63 100644
--- a/csharp/src/Apache.Arrow.Adbc/Tracing/ActivityTrace.cs
+++ b/csharp/src/Apache.Arrow.Adbc/Tracing/ActivityTrace.cs
@@ -267,7 +267,7 @@ public void Dispose()
///
/// If possible, gets the file version for the assembly associated with the given Type.
///
- [SuppressMessage("SingleFile", "IL3000", Justification="Using guard")]
+ [SuppressMessage("SingleFile", "IL3000", Justification = "Using guard")]
public static string GetAssemblyVersion(Type type)
{
var versionAttr = type.Assembly.GetCustomAttribute();
diff --git a/csharp/test/Apache.Arrow.Adbc.Tests/AdbcTests.cs b/csharp/test/Apache.Arrow.Adbc.Tests/AdbcTests.cs
index 3b55387b1d..347f127ef3 100644
--- a/csharp/test/Apache.Arrow.Adbc.Tests/AdbcTests.cs
+++ b/csharp/test/Apache.Arrow.Adbc.Tests/AdbcTests.cs
@@ -207,7 +207,7 @@ private string GetPathForAdbcH()
{
// find the adbc.h file from the repo
- string path = Path.Combine(new string[] { "..", "..", "..", "..", "..", "c", "include", "arrow-adbc", "adbc.h"});
+ string path = Path.Combine(new string[] { "..", "..", "..", "..", "..", "c", "include", "arrow-adbc", "adbc.h" });
Assert.True(File.Exists(path));
diff --git a/csharp/test/Apache.Arrow.Adbc.Tests/ClientTests.cs b/csharp/test/Apache.Arrow.Adbc.Tests/ClientTests.cs
index ac2d4159fa..0eeedb1d11 100644
--- a/csharp/test/Apache.Arrow.Adbc.Tests/ClientTests.cs
+++ b/csharp/test/Apache.Arrow.Adbc.Tests/ClientTests.cs
@@ -65,7 +65,7 @@ public static void CanClientExecuteUpdate(
int rows = adbcCommand.ExecuteNonQuery();
- Assert.True(expectedResults[i]==rows, Utils.FormatMessage("Expected results are not equal", environmentName));
+ Assert.True(expectedResults[i] == rows, Utils.FormatMessage("Expected results are not equal", environmentName));
}
}
@@ -187,7 +187,7 @@ public static void VerifyTypesAndValues(
{
var column_schema = reader.GetColumnSchema();
DataTable? dataTable = reader.GetSchemaTable();
- Assert.True(dataTable != null, Utils.FormatMessage("dataTable is null", environmentName) );
+ Assert.True(dataTable != null, Utils.FormatMessage("dataTable is null", environmentName));
Assert.True(reader.FieldCount == sample.ExpectedValues.Count, Utils.FormatMessage($"{sample.ExpectedValues.Count} fields were expected but {reader.FieldCount} fields were returned for the query [{sample.Query}]", environmentName));
diff --git a/csharp/test/Apache.Arrow.Adbc.Tests/Metadata/AdbcTable.cs b/csharp/test/Apache.Arrow.Adbc.Tests/Metadata/AdbcTable.cs
index 7f119f2957..6f3b133a31 100644
--- a/csharp/test/Apache.Arrow.Adbc.Tests/Metadata/AdbcTable.cs
+++ b/csharp/test/Apache.Arrow.Adbc.Tests/Metadata/AdbcTable.cs
@@ -42,6 +42,6 @@ public class AdbcTable
///
/// The constrains associated with the table.
///
- public List? Constraints { get; set; }
+ public List? Constraints { get; set; }
}
}
diff --git a/csharp/test/Apache.Arrow.Adbc.Tests/TestBase.cs b/csharp/test/Apache.Arrow.Adbc.Tests/TestBase.cs
index 111540467f..15a8d342e2 100644
--- a/csharp/test/Apache.Arrow.Adbc.Tests/TestBase.cs
+++ b/csharp/test/Apache.Arrow.Adbc.Tests/TestBase.cs
@@ -616,7 +616,8 @@ protected string DelimitIdentifier(string value)
protected static void AssertContainsAll(string[] expectedTexts, string value)
{
- if (expectedTexts == null) { return; };
+ if (expectedTexts == null) { return; }
+
foreach (string text in expectedTexts)
{
Assert.Contains(text, value);
diff --git a/csharp/test/Apache.Arrow.Adbc.Tests/Xunit/OrderAttribute.cs b/csharp/test/Apache.Arrow.Adbc.Tests/Xunit/OrderAttribute.cs
index 7831fdf96f..07c4042094 100644
--- a/csharp/test/Apache.Arrow.Adbc.Tests/Xunit/OrderAttribute.cs
+++ b/csharp/test/Apache.Arrow.Adbc.Tests/Xunit/OrderAttribute.cs
@@ -23,7 +23,7 @@ namespace Apache.Arrow.Adbc.Tests.Xunit
/// Used to specify the order of Xunit tests.
///
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
- public class OrderAttribute : Attribute
+ public class OrderAttribute : Attribute
{
public int Order { get; private set; }
diff --git a/csharp/test/Drivers/Interop/FlightSql/FlightSqlData.cs b/csharp/test/Drivers/Interop/FlightSql/FlightSqlData.cs
index 42c5a2323a..5cc2c3f247 100644
--- a/csharp/test/Drivers/Interop/FlightSql/FlightSqlData.cs
+++ b/csharp/test/Drivers/Interop/FlightSql/FlightSqlData.cs
@@ -262,7 +262,7 @@ private static SampleDataBuilder GetSpiceAISampleData()
StructBehavior = "Strict",
Query = "SELECT " +
"ARRAY[n_regionkey, n_nationkey] AS \"List\", " +
- "struct(n_regionkey, 'Test Value') AS Struct "+
+ "struct(n_regionkey, 'Test Value') AS Struct " +
"FROM nation WHERE n_regionkey = 0 AND n_nationkey = 5",
ExpectedValues = new List()
{
diff --git a/csharp/test/Drivers/Interop/FlightSql/FlightSqlTestingUtils.cs b/csharp/test/Drivers/Interop/FlightSql/FlightSqlTestingUtils.cs
index 22fde0ce07..74d0b776b1 100644
--- a/csharp/test/Drivers/Interop/FlightSql/FlightSqlTestingUtils.cs
+++ b/csharp/test/Drivers/Interop/FlightSql/FlightSqlTestingUtils.cs
@@ -45,14 +45,14 @@ out Dictionary parameters
{
// see https://arrow.apache.org/adbc/main/driver/flight_sql.html
- parameters = new Dictionary{};
+ parameters = new Dictionary { };
- if(!string.IsNullOrEmpty(environment.Uri))
+ if (!string.IsNullOrEmpty(environment.Uri))
{
parameters.Add(FlightSqlParameters.Uri, environment.Uri!);
}
- foreach(string key in environment.RPCCallHeaders.Keys)
+ foreach (string key in environment.RPCCallHeaders.Keys)
{
parameters.Add(FlightSqlParameters.OptionRPCCallHeaderPrefix + key, environment.RPCCallHeaders[key]);
}
diff --git a/csharp/test/Telemetry/Traces/Exporters/FileExporter/FileExporterTests.cs b/csharp/test/Telemetry/Traces/Exporters/FileExporter/FileExporterTests.cs
index 4e62ea67b3..66e6b4fa34 100644
--- a/csharp/test/Telemetry/Traces/Exporters/FileExporter/FileExporterTests.cs
+++ b/csharp/test/Telemetry/Traces/Exporters/FileExporter/FileExporterTests.cs
@@ -21,11 +21,11 @@
using System.Linq;
using System.Text;
using System.Threading.Tasks;
+using Apache.Arrow.Adbc.Telemetry.Traces.Exporters.FileExporter;
using OpenTelemetry;
using OpenTelemetry.Trace;
using Xunit;
using Xunit.Abstractions;
-using Apache.Arrow.Adbc.Telemetry.Traces.Exporters.FileExporter;
namespace Apache.Arrow.Adbc.Tests.Telemetry.Traces.Exporters.FileExporter
{