From 401555d96dcafc666e97d93d816223152261826e Mon Sep 17 00:00:00 2001 From: Simon Shanks Date: Tue, 15 Sep 2026 13:34:09 +0100 Subject: [PATCH 1/3] Avoid unnecessary zero-length array allocations --- kx.Test/Connection/ConnectionNullTests.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kx.Test/Connection/ConnectionNullTests.cs b/kx.Test/Connection/ConnectionNullTests.cs index 8045868..dac0272 100644 --- a/kx.Test/Connection/ConnectionNullTests.cs +++ b/kx.Test/Connection/ConnectionNullTests.cs @@ -646,7 +646,7 @@ public void ConnectionIsQNullReturnsFalseForTimeSpanArray() [Test] public void ConnectionIsQNullReturnsFalseForDict() { - c.Dict input = new c.Dict(new string[] { }, new object[] { }); + c.Dict input = new c.Dict(Array.Empty(), Array.Empty()); Assert.IsFalse(c.qn(input)); } @@ -654,7 +654,7 @@ public void ConnectionIsQNullReturnsFalseForDict() [Test] public void ConnectionIsQNullReturnsFalseForFlip() { - c.Flip input = new c.Flip(new c.Dict(new string[] { }, new object[] { })); + c.Flip input = new c.Flip(new c.Dict(Array.Empty(), Array.Empty())); Assert.IsFalse(c.qn(input)); } From f418009add5e6dbec7f73c038eca4407bcaf54d9 Mon Sep 17 00:00:00 2001 From: Simon Shanks Date: Tue, 15 Sep 2026 13:36:25 +0100 Subject: [PATCH 2/3] exclude kx.Test/Scripts/GenerateLocalReport.ps1 from sonar report --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2cacefc..5d80e8f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -50,7 +50,7 @@ jobs: dotnet tool update dotnet-sonarscanner --tool-path ${{ runner.temp }}\scanner - name: SonarQube Cloud scanner begin if: ${{ github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && env.SONAR_TOKEN != '') }} - run: ${{ runner.temp }}\scanner\dotnet-sonarscanner begin /k:"KxSystems_csharpkdb" /o:"kxsystems" /d:sonar.token="$env:SONAR_TOKEN" /d:sonar.cs.vstest.reportsPaths="**\TestResults\*.trx" /d:sonar.cs.opencover.reportsPaths="*\coverage.net8.0.opencover.xml" /d:sonar.verbose=false + run: ${{ runner.temp }}\scanner\dotnet-sonarscanner begin /k:"KxSystems_csharpkdb" /o:"kxsystems" /d:sonar.token="$env:SONAR_TOKEN" /d:sonar.cs.vstest.reportsPaths="**\TestResults\*.trx" /d:sonar.cs.opencover.reportsPaths="*\coverage.net8.0.opencover.xml" /d:sonar.verbose=false /d:sonar.exclusions="kx.Test/Scripts/GenerateLocalReport.ps1" - name: Build run : dotnet build /p:Configuration=Release .\CSharpKdb.sln - name: Test .NET Framework 4.7.2 From 03205eb8428b8b93aa1c6c0f369d33af47a58601 Mon Sep 17 00:00:00 2001 From: Simon Shanks Date: Tue, 15 Sep 2026 13:45:46 +0100 Subject: [PATCH 3/3] prefer static readonly fields --- kx.Test/Connection/ConnectionArrayTests.cs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/kx.Test/Connection/ConnectionArrayTests.cs b/kx.Test/Connection/ConnectionArrayTests.cs index 643c417..9441137 100644 --- a/kx.Test/Connection/ConnectionArrayTests.cs +++ b/kx.Test/Connection/ConnectionArrayTests.cs @@ -7,12 +7,14 @@ namespace kx.Test.Connection [TestFixture] public class ConnectionArrayTests { + private static readonly string[] FlipKeys = {"Key_1"}; + private static readonly object[] FlipValues = {new object[] { "Value_1" }}; [Test] public void ConnectionReturnsExpectedLengthForDict() { const int expected = 1; - c.Dict dict = new c.Dict(new[] { "Key_1" }, new object[] { "Value_1" }); + c.Dict dict = new c.Dict(FlipKeys, FlipValues); int count = c.n(dict); @@ -24,7 +26,7 @@ public void ConnectionReturnsExpectedLengthForFlip() { const int expected = 1; - c.Flip flip = new c.Flip(new c.Dict(new[] { "Key_1" }, new object[] { new object[] { "Value_1" } })); + c.Flip flip = new c.Flip(new c.Dict(FlipKeys, FlipValues)); int count = c.n(flip); @@ -103,7 +105,7 @@ public void ConnectionTdThrowsIfXIsNull() [Test] public void ConnectionTableReturnsExpectedTableIfObjectIsFlip() { - c.Flip flip = new c.Flip(new c.Dict(new[] { "Key_1" }, new object[] { new object[] { "Value_1" } })); + c.Flip flip = new c.Flip(new c.Dict(FlipKeys, FlipValues)); object result = c.td(flip); @@ -116,8 +118,8 @@ public void ConnectionTableReturnsExpectedTableIfObjectIsDict() { c.Dict dict = new c.Dict ( - new c.Flip(new c.Dict(new[] { "Key_1" }, new object[] { new object[] { "Value_1" } })), - new c.Flip(new c.Dict(new[] { "Key_1" }, new object[] { new object[] { "Value_1" } })) + new c.Flip(new c.Dict(FlipKeys, FlipValues)), + new c.Flip(new c.Dict(FlipKeys, FlipValues)) ); object result = c.td(dict);