From 90a35c5e4971fb2473a34d609ff345665315f4e9 Mon Sep 17 00:00:00 2001 From: Atif Aziz Date: Sat, 28 Dec 2024 14:26:09 +0100 Subject: [PATCH] Update .NET SDK to 9, including dependencies --- .github/workflows/build.yml | 6 ++++-- MoreLinq.Test.Aot/MoreLinq.Test.Aot.csproj | 18 +++++++++--------- MoreLinq.Test.Aot/ToDataTableTest.cs | 8 ++++---- MoreLinq.Test/MoreLinq.Test.csproj | 7 ++++--- MoreLinq.Test/ToDataTableTest.cs | 8 ++++---- MoreLinq/Experimental/Batch.cs | 10 +++++----- MoreLinq/MoreLinq.csproj | 2 +- MoreLinq/ToDataTable.cs | 2 ++ appveyor.yml | 2 ++ .../MoreLinq.ExtensionsGenerator.csproj | 7 ++++--- build.cmd | 10 +++++++++- build.sh | 9 ++++++++- global.json | 2 +- test.cmd | 11 +++++++---- test.sh | 10 ++++++---- 15 files changed, 70 insertions(+), 42 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5a6baaf3d..8a38d1342 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -63,10 +63,12 @@ jobs: with: global-json-file: global.json - - name: Setup .NET SDK 6.0 + - name: Setup .NET SDK 6.0, 8.0 uses: actions/setup-dotnet@v3 with: - dotnet-version: 6.0.x + dotnet-version: | + 6.0.x + 8.0.x - name: .NET Information run: dotnet --info diff --git a/MoreLinq.Test.Aot/MoreLinq.Test.Aot.csproj b/MoreLinq.Test.Aot/MoreLinq.Test.Aot.csproj index 219cc362d..d04cc9709 100644 --- a/MoreLinq.Test.Aot/MoreLinq.Test.Aot.csproj +++ b/MoreLinq.Test.Aot/MoreLinq.Test.Aot.csproj @@ -1,21 +1,21 @@  - net8.0 + net9.0;net8.0 exe false true - - - - - - - - + + + + + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/MoreLinq.Test.Aot/ToDataTableTest.cs b/MoreLinq.Test.Aot/ToDataTableTest.cs index c0be620f1..d394ca43c 100644 --- a/MoreLinq.Test.Aot/ToDataTableTest.cs +++ b/MoreLinq.Test.Aot/ToDataTableTest.cs @@ -19,7 +19,7 @@ namespace MoreLinq.Test.Aot { using System; using System.Collections; - using System.Collections.Generic; + using System.Collections.Immutable; using System.Data; using System.Diagnostics.CodeAnalysis; using System.Linq; @@ -42,12 +42,12 @@ sealed class TestObject(int key) public override string ToString() => nameof(TestObject); } - readonly IReadOnlyCollection testObjects; + readonly ImmutableArray testObjects; public ToDataTableTest() => this.testObjects = Enumerable.Range(0, 3) .Select(i => new TestObject(i)) - .ToArray(); + .ToImmutableArray(); [TestMethod] public void ToDataTableNullMemberExpressionMethod() @@ -158,7 +158,7 @@ public void ToDataTableContainsAllElements() var dt = Act(); - Assert.AreEqual(this.testObjects.Count, dt.Rows.Count); + Assert.AreEqual(this.testObjects.Length, dt.Rows.Count); } [TestMethod] diff --git a/MoreLinq.Test/MoreLinq.Test.csproj b/MoreLinq.Test/MoreLinq.Test.csproj index 31b4ce6d9..559c0aa51 100644 --- a/MoreLinq.Test/MoreLinq.Test.csproj +++ b/MoreLinq.Test/MoreLinq.Test.csproj @@ -2,7 +2,7 @@ MoreLinq.Test - net8.0;net6.0;net471 + net9.0;net8.0;net6.0;net471 portable MoreLinq.Test Exe @@ -32,14 +32,14 @@ runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + @@ -48,6 +48,7 @@ + diff --git a/MoreLinq.Test/ToDataTableTest.cs b/MoreLinq.Test/ToDataTableTest.cs index 65958f544..11c349f72 100644 --- a/MoreLinq.Test/ToDataTableTest.cs +++ b/MoreLinq.Test/ToDataTableTest.cs @@ -19,7 +19,7 @@ namespace MoreLinq.Test { using System; using System.Collections; - using System.Collections.Generic; + using System.Collections.Immutable; using System.Data; using System.Linq.Expressions; using NUnit.Framework; @@ -41,12 +41,12 @@ sealed class TestObject(int key) public override string ToString() => nameof(TestObject); } - readonly IReadOnlyCollection testObjects; + readonly ImmutableArray testObjects; public ToDataTableTest() => this.testObjects = Enumerable.Range(0, 3) .Select(i => new TestObject(i)) - .ToArray(); + .ToImmutableArray(); [Test] public void ToDataTableNullMemberExpressionMethod() @@ -135,7 +135,7 @@ public void ToDataTableSchemaInDeclarationOrder() public void ToDataTableContainsAllElements() { var dt = this.testObjects.ToDataTable(); - Assert.That(dt.Rows.Count, Is.EqualTo(this.testObjects.Count)); + Assert.That(dt.Rows.Count, Is.EqualTo(this.testObjects.Length)); } [Test] diff --git a/MoreLinq/Experimental/Batch.cs b/MoreLinq/Experimental/Batch.cs index d3c444804..03a6394f6 100644 --- a/MoreLinq/Experimental/Batch.cs +++ b/MoreLinq/Experimental/Batch.cs @@ -246,12 +246,12 @@ public CurrentPoolArrayProvider(IEnumerator<(T[], int)> rental, ArrayPool poo public bool UpdateWithNext() { - if (this.rental is { Current: var (array, _) } rental) + if (this.rental is { } rental) { Debug.Assert(this.pool is not null); if (this.rented) { - this.pool.Return(array); + this.pool.Return(this.array); this.rented = false; } @@ -279,12 +279,12 @@ public override T this[int index] public void Dispose() { - if (this.rental is { Current: var (array, _) } enumerator) + if (this.rental is { } rental) { Debug.Assert(this.pool is not null); if (this.rented) - this.pool.Return(array); - enumerator.Dispose(); + this.pool.Return(this.array); + rental.Dispose(); this.array = []; this.count = 0; this.rental = null; diff --git a/MoreLinq/MoreLinq.csproj b/MoreLinq/MoreLinq.csproj index 4da96aafa..bf796f42b 100644 --- a/MoreLinq/MoreLinq.csproj +++ b/MoreLinq/MoreLinq.csproj @@ -164,7 +164,7 @@ all - + diff --git a/MoreLinq/ToDataTable.cs b/MoreLinq/ToDataTable.cs index 1872c3d85..41ff4cf8a 100644 --- a/MoreLinq/ToDataTable.cs +++ b/MoreLinq/ToDataTable.cs @@ -156,7 +156,9 @@ static TTable ToDataTable(IEnumerable source, TTable table, Member return table; } +#pragma warning disable CA1859 // Use concrete types when possible for improved performance static MemberInfo[] PrepareMemberInfos(ICollection>> expressions) +#pragma warning restore CA1859 // Use concrete types when possible for improved performance { if (expressions.Count == 0) return []; diff --git a/appveyor.yml b/appveyor.yml index 108698254..bafa41b90 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -49,8 +49,10 @@ install: - git reset --hard - ps: if ($isWindows) { tools\dotnet-install.ps1 -JSonFile global.json } - ps: if ($isWindows) { tools\dotnet-install.ps1 -Runtime dotnet -Version 6.0.11 -SkipNonVersionedFiles } +- ps: if ($isWindows) { tools\dotnet-install.ps1 -Runtime dotnet -Version 8.0.11 -SkipNonVersionedFiles } - sh: ./tools/dotnet-install.sh --jsonfile global.json - sh: ./tools/dotnet-install.sh --runtime dotnet --version 6.0.11 --skip-non-versioned-files +- sh: ./tools/dotnet-install.sh --runtime dotnet --version 8.0.11 --skip-non-versioned-files - sh: export PATH="$HOME/.dotnet:$PATH" before_build: - dotnet --info diff --git a/bld/ExtensionsGenerator/MoreLinq.ExtensionsGenerator.csproj b/bld/ExtensionsGenerator/MoreLinq.ExtensionsGenerator.csproj index 665931e3e..ad0c81d31 100644 --- a/bld/ExtensionsGenerator/MoreLinq.ExtensionsGenerator.csproj +++ b/bld/ExtensionsGenerator/MoreLinq.ExtensionsGenerator.csproj @@ -1,12 +1,13 @@  Exe - net8.0 + net9.0 false + false - - + + diff --git a/build.cmd b/build.cmd index 632a0534c..2e269bbfa 100644 --- a/build.cmd +++ b/build.cmd @@ -5,6 +5,7 @@ popd & exit /b %ERRORLEVEL% :main setlocal +set MSBUILDTERMINALLOGGER=off for %%i in (dotnet.exe) do set dotnet=%%~dpnx$PATH:i if "%dotnet%"=="" goto :nodotnet if "%1"=="docs" shift & goto :docs @@ -27,7 +28,14 @@ exit /b 2 :codegen echo | set /p=Generating extensions wrappers (%1)... -dotnet run --project bld/ExtensionsGenerator/MoreLinq.ExtensionsGenerator.csproj -c Release -- %2 %3 %4 %5 %6 %7 %8 %9 > "%temp%\%~nx1" ^ +dotnet build bld\ExtensionsGenerator\MoreLinq.ExtensionsGenerator.csproj -c Release >build.log 2>&1 || ( + echo Failed! + type build.log + del build.log + exit /b 1 +) +del build.log +dotnet bld\ExtensionsGenerator\bin\Release\MoreLinq.ExtensionsGenerator.dll %2 %3 %4 %5 %6 %7 %8 %9 > "%temp%\%~nx1" ^ && move "%temp%\%~nx1" "%~dp1" > nul ^ && echo Done. exit /b %ERRORLEVEL% diff --git a/build.sh b/build.sh index ac7f75b51..e15b3fc3c 100755 --- a/build.sh +++ b/build.sh @@ -1,13 +1,20 @@ #!/usr/bin/env bash set -e cd "$(dirname "$0")" +export MSBUILDTERMINALLOGGER=off dotnet restore dotnet tool restore codegen() { dest="$1" printf "Generating extensions wrappers (%s)..." "$1" shift - dotnet run --project bld/ExtensionsGenerator/MoreLinq.ExtensionsGenerator.csproj -c Release -- "$@" > "$dest" + dotnet build bld/ExtensionsGenerator/MoreLinq.ExtensionsGenerator.csproj -c Release >build.log || ( + printf "Failed!\n" + cat build.log + rm build.log + exit 1 + ) + dotnet bld/ExtensionsGenerator/bin/Release/MoreLinq.ExtensionsGenerator.dll "$@" > "$dest" printf "Done.\n" } codegen MoreLinq/Extensions.g.cs -x "[/\\\\]ToDataTable\.cs$" -u System.Linq -u System.Collections MoreLinq diff --git a/global.json b/global.json index db09cbbe9..72f400ebe 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "8.0.400", + "version": "9.0.100", "rollForward": "latestPatch" } } diff --git a/test.cmd b/test.cmd index 209719ca3..87185c742 100644 --- a/test.cmd +++ b/test.cmd @@ -8,10 +8,12 @@ setlocal if not defined SKIP_TEST_BUILD set SKIP_TEST_BUILD=false if %SKIP_TEST_BUILD%==false call build || exit /b 1 if not "%~1"=="aot" goto :test-all -call :test-aot +call :test-aot net8.0 && call :test-aot net9.0 exit /b %ERRORLEVEL% :test-all call :clean ^ + && call :test net9.0 Debug ^ + && call :test net9.0 Release ^ && call :test net8.0 Debug ^ && call :test net8.0 Release ^ && call :test net6.0 Debug ^ @@ -19,7 +21,8 @@ call :clean ^ && call :test net471 Debug ^ && call :test net471 Release ^ && call :report-cover ^ - && call :test-aot + && call :test-aot net8.0 ^ + && call :test-aot net9.0 exit /b %ERRORLEVEL% :clean @@ -60,10 +63,10 @@ exit /b %ERRORLEVEL% :test-aot setlocal cd MoreLinq.Test.Aot -dotnet publish +dotnet publish -f %1 if not ERRORLEVEL==0 exit /b %ERRORLEVEL% set AOT_TEST_PUBLISH_DIR= -for /f %%d in ('dir /ad /s /b publish') do if not defined AOT_TEST_PUBLISH_DIR set AOT_TEST_PUBLISH_DIR=%%~d +for /f %%d in ('cmd /c "dir /ad /s /b publish | findstr /c:%1"') do if not defined AOT_TEST_PUBLISH_DIR set AOT_TEST_PUBLISH_DIR=%%~d if not defined AOT_TEST_PUBLISH_DIR ( echo>&2 Published binary directory not found! exit /b 1 diff --git a/test.sh b/test.sh index 5287da315..a80e31dc0 100755 --- a/test.sh +++ b/test.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -set -e +set -eo pipefail cd "$(dirname "$0")" if [[ "${SKIP_TEST_BUILD:=false}" == "false" ]]; then ./build.sh $c @@ -12,7 +12,7 @@ if [[ -z "$1" ]]; then else configs="$1" fi -for f in net6.0 net8.0; do +for f in net6.0 net8.0 net9.0; do for c in $configs; do dotnet test --no-build -c $c -f $f --settings MoreLinq.Test/coverlet.runsettings MoreLinq.Test TEST_RESULTS_DIR="$(ls -dc MoreLinq.Test/TestResults/* | head -1)" @@ -23,5 +23,7 @@ dotnet reportgenerator -reports:MoreLinq.Test/TestResults/coverage-*.opencover.x -reporttypes:Html\;TextSummary \ -targetdir:MoreLinq.Test/TestResults/reports cat MoreLinq.Test/TestResults/reports/Summary.txt -dotnet publish MoreLinq.Test.Aot -"$(find MoreLinq.Test.Aot -type d -name publish)/MoreLinq.Test.Aot" +for f in net8.0 net9.0; do + dotnet publish -f $f MoreLinq.Test.Aot + "$(find MoreLinq.Test.Aot -type d -name publish | grep -F $f)/MoreLinq.Test.Aot" +done