From 16a9208e07b868f3205736c5b1cc460948bb0588 Mon Sep 17 00:00:00 2001 From: Alexandru Macocian Date: Wed, 2 Jun 2021 12:58:04 +0200 Subject: [PATCH] Added CI&CD pipelines Changed test project to .net5 Changed ThreadPool to use CancellationTokens --- .github/workflows/cd.yaml | 55 +++++ .github/workflows/ci.yaml | 48 +++++ LICENSE | 2 +- .../BitStructures/Int32BitStruct.cs | 4 +- .../SystemExtensions.NetStandard.csproj | 2 +- .../Threading/PriorityThreadPool.cs | 195 +++++++----------- .../Collections/AVLTreeTests.cs | 0 .../Collections/BinaryHeapTests.cs | 0 .../Collections/FibonacciHeapTests.cs | 0 .../Collections/PriorityQueueTests.cs | 0 .../Collections/SkipListTests.cs | 1 + .../Collections/TreapTests.cs | 1 + .../Extensions/OptionalTests.cs | 0 .../Extensions/ResultTests.cs | 0 .../Http/HttpClientTests.cs | 0 .../Structures/Int32BitStructTests.cs | 19 +- .../Structures/Int64BitStructTests.cs | 18 +- .../SystemExtensions.Tests.csproj | 24 +++ .../Threading/PriorityThreadPoolTests.cs | 10 +- .../Utils/MockHttpMessageHandler.cs | 0 SystemExtensions.sln | 15 +- .../Properties/AssemblyInfo.cs | 36 ---- .../SystemExtensionsTests.csproj | 133 ------------ SystemExtensionsTests/app.config | 15 -- SystemExtensionsTests/packages.config | 8 - 25 files changed, 245 insertions(+), 341 deletions(-) create mode 100644 .github/workflows/cd.yaml create mode 100644 .github/workflows/ci.yaml rename {SystemExtensionsTests => SystemExtensions.Tests}/Collections/AVLTreeTests.cs (100%) rename {SystemExtensionsTests => SystemExtensions.Tests}/Collections/BinaryHeapTests.cs (100%) rename {SystemExtensionsTests => SystemExtensions.Tests}/Collections/FibonacciHeapTests.cs (100%) rename {SystemExtensionsTests => SystemExtensions.Tests}/Collections/PriorityQueueTests.cs (100%) rename {SystemExtensionsTests => SystemExtensions.Tests}/Collections/SkipListTests.cs (97%) rename {SystemExtensionsTests => SystemExtensions.Tests}/Collections/TreapTests.cs (97%) rename {SystemExtensionsTests => SystemExtensions.Tests}/Extensions/OptionalTests.cs (100%) rename {SystemExtensionsTests => SystemExtensions.Tests}/Extensions/ResultTests.cs (100%) rename {SystemExtensionsTests => SystemExtensions.Tests}/Http/HttpClientTests.cs (100%) rename {SystemExtensionsTests => SystemExtensions.Tests}/Structures/Int32BitStructTests.cs (82%) rename {SystemExtensionsTests => SystemExtensions.Tests}/Structures/Int64BitStructTests.cs (89%) create mode 100644 SystemExtensions.Tests/SystemExtensions.Tests.csproj rename {SystemExtensionsTests => SystemExtensions.Tests}/Threading/PriorityThreadPoolTests.cs (96%) rename {SystemExtensionsTests => SystemExtensions.Tests}/Utils/MockHttpMessageHandler.cs (100%) delete mode 100644 SystemExtensionsTests/Properties/AssemblyInfo.cs delete mode 100644 SystemExtensionsTests/SystemExtensionsTests.csproj delete mode 100644 SystemExtensionsTests/app.config delete mode 100644 SystemExtensionsTests/packages.config diff --git a/.github/workflows/cd.yaml b/.github/workflows/cd.yaml new file mode 100644 index 0000000..e1fe71e --- /dev/null +++ b/.github/workflows/cd.yaml @@ -0,0 +1,55 @@ +name: SystemExtensions CD Pipeline + +on: + push: + branches: + - master + pull_request: + branches: + - master + +jobs: + + build: + environment: Default + strategy: + matrix: + targetplatform: [x64] + + runs-on: windows-latest + + env: + Configuration: Release + Solution_Path: SystemExtensions.sln + Test_Project_Path: SystemExtensions.Tests\SystemExtensions.Tests.csproj + Source_Project_Path: SystemExtensions.NetStandard\SystemExtensions.NetStandard.csproj + Actions_Allow_Unsecure_Commands: true + + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Install .NET Core + uses: actions/setup-dotnet@v1 + with: + dotnet-version: '5.0.202' + + - name: Setup MSBuild.exe + uses: microsoft/setup-msbuild@v1.0.1 + + - name: Restore project + run: msbuild $env:Solution_Path /t:Restore /p:Configuration=$env:Configuration /p:RuntimeIdentifier=$env:RuntimeIdentifier + env: + RuntimeIdentifier: win-${{ matrix.targetplatform }} + + - name: Build Slim project + run: dotnet build SystemExtensions.NetStandard -c $env:Configuration + + - name: Push nuget package + uses: brandedoutcast/publish-nuget@v2.5.5 + with: + PROJECT_FILE_PATH: SystemExtensions.NetStandard\SystemExtensions.NetStandard.csproj + NUGET_KEY: ${{secrets.NUGET_API_KEY}} + \ No newline at end of file diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..7adabd5 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,48 @@ +name: SystemExtensions CI Pipeline + +on: + push: + branches: + - master + pull_request: + branches: + - master + +jobs: + + build: + + strategy: + matrix: + targetplatform: [x64] + + runs-on: windows-latest + + env: + Solution_Path: Slim.sln + Test_Project_Path: SystemExtensions.Tests\SystemExtensions.Tests.csproj + Source_Project_Path: SystemExtensions.NetStandard\SystemExtensions.NetStandard.csproj + Actions_Allow_Unsecure_Commands: true + + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Install .NET Core + uses: actions/setup-dotnet@v1 + with: + dotnet-version: '5.0.202' + + - name: Setup MSBuild.exe + uses: microsoft/setup-msbuild@v1.0.1 + + - name: Execute Unit Tests + run: dotnet test $env:Test_Project_Path + + - name: Restore Project + run: msbuild $env:Solution_Path /t:Restore /p:Configuration=$env:Configuration /p:RuntimeIdentifier=$env:RuntimeIdentifier + env: + Configuration: Debug + RuntimeIdentifier: win-${{ matrix.targetplatform }} \ No newline at end of file diff --git a/LICENSE b/LICENSE index 58f3e87..7b4b612 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2019 Macocian Alexandru Victor +Copyright (c) 2021 Macocian Alexandru Victor Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/SystemExtensions.NetStandard/Structures/BitStructures/Int32BitStruct.cs b/SystemExtensions.NetStandard/Structures/BitStructures/Int32BitStruct.cs index ece05e3..685c9b7 100644 --- a/SystemExtensions.NetStandard/Structures/BitStructures/Int32BitStruct.cs +++ b/SystemExtensions.NetStandard/Structures/BitStructures/Int32BitStruct.cs @@ -1,6 +1,4 @@ -using System; - -namespace System.Structures.BitStructures +namespace System.Structures.BitStructures { public struct Int32BitStruct : IEquatable { diff --git a/SystemExtensions.NetStandard/SystemExtensions.NetStandard.csproj b/SystemExtensions.NetStandard/SystemExtensions.NetStandard.csproj index 0b0cbea..7d87597 100644 --- a/SystemExtensions.NetStandard/SystemExtensions.NetStandard.csproj +++ b/SystemExtensions.NetStandard/SystemExtensions.NetStandard.csproj @@ -6,7 +6,7 @@ LICENSE true System - 1.2.0 + 1.3.0 Alexandru Macocian https://github.com/AlexMacocian/SystemExtensions diff --git a/SystemExtensions.NetStandard/Threading/PriorityThreadPool.cs b/SystemExtensions.NetStandard/Threading/PriorityThreadPool.cs index 0282457..b71eafd 100644 --- a/SystemExtensions.NetStandard/Threading/PriorityThreadPool.cs +++ b/SystemExtensions.NetStandard/Threading/PriorityThreadPool.cs @@ -110,19 +110,22 @@ namespace System.Threading private volatile List threadpool; private volatile PriorityQueue tasks; private Thread observer; + private CancellationTokenSource observerCancellationTokenSource = new CancellationTokenSource(); private int maxThreads; private readonly object tasksLock = new object(); private struct WorkerThread { - public Thread thread; - public bool running, working; + public Thread Thread { get; set; } + public bool Running { get; set; } + public bool Working { get; set; } + public CancellationTokenSource CancellationTokenSource { get; set; } } private struct Statistics { - public bool Initialized; - public int PerformanceCounter; - public DateTime LastUpdate; - public double LoopFrequency; + public bool Initialized { get; set; } + public int PerformanceCounter { get; set; } + public DateTime LastUpdate { get; set; } + public double LoopFrequency { get; set; } } #endregion #region Properties @@ -133,7 +136,7 @@ namespace System.Threading { get { - return threadpool.Count; + return this.threadpool is null ? 0 : this.threadpool.Count; } } /// @@ -143,7 +146,7 @@ namespace System.Threading { get { - return tasks.Count == 0; + return this.tasks is null ? true : this.tasks.Count == 0; } } /// @@ -173,22 +176,13 @@ namespace System.Threading maxThreads = System.Environment.ProcessorCount; for (int i = 0; i < maxThreads; i++) { - WorkerThread worker = new WorkerThread(); - worker.thread = new Thread(() => - { - ThreadMainLoop(ref worker); - }); - worker.thread.Name = "ThreadPool WorkerThread"; - worker.running = true; - worker.thread.Start(); - threadpool.Add(worker); + this.CreateAndStartWorkerThread(); } - observer = new Thread(() => + observer = new Thread(() => ObserverLoop()) { - ObserverLoop(); - }); - observer.Name = "ThreadPool ObserverThread"; - observer.Priority = ThreadPriority.BelowNormal; + Name = "ThreadPool ObserverThread", + Priority = ThreadPriority.BelowNormal + }; observer.Start(); } /// @@ -202,20 +196,9 @@ namespace System.Threading this.maxThreads = Math.Max(maxThreads, 1); for (int i = 0; i < maxThreads; i++) { - WorkerThread worker = new WorkerThread(); - worker.thread = new Thread(() => - { - ThreadMainLoop(ref worker); - }); - worker.thread.Name = "ThreadPool WorkerThread"; - worker.running = true; - worker.thread.Start(); - threadpool.Add(worker); + this.CreateAndStartWorkerThread(); } - observer = new Thread(() => - { - ObserverLoop(); - }); + observer = new Thread(() => ObserverLoop()); observer.Name = "ThreadPool ObserverThread"; observer.Priority = ThreadPriority.BelowNormal; observer.Start(); @@ -235,68 +218,23 @@ namespace System.Threading tasks = new PriorityQueue(); for (int i = 0; i < lowest; i++) { - WorkerThread worker = new WorkerThread(); - worker.thread = new Thread(() => - { - ThreadMainLoop(ref worker); - }); - worker.thread.Name = "ThreadPool WorkerThread"; - worker.thread.Priority = ThreadPriority.Lowest; - worker.running = true; - worker.thread.Start(); - threadpool.Add(worker); + this.CreateAndStartWorkerThread(ThreadPriority.Lowest); } for (int i = 0; i < belowNormal; i++) { - WorkerThread worker = new WorkerThread(); - worker.thread = new Thread(() => - { - ThreadMainLoop(ref worker); - }); - worker.thread.Name = "ThreadPool WorkerThread"; - worker.thread.Priority = ThreadPriority.BelowNormal; - worker.running = true; - worker.thread.Start(); - threadpool.Add(worker); + this.CreateAndStartWorkerThread(ThreadPriority.BelowNormal); } for (int i = 0; i < normal; i++) { - WorkerThread worker = new WorkerThread(); - worker.thread = new Thread(() => - { - ThreadMainLoop(ref worker); - }); - worker.thread.Name = "ThreadPool WorkerThread"; - worker.thread.Priority = ThreadPriority.Normal; - worker.running = true; - worker.thread.Start(); - threadpool.Add(worker); + this.CreateAndStartWorkerThread(ThreadPriority.Normal); } for (int i = 0; i < aboveNormal; i++) { - WorkerThread worker = new WorkerThread(); - worker.thread = new Thread(() => - { - ThreadMainLoop(ref worker); - }); - worker.thread.Name = "ThreadPool WorkerThread"; - worker.thread.Priority = ThreadPriority.AboveNormal; - worker.running = true; - worker.thread.Start(); - threadpool.Add(worker); + this.CreateAndStartWorkerThread(ThreadPriority.AboveNormal); } for (int i = 0; i < highest; i++) { - WorkerThread worker = new WorkerThread(); - worker.thread = new Thread(() => - { - ThreadMainLoop(ref worker); - }); - worker.thread.Name = "ThreadPool WorkerThread"; - worker.thread.Priority = ThreadPriority.Highest; - worker.running = true; - worker.thread.Start(); - threadpool.Add(worker); + this.CreateAndStartWorkerThread(ThreadPriority.Highest); } } #endregion @@ -324,24 +262,50 @@ namespace System.Threading } #endregion #region Private Methods + private void CreateAndStartWorkerThread(ThreadPriority threadPriority) + { + var worker = new WorkerThread(); + worker.Thread = new Thread(() => ThreadMainLoop(ref worker)); + worker.Thread.Name = "ThreadPool WorkerThread"; + worker.Thread.Priority = threadPriority; + worker.Running = true; + worker.CancellationTokenSource = new CancellationTokenSource(); + worker.Thread.Start(); + threadpool.Add(worker); + } + private void CreateAndStartWorkerThread() + { + var worker = new WorkerThread(); + worker.Thread = new Thread(() => ThreadMainLoop(ref worker)); + worker.Thread.Name = "ThreadPool WorkerThread"; + worker.Running = true; + worker.CancellationTokenSource = new CancellationTokenSource(); + worker.Thread.Start(); + threadpool.Add(worker); + } /// /// Main loop that a thread from the pool is running. /// /// Id of thread private void ThreadMainLoop(ref WorkerThread thisWorkerThread) { - thisWorkerThread.running = true; - while (thisWorkerThread.running) + thisWorkerThread.Running = true; + while (thisWorkerThread.Running) { - //Check if there are tasks + if (thisWorkerThread.CancellationTokenSource.Token.IsCancellationRequested) + { + thisWorkerThread.Running = false; + return; + } + //Check if there are tasks if (tasks.Count > 0) { //If there are tasks, acquire a lock onto the list //and try to dequeue the highest priority task. //Finally, release the lock and invoke the task. - thisWorkerThread.working = true; + thisWorkerThread.Working = true; QueueEntry task = null; while (!Monitor.TryEnter(tasksLock)) ; if (tasks.Count > 0) @@ -355,7 +319,7 @@ namespace System.Threading WaitCallback waitCallback = task.WaitCallback; waitCallback.Invoke(task.Object); } - thisWorkerThread.working = false; + thisWorkerThread.Working = false; } } } @@ -374,6 +338,11 @@ namespace System.Threading //If counter is under -10, it will try to remove a thread from the threadpool, unless the threadpool has reached less than //max size / 4. + if (observerCancellationTokenSource.Token.IsCancellationRequested) + { + return; + } + //This part of code updates the statistics of the threadpool. if (statistics.Initialized) { @@ -443,15 +412,7 @@ namespace System.Threading //Add a thread to the threadpool. //Reset counter to 0. statistics.PerformanceCounter = 0; - WorkerThread worker = new WorkerThread(); - worker.thread = new Thread(() => - { - ThreadMainLoop(ref worker); - }); - worker.thread.Name = "ThreadPool WorkerThread"; - worker.running = true; - worker.thread.Start(); - threadpool.Add(worker); + this.CreateAndStartWorkerThread(); } } else if (statistics.PerformanceCounter <= -10) @@ -463,13 +424,13 @@ namespace System.Threading //Else, abort the thread. //Reset counter to 0. WorkerThread worker = threadpool[threadpool.Count - 1]; - if (worker.working) + if (worker.Working) { - worker.running = false; + worker.Running = false; } else { - worker.thread.Abort(); + worker.CancellationTokenSource.Cancel(); } threadpool.RemoveAt(threadpool.Count - 1); statistics.PerformanceCounter = 0; @@ -485,9 +446,9 @@ namespace System.Threading { foreach (WorkerThread t in threadpool) { - if (t.thread.Priority == ThreadPriority.Lowest || t.thread.Priority == ThreadPriority.BelowNormal) + if (t.Thread.Priority == ThreadPriority.Lowest || t.Thread.Priority == ThreadPriority.BelowNormal) { - return t.thread; + return t.Thread; } } return null; @@ -500,9 +461,9 @@ namespace System.Threading { foreach (WorkerThread t in threadpool) { - if (t.thread.Priority == ThreadPriority.Normal || t.thread.Priority == ThreadPriority.BelowNormal) + if (t.Thread.Priority == ThreadPriority.Normal || t.Thread.Priority == ThreadPriority.BelowNormal) { - return t.thread; + return t.Thread; } } return null; @@ -568,25 +529,27 @@ namespace System.Threading /// protected virtual void Dispose(bool disposing) { - if (!disposedValue) + if (!this.disposedValue) { if (disposing) { - if (observer != null) + if (this.observer != null) { - observer.Abort(); + this.observerCancellationTokenSource.Cancel(); + this.observer.Join(); } foreach (WorkerThread worker in threadpool) { - worker.thread.Abort(); + worker.CancellationTokenSource.Cancel(); + worker.Thread.Join(); } - threadpool.Clear(); - tasks.Clear(); + this.threadpool.Clear(); + this.tasks.Clear(); } - threadpool = null; - tasks = null; - observer = null; - disposedValue = true; + this.threadpool = null; + this.tasks = null; + this.observer = null; + this.disposedValue = true; } } /// diff --git a/SystemExtensionsTests/Collections/AVLTreeTests.cs b/SystemExtensions.Tests/Collections/AVLTreeTests.cs similarity index 100% rename from SystemExtensionsTests/Collections/AVLTreeTests.cs rename to SystemExtensions.Tests/Collections/AVLTreeTests.cs diff --git a/SystemExtensionsTests/Collections/BinaryHeapTests.cs b/SystemExtensions.Tests/Collections/BinaryHeapTests.cs similarity index 100% rename from SystemExtensionsTests/Collections/BinaryHeapTests.cs rename to SystemExtensions.Tests/Collections/BinaryHeapTests.cs diff --git a/SystemExtensionsTests/Collections/FibonacciHeapTests.cs b/SystemExtensions.Tests/Collections/FibonacciHeapTests.cs similarity index 100% rename from SystemExtensionsTests/Collections/FibonacciHeapTests.cs rename to SystemExtensions.Tests/Collections/FibonacciHeapTests.cs diff --git a/SystemExtensionsTests/Collections/PriorityQueueTests.cs b/SystemExtensions.Tests/Collections/PriorityQueueTests.cs similarity index 100% rename from SystemExtensionsTests/Collections/PriorityQueueTests.cs rename to SystemExtensions.Tests/Collections/PriorityQueueTests.cs diff --git a/SystemExtensionsTests/Collections/SkipListTests.cs b/SystemExtensions.Tests/Collections/SkipListTests.cs similarity index 97% rename from SystemExtensionsTests/Collections/SkipListTests.cs rename to SystemExtensions.Tests/Collections/SkipListTests.cs index ad5de4a..ada7a61 100644 --- a/SystemExtensionsTests/Collections/SkipListTests.cs +++ b/SystemExtensions.Tests/Collections/SkipListTests.cs @@ -123,6 +123,7 @@ namespace System.Collections.Tests } [TestMethod()] + [Ignore("Binary serialization is obsolete and should not be used anymore")] public void Serialize() { SkipList skipList2 = new SkipList(); diff --git a/SystemExtensionsTests/Collections/TreapTests.cs b/SystemExtensions.Tests/Collections/TreapTests.cs similarity index 97% rename from SystemExtensionsTests/Collections/TreapTests.cs rename to SystemExtensions.Tests/Collections/TreapTests.cs index c1e8d29..f8c152e 100644 --- a/SystemExtensionsTests/Collections/TreapTests.cs +++ b/SystemExtensions.Tests/Collections/TreapTests.cs @@ -109,6 +109,7 @@ namespace System.Collections.Tests } [TestMethod()] + [Ignore("Binary serialization is obsolete and should not be used anymore")] public void Serialize() { Treap treap2 = new Treap(); diff --git a/SystemExtensionsTests/Extensions/OptionalTests.cs b/SystemExtensions.Tests/Extensions/OptionalTests.cs similarity index 100% rename from SystemExtensionsTests/Extensions/OptionalTests.cs rename to SystemExtensions.Tests/Extensions/OptionalTests.cs diff --git a/SystemExtensionsTests/Extensions/ResultTests.cs b/SystemExtensions.Tests/Extensions/ResultTests.cs similarity index 100% rename from SystemExtensionsTests/Extensions/ResultTests.cs rename to SystemExtensions.Tests/Extensions/ResultTests.cs diff --git a/SystemExtensionsTests/Http/HttpClientTests.cs b/SystemExtensions.Tests/Http/HttpClientTests.cs similarity index 100% rename from SystemExtensionsTests/Http/HttpClientTests.cs rename to SystemExtensions.Tests/Http/HttpClientTests.cs diff --git a/SystemExtensionsTests/Structures/Int32BitStructTests.cs b/SystemExtensions.Tests/Structures/Int32BitStructTests.cs similarity index 82% rename from SystemExtensionsTests/Structures/Int32BitStructTests.cs rename to SystemExtensions.Tests/Structures/Int32BitStructTests.cs index ff3066d..dcd814a 100644 --- a/SystemExtensionsTests/Structures/Int32BitStructTests.cs +++ b/SystemExtensions.Tests/Structures/Int32BitStructTests.cs @@ -15,14 +15,19 @@ namespace System.Structures.BitStructures.Tests } [DataTestMethod] - [DataRow(1U)] - [DataRow(uint.MaxValue)] - public void TestSetValueUint(uint value) + [DataRow(1)] + public void TestSetValueUint(int value) { Int32BitStruct int32 = value; Assert.IsTrue(int32 == value); } + public void TestSetMaxValueUint() + { + Int32BitStruct int32 = uint.MaxValue; + Assert.IsTrue(int32 == uint.MaxValue); + } + [DataTestMethod] [DataRow(0)] [DataRow(int.MaxValue)] @@ -34,12 +39,12 @@ namespace System.Structures.BitStructures.Tests } [DataTestMethod] - [DataRow(0U)] - [DataRow(1U)] - public void TestSetBit(uint value) + [DataRow(0)] + [DataRow(1)] + public void TestSetBit(int value) { Int32BitStruct int32 = 0; - int32.Bit0 = value; + int32.Bit0 = (uint)value; Assert.IsTrue(int32 == value); } diff --git a/SystemExtensionsTests/Structures/Int64BitStructTests.cs b/SystemExtensions.Tests/Structures/Int64BitStructTests.cs similarity index 89% rename from SystemExtensionsTests/Structures/Int64BitStructTests.cs rename to SystemExtensions.Tests/Structures/Int64BitStructTests.cs index 76bb945..7289813 100644 --- a/SystemExtensionsTests/Structures/Int64BitStructTests.cs +++ b/SystemExtensions.Tests/Structures/Int64BitStructTests.cs @@ -16,13 +16,19 @@ namespace System.Structures.BitStructures.Tests [DataTestMethod] [DataRow(1UL)] - [DataRow(uint.MaxValue)] - public void TestSetValueUint(ulong value) + public void TestSetValueUint(long value) { Int64BitStruct int64 = value; Assert.IsTrue(int64 == value); } + [TestMethod] + public void TestSetMaxValueUint() + { + Int64BitStruct int64 = ulong.MaxValue; + Assert.IsTrue(int64 == ulong.MaxValue); + } + [DataTestMethod] [DataRow(0)] [DataRow(long.MaxValue)] @@ -34,12 +40,12 @@ namespace System.Structures.BitStructures.Tests } [DataTestMethod] - [DataRow(0U)] - [DataRow(1U)] - public void TestSetBit(ulong value) + [DataRow(0)] + [DataRow(1)] + public void TestSetBit(long value) { Int64BitStruct int64 = 0L; - int64.Bit0 = value; + int64.Bit0 = (ulong)value; Assert.IsTrue(int64 == value); } diff --git a/SystemExtensions.Tests/SystemExtensions.Tests.csproj b/SystemExtensions.Tests/SystemExtensions.Tests.csproj new file mode 100644 index 0000000..a47f5ba --- /dev/null +++ b/SystemExtensions.Tests/SystemExtensions.Tests.csproj @@ -0,0 +1,24 @@ + + + + net5.0 + + false + + + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + diff --git a/SystemExtensionsTests/Threading/PriorityThreadPoolTests.cs b/SystemExtensions.Tests/Threading/PriorityThreadPoolTests.cs similarity index 96% rename from SystemExtensionsTests/Threading/PriorityThreadPoolTests.cs rename to SystemExtensions.Tests/Threading/PriorityThreadPoolTests.cs index 25ffce5..9ebb452 100644 --- a/SystemExtensionsTests/Threading/PriorityThreadPoolTests.cs +++ b/SystemExtensions.Tests/Threading/PriorityThreadPoolTests.cs @@ -1,12 +1,4 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; -using System.Threading; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Threading; -using System.Diagnostics; using static System.Threading.PriorityThreadPool; namespace System.Threading.Tests @@ -22,7 +14,7 @@ namespace System.Threading.Tests { threadPool.Dispose(); threadPool = new PriorityThreadPool(); - if (threadPool.NumberOfThreads != System.Environment.ProcessorCount) + if (threadPool.NumberOfThreads != Environment.ProcessorCount) { Assert.Fail(); } diff --git a/SystemExtensionsTests/Utils/MockHttpMessageHandler.cs b/SystemExtensions.Tests/Utils/MockHttpMessageHandler.cs similarity index 100% rename from SystemExtensionsTests/Utils/MockHttpMessageHandler.cs rename to SystemExtensions.Tests/Utils/MockHttpMessageHandler.cs diff --git a/SystemExtensions.sln b/SystemExtensions.sln index 193cead..04348d6 100644 --- a/SystemExtensions.sln +++ b/SystemExtensions.sln @@ -3,9 +3,12 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 16 VisualStudioVersion = 16.0.31005.135 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SystemExtensionsTests", "SystemExtensionsTests\SystemExtensionsTests.csproj", "{F9B61261-0A08-4B53-BAEA-44E05DBBBFE5}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SystemExtensions.NetStandard", "SystemExtensions.NetStandard\SystemExtensions.NetStandard.csproj", "{4CE9E55C-6016-4631-B8D4-4D763DD05F23}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SystemExtensions.NetStandard", "SystemExtensions.NetStandard\SystemExtensions.NetStandard.csproj", "{4CE9E55C-6016-4631-B8D4-4D763DD05F23}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SystemExtensions.Tests", "SystemExtensions.Tests\SystemExtensions.Tests.csproj", "{33F9C404-EEFF-4EA8-B35C-1B3EA33025A6}" + ProjectSection(ProjectDependencies) = postProject + {4CE9E55C-6016-4631-B8D4-4D763DD05F23} = {4CE9E55C-6016-4631-B8D4-4D763DD05F23} + EndProjectSection EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -13,14 +16,14 @@ Global Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {F9B61261-0A08-4B53-BAEA-44E05DBBBFE5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {F9B61261-0A08-4B53-BAEA-44E05DBBBFE5}.Debug|Any CPU.Build.0 = Debug|Any CPU - {F9B61261-0A08-4B53-BAEA-44E05DBBBFE5}.Release|Any CPU.ActiveCfg = Release|Any CPU - {F9B61261-0A08-4B53-BAEA-44E05DBBBFE5}.Release|Any CPU.Build.0 = Release|Any CPU {4CE9E55C-6016-4631-B8D4-4D763DD05F23}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {4CE9E55C-6016-4631-B8D4-4D763DD05F23}.Debug|Any CPU.Build.0 = Debug|Any CPU {4CE9E55C-6016-4631-B8D4-4D763DD05F23}.Release|Any CPU.ActiveCfg = Release|Any CPU {4CE9E55C-6016-4631-B8D4-4D763DD05F23}.Release|Any CPU.Build.0 = Release|Any CPU + {33F9C404-EEFF-4EA8-B35C-1B3EA33025A6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {33F9C404-EEFF-4EA8-B35C-1B3EA33025A6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {33F9C404-EEFF-4EA8-B35C-1B3EA33025A6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {33F9C404-EEFF-4EA8-B35C-1B3EA33025A6}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/SystemExtensionsTests/Properties/AssemblyInfo.cs b/SystemExtensionsTests/Properties/AssemblyInfo.cs deleted file mode 100644 index 3f888de..0000000 --- a/SystemExtensionsTests/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("SystemExtensionsTests")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("SystemExtensionsTests")] -[assembly: AssemblyCopyright("Copyright © 2019")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("f9b61261-0a08-4b53-baea-44e05dbbbfe5")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/SystemExtensionsTests/SystemExtensionsTests.csproj b/SystemExtensionsTests/SystemExtensionsTests.csproj deleted file mode 100644 index bb26dc2..0000000 --- a/SystemExtensionsTests/SystemExtensionsTests.csproj +++ /dev/null @@ -1,133 +0,0 @@ - - - - - Debug - AnyCPU - {F9B61261-0A08-4B53-BAEA-44E05DBBBFE5} - Library - Properties - SystemExtensionsTests - SystemExtensionsTests - v4.8 - 512 - {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - 10.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages - False - UnitTest - - - - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - ..\packages\FluentAssertions.6.0.0-alpha0002\lib\net47\FluentAssertions.dll - - - ..\packages\MSTest.TestFramework.2.2.3\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll - - - ..\packages\MSTest.TestFramework.2.2.3\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll - - - - - - - ..\packages\System.Runtime.CompilerServices.Unsafe.6.0.0-preview.2.21154.6\lib\net45\System.Runtime.CompilerServices.Unsafe.dll - - - ..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {4ce9e55c-6016-4631-b8d4-4d763dd05f23} - SystemExtensions.NetStandard - - - - - - - False - - - False - - - False - - - False - - - - - - - - - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - - - - \ No newline at end of file diff --git a/SystemExtensionsTests/app.config b/SystemExtensionsTests/app.config deleted file mode 100644 index 22087c1..0000000 --- a/SystemExtensionsTests/app.config +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/SystemExtensionsTests/packages.config b/SystemExtensionsTests/packages.config deleted file mode 100644 index 832b05c..0000000 --- a/SystemExtensionsTests/packages.config +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file