diff --git a/.github/workflows/continuous.yml b/.github/workflows/continuous.yml index 5383e351..b3734b9b 100644 --- a/.github/workflows/continuous.yml +++ b/.github/workflows/continuous.yml @@ -24,6 +24,22 @@ jobs: runs-on: windows-latest steps: - uses: actions/checkout@v1 + + - name: Setup .NET 2.2 + uses: actions/setup-dotnet@v1 + with: + dotnet-version: 2.2.* + + - name: Setup .NET 3.0 + uses: actions/setup-dotnet@v1 + with: + dotnet-version: 3.0.* + + - name: Setup .NET 3.1 + uses: actions/setup-dotnet@v1 + with: + dotnet-version: 3.1.* + - 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 c3296452..5fe08553 100644 --- a/.github/workflows/continuousCore.yml +++ b/.github/workflows/continuousCore.yml @@ -24,6 +24,22 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v1 + + - name: Setup .NET 2.2 + uses: actions/setup-dotnet@v1 + with: + dotnet-version: 2.2.* + + - name: Setup .NET 3.0 + uses: actions/setup-dotnet@v1 + with: + dotnet-version: 3.0.* + + - name: Setup .NET 3.1 + uses: actions/setup-dotnet@v1 + with: + dotnet-version: 3.1.* + - name: Run './build.cmd TestCoreOnly' run: ./build.cmd TestCoreOnly env: @@ -37,6 +53,22 @@ jobs: runs-on: macOS-latest steps: - uses: actions/checkout@v1 + + - name: Setup .NET 2.2 + uses: actions/setup-dotnet@v1 + with: + dotnet-version: 2.2.* + + - name: Setup .NET 3.0 + uses: actions/setup-dotnet@v1 + with: + dotnet-version: 3.0.* + + - name: Setup .NET 3.1 + uses: actions/setup-dotnet@v1 + with: + dotnet-version: 3.1.* + - name: Run './build.cmd TestCoreOnly' run: ./build.cmd TestCoreOnly env: diff --git a/Build/Common.Tests.props b/Build/Common.Tests.props index 221fc4e2..e8725f96 100644 --- a/Build/Common.Tests.props +++ b/Build/Common.Tests.props @@ -6,7 +6,7 @@ - + all diff --git a/Build/Nuke/Build.cs b/Build/Nuke/Build.cs index b52b1549..9eb17d3b 100644 --- a/Build/Nuke/Build.cs +++ b/Build/Nuke/Build.cs @@ -22,6 +22,7 @@ [GitHubActions( "continuous", GitHubActionsImage.WindowsLatest, + AutoGenerate = false, On = new[] { GitHubActionsTrigger.Push }, ImportGitHubTokenAs = nameof(GitHubToken), InvokedTargets = new[] { nameof(Test), nameof(Pack) })] @@ -29,18 +30,14 @@ "continuousCore", GitHubActionsImage.UbuntuLatest, GitHubActionsImage.MacOsLatest, + AutoGenerate = false, On = new[] { GitHubActionsTrigger.Push }, ImportGitHubTokenAs = nameof(GitHubToken), InvokedTargets = new[] { nameof(TestCoreOnly) })] -[AppVeyor( - AppVeyorImage.VisualStudio2019, - SkipTags = true, - InvokedTargets = new[] { nameof(Test), nameof(Pack) })] [AzurePipelines( suffix: null, AzurePipelinesImage.WindowsLatest, - AzurePipelinesImage.UbuntuLatest, - AzurePipelinesImage.MacOsLatest, + AutoGenerate = false, InvokedTargets = new[] { nameof(Test), nameof(TestCoreOnly), nameof(Pack) }, NonEntryTargets = new[] { nameof(Restore) }, ExcludedTargets = new[] { nameof(Clean), nameof(PackCoreOnly)})] @@ -92,13 +89,16 @@ partial class Build : Nuke.Common.NukeBuild void ExecutesCompile(bool excludeNetFramework) { + DotNet("--info"); + Logger.Info(excludeNetFramework ? "Exclude net framework" : "Include net framework"); if (excludeNetFramework) { - var frameworks = + var projectWithFrameworkAndPlatform = from project in AllProjects from framework in project.GetTargetFrameworks(true) - select new {project, framework}; + from platform in project.GetPlatforms() + select new {project, framework, platform}; DotNetBuild(s => s @@ -107,8 +107,9 @@ from framework in project.GetTargetFrameworks(true) .SetAssemblyVersion(GitVersion.AssemblySemVer) .SetFileVersion(GitVersion.AssemblySemFileVer) .SetInformationalVersion(GitVersion.InformationalVersion) - .CombineWith(frameworks, (s, f) => s + .CombineWith(projectWithFrameworkAndPlatform, (s, f) => s .SetFramework(f.framework) + .SetProperty("Platform", f.platform) .SetProjectFile(f.project))); } else @@ -124,7 +125,7 @@ from framework in project.GetTargetFrameworks(true) } Target Test => _ => _ - .DependsOn(Compile) + .DependsOn(Compile) .Produces(TestResultDirectory / "*.trx") .Executes(() => ExecutesTest(false)); @@ -134,8 +135,9 @@ void ExecutesTest(bool excludeNetFramework) var testConfigurations = from project in TestProjects - from framework in project.GetTargetFrameworksForTest(excludeNetFramework) - select new {project, framework}; + from framework in project.GetTargetFrameworks(excludeNetFramework) + from platform in project.GetPlatformsForTests() + select new {project, framework, platform}; DotNetTest(_ => { @@ -148,6 +150,8 @@ from framework in project.GetTargetFrameworksForTest(excludeNetFramework) .CombineWith(testConfigurations, (_, v) => _ .SetProjectFile(v.project) .SetFramework(v.framework) + .DisableNoBuild() + .SetProperty("Platform", v.platform) .SetLogger($"trx;LogFileName={v.project.Name}-{v.framework}.trx")); }); diff --git a/Build/Nuke/ProjectExtensions.cs b/Build/Nuke/ProjectExtensions.cs index fd5ed795..48a72bb9 100644 --- a/Build/Nuke/ProjectExtensions.cs +++ b/Build/Nuke/ProjectExtensions.cs @@ -1,5 +1,7 @@ +using System; using System.Collections.Generic; using System.Linq; +using System.Runtime.InteropServices; using Nuke.Common.ProjectModel; public static class ProjectExtensions @@ -12,14 +14,28 @@ public static IReadOnlyCollection GetTargetFrameworks(this Project proje return frameworks.Where(x => x.Contains("standard") || x.Contains("core")).ToList(); } - public static IReadOnlyCollection GetTargetFrameworksForTest(this Project project, bool excludeNetFramework) + public static IReadOnlyCollection GetPlatforms(this Project project) { - var frameworks = project - .GetTargetFrameworks() - //because github actions and azure pipeline does not handle it. - .Where(x=> !(x.Contains("netcoreapp1") || x.Contains("netcoreapp2.2"))); - if (!excludeNetFramework) - return frameworks.ToList(); - return frameworks.Where(x => x.Contains("standard") || x.Contains("core")).ToList(); + var msbuildProject = project.GetMSBuildProject(); + var targetFrameworkProperty = msbuildProject.GetProperty("Platform"); + if (targetFrameworkProperty != null) + return new[] { targetFrameworkProperty.EvaluatedValue }; + + var targetFrameworksProperty = msbuildProject.GetProperty("Platforms"); + if (targetFrameworksProperty != null) + return targetFrameworksProperty.EvaluatedValue.Split(';'); + + return new string[0]; } + + public static IReadOnlyCollection GetPlatformsForTests(this Project project) + { + + var isWindows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows); + var platforms = project.GetPlatforms(); + if (isWindows) + return platforms; + return platforms.Where(x=> x != "x86").ToList(); + } + } \ No newline at end of file diff --git a/Build/x64.runsettings b/Build/x64.runsettings new file mode 100644 index 00000000..2f8022be --- /dev/null +++ b/Build/x64.runsettings @@ -0,0 +1,10 @@ + + + + + + + x64 + + + \ No newline at end of file diff --git a/Build/x86.runsettings b/Build/x86.runsettings new file mode 100644 index 00000000..7c5cff4c --- /dev/null +++ b/Build/x86.runsettings @@ -0,0 +1,10 @@ + + + + + + + x86 + + + \ No newline at end of file diff --git a/StructLinq.sln b/StructLinq.sln index 735a6711..00dcc86c 100644 --- a/StructLinq.sln +++ b/StructLinq.sln @@ -6,6 +6,11 @@ MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StructLinq", "src\StructLinq\StructLinq.csproj", "{458ED1F2-37EC-4569-9958-728CEFA43D8C}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "_Build", "_Build", "{2987C571-432E-4640-8D24-A3F8C9341276}" + ProjectSection(SolutionItems) = preProject + azure-pipelines.yml = azure-pipelines.yml + .github\workflows\continuous.yml = .github\workflows\continuous.yml + .github\workflows\continuousCore.yml = .github\workflows\continuousCore.yml + EndProjectSection EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StructLinq.Tests", "src\StructLinq.Tests\StructLinq.Tests.csproj", "{355C025E-3001-40F0-A456-05C13AF94466}" EndProject diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index ba78fa96..00000000 --- a/appveyor.yml +++ /dev/null @@ -1,28 +0,0 @@ -# ------------------------------------------------------------------------------ -# -# -# This code was generated. -# -# - To turn off auto-generation set: -# -# [AppVeyor (AutoGenerate = false)] -# -# - To trigger manual generation invoke: -# -# nuke --generate-configuration AppVeyor --host AppVeyor -# -# -# ------------------------------------------------------------------------------ - -image: - - Visual Studio 2019 - -skip_tags: true - -build_script: - - cmd: .\build.cmd Test Pack - - sh: ./build.cmd Test Pack - -artifacts: - - path: .result/test-results/*.trx - - path: .result/packages/*.nupkg diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 366cc7ba..4d901dcb 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -21,9 +21,19 @@ stages: pool: vmImage: 'windows-latest' jobs: + - job: Setup + displayName: 'Setup' + dependsOn: [ ] + steps: + - task: UseDotNet@2 + displayName: 'Setup .NET Core 2.2' + inputs: + packageType: runtime + version: 2.2.x + - job: Compile displayName: '⚙️ Compile' - dependsOn: [ ] + dependsOn: [ Setup ] steps: - task: CmdLine@2 inputs: @@ -50,51 +60,3 @@ stages: inputs: artifactName: packages pathtoPublish: '.result/packages' - - stage: ubuntu_latest - displayName: 'ubuntu-latest' - dependsOn: [ ] - pool: - vmImage: 'ubuntu-latest' - jobs: - - job: CompileCoreOnly - displayName: '⚙️ CompileCoreOnly' - dependsOn: [ ] - steps: - - task: CmdLine@2 - inputs: - script: './build.cmd Restore CompileCoreOnly --skip' - - job: TestCoreOnly - displayName: '🚦 TestCoreOnly' - dependsOn: [ CompileCoreOnly ] - steps: - - task: CmdLine@2 - inputs: - script: './build.cmd TestCoreOnly --skip' - - task: PublishBuildArtifacts@1 - inputs: - artifactName: test-results - pathtoPublish: '.result/test-results' - - stage: macOS_latest - displayName: 'macOS-latest' - dependsOn: [ ] - pool: - vmImage: 'macOS-latest' - jobs: - - job: CompileCoreOnly - displayName: '⚙️ CompileCoreOnly' - dependsOn: [ ] - steps: - - task: CmdLine@2 - inputs: - script: './build.cmd Restore CompileCoreOnly --skip' - - job: TestCoreOnly - displayName: '🚦 TestCoreOnly' - dependsOn: [ CompileCoreOnly ] - steps: - - task: CmdLine@2 - inputs: - script: './build.cmd TestCoreOnly --skip' - - task: PublishBuildArtifacts@1 - inputs: - artifactName: test-results - pathtoPublish: '.result/test-results' diff --git a/src/StructLinq.BCL.Tests/ListLayoutTests.cs b/src/StructLinq.BCL.Tests/ListLayoutTests.cs index 871a46d9..89115ab7 100644 --- a/src/StructLinq.BCL.Tests/ListLayoutTests.cs +++ b/src/StructLinq.BCL.Tests/ListLayoutTests.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Linq; using FluentAssertions; using StructLinq.BCL.List; @@ -6,7 +7,7 @@ namespace StructLinq.BCL.Tests { - public unsafe class ListLayoutTests + public class ListLayoutTests { [Theory] [InlineData(0)] @@ -35,7 +36,28 @@ public void ShouldMatchArrayOfString(int size) layout.Items[i].Should().Be((i - 1).ToString()); } } + } +#if IS_X86 + public class BitnessTests + { + [Fact] + public void Checkx86Bitness() + { + Assert.Equal(4, IntPtr.Size); + } + } +#endif +#if IS_X64 + public class BitnessTests + { + [Fact] + public void Checkx64Bitness() + { + Assert.Equal(8, IntPtr.Size); + } } +#endif + } diff --git a/src/StructLinq.BCL.Tests/StructLinq.BCL.x64.Tests.csproj b/src/StructLinq.BCL.Tests/StructLinq.BCL.x64.Tests.csproj index b3832caa..6b2f8a45 100644 --- a/src/StructLinq.BCL.Tests/StructLinq.BCL.x64.Tests.csproj +++ b/src/StructLinq.BCL.Tests/StructLinq.BCL.x64.Tests.csproj @@ -1,10 +1,12 @@  - net452;net472;net48;netcoreapp1.0;netcoreapp1.1;netcoreapp2.0;netcoreapp2.1;netcoreapp2.2;netcoreapp3.0;netcoreapp3.1 + net452;net472;net48;netcoreapp2.1;netcoreapp2.2;netcoreapp3.0;netcoreapp3.1 x64 true x64 + $(RootDir)\Build\x64.runsettings + IS_X64 diff --git a/src/StructLinq.BCL.Tests/StructLinq.BCL.x86.Tests.csproj b/src/StructLinq.BCL.Tests/StructLinq.BCL.x86.Tests.csproj index f0536d0c..f5bd6932 100644 --- a/src/StructLinq.BCL.Tests/StructLinq.BCL.x86.Tests.csproj +++ b/src/StructLinq.BCL.Tests/StructLinq.BCL.x86.Tests.csproj @@ -1,10 +1,12 @@  - net452;net472;net48;netcoreapp1.0;netcoreapp1.1;netcoreapp2.0;netcoreapp2.1;netcoreapp2.2;netcoreapp3.0;netcoreapp3.1 + net452;net472;net48;netcoreapp2.1;netcoreapp2.2;netcoreapp3.0;netcoreapp3.1 x86 true x86 + $(RootDir)\Build\x86.runsettings + IS_X86 diff --git a/src/StructLinq.BCL/List/ListEnumerable.cs b/src/StructLinq.BCL/List/ListEnumerable.cs index d1e3db3b..cf762992 100644 --- a/src/StructLinq.BCL/List/ListEnumerable.cs +++ b/src/StructLinq.BCL/List/ListEnumerable.cs @@ -32,7 +32,7 @@ public readonly ArrayStructEnumerator GetEnumerator() public readonly int Count { [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => MathHelpers.Max(0, MathHelpers.Min(list.Count, count) - start); + get => MathHelpers.Max(0, MathHelpers.Min(layout.Size, count) - start); } [MethodImpl(MethodImplOptions.AggressiveInlining)] diff --git a/src/StructLinq.BCL/StructLinq.BCL.csproj b/src/StructLinq.BCL/StructLinq.BCL.csproj index bb302f86..f5c41750 100644 --- a/src/StructLinq.BCL/StructLinq.BCL.csproj +++ b/src/StructLinq.BCL/StructLinq.BCL.csproj @@ -1,7 +1,7 @@  - net452;net472;net48;netcoreapp1.0;netcoreapp1.1;netcoreapp2.0;netcoreapp2.1;netcoreapp2.2;netcoreapp3.0;netcoreapp3.1 + net452;net472;net48;netcoreapp2.1;netcoreapp2.2;netcoreapp3.0;netcoreapp3.1