From 67a5e6a0af120980978d98842d3ccfadaafdb1bb Mon Sep 17 00:00:00 2001 From: Ruofan Date: Thu, 11 Jan 2024 13:27:30 +0800 Subject: [PATCH 1/3] Use .Net 8.0 instead of .Net 7.0 1. Update some third-party components 2. Remove netcoreapp2.0 from test project due to security vulnerability 3. Mark library as Trimmable 4. Support .Net 8.0 and drop support for .Net 7.0 --- .globalconfig | 3 --- ConcurrentPriorityQueue.sln | 9 ++----- .../ConcurrentPriorityQueue.csproj | 22 +++------------- .../ConcurrentPriorityQueueTests.csproj | 24 +++++------------- ...riorityQueueBlockingCollectionUnitTests.cs | 12 ++++----- Directory.Build.props | 15 +++++------ ...GenericConcurrentPriorityQueueTests.csproj | 25 +++++-------------- 7 files changed, 30 insertions(+), 80 deletions(-) diff --git a/.globalconfig b/.globalconfig index 8e3b570..141629b 100644 --- a/.globalconfig +++ b/.globalconfig @@ -24,9 +24,6 @@ dotnet_diagnostic.SA1309.severity = none # SA1101: Prefix local calls with this dotnet_diagnostic.SA1101.severity = none -# Default severity for all analyzer diagnostics -dotnet_analyzer_diagnostic.severity = error - # IDE0011: Add braces csharp_prefer_braces = when_multiline diff --git a/ConcurrentPriorityQueue.sln b/ConcurrentPriorityQueue.sln index 62ee1d4..10620c7 100644 --- a/ConcurrentPriorityQueue.sln +++ b/ConcurrentPriorityQueue.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.30523.141 +# Visual Studio Version 17 +VisualStudioVersion = 17.8.34408.163 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConcurrentPriorityQueue", "ConcurrentPriorityQueue\ConcurrentPriorityQueue.csproj", "{E6C7464F-9840-4477-AB3E-8D7A4539D016}" EndProject @@ -9,11 +9,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConcurrentPriorityQueueTest EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GenericConcurrentPriorityQueueTests", "GenericConcurrentPriorityQueueTests\GenericConcurrentPriorityQueueTests.csproj", "{D5BAFA8A-1330-468A-B183-451C5349F198}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{DD33233E-9CC4-4DEE-BEE7-AAADEC1EDB65}" - ProjectSection(SolutionItems) = preProject - .editorconfig = .editorconfig - EndProjectSection -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU diff --git a/ConcurrentPriorityQueue/ConcurrentPriorityQueue.csproj b/ConcurrentPriorityQueue/ConcurrentPriorityQueue.csproj index 25b18eb..f8628d6 100644 --- a/ConcurrentPriorityQueue/ConcurrentPriorityQueue.csproj +++ b/ConcurrentPriorityQueue/ConcurrentPriorityQueue.csproj @@ -1,32 +1,18 @@  - net48;netstandard2.0;net6.0;net7.0 + true + net48;netstandard2.0;net6.0;net8.0 Noam Yogev - - A thread-safe generic first in-first out (FIFO) collection with support for priority queuing. - + A thread-safe generic first in-first out (FIFO) collection with support for priority queuing. https://github.com/noamyogev84/ConcurrentPriorityQueue https://github.com/noamyogev84/ConcurrentPriorityQueue threading thread-safe producerconsumer concurrent-collection concurrent blocking-collection collections PriorityConcurrentQueue - - - - - - - - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/ConcurrentPriorityQueueTests/ConcurrentPriorityQueueTests.csproj b/ConcurrentPriorityQueueTests/ConcurrentPriorityQueueTests.csproj index a60a692..e936bd1 100644 --- a/ConcurrentPriorityQueueTests/ConcurrentPriorityQueueTests.csproj +++ b/ConcurrentPriorityQueueTests/ConcurrentPriorityQueueTests.csproj @@ -1,7 +1,7 @@  - net48;netcoreapp2.0;net6.0;net7.0 + net48;net6.0;net8.0 ..\ConcurrentPriorityQueue.ruleset false true @@ -16,17 +16,12 @@ - - - + + - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - + + + all runtime; build; native; contentfiles; analyzers; buildtransitive @@ -36,11 +31,4 @@ - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - diff --git a/ConcurrentPriorityQueueTests/PriorityQueueBlockingCollectionUnitTests.cs b/ConcurrentPriorityQueueTests/PriorityQueueBlockingCollectionUnitTests.cs index 56adce4..ea0503e 100644 --- a/ConcurrentPriorityQueueTests/PriorityQueueBlockingCollectionUnitTests.cs +++ b/ConcurrentPriorityQueueTests/PriorityQueueBlockingCollectionUnitTests.cs @@ -22,25 +22,25 @@ public PriorityQueueBlockingCollectionUnitTests() } [Fact] - public async Task Test_ConsumingTaskBlocksUntilNoMoreAdditions() + public async Task Test_ConsumingTaskBlocksUntilNoMoreAdditionsAsync() { const int numberOfItemsToAdd = 10; const int defaultSleepTimeBetweenAdds = 1000; // Add items and signal for completion when done. - _ = Task.Run(() => AddItems(numberOfItemsToAdd, defaultSleepTimeBetweenAdds)) + _ = Task.Run(() => AddItemsAsync(numberOfItemsToAdd, defaultSleepTimeBetweenAdds)) .ContinueWith(t => _targetCollection.CompleteAdding()); // Take items as long as they continue to be added. - _ = Task.Run(TakeItems).ConfigureAwait(false); + _ = Task.Run(TakeItemsAsync).ConfigureAwait(true); // Wait for all tasks to end. - await Task.WhenAll(AddItems(numberOfItemsToAdd, defaultSleepTimeBetweenAdds), TakeItems()).ConfigureAwait(false); + await Task.WhenAll(AddItemsAsync(numberOfItemsToAdd, defaultSleepTimeBetweenAdds), TakeItemsAsync()).ConfigureAwait(true); } public void Dispose() => _targetCollection.Dispose(); - private async Task AddItems(int numberOfItemsToAdd, int sleepTime = 0) + private async Task AddItemsAsync(int numberOfItemsToAdd, int sleepTime = 0) { for (var i = 0; i < numberOfItemsToAdd; ++i) { @@ -49,7 +49,7 @@ private async Task AddItems(int numberOfItemsToAdd, int sleepTime = 0) } } - private Task TakeItems() + private Task TakeItemsAsync() { // blocks until signaled on completion. foreach (var item in _targetCollection.GetConsumingEnumerable()) diff --git a/Directory.Build.props b/Directory.Build.props index b4fada6..da4c914 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,19 +1,16 @@ - - true - - + all runtime; build; native; contentfiles; analyzers; buildtransitive - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - + all runtime; build; native; contentfiles; analyzers; buildtransitive + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + \ No newline at end of file diff --git a/GenericConcurrentPriorityQueueTests/GenericConcurrentPriorityQueueTests.csproj b/GenericConcurrentPriorityQueueTests/GenericConcurrentPriorityQueueTests.csproj index 7499b9d..da32d84 100644 --- a/GenericConcurrentPriorityQueueTests/GenericConcurrentPriorityQueueTests.csproj +++ b/GenericConcurrentPriorityQueueTests/GenericConcurrentPriorityQueueTests.csproj @@ -1,23 +1,17 @@  - net48;netcoreapp2.0;net6.0;net7.0 + net48;net6.0;net8.0 false true - - - - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - + + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive @@ -27,11 +21,4 @@ - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - From aade4baed3e42be336c1c97ec2eab94675534f8b Mon Sep 17 00:00:00 2001 From: Ruofan Date: Thu, 11 Jan 2024 13:32:11 +0800 Subject: [PATCH 2/3] Update build.yml --- .github/workflows/build.yml | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 12cb1e7..3eb5928 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -8,20 +8,27 @@ on: jobs: build: - runs-on: windows-2022 + runs-on: windows-latest steps: - - uses: actions/checkout@v3.3.0 + - name: Checkout + uses: actions/checkout@v4.1.1 + with: + fetch-depth: 0 + - name: Setup .NET - uses: actions/setup-dotnet@v3.0.3 + uses: actions/setup-dotnet@v4.0.0 with: dotnet-version: | - 7.x + 8.x 6.x 2.x + - name: Restore dependencies run: dotnet restore + - name: Build run: dotnet build --no-restore + - name: Test run: dotnet test --no-build --verbosity normal From cbf3c054b475fffe4cc0a6058a3790c16e1e6e4b Mon Sep 17 00:00:00 2001 From: Ruofan Date: Thu, 11 Jan 2024 13:34:32 +0800 Subject: [PATCH 3/3] Github action: add support for cancellation --- .github/workflows/build.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3eb5928..c9c504d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,4 +1,4 @@ -name: Build and test library +name: Build and Test ConcurrentPriorityQueue on: push: @@ -6,6 +6,10 @@ on: pull_request: branches: [develop] +concurrency: + group: ${{github.workflow}}-${{github.event.pull_request.number || github.ref}} + cancel-in-progress: true + jobs: build: runs-on: windows-latest