From 4ff9115859627a0c7e0b894aa0fdf2c42a0b4a17 Mon Sep 17 00:00:00 2001 From: Rcmcpe Date: Thu, 26 Mar 2020 22:03:16 +0800 Subject: [PATCH] migrate to .NET 5, other improvements --- .../Arknights Automation Library.csproj | 20 ++--- Auto Arknights CLI/Auto Arknights CLI.csproj | 2 +- Auto Arknights CLI/AutoArknights.cs | 14 ++-- Auto Arknights CLI/Entry.cs | 42 +++++----- Auto Arknights GUI/Auto Arknights GUI.csproj | 78 +++++++++---------- Auto Arknights GUI/Properties/Annotations.cs | 24 +----- Crlib | 2 +- REVUnit.ImageLocator | 2 +- 8 files changed, 79 insertions(+), 105 deletions(-) diff --git a/Arknights Automation Library/Arknights Automation Library.csproj b/Arknights Automation Library/Arknights Automation Library.csproj index 2743d98..ed4d47f 100644 --- a/Arknights Automation Library/Arknights Automation Library.csproj +++ b/Arknights Automation Library/Arknights Automation Library.csproj @@ -1,15 +1,15 @@  - netcoreapp3.1 + netcoreapp5.0 REVUnit.AutoArknights.Core REVUnit.AutoArknights.Core - - - - - + + + + + @@ -18,13 +18,13 @@ PreserveNewest - + - + - - + + diff --git a/Auto Arknights CLI/Auto Arknights CLI.csproj b/Auto Arknights CLI/Auto Arknights CLI.csproj index 805414a..7d6bc89 100644 --- a/Auto Arknights CLI/Auto Arknights CLI.csproj +++ b/Auto Arknights CLI/Auto Arknights CLI.csproj @@ -1,7 +1,7 @@ Exe - netcoreapp3.1 + netcoreapp5.0 REVUnit.AutoArknights.CLI true true diff --git a/Auto Arknights CLI/AutoArknights.cs b/Auto Arknights CLI/AutoArknights.cs index 4210ab0..837dbd1 100644 --- a/Auto Arknights CLI/AutoArknights.cs +++ b/Auto Arknights CLI/AutoArknights.cs @@ -17,22 +17,22 @@ public AutoArknights() Console.ReadKey(true); return; } - + IConfiguration config = new ConfigurationBuilder().AddJsonFile(".\\Config.json").Build(); _automation = new Automation(config["Adb:Path"], config["Adb:Remote"]); } + public void Dispose() + { + Console.WriteLine("Disposing!"); + _automation.Dispose(); + } + public void Run() { var cin = new Cin(); _automation.Schedule.Add(new RepeatLevelJob(RepeatLevelJob.Mode.SpecifiedTimes, cin.Get("输入刷关次数"))); _automation.Schedule.ExecuteAll(); } - - public void Dispose() - { - Console.WriteLine("Disposing!"); - _automation.Dispose(); - } } } \ No newline at end of file diff --git a/Auto Arknights CLI/Entry.cs b/Auto Arknights CLI/Entry.cs index 6c2896f..05098e9 100644 --- a/Auto Arknights CLI/Entry.cs +++ b/Auto Arknights CLI/Entry.cs @@ -1,31 +1,27 @@ -using System; -using System.Threading; -using System.Threading.Tasks; -using Microsoft.Extensions.Configuration; -using REVUnit.AutoArknights.Core; -using REVUnit.Crlib.Extension; -using REVUnit.Crlib.Input; - -namespace REVUnit.AutoArknights.CLI +namespace REVUnit.AutoArknights.CLI { public static class Entry { public static void Main() { - var src = new CancellationTokenSource(); - var task = new Task(() => - { - using var app = new AutoArknights(); - app.Run(); - }, src.Token, TaskCreationOptions.LongRunning); - XConsole.Exiting += () => - { - src.Cancel(); - Console.WriteLine("已释放非托管资源。"); - Environment.Exit(0); - }; - task.Start(); - task.Wait(src.Token); + using var app = new AutoArknights(); + app.Run(); + // 经过实验,并不能释放非托管资源。 + // TODO See https://github.com/CCRcmcpe/Auto-Arknights/issues/1 + // var src = new CancellationTokenSource(); + // var task = new Task(() => + // { + // using var app = new AutoArknights(); + // app.Run(); + // }, src.Token, TaskCreationOptions.LongRunning); + // XConsole.Exiting += () => + // { + // src.Cancel(); + // Console.WriteLine("已释放非托管资源。"); + // Environment.Exit(0); + // }; + // task.Start(); + // task.Wait(src.Token); } } } \ No newline at end of file diff --git a/Auto Arknights GUI/Auto Arknights GUI.csproj b/Auto Arknights GUI/Auto Arknights GUI.csproj index 06623ee..ac3355c 100644 --- a/Auto Arknights GUI/Auto Arknights GUI.csproj +++ b/Auto Arknights GUI/Auto Arknights GUI.csproj @@ -1,6 +1,6 @@  - netcoreapp3.1 + netcoreapp5.0 WinExe REVUnit.AutoArknights.GUI true @@ -24,50 +24,50 @@ - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + - + diff --git a/Auto Arknights GUI/Properties/Annotations.cs b/Auto Arknights GUI/Properties/Annotations.cs index e3073fa..67af69c 100644 --- a/Auto Arknights GUI/Properties/Annotations.cs +++ b/Auto Arknights GUI/Properties/Annotations.cs @@ -1,26 +1,4 @@ -/* MIT License - -Copyright (c) 2016 JetBrains http://www.jetbrains.com - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. */ - -using System; +using System; // ReSharper disable InheritdocConsiderUsage diff --git a/Crlib b/Crlib index 9d24ece..807c91f 160000 --- a/Crlib +++ b/Crlib @@ -1 +1 @@ -Subproject commit 9d24eced7ef8d16499c7ca9199efa731f941e3a2 +Subproject commit 807c91f6c35515d21019da6dbd839d09dbaf29fe diff --git a/REVUnit.ImageLocator b/REVUnit.ImageLocator index 1adcbac..1757ba9 160000 --- a/REVUnit.ImageLocator +++ b/REVUnit.ImageLocator @@ -1 +1 @@ -Subproject commit 1adcbac11708d72403792c21f66199078e832b31 +Subproject commit 1757ba9e0f507b7d43dc0423a7c565d543e0fe4e