diff --git a/.github/workflows/continuous.yml b/.github/workflows/continuous.yml index b3734b9b..fe5442f7 100644 --- a/.github/workflows/continuous.yml +++ b/.github/workflows/continuous.yml @@ -40,6 +40,11 @@ jobs: with: dotnet-version: 3.1.* + - name: Setup .NET 5.0 + uses: actions/setup-dotnet@v1 + with: + dotnet-version: 5.0.* + - name: Run './build.cmd Test Pack' run: ./build.cmd Test Pack env: diff --git a/.github/workflows/continuousCore.yml b/.github/workflows/continuousCore.yml index 5fe08553..838b3805 100644 --- a/.github/workflows/continuousCore.yml +++ b/.github/workflows/continuousCore.yml @@ -40,6 +40,11 @@ jobs: with: dotnet-version: 3.1.* + - name: Setup .NET 5.0 + uses: actions/setup-dotnet@v1 + with: + dotnet-version: 5.0.* + - name: Run './build.cmd TestCoreOnly' run: ./build.cmd TestCoreOnly env: @@ -69,6 +74,11 @@ jobs: with: dotnet-version: 3.1.* + - name: Setup .NET 5.0 + uses: actions/setup-dotnet@v1 + with: + dotnet-version: 5.0.* + - name: Run './build.cmd TestCoreOnly' run: ./build.cmd TestCoreOnly env: diff --git a/Build/Common.Benchmark.props b/Build/Common.Benchmark.props index dbad96c5..fa7ca0aa 100644 --- a/Build/Common.Benchmark.props +++ b/Build/Common.Benchmark.props @@ -1,6 +1,6 @@ - netcoreapp3.1;net48 + netcoreapp3.1;net48;net50 diff --git a/Build/Common.Tests.props b/Build/Common.Tests.props index e8725f96..d7dbdc8e 100644 --- a/Build/Common.Tests.props +++ b/Build/Common.Tests.props @@ -1,6 +1,6 @@ - netcoreapp3.1;net48 + netcoreapp3.1;net48;net50 False diff --git a/Build/Nuke/Build.cs b/Build/Nuke/Build.cs index 9eb17d3b..3c4cfb85 100644 --- a/Build/Nuke/Build.cs +++ b/Build/Nuke/Build.cs @@ -13,6 +13,7 @@ using Nuke.Common.Tooling; using Nuke.Common.Tools.DotNet; using Nuke.Common.Tools.GitVersion; +using Nuke.Common.Tools.Xunit; using Nuke.Common.Utilities.Collections; using static Nuke.Common.IO.FileSystemTasks; using static Nuke.Common.Tools.DotNet.DotNetTasks; @@ -89,7 +90,6 @@ partial class Build : Nuke.Common.NukeBuild void ExecutesCompile(bool excludeNetFramework) { - DotNet("--info"); Logger.Info(excludeNetFramework ? "Exclude net framework" : "Include net framework"); if (excludeNetFramework) @@ -167,7 +167,7 @@ from platform in project.GetPlatformsForTests() .Executes(() => { var excludeNetFramework = AllProjects.SelectMany(x => x.GetTargetFrameworks()).Distinct() - .Any(x => !x.Contains("standard") || !x.Contains("core")); + .Any(x => !x.Contains("standard") || !x.Contains("core") || !x.Contains("net50")); ExecutesCompile(excludeNetFramework); }); @@ -177,7 +177,7 @@ from platform in project.GetPlatformsForTests() .Executes(() => { var excludeNetFramework = AllProjects.SelectMany(x => x.GetTargetFrameworks()).Distinct() - .Any(x => !x.Contains("standard") || !x.Contains("core")); + .Any(x => !x.Contains("standard") || !x.Contains("core") || !x.Contains("net50")); ExecutesTest(excludeNetFramework); }); diff --git a/Build/Nuke/NukeBuild.csproj b/Build/Nuke/NukeBuild.csproj index 08d959b1..cb6d835f 100644 --- a/Build/Nuke/NukeBuild.csproj +++ b/Build/Nuke/NukeBuild.csproj @@ -2,7 +2,7 @@ Exe - netcoreapp3.0 + net50 CS0649;CS0169 false ..\.. diff --git a/Build/Nuke/ProjectExtensions.cs b/Build/Nuke/ProjectExtensions.cs index 48a72bb9..2e555aca 100644 --- a/Build/Nuke/ProjectExtensions.cs +++ b/Build/Nuke/ProjectExtensions.cs @@ -11,7 +11,7 @@ public static IReadOnlyCollection GetTargetFrameworks(this Project proje var frameworks = project.GetTargetFrameworks(); if (!excludeNetFramework) return frameworks.ToList(); - return frameworks.Where(x => x.Contains("standard") || x.Contains("core")).ToList(); + return frameworks.Where(x => x.Contains("standard") || x.Contains("core") || x.Contains("net50")).ToList(); } public static IReadOnlyCollection GetPlatforms(this Project project) diff --git a/build.ps1 b/build.ps1 index a180d0ca..11db5994 100644 --- a/build.ps1 +++ b/build.ps1 @@ -39,14 +39,12 @@ function ExecSafe([scriptblock] $cmd) { # Print environment variables Get-Item -Path Env:* | Sort-Object -Property Name | ForEach-Object {"{0}={1}" -f $_.Name,$_.Value} -$DotNetVersion = "3.1.403" - # If dotnet CLI is installed globally and it matches requested version, use for execution -# if ($null -ne (Get-Command "dotnet" -ErrorAction SilentlyContinue) -and ` - # $(dotnet --version) -and $LASTEXITCODE -eq 0) { - # $env:DOTNET_EXE = (Get-Command "dotnet").Path -# } -# else { + if ($null -ne (Get-Command "dotnet" -ErrorAction SilentlyContinue) -and ` + $(dotnet --version) -and $LASTEXITCODE -eq 0) { + $env:DOTNET_EXE = (Get-Command "dotnet").Path + } + else { # Download install script $DotNetInstallFile = "$TempDirectory\dotnet-install.ps1" New-Item -ItemType Directory -Path $TempDirectory -Force | Out-Null @@ -69,7 +67,7 @@ $DotNetVersion = "3.1.403" ExecSafe { & $DotNetInstallFile -InstallDir $DotNetDirectory -Version $DotNetVersion -NoPath } } $env:DOTNET_EXE = "$DotNetDirectory\dotnet.exe" -# } + } Write-Output "Path: $($env:DOTNET_EXE)" diff --git a/src/StructLinq.BCL.Tests/ListLayoutTests.cs b/src/StructLinq.BCL.Tests/ListLayoutTests.cs index 89115ab7..a03b99f3 100644 --- a/src/StructLinq.BCL.Tests/ListLayoutTests.cs +++ b/src/StructLinq.BCL.Tests/ListLayoutTests.cs @@ -9,6 +9,17 @@ namespace StructLinq.BCL.Tests { public class ListLayoutTests { + [Theory] + [InlineData(0)] + [InlineData(10)] + [InlineData(100)] + public void ShouldCountMustBe(int size) + { + var list = Enumerable.Range(-1, size).ToList(); + var layout = Unsafe.As, ListLayout>(ref list); + layout.Size.Should().Be(size); + } + [Theory] [InlineData(0)] [InlineData(10)] diff --git a/src/StructLinq.BCL.Tests/StructLinq.BCL.x64.Tests.csproj b/src/StructLinq.BCL.Tests/StructLinq.BCL.x64.Tests.csproj index 6b2f8a45..fe2485ad 100644 --- a/src/StructLinq.BCL.Tests/StructLinq.BCL.x64.Tests.csproj +++ b/src/StructLinq.BCL.Tests/StructLinq.BCL.x64.Tests.csproj @@ -1,12 +1,13 @@  - net452;net472;net48;netcoreapp2.1;netcoreapp2.2;netcoreapp3.0;netcoreapp3.1 + net452;net472;net48;netcoreapp2.1;netcoreapp2.2;netcoreapp3.0;netcoreapp3.1;net50 x64 true x64 $(RootDir)\Build\x64.runsettings IS_X64 + StructLinq.BCL.Tests diff --git a/src/StructLinq.BCL.Tests/StructLinq.BCL.x86.Tests.csproj b/src/StructLinq.BCL.Tests/StructLinq.BCL.x86.Tests.csproj index f5bd6932..dbeb52cd 100644 --- a/src/StructLinq.BCL.Tests/StructLinq.BCL.x86.Tests.csproj +++ b/src/StructLinq.BCL.Tests/StructLinq.BCL.x86.Tests.csproj @@ -1,12 +1,13 @@  - net452;net472;net48;netcoreapp2.1;netcoreapp2.2;netcoreapp3.0;netcoreapp3.1 + net452;net472;net48;netcoreapp2.1;netcoreapp2.2;netcoreapp3.0;netcoreapp3.1;net50 x86 true x86 $(RootDir)\Build\x86.runsettings IS_X86 + StructLinq.BCL.Tests diff --git a/src/StructLinq.BCL/Dictionary/DictionaryLayout.cs b/src/StructLinq.BCL/Dictionary/DictionaryLayout.cs index 302828b5..b2cd58fc 100644 --- a/src/StructLinq.BCL/Dictionary/DictionaryLayout.cs +++ b/src/StructLinq.BCL/Dictionary/DictionaryLayout.cs @@ -15,6 +15,16 @@ internal struct Entry internal TKey Key; // Key of entry internal TValue Value; // Value of entry } +#else +#if (NET5_0) + + internal struct Entry + { + public uint HashCode; + public int Next; + internal TKey Key; // Key of entry + internal TValue Value; // Value of entry + } #else internal struct Entry { @@ -23,5 +33,6 @@ internal struct Entry internal TKey Key; // Key of entry internal TValue Value; // Value of entry } + #endif #endif } diff --git a/src/StructLinq.BCL/List/ListLayout.cs b/src/StructLinq.BCL/List/ListLayout.cs index 78c59e2c..88caa356 100644 --- a/src/StructLinq.BCL/List/ListLayout.cs +++ b/src/StructLinq.BCL/List/ListLayout.cs @@ -1,30 +1,23 @@ // ReSharper disable InconsistentNaming - -using System; - namespace StructLinq.BCL.List { - -#if (NETCOREAPP3_0 || NETCOREAPP3_1) +#if (NETCOREAPP3_0 || NETCOREAPP3_1 || NET5_0) internal class ListLayout { internal T[] Items; -#pragma warning disable 169 internal int Size; -#pragma warning restore 169 } #else internal class ListLayout { internal T[] Items; -#pragma warning disable 169 internal int Size; +#pragma warning disable 169 private int Version; private object SyncRoot; #pragma warning restore 169 } - #endif } \ No newline at end of file diff --git a/src/StructLinq.BCL/StructLinq.BCL.csproj b/src/StructLinq.BCL/StructLinq.BCL.csproj index f5c41750..2d6dedea 100644 --- a/src/StructLinq.BCL/StructLinq.BCL.csproj +++ b/src/StructLinq.BCL/StructLinq.BCL.csproj @@ -1,7 +1,7 @@  - net452;net472;net48;netcoreapp2.1;netcoreapp2.2;netcoreapp3.0;netcoreapp3.1 + net452;net472;net48;netcoreapp2.1;netcoreapp2.2;netcoreapp3.0;netcoreapp3.1;net50 diff --git a/src/StructLinq.Tests/AbstractCollectionTests.cs b/src/StructLinq.Tests/AbstractCollectionTests.cs index fd2ad9e5..e2013c89 100644 --- a/src/StructLinq.Tests/AbstractCollectionTests.cs +++ b/src/StructLinq.Tests/AbstractCollectionTests.cs @@ -75,7 +75,9 @@ public void ShouldClone() var obj = collection.Clone(); //Assert +#pragma warning disable CA2013 // Do not use ReferenceEquals with value types Assert.False(object.ReferenceEquals(collection, obj)); +#pragma warning restore CA2013 // Do not use ReferenceEquals with value types obj.Should().BeOfType(); var clone = (TStructCollection) obj; Assert.Equal(collection.ToEnumerable().ToArray(), clone.ToEnumerable().ToArray()); diff --git a/src/StructLinq.Tests/AbstractRefCollectionTests.cs b/src/StructLinq.Tests/AbstractRefCollectionTests.cs index 926a2d97..361c7120 100644 --- a/src/StructLinq.Tests/AbstractRefCollectionTests.cs +++ b/src/StructLinq.Tests/AbstractRefCollectionTests.cs @@ -109,7 +109,9 @@ public void ShouldClone() var obj = collection.Clone(); //Assert +#pragma warning disable CA2013 // Do not use ReferenceEquals with value types Assert.False(object.ReferenceEquals(collection, obj)); +#pragma warning restore CA2013 // Do not use ReferenceEquals with value types obj.Should().BeOfType(); var clone = (TStructCollection) obj; Assert.Equal(collection.ToEnumerable().ToArray(), clone.ToEnumerable().ToArray()); diff --git a/src/StructLinq.Tests/SumTests.cs b/src/StructLinq.Tests/SumTests.cs index e0d3e018..8079a00c 100644 --- a/src/StructLinq.Tests/SumTests.cs +++ b/src/StructLinq.Tests/SumTests.cs @@ -1,5 +1,4 @@ using System.Linq; -using System.Runtime.InteropServices.WindowsRuntime; using Xunit; namespace StructLinq.Tests