From 9b7e42caab427271e7230b11d10b25b00dcb3a3d Mon Sep 17 00:00:00 2001 From: Panos Athanasiou Date: Wed, 22 Jul 2026 23:44:45 +0300 Subject: [PATCH] refactor: msbuild and repo files - Streamline Directory.Build.props and Directory.Packages.props files - Use MinVer for versioning and ThisAssembly for static class generation of version info - Upgrade packages - Add traversal project for samples - Fix samples - Fix publish.yaml --- .gitattributes | 2 ++ .github/workflows/publish.yaml | 2 +- .github/workflows/pull_request.yaml | 4 +++ Directory.Build.props | 15 +++++------ Directory.Packages.props | 15 +++++------ benchmark/Directory.Packages.props | 9 +++---- cake.cs | 25 +++++++++++++------ global.json | 3 ++- .../Blazor/Blazor.Client/Pages/Counter.razor | 2 +- .../Blazor/Components/Pages/Weather.razor | 2 +- sample/Console/ProgramRequests.cs | 2 +- sample/Console/ProgramStreams.cs | 2 +- sample/Directory.Build.props | 2 ++ sample/Directory.Packages.props | 11 ++++---- sample/WebApi/Program.cs | 2 +- sample/sample.proj | 5 ++++ src/Directory.Build.props | 6 +++++ src/Directory.Packages.props | 7 ++++++ .../Extensions/SourceBuilderExtensions.cs | 10 ++++---- .../Pipelines.Generator.csproj | 1 - test/Directory.Build.props | 12 +++++++++ test/Directory.Packages.props | 8 +++--- ...es.Generator.Test.Integration.NuGet.csproj | 1 - ...ipelines.Generator.Test.Integration.csproj | 1 - .../Pipelines.Generator.Test.csproj | 1 - version.json | 18 ------------- 26 files changed, 96 insertions(+), 72 deletions(-) create mode 100644 sample/sample.proj create mode 100644 src/Directory.Build.props create mode 100644 src/Directory.Packages.props create mode 100644 test/Directory.Build.props delete mode 100644 version.json diff --git a/.gitattributes b/.gitattributes index ec10f3b..40e83cd 100644 --- a/.gitattributes +++ b/.gitattributes @@ -86,6 +86,8 @@ * text=auto *.cs text diff=csharp +*.razor linguist-language=C# +*.verified.cs text eol=lf working-tree-encoding=UTF-8 *.cshtml text diff=html *.csx text diff=csharp *.sln text eol=crlf diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index ce9b866..3a49aa5 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -8,7 +8,7 @@ on: - v[0-9]+.[0-9]+.[0-9]+ paths: - src/** - - Directory.build.packages + - Directory.Packages.props permissions: id-token: write contents: read diff --git a/.github/workflows/pull_request.yaml b/.github/workflows/pull_request.yaml index 57b387e..2836a4f 100644 --- a/.github/workflows/pull_request.yaml +++ b/.github/workflows/pull_request.yaml @@ -1,4 +1,6 @@ name: Pull Request +permissions: + contents: read on: pull_request: branches: @@ -9,11 +11,13 @@ on: - Directory.Packages.props types: - opened + - synchronize - ready_for_review - review_requested jobs: pull_request: runs-on: ubuntu-latest + if: github.event.pull_request.draft == false steps: - name: Checkout uses: Actions/Checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 diff --git a/Directory.Build.props b/Directory.Build.props index 4ba651b..92c50cc 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -10,6 +10,8 @@ Debug $(NoWarn);CS8509;IDE0039;IDE0130;IDE0290;IDE0060;RZ10012;IDE0052;BL0007;NU5128;IDE0079;CS8424;IDE0305 $(WarningsAsErrors);RZ2012 + v + dev @@ -19,18 +21,14 @@ true - - - true - $(MSBuildThisFileDirectory) - - Heretic Software - Copyright (c) $([System.DateTimeOffset]::UtcNow.ToString("yyyy")) $(Authors) + 2026 + Copyright (c) $(Year) $(Authors) https://www.github.com/HereticSoftware - $(OrganizationUrl)/Pipelines + Pipelines + $(OrganizationUrl)/$(RepositoryName) git MIT @@ -59,5 +57,4 @@ - \ No newline at end of file diff --git a/Directory.Packages.props b/Directory.Packages.props index 3fe5f1e..0299792 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -2,16 +2,17 @@ true - + - - - - + + + + - - + + + diff --git a/benchmark/Directory.Packages.props b/benchmark/Directory.Packages.props index 90f814c..b095223 100644 --- a/benchmark/Directory.Packages.props +++ b/benchmark/Directory.Packages.props @@ -3,16 +3,15 @@ - + - - - + + + - diff --git a/cake.cs b/cake.cs index d0a782e..f68f9c3 100644 --- a/cake.cs +++ b/cake.cs @@ -1,15 +1,12 @@ +#! #:sdk Cake.Sdk -#:property ManagePackageVersionsCentrally=false -#:package Cake.GitVersioning@3.9.50 -#:package NuGet.Protocol@7.3.1 var target = Argument("target"); var nugetApiKey = EnvironmentVariable("NUGET_API_KEY", string.Empty); var nugetSource = EnvironmentVariable("NUGET_SOURCE", string.Empty); var configuration = "Release"; -var version = GitVersioningGetVersion(); -Information("Version: {0}, Configuration: {1}", version.SemVer2, configuration); +var version = ThisAssembly.Info.InformationalVersion; DirectoryPath[] srcProjects = [ "src/Pipelines", @@ -23,6 +20,8 @@ .. testProjects ]; +Information("Pipelines Version {0} Configuration {1}", version, configuration); + var restore = Task("Restore") .DoesForEach(projects, dir => { @@ -83,8 +82,8 @@ .. testProjects .IsDependentOn(testNuget); var publish = Task("Publish") - .WithCriteria(!string.IsNullOrEmpty(nugetSource), "Environment variable `NUGET_API_KEY` was not provided") - .WithCriteria(!string.IsNullOrEmpty(nugetApiKey), "Environment variable `NUGET_SOURCE` was not provided") + .WithCriteria(() => !string.IsNullOrEmpty(nugetSource), "Environment variable `NUGET_API_KEY` was not provided") + .WithCriteria(() => !string.IsNullOrEmpty(nugetApiKey), "Environment variable `NUGET_SOURCE` was not provided") .IsDependentOn(build) .IsDependentOn(test) .IsDependentOn(testNuget) @@ -96,4 +95,14 @@ .. testProjects DotNetNuGetPush("packages/*.nupkg", new() { Source = nugetSource, ApiKey = nugetApiKey }); }); -RunTarget(target); +try +{ + RunTarget(target); +} +catch (Exception ex) +{ + if (((int)Context.Log.Verbosity) > 2) + AnsiConsole.WriteException(ex); + else + Error(ex.Message); +} diff --git a/global.json b/global.json index af7975a..f6c838b 100644 --- a/global.json +++ b/global.json @@ -5,7 +5,8 @@ "allowPrerelease": false }, "msbuild-sdks": { - "Cake.Sdk": "6.1.1", + "Microsoft.Build.Traversal": "4.1.0", + "Cake.Sdk": "6.2.0", "ViHo.PackAsAnalyzer": "1.0.1" }, "test": { diff --git a/sample/Blazor/Blazor.Client/Pages/Counter.razor b/sample/Blazor/Blazor.Client/Pages/Counter.razor index 0e52794..b41a342 100644 --- a/sample/Blazor/Blazor.Client/Pages/Counter.razor +++ b/sample/Blazor/Blazor.Client/Pages/Counter.razor @@ -17,6 +17,6 @@ private async Task IncrementCount() { - current = await pipeline.Request.Execute(new IncrementCounterRequest(current.Count)); + current = await pipeline.Request(new IncrementCounterRequest(current.Count)); } } diff --git a/sample/Blazor/Blazor/Components/Pages/Weather.razor b/sample/Blazor/Blazor/Components/Pages/Weather.razor index 5eb6499..f931d8c 100644 --- a/sample/Blazor/Blazor/Components/Pages/Weather.razor +++ b/sample/Blazor/Blazor/Components/Pages/Weather.razor @@ -44,7 +44,7 @@ else { forecasts ??= []; - await foreach (var forecast in pipeline.Stream.Execute(new GetWeatherForecasts(5))) + await foreach (var forecast in pipeline.Stream(new GetWeatherForecasts(5))) { forecasts = forecasts.Value.Add(forecast); this.StateHasChanged(); diff --git a/sample/Console/ProgramRequests.cs b/sample/Console/ProgramRequests.cs index 296630f..ca74d32 100644 --- a/sample/Console/ProgramRequests.cs +++ b/sample/Console/ProgramRequests.cs @@ -31,7 +31,7 @@ public static async Task Run(CancellationToken ct = default) var id = 10; var request = new Ping(id); - var response = await pipeline.Request.Execute(request, ct); + var response = await pipeline.Request(request, ct); Console.WriteLine($""" ----------------------------------- diff --git a/sample/Console/ProgramStreams.cs b/sample/Console/ProgramStreams.cs index a19ee69..33d52ac 100644 --- a/sample/Console/ProgramStreams.cs +++ b/sample/Console/ProgramStreams.cs @@ -33,7 +33,7 @@ public static async Task Run(CancellationToken ct = default) var id = 20; var request = new Ping(id); - await foreach (var response in pipeline.Stream.Execute(request, ct)) + await foreach (var response in pipeline.Stream(request, ct)) { Console.WriteLine($""" ----------------------------------- diff --git a/sample/Directory.Build.props b/sample/Directory.Build.props index 274a773..616ba64 100644 --- a/sample/Directory.Build.props +++ b/sample/Directory.Build.props @@ -1,4 +1,6 @@ + + diff --git a/sample/Directory.Packages.props b/sample/Directory.Packages.props index 8ba4aa5..db1c7d1 100644 --- a/sample/Directory.Packages.props +++ b/sample/Directory.Packages.props @@ -3,11 +3,12 @@ - - - - - + + + + + + diff --git a/sample/WebApi/Program.cs b/sample/WebApi/Program.cs index f43c2ee..de64f9b 100644 --- a/sample/WebApi/Program.cs +++ b/sample/WebApi/Program.cs @@ -24,7 +24,7 @@ app.UseHttpsRedirection(); app - .MapGet("/weatherforecast", (Pipeline pipeline, CancellationToken ct) => pipeline.Request.Execute(new GetWeatherForecasts(), ct)) + .MapGet("/weatherforecast", (Pipeline pipeline, CancellationToken ct) => pipeline.Request(new GetWeatherForecasts(), ct)) .WithName("Get Weather Forecast") .WithDescription("Uses the Pipeline (mediator) type to send a request, since the request implements the IRequest interface the method only needs a new Instance of the request type."); diff --git a/sample/sample.proj b/sample/sample.proj new file mode 100644 index 0000000..dd1e72e --- /dev/null +++ b/sample/sample.proj @@ -0,0 +1,5 @@ + + + + + diff --git a/src/Directory.Build.props b/src/Directory.Build.props new file mode 100644 index 0000000..616ba64 --- /dev/null +++ b/src/Directory.Build.props @@ -0,0 +1,6 @@ + + + + + + diff --git a/src/Directory.Packages.props b/src/Directory.Packages.props new file mode 100644 index 0000000..936d882 --- /dev/null +++ b/src/Directory.Packages.props @@ -0,0 +1,7 @@ + + + + + + + diff --git a/src/Pipelines.Generator/Extensions/SourceBuilderExtensions.cs b/src/Pipelines.Generator/Extensions/SourceBuilderExtensions.cs index 5f93dff..260e8b8 100644 --- a/src/Pipelines.Generator/Extensions/SourceBuilderExtensions.cs +++ b/src/Pipelines.Generator/Extensions/SourceBuilderExtensions.cs @@ -28,7 +28,7 @@ public void AutoGeneratedCodeHeader() const string header = $""" //------------------------------------------------------------------------------ // - // This code was generated by the Pipelines.Generator v{ThisAssembly.AssemblyInformationalVersion} source generator. + // This code was generated by the Pipelines.Generator v{ThisAssembly.Info.InformationalVersion} source generator. // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -67,10 +67,10 @@ public void UsingSystemCodeDomCompiler() /// public void GeneratedCodeAttribute(bool full = false) { - if (full) - sb.Line(sb, $"""[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Pipelines.Generator", "{ThisAssembly.AssemblyInformationalVersion}")]"""); - else - sb.Line(sb, $"""[GeneratedCodeAttribute("Pipelines.Generator", "{ThisAssembly.AssemblyInformationalVersion}")]"""); + const string f = $"""[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Pipelines.Generator", "{ThisAssembly.Info.InformationalVersion}")]"""; + const string s = $"""[GeneratedCodeAttribute("Pipelines.Generator", "{ThisAssembly.Info.InformationalVersion}")]"""; + + sb.Line(full ? f : s); } /// diff --git a/src/Pipelines.Generator/Pipelines.Generator.csproj b/src/Pipelines.Generator/Pipelines.Generator.csproj index 7cf5ae2..f1e0b9d 100644 --- a/src/Pipelines.Generator/Pipelines.Generator.csproj +++ b/src/Pipelines.Generator/Pipelines.Generator.csproj @@ -6,7 +6,6 @@ false true $(NoWarn);NU5128 - true diff --git a/test/Directory.Build.props b/test/Directory.Build.props new file mode 100644 index 0000000..a4ca287 --- /dev/null +++ b/test/Directory.Build.props @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/test/Directory.Packages.props b/test/Directory.Packages.props index 2aec013..900b6ee 100644 --- a/test/Directory.Packages.props +++ b/test/Directory.Packages.props @@ -2,12 +2,12 @@ - - + + - + - + diff --git a/test/Pipelines.Generator.Test.Integration.NuGet/Pipelines.Generator.Test.Integration.NuGet.csproj b/test/Pipelines.Generator.Test.Integration.NuGet/Pipelines.Generator.Test.Integration.NuGet.csproj index 37d6b2a..e594801 100644 --- a/test/Pipelines.Generator.Test.Integration.NuGet/Pipelines.Generator.Test.Integration.NuGet.csproj +++ b/test/Pipelines.Generator.Test.Integration.NuGet/Pipelines.Generator.Test.Integration.NuGet.csproj @@ -8,7 +8,6 @@ - diff --git a/test/Pipelines.Generator.Test.Integration/Pipelines.Generator.Test.Integration.csproj b/test/Pipelines.Generator.Test.Integration/Pipelines.Generator.Test.Integration.csproj index 043e19d..a28879f 100644 --- a/test/Pipelines.Generator.Test.Integration/Pipelines.Generator.Test.Integration.csproj +++ b/test/Pipelines.Generator.Test.Integration/Pipelines.Generator.Test.Integration.csproj @@ -8,7 +8,6 @@ - diff --git a/test/Pipelines.Generator.Test/Pipelines.Generator.Test.csproj b/test/Pipelines.Generator.Test/Pipelines.Generator.Test.csproj index 802ab28..f3771d4 100644 --- a/test/Pipelines.Generator.Test/Pipelines.Generator.Test.csproj +++ b/test/Pipelines.Generator.Test/Pipelines.Generator.Test.csproj @@ -10,7 +10,6 @@ - diff --git a/version.json b/version.json deleted file mode 100644 index 452026f..0000000 --- a/version.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/main/src/NerdBank.GitVersioning/version.schema.json", - "version": "1.0-alpha.{height}", - "pathFilters": [ - "/src", - "/Directory.Packages.props" - ], - "publicReleaseRefSpec": [ - "^refs/heads/main", - "^refs/tags/v\\d+\\.\\d+\\.\\d+" - ], - "nugetPackageVersion": { - "semVer": 2 - }, - "assemblyVersion": { - "precision": "revision" - } -}