From 678f5d3aab28b969b28224dc34e543189ac3c5af Mon Sep 17 00:00:00 2001 From: alterNERDtive Date: Sat, 9 Jul 2022 16:33:32 +0200 Subject: [PATCH] =?UTF-8?q?Very=20Atomic=20Commit=E2=84=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/create-release.yaml | 4 +- .github/workflows/push-test.yaml | 4 +- ExamplePlugin/ExamplePlugin.cs | 2 +- ExamplePlugin/ExamplePlugin.csproj | 2 + ExamplePlugin/GlobalSuppressions.cs | 22 ++++++- VoiceAttack-Framework-Test/Usings.cs | 1 + .../VoiceAttack-Framework-Test.csproj | 25 +++++++ .../VoiceAttackLogTest.cs | 29 ++++++++ .../VoiceAttackPluginTest.cs | 25 +++++++ VoiceAttack-Framework.sln | 6 ++ VoiceAttack-Framework/GlobalSuppressions.cs | 22 ++++++- .../VoiceAttack-Framework.csproj | 2 + VoiceAttack-Framework/VoiceAttackPlugin.cs | 66 +++++++++---------- 13 files changed, 165 insertions(+), 45 deletions(-) create mode 100644 VoiceAttack-Framework-Test/Usings.cs create mode 100644 VoiceAttack-Framework-Test/VoiceAttack-Framework-Test.csproj create mode 100644 VoiceAttack-Framework-Test/VoiceAttackLogTest.cs create mode 100644 VoiceAttack-Framework-Test/VoiceAttackPluginTest.cs diff --git a/.github/workflows/create-release.yaml b/.github/workflows/create-release.yaml index 560d81b..2163124 100644 --- a/.github/workflows/create-release.yaml +++ b/.github/workflows/create-release.yaml @@ -34,11 +34,11 @@ jobs: run: dotnet pack -c release - name: Push NuGet package - run: dotnet nuget push "FIXXME/bin/Release/alterNERDtive.YAVAPF.*.nupkg" -source 'https://api.nuget.org/v3/index.json' -apikey ${{secrets.NUGET_AUTH_TOKEN}} + run: dotnet nuget push "VoiceAttack-Framework/bin/Release/alterNERDtive.YAVAPF.*.nupkg" -source 'https://api.nuget.org/v3/index.json' -apikey ${{secrets.NUGET_AUTH_TOKEN}} - name: Draft release uses: ncipollo/release-action@v1 with: - artifacts: "FIXXME/bin/Release/alterNERDtive.YAVAPF.*.nupkg" + artifacts: "VoiceAttack-Framework/bin/Release/alterNERDtive.YAVAPF.*nupkg" bodyFile: "CHANGELOG.md" draft: true diff --git a/.github/workflows/push-test.yaml b/.github/workflows/push-test.yaml index 2d69950..1894e2e 100644 --- a/.github/workflows/push-test.yaml +++ b/.github/workflows/push-test.yaml @@ -1,11 +1,11 @@ -name: Run tests on push push +name: Run tests on push on: push jobs: build: - name: Test EDNA + name: Run tests runs-on: windows-latest permissions: contents: write diff --git a/ExamplePlugin/ExamplePlugin.cs b/ExamplePlugin/ExamplePlugin.cs index 5beb074..781f772 100644 --- a/ExamplePlugin/ExamplePlugin.cs +++ b/ExamplePlugin/ExamplePlugin.cs @@ -230,7 +230,7 @@ namespace alterNERDtive.Yavapf.Example [String] public static void StringChanged(string name, string? from, string? to, Guid? internalID) { - Plugin.Log.Notice($"This is the example handler for changed string variables. '{name}' changed from '{from ?? "Not Set"}' to '{to}'."); + Plugin.Log.Notice($"This is the example handler for changed string variables. '{name}' changed from '{from ?? "Not Set"}' to '{to ?? "Not Set"}'."); } } } diff --git a/ExamplePlugin/ExamplePlugin.csproj b/ExamplePlugin/ExamplePlugin.csproj index c9ca55f..996ab4c 100644 --- a/ExamplePlugin/ExamplePlugin.csproj +++ b/ExamplePlugin/ExamplePlugin.csproj @@ -4,6 +4,8 @@ net48 alterNERDtive.Yavapf.Example enable + + true diff --git a/ExamplePlugin/GlobalSuppressions.cs b/ExamplePlugin/GlobalSuppressions.cs index c03bb2a..18fda33 100644 --- a/ExamplePlugin/GlobalSuppressions.cs +++ b/ExamplePlugin/GlobalSuppressions.cs @@ -1,8 +1,26 @@ -// This file is used by Code Analysis to maintain SuppressMessage +// +// Copyright 2022 alterNERDtive. +// +// This file is part of YAVAPF. +// +// YAVAPF is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// YAVAPF is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with YAVAPF. If not, see <https://www.gnu.org/licenses/>. +// + +// This file is used by Code Analysis to maintain SuppressMessage // attributes that are applied to this project. // Project-level suppressions either have no target or are given // a specific target and scoped to a namespace, type, member, etc. - using System.Diagnostics.CodeAnalysis; [assembly: SuppressMessage("StyleCop.CSharp.NamingRules", "SA1300:Element should begin with upper-case letter", Justification = "It’s my name, you prick :)", Scope = "namespace", Target = "~N:alterNERDtive.Yavapf.Example")] diff --git a/VoiceAttack-Framework-Test/Usings.cs b/VoiceAttack-Framework-Test/Usings.cs new file mode 100644 index 0000000..8c927eb --- /dev/null +++ b/VoiceAttack-Framework-Test/Usings.cs @@ -0,0 +1 @@ +global using Xunit; \ No newline at end of file diff --git a/VoiceAttack-Framework-Test/VoiceAttack-Framework-Test.csproj b/VoiceAttack-Framework-Test/VoiceAttack-Framework-Test.csproj new file mode 100644 index 0000000..7d39cac --- /dev/null +++ b/VoiceAttack-Framework-Test/VoiceAttack-Framework-Test.csproj @@ -0,0 +1,25 @@ + + + + net48 + VoiceAttack_Framework_Test + enable + enable + + false + + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + diff --git a/VoiceAttack-Framework-Test/VoiceAttackLogTest.cs b/VoiceAttack-Framework-Test/VoiceAttackLogTest.cs new file mode 100644 index 0000000..b29490d --- /dev/null +++ b/VoiceAttack-Framework-Test/VoiceAttackLogTest.cs @@ -0,0 +1,29 @@ +// +// Copyright 2022 alterNERDtive. +// +// This file is part of YAVAPF. +// +// YAVAPF is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// YAVAPF is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with YAVAPF. If not, see <https://www.gnu.org/licenses/>. +// + +namespace VoiceAttack_Framework_Test +{ + public class VoiceAttackLogTest + { + [Fact] + public void Test1() + { + } + } +} diff --git a/VoiceAttack-Framework-Test/VoiceAttackPluginTest.cs b/VoiceAttack-Framework-Test/VoiceAttackPluginTest.cs new file mode 100644 index 0000000..6b2ddea --- /dev/null +++ b/VoiceAttack-Framework-Test/VoiceAttackPluginTest.cs @@ -0,0 +1,25 @@ +// +// Copyright 2022 alterNERDtive. +// +// This file is part of YAVAPF. +// +// YAVAPF is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// YAVAPF is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with YAVAPF. If not, see <https://www.gnu.org/licenses/>. +// + +namespace VoiceAttack_Framework_Test +{ + internal class VoiceAttackPluginTest + { + } +} diff --git a/VoiceAttack-Framework.sln b/VoiceAttack-Framework.sln index 1aaca5d..49cc899 100644 --- a/VoiceAttack-Framework.sln +++ b/VoiceAttack-Framework.sln @@ -48,6 +48,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docs", "docs", "{3FE46F37-0 docs\variables.md = docs\variables.md EndProjectSection EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VoiceAttack-Framework-Test", "VoiceAttack-Framework-Test\VoiceAttack-Framework-Test.csproj", "{D49B2D9A-1014-4554-977A-E57E9972D196}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -62,6 +64,10 @@ Global {E390356B-4039-4364-B49C-38A37046A7BD}.Debug|Any CPU.Build.0 = Debug|Any CPU {E390356B-4039-4364-B49C-38A37046A7BD}.Release|Any CPU.ActiveCfg = Release|Any CPU {E390356B-4039-4364-B49C-38A37046A7BD}.Release|Any CPU.Build.0 = Release|Any CPU + {D49B2D9A-1014-4554-977A-E57E9972D196}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D49B2D9A-1014-4554-977A-E57E9972D196}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D49B2D9A-1014-4554-977A-E57E9972D196}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D49B2D9A-1014-4554-977A-E57E9972D196}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/VoiceAttack-Framework/GlobalSuppressions.cs b/VoiceAttack-Framework/GlobalSuppressions.cs index ebe7e57..594a1cd 100644 --- a/VoiceAttack-Framework/GlobalSuppressions.cs +++ b/VoiceAttack-Framework/GlobalSuppressions.cs @@ -1,8 +1,26 @@ -// This file is used by Code Analysis to maintain SuppressMessage +// +// Copyright 2022 alterNERDtive. +// +// This file is part of YAVAPF. +// +// YAVAPF is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// YAVAPF is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with YAVAPF. If not, see <https://www.gnu.org/licenses/>. +// + +// This file is used by Code Analysis to maintain SuppressMessage // attributes that are applied to this project. // Project-level suppressions either have no target or are given // a specific target and scoped to a namespace, type, member, etc. - using System.Diagnostics.CodeAnalysis; [assembly: SuppressMessage("StyleCop.CSharp.NamingRules", "SA1300:Element should begin with upper-case letter", Justification = "because that’s my name", Scope = "namespace", Target = "~N:alterNERDtive.Yavapf")] diff --git a/VoiceAttack-Framework/VoiceAttack-Framework.csproj b/VoiceAttack-Framework/VoiceAttack-Framework.csproj index afb663c..d1a8e1d 100644 --- a/VoiceAttack-Framework/VoiceAttack-Framework.csproj +++ b/VoiceAttack-Framework/VoiceAttack-Framework.csproj @@ -24,6 +24,8 @@ True True snupkg + + true diff --git a/VoiceAttack-Framework/VoiceAttackPlugin.cs b/VoiceAttack-Framework/VoiceAttackPlugin.cs index a5e77f0..00ba08b 100644 --- a/VoiceAttack-Framework/VoiceAttackPlugin.cs +++ b/VoiceAttack-Framework/VoiceAttackPlugin.cs @@ -265,50 +265,32 @@ namespace alterNERDtive.Yavapf this.vaProxy.IntegerVariableChanged += this.IntegerVariableChanged; this.vaProxy.TextVariableChanged += this.TextVariableChanged; - foreach (MethodInfo m in this.GetType().GetMethods().Where(m => m.GetCustomAttributes().Any()).ToList()) - { - this.InitActions += (Action)m.CreateDelegate(typeof(Action)); - } + this.GetType().GetMethods().Where(m => m.GetCustomAttributes().Any()).ToList().ForEach( + m => this.InitActions += (Action)m.CreateDelegate(typeof(Action))); - foreach (MethodInfo m in this.GetType().GetMethods().Where(m => m.GetCustomAttributes().Any()).ToList()) - { - this.ExitActions += (Action)m.CreateDelegate(typeof(Action)); - } + this.GetType().GetMethods().Where(m => m.GetCustomAttributes().Any()).ToList().ForEach( + m => this.ExitActions += (Action)m.CreateDelegate(typeof(Action))); - foreach (MethodInfo m in this.GetType().GetMethods().Where(m => m.GetCustomAttributes().Any()).ToList()) - { - this.StopActions += (Action)m.CreateDelegate(typeof(Action)); - } + this.GetType().GetMethods().Where(m => m.GetCustomAttributes().Any()).ToList().ForEach( + m => this.StopActions += (Action)m.CreateDelegate(typeof(Action))); - foreach (MethodInfo m in this.GetType().GetMethods().Where(m => m.GetCustomAttributes().Any()).ToList()) - { - this.Contexts += (Action)m.CreateDelegate(typeof(Action)); - } + this.GetType().GetMethods().Where(m => m.GetCustomAttributes().Any()).ToList().ForEach( + m => this.Contexts += (Action)m.CreateDelegate(typeof(Action))); - foreach (MethodInfo m in this.GetType().GetMethods().Where(m => m.GetCustomAttributes().Any()).ToList()) - { - this.BoolChangedHandlers += (Action)m.CreateDelegate(typeof(Action)); - } + this.GetType().GetMethods().Where(m => m.GetCustomAttributes().Any()).ToList().ForEach( + m => this.BoolChangedHandlers += (Action)m.CreateDelegate(typeof(Action))); - foreach (MethodInfo m in this.GetType().GetMethods().Where(m => m.GetCustomAttributes().Any()).ToList()) - { - this.DateTimeChangedHandlers += (Action)m.CreateDelegate(typeof(Action)); - } + this.GetType().GetMethods().Where(m => m.GetCustomAttributes().Any()).ToList().ForEach( + m => this.DateTimeChangedHandlers += (Action)m.CreateDelegate(typeof(Action))); - foreach (MethodInfo m in this.GetType().GetMethods().Where(m => m.GetCustomAttributes().Any()).ToList()) - { - this.DecimalChangedHandlers += (Action)m.CreateDelegate(typeof(Action)); - } + this.GetType().GetMethods().Where(m => m.GetCustomAttributes().Any()).ToList().ForEach( + m => this.DecimalChangedHandlers += (Action)m.CreateDelegate(typeof(Action))); - foreach (MethodInfo m in this.GetType().GetMethods().Where(m => m.GetCustomAttributes().Any()).ToList()) - { - this.IntChangedHandlers += (Action)m.CreateDelegate(typeof(Action)); - } + this.GetType().GetMethods().Where(m => m.GetCustomAttributes().Any()).ToList().ForEach( + m => this.IntChangedHandlers += (Action)m.CreateDelegate(typeof(Action))); - foreach (MethodInfo m in this.GetType().GetMethods().Where(m => m.GetCustomAttributes().Any()).ToList()) - { - this.StringChangedHandlers += (Action)m.CreateDelegate(typeof(Action)); - } + this.GetType().GetMethods().Where(m => m.GetCustomAttributes().Any()).ToList().ForEach( + m => this.StringChangedHandlers += (Action)m.CreateDelegate(typeof(Action))); this.Log.Debug("Running Init handlers …"); this.InitActions?.Invoke(vaProxy); @@ -516,12 +498,24 @@ namespace alterNERDtive.Yavapf /// The type of the list. protected class HandlerList : List { + /// + /// Adds a handler to the list. + /// + /// The list to add to. + /// The handler to add. + /// The sum of both. public static HandlerList operator +(HandlerList handlers, T item) { handlers.Add(item); return handlers; } + /// + /// Removes a handler from the list. + /// + /// The list to remove from. + /// The handler to remove. + /// The list without the handler. public static HandlerList operator -(HandlerList handlers, T item) { handlers.Remove(item);