From 018b57e26442ae8ad1ab0930ca5bc4488f6dba94 Mon Sep 17 00:00:00 2001 From: rameel Date: Mon, 19 Aug 2024 12:09:39 +0500 Subject: [PATCH 1/9] Formatting --- .github/workflows/publish.yml | 62 +++++++++--------- .github/workflows/test.yml | 2 +- Directory.Build.props | 10 +-- Ramstack.Structures.sln | 2 +- .../Collections/ImmutableArrayExtensions.cs | 2 +- .../Properties/AssemblyInfo.cs | 64 +++++++++---------- .../Ramstack.Structures.csproj | 2 +- 7 files changed, 72 insertions(+), 72 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 3b9b8d6..dedd6b7 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,31 +1,31 @@ -name: Publish - -on: - push: - tags: - - "[0-9]+.[0-9]+.[0-9]+" - -jobs: - publish: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 2 - - - name: Setup .NET - uses: actions/setup-dotnet@v3 - with: - dotnet-version: 9.0.x - - - name: Restore - run: dotnet restore - - - name: Build - run: dotnet build -c Release --no-restore - - - name: Pack - run: dotnet pack -c Release -o ./nuget --no-build - - - name: Publish - run: dotnet nuget push ./nuget/*.nupkg --api-key ${{secrets.NUGET_API_KEY}} --skip-duplicate -s https://api.nuget.org/v3/index.json +name: Publish + +on: + push: + tags: + - "[0-9]+.[0-9]+.[0-9]+" + +jobs: + publish: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 2 + + - name: Setup .NET + uses: actions/setup-dotnet@v3 + with: + dotnet-version: 9.0.x + + - name: Restore + run: dotnet restore + + - name: Build + run: dotnet build -c Release --no-restore + + - name: Pack + run: dotnet pack -c Release -o ./nuget --no-build + + - name: Publish + run: dotnet nuget push ./nuget/*.nupkg --api-key ${{secrets.NUGET_API_KEY}} --skip-duplicate -s https://api.nuget.org/v3/index.json diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8df697e..bac3149 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,4 +1,4 @@ -name: Build & Test +name: Build & Test on: pull_request: diff --git a/Directory.Build.props b/Directory.Build.props index ed14ea7..bf61882 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,5 +1,5 @@ - - - true - - + + + true + + diff --git a/Ramstack.Structures.sln b/Ramstack.Structures.sln index cb84108..c921cff 100644 --- a/Ramstack.Structures.sln +++ b/Ramstack.Structures.sln @@ -1,4 +1,4 @@ - + Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.0.31903.59 diff --git a/Ramstack.Structures/Collections/ImmutableArrayExtensions.cs b/Ramstack.Structures/Collections/ImmutableArrayExtensions.cs index 3041f0f..5da1490 100644 --- a/Ramstack.Structures/Collections/ImmutableArrayExtensions.cs +++ b/Ramstack.Structures/Collections/ImmutableArrayExtensions.cs @@ -1,4 +1,4 @@ -using System.Collections.Immutable; +using System.Collections.Immutable; using System.Runtime.InteropServices; namespace Ramstack.Collections; diff --git a/Ramstack.Structures/Properties/AssemblyInfo.cs b/Ramstack.Structures/Properties/AssemblyInfo.cs index 8fc4963..63851e9 100644 --- a/Ramstack.Structures/Properties/AssemblyInfo.cs +++ b/Ramstack.Structures/Properties/AssemblyInfo.cs @@ -1,32 +1,32 @@ -// ReSharper disable UnusedMember.Global - -[module: System.Runtime.CompilerServices.SkipLocalsInit] - -#if !NET8_0_OR_GREATER - -// ReSharper disable once CheckNamespace -namespace System.Runtime.CompilerServices -{ - /// - /// The type of the builder to use to construct the collection. - /// The name of the method on the builder to use to construct the collection. - [AttributeUsage( - AttributeTargets.Class - | AttributeTargets.Struct - | AttributeTargets.Interface, - Inherited = false)] - internal sealed class CollectionBuilderAttribute(Type builderType, string methodName) : Attribute - { - /// - /// Gets the type of the builder to use to construct the collection. - /// - public Type BuilderType => builderType; - - /// - /// Gets the name of the method on the builder to use to construct the collection. - /// - public string MethodName => methodName; - } -} - -#endif +// ReSharper disable UnusedMember.Global + +[module: System.Runtime.CompilerServices.SkipLocalsInit] + +#if !NET8_0_OR_GREATER + +// ReSharper disable once CheckNamespace +namespace System.Runtime.CompilerServices +{ + /// + /// The type of the builder to use to construct the collection. + /// The name of the method on the builder to use to construct the collection. + [AttributeUsage( + AttributeTargets.Class + | AttributeTargets.Struct + | AttributeTargets.Interface, + Inherited = false)] + internal sealed class CollectionBuilderAttribute(Type builderType, string methodName) : Attribute + { + /// + /// Gets the type of the builder to use to construct the collection. + /// + public Type BuilderType => builderType; + + /// + /// Gets the name of the method on the builder to use to construct the collection. + /// + public string MethodName => methodName; + } +} + +#endif diff --git a/Ramstack.Structures/Ramstack.Structures.csproj b/Ramstack.Structures/Ramstack.Structures.csproj index 5b285dc..732bef6 100644 --- a/Ramstack.Structures/Ramstack.Structures.csproj +++ b/Ramstack.Structures/Ramstack.Structures.csproj @@ -53,7 +53,7 @@ Ramstack.Collections.ReadOnlyArray<T> - + From 4427cb27bd5b7c174a90fd8a348ee67738f538e7 Mon Sep 17 00:00:00 2001 From: rameel Date: Mon, 19 Aug 2024 12:25:30 +0500 Subject: [PATCH 2/9] Reduce method IL-size --- .../Collections/ReadOnlyArray`1.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Ramstack.Structures/Collections/ReadOnlyArray`1.cs b/Ramstack.Structures/Collections/ReadOnlyArray`1.cs index ccfa27c..5cf79e0 100644 --- a/Ramstack.Structures/Collections/ReadOnlyArray`1.cs +++ b/Ramstack.Structures/Collections/ReadOnlyArray`1.cs @@ -140,8 +140,8 @@ public Enumerator GetEnumerator() [MethodImpl(MethodImplOptions.AggressiveInlining)] public ReadOnlyArray Slice(int start) { - var array = Inner!; - _ = array.Length; + var array = Inner; + _ = array!.Length; return start != 0 ? new ReadOnlyArray(array.AsSpan(start)) @@ -159,8 +159,8 @@ public ReadOnlyArray Slice(int start) [MethodImpl(MethodImplOptions.AggressiveInlining)] public ReadOnlyArray Slice(int start, int length) { - var array = Inner!; - var count = array.Length; + var array = Inner; + var count = array!.Length; if (start == 0 && length == count) return this; @@ -266,8 +266,8 @@ public ref readonly T GetPinnableReference() => /// The span to copy items into. public void CopyTo(Span destination) { - var array = this; - _ = array.Length; + var array = Inner; + _ = array!.Length; array.AsSpan().CopyTo(destination); } @@ -282,8 +282,8 @@ public void CopyTo(Span destination) /// public bool TryCopyTo(Span destination) { - var array = this; - _ = array.Length; + var array = Inner; + _ = array!.Length; return array.AsSpan().TryCopyTo(destination); } From a83d2cbc64f402737feecd6c4704e3e5adc13179 Mon Sep 17 00:00:00 2001 From: rameel Date: Mon, 19 Aug 2024 12:28:44 +0500 Subject: [PATCH 3/9] Add Debug and Release test runs --- .github/workflows/test.yml | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index bac3149..359949b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,4 +1,4 @@ -name: Build & Test +name: Test on: pull_request: @@ -15,19 +15,14 @@ jobs: steps: - uses: actions/checkout@v4 - with: - fetch-depth: 2 - name: Setup .NET uses: actions/setup-dotnet@v3 with: dotnet-version: 9.0.x - - name: Restore dependencies - run: dotnet restore - - - name: Build - run: dotnet build -c Release --no-restore + - name: Test (Debug) + run: dotnet test -c Debug - - name: Test - run: dotnet test --no-restore --verbosity normal + - name: Test (Release) + run: dotnet test -c Debug From dffa75e3d3d653f285870ce3fbf49e40b3c34e70 Mon Sep 17 00:00:00 2001 From: rameel Date: Mon, 19 Aug 2024 12:30:01 +0500 Subject: [PATCH 4/9] Fix typo --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 359949b..f254e73 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -25,4 +25,4 @@ jobs: run: dotnet test -c Debug - name: Test (Release) - run: dotnet test -c Debug + run: dotnet test -c Release From db4a33c0d36bf9c983ed2fb990d4a3ae630fe5cd Mon Sep 17 00:00:00 2001 From: rameel Date: Mon, 19 Aug 2024 17:48:26 +0500 Subject: [PATCH 5/9] Simplify github workflows --- .github/workflows/publish.yml | 10 +++------- .github/workflows/test.yml | 3 ++- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index dedd6b7..6042be5 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -9,20 +9,16 @@ jobs: publish: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 2 + - name: Checkout + uses: actions/checkout@v4 - name: Setup .NET uses: actions/setup-dotnet@v3 with: dotnet-version: 9.0.x - - name: Restore - run: dotnet restore - - name: Build - run: dotnet build -c Release --no-restore + run: dotnet build -c Release - name: Pack run: dotnet pack -c Release -o ./nuget --no-build diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f254e73..a0526f4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -14,7 +14,8 @@ jobs: os: [ubuntu-latest] steps: - - uses: actions/checkout@v4 + - name: Checkout + uses: actions/checkout@v4 - name: Setup .NET uses: actions/setup-dotnet@v3 From 0db95a7bf3def1cef8286d0e0880057d2b8ea520 Mon Sep 17 00:00:00 2001 From: rameel Date: Mon, 19 Aug 2024 17:54:20 +0500 Subject: [PATCH 6/9] Restore Build steps --- .github/workflows/test.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a0526f4..bfb96e5 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -22,8 +22,14 @@ jobs: with: dotnet-version: 9.0.x + - name: Build (Debug) + run: dotnet build -c Debug + + - name: Build (Release) + run: dotnet build -c Release + - name: Test (Debug) - run: dotnet test -c Debug + run: dotnet test -c Debug --no-build - name: Test (Release) - run: dotnet test -c Release + run: dotnet test -c Release --no-build From 00a943a569d27ff8aa4f02725652cf7286cff9aa Mon Sep 17 00:00:00 2001 From: rameel Date: Tue, 18 Mar 2025 06:59:53 +0500 Subject: [PATCH 7/9] Restrict publishing to main repository --- .github/workflows/publish.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 6042be5..689911d 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -7,6 +7,7 @@ on: jobs: publish: + if: github.repository == 'rameel/ramstack.structures' runs-on: ubuntu-latest steps: - name: Checkout From b9925037d2d7cc4fbef4bf8c8d1bf0f968c999c2 Mon Sep 17 00:00:00 2001 From: rameel Date: Tue, 18 Mar 2025 07:00:42 +0500 Subject: [PATCH 8/9] Support pre-release tags --- .github/workflows/publish.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 689911d..94c6c15 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -4,6 +4,7 @@ on: push: tags: - "[0-9]+.[0-9]+.[0-9]+" + - "[0-9]+.[0-9]+.[0-9]+-[a-z]+.[0-9]+" jobs: publish: From b1bcef4affacdc0223d8d80a75eec88c4f095856 Mon Sep 17 00:00:00 2001 From: rameel Date: Tue, 18 Mar 2025 07:07:19 +0500 Subject: [PATCH 9/9] Update github workflows --- .github/workflows/publish.yml | 18 ++++++++++++------ .github/workflows/test.yml | 26 ++++++++++---------------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 94c6c15..ddf3005 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -11,19 +11,25 @@ jobs: if: github.repository == 'rameel/ramstack.structures' runs-on: ubuntu-latest steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Setup .NET + - name: Install .NET uses: actions/setup-dotnet@v3 with: dotnet-version: 9.0.x + - name: Checkout + uses: actions/checkout@v4 + - name: Build run: dotnet build -c Release - - name: Pack + - name: Create NuGet Packages run: dotnet pack -c Release -o ./nuget --no-build - - name: Publish + - name: Publish NuGet Packages run: dotnet nuget push ./nuget/*.nupkg --api-key ${{secrets.NUGET_API_KEY}} --skip-duplicate -s https://api.nuget.org/v3/index.json + + - name: Create GitHub Release + uses: softprops/action-gh-release@v2 + with: + draft: true + files: nuget/* diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index bfb96e5..ecbf4c3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,4 +1,4 @@ -name: Test +name: Build & Test on: pull_request: @@ -6,12 +6,8 @@ on: jobs: build-and-test: - - name: build-and-test-${{ matrix.os }} - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ubuntu-latest] + name: "Test project" + runs-on: ubuntu-latest steps: - name: Checkout @@ -20,16 +16,14 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v3 with: - dotnet-version: 9.0.x - - - name: Build (Debug) - run: dotnet build -c Debug - - - name: Build (Release) - run: dotnet build -c Release + dotnet-version: | + 6.x + 7.x + 8.x + 9.x - name: Test (Debug) - run: dotnet test -c Debug --no-build + run: dotnet test -c Debug - name: Test (Release) - run: dotnet test -c Release --no-build + run: dotnet test -c Release