From edf0abcd117f4a2c64e117811d73a0dcb63d2ffb Mon Sep 17 00:00:00 2001 From: Marco van den Oever Date: Fri, 12 Jul 2024 21:27:59 +0200 Subject: [PATCH 1/5] [Build/GitHub] Added manual workflow dispatch --- .github/workflows/ci.yml | 6 ++++ .nuke/build.schema.json | 6 ++-- src/01-Build/NukeBuild/Build.cs | 60 ++++++++++++++------------------- 3 files changed, 34 insertions(+), 38 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 73c374ff..3d90d6f5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,6 +20,11 @@ on: push: branches: - master + workflow_dispatch: + inputs: + name: + description: "name" + required: false jobs: windows-latest: @@ -39,6 +44,7 @@ jobs: - name: 'Run: PublishRelease' run: ./src/build.cmd PublishRelease env: + name: ${{ github.event.inputs.name }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: 'Publish: win-x64_self-contained.zip' uses: actions/upload-artifact@v3 diff --git a/.nuke/build.schema.json b/.nuke/build.schema.json index 9fb4556e..496250fc 100644 --- a/.nuke/build.schema.json +++ b/.nuke/build.schema.json @@ -85,8 +85,7 @@ "PublishWin64Aot", "PublishWin64FrameworkDependent", "PublishWin64SelfContained", - "ReportInfo", - "Restore" + "ReportInfo" ] } }, @@ -109,8 +108,7 @@ "PublishWin64Aot", "PublishWin64FrameworkDependent", "PublishWin64SelfContained", - "ReportInfo", - "Restore" + "ReportInfo" ] } }, diff --git a/src/01-Build/NukeBuild/Build.cs b/src/01-Build/NukeBuild/Build.cs index f1fbb432..f5801834 100644 --- a/src/01-Build/NukeBuild/Build.cs +++ b/src/01-Build/NukeBuild/Build.cs @@ -24,6 +24,7 @@ GitHubActionsImage.WindowsLatest, FetchDepth = 0, OnPushBranches = ["master"], + OnWorkflowDispatchOptionalInputs = [ "name" ], EnableGitHubToken = true, InvokedTargets = [nameof(PublishRelease)])] [SuppressMessage("Major Bug", "S3903:Types should be defined in named namespaces", Justification = "MvdO: Build script.")] @@ -54,6 +55,8 @@ public sealed class Build : NukeBuild [Solution(GenerateProjects = true, SuppressBuildProjectCheck = true)] private readonly Solution Solution; + private AbsolutePath PathToWin64AotZip => ArtifactsDirectory / $"win-x64_aot.zip"; + private AbsolutePath PathToWin64FrameworkDependentZip => ArtifactsDirectory / $"win-x64_framework-dependent.zip"; private AbsolutePath PathToWin64SelfContainedZip => ArtifactsDirectory / $"win-x64_self-contained.zip"; @@ -94,21 +97,38 @@ public sealed class Build : NukeBuild }); /// - /// NuGet restore. + /// Windows x64 AOT. /// - public Target Restore => _ => _ + private Target PublishWin64Aot => _ => _ .DependsOn(Clean) + .Produces(PathToWin64AotZip) .Executes(() => { - DotNetRestore(_ => _ - .SetProcessWorkingDirectory(Solution.Directory)); + var staging = StagingDirectory / "win-x64_aot"; + + DotNetPublish(_ => _ + .SetAssemblyVersion(AssemblyVersion) + .SetInformationalVersion(InformationalVersion) + .SetConfiguration(Configuration) + .SetFramework("net8.0-windows") + .SetProject(Solution._0_Host.Wtq_Host_Windows) + .SetOutput(staging) + .SetProperty("PublishAot", true) + .SetProperty("InvariantGlobalization", true) + .SetRuntime("win-x64")); + + staging.ZipTo( + PathToWin64AotZip, + filter: x => x.HasExtension(".exe", ".jsonc"), + compressionLevel: CompressionLevel.SmallestSize, + fileMode: System.IO.FileMode.CreateNew); }); /// /// Windows x64 framework dependent. /// private Target PublishWin64FrameworkDependent => _ => _ - .DependsOn(Restore) + .DependsOn(Clean) .Produces(PathToWin64FrameworkDependentZip) .Executes(() => { @@ -136,7 +156,7 @@ public sealed class Build : NukeBuild /// Windows x64 self contained. /// private Target PublishWin64SelfContained => _ => _ - .DependsOn(Restore) + .DependsOn(Clean) .Produces(PathToWin64SelfContainedZip) .Executes(() => { @@ -160,34 +180,6 @@ public sealed class Build : NukeBuild fileMode: System.IO.FileMode.CreateNew); }); - /// - /// Windows x64 AOT. - /// - private Target PublishWin64Aot => _ => _ - .DependsOn(Restore) - .Produces(PathToWin64SelfContainedZip) - .Executes(() => - { - var staging = StagingDirectory / "win-x64_aot"; - - DotNetPublish(_ => _ - .SetAssemblyVersion(AssemblyVersion) - .SetInformationalVersion(InformationalVersion) - .SetConfiguration(Configuration) - .SetFramework("net8.0-windows") - .SetProject(Solution._0_Host.Wtq_Host_Windows) - .SetOutput(staging) - .SetProperty("PublishAot", true) - .SetProperty("InvariantGlobalization", true) - .SetRuntime("win-x64")); - - staging.ZipTo( - PathToWin64SelfContainedZip, - filter: x => x.HasExtension(".exe", ".jsonc"), - compressionLevel: CompressionLevel.SmallestSize, - fileMode: System.IO.FileMode.CreateNew); - }); - /// /// Scoop manifest. /// From 84e106005d217a7de593b04be3ac28ba3970ba50 Mon Sep 17 00:00:00 2001 From: Marco van den Oever Date: Sun, 14 Jul 2024 12:57:50 +0200 Subject: [PATCH 2/5] Package updates --- src/Directory.Packages.props | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/Directory.Packages.props b/src/Directory.Packages.props index a7b3295e..724ef126 100644 --- a/src/Directory.Packages.props +++ b/src/Directory.Packages.props @@ -3,18 +3,17 @@ true - + - - + - + - - - + + + From 4db65efa16bcbd737d19d584bee1a974d0bb0af8 Mon Sep 17 00:00:00 2001 From: Marco van den Oever Date: Sun, 14 Jul 2024 13:03:34 +0200 Subject: [PATCH 3/5] [WtqRect] Contains() --- src/10-Core/Wtq/Data/WtqRect.cs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/10-Core/Wtq/Data/WtqRect.cs b/src/10-Core/Wtq/Data/WtqRect.cs index 1f54d6b3..39563fdf 100644 --- a/src/10-Core/Wtq/Data/WtqRect.cs +++ b/src/10-Core/Wtq/Data/WtqRect.cs @@ -1,4 +1,6 @@ -namespace Wtq.Data; +using System.Drawing; + +namespace Wtq.Data; public struct WtqRect : IEquatable { @@ -36,6 +38,15 @@ public static WtqRect Lerp(WtqRect b1, WtqRect b2, float by) }; } + public readonly bool Contains(Point pos) + { + return + X < pos.X && + Y < pos.Y && + X + Width > pos.X && + Y + Height > pos.Y; + } + public readonly bool Contains(WtqVec2I pos) { return From 69c12828e2a5f727ea54ae48dec89eca4aaba0d9 Mon Sep 17 00:00:00 2001 From: Marco van den Oever Date: Sun, 14 Jul 2024 13:07:18 +0200 Subject: [PATCH 4/5] Async extensions (NoCtx) --- src/10-Core/Wtq/Utils/SystemExtensions.cs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 src/10-Core/Wtq/Utils/SystemExtensions.cs diff --git a/src/10-Core/Wtq/Utils/SystemExtensions.cs b/src/10-Core/Wtq/Utils/SystemExtensions.cs new file mode 100644 index 00000000..a98cf9c0 --- /dev/null +++ b/src/10-Core/Wtq/Utils/SystemExtensions.cs @@ -0,0 +1,22 @@ +using System.Runtime.CompilerServices; + +namespace Wtq.Utils; + +public static class SystemExtensions +{ + [SuppressMessage("Usage", "VSTHRD003:Avoid awaiting foreign Tasks", Justification = "MvdO: Whether or not to await is up to the caller.")] + public static ConfiguredTaskAwaitable NoCtx(this Task task) + { + ArgumentNullException.ThrowIfNull(task); + + return task.ConfigureAwait(false); + } + + [SuppressMessage("Usage", "VSTHRD003:Avoid awaiting foreign Tasks", Justification = "MvdO: Whether or not to await is up to the caller.")] + public static ConfiguredTaskAwaitable NoCtx(this Task task) + { + ArgumentNullException.ThrowIfNull(task); + + return task.ConfigureAwait(false); + } +} \ No newline at end of file From 39ca2bbe92f133148f5476ac4d6340e9cf3da7e4 Mon Sep 17 00:00:00 2001 From: Marco van den Oever Date: Sun, 14 Jul 2024 13:09:25 +0200 Subject: [PATCH 5/5] Removed UI test project for now --- src/30-Host/Wtq.UITest/Program.cs | 12 --------- .../Wtq.UITest/ServiceCollectionExtensions.cs | 22 --------------- src/30-Host/Wtq.UITest/SomeTest.cs | 27 ------------------- src/30-Host/Wtq.UITest/Wtq.UITest.csproj | 25 ----------------- 4 files changed, 86 deletions(-) delete mode 100644 src/30-Host/Wtq.UITest/Program.cs delete mode 100644 src/30-Host/Wtq.UITest/ServiceCollectionExtensions.cs delete mode 100644 src/30-Host/Wtq.UITest/SomeTest.cs delete mode 100644 src/30-Host/Wtq.UITest/Wtq.UITest.csproj diff --git a/src/30-Host/Wtq.UITest/Program.cs b/src/30-Host/Wtq.UITest/Program.cs deleted file mode 100644 index 82d25b9f..00000000 --- a/src/30-Host/Wtq.UITest/Program.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System.Threading.Tasks; - -namespace Wtq.UITest; - -public sealed class Program -{ - private readonly Microsoft.Extensions.Logging.ILogger _log; - - public static async Task Main(string[] args) - { - } -} \ No newline at end of file diff --git a/src/30-Host/Wtq.UITest/ServiceCollectionExtensions.cs b/src/30-Host/Wtq.UITest/ServiceCollectionExtensions.cs deleted file mode 100644 index 3bd3d193..00000000 --- a/src/30-Host/Wtq.UITest/ServiceCollectionExtensions.cs +++ /dev/null @@ -1,22 +0,0 @@ -//using Ardalis.GuardClauses; -//using Microsoft.Extensions.DependencyInjection; -//using Microsoft.Extensions.Hosting; -//using System; - -//namespace Wtq.Windows; - -//public static class ServiceCollectionExtensions -//{ -// public static IServiceCollection AddSingletonHostedService(this IServiceCollection services) -// where TService : class -// where TImplementation : class, TService, IHostedService -// { -// Guard.Against.Null(services, nameof(services)); - -// services.AddSingleton(); - -// services.AddHostedService(p => (TImplementation)p.GetRequiredService()); - -// return services; -// } -//} \ No newline at end of file diff --git a/src/30-Host/Wtq.UITest/SomeTest.cs b/src/30-Host/Wtq.UITest/SomeTest.cs deleted file mode 100644 index 45ff9f9b..00000000 --- a/src/30-Host/Wtq.UITest/SomeTest.cs +++ /dev/null @@ -1,27 +0,0 @@ -using Microsoft.VisualStudio.TestTools.UnitTesting; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Wtq.UITest; - -[TestClass] -public sealed class SomeTest -{ - - - [TestMethod] - public async Task MethodName() - { - // Arrange - //Wtq.Windows.Program.Main() - - // Act - - // Assert - Assert.Inconclusive(); - } - -} diff --git a/src/30-Host/Wtq.UITest/Wtq.UITest.csproj b/src/30-Host/Wtq.UITest/Wtq.UITest.csproj deleted file mode 100644 index 5c830976..00000000 --- a/src/30-Host/Wtq.UITest/Wtq.UITest.csproj +++ /dev/null @@ -1,25 +0,0 @@ - - - Wtq.UITest - Wtq.UITest - - net8.0-windows - - - - - Always - - - - - - - - - - - - - -