From 3c701f4f8f54c0d66cffb44fbdca5dc8c8c4fc88 Mon Sep 17 00:00:00 2001 From: Konstantin S Date: Tue, 10 Dec 2024 16:04:52 +0400 Subject: [PATCH] feat: Added net9 explicit support. --- H.Hooks.sln | 9 ++++++ README.md | 3 +- .../H.Hooks.ConsoleApp.csproj | 2 +- src/helpers/TrimmingHelper/Program.cs | 1 + .../TrimmingHelper/TrimmingHelper.csproj | 30 +++++++++++++++++++ src/libs/Directory.Build.props | 30 ++++++++++++------- src/libs/H.Hooks/H.Hooks.csproj | 15 +++------- src/libs/H.Hooks/Keyboard.cs | 2 +- src/libs/H.Hooks/Keys.cs | 2 +- .../H.Hooks.IntegrationTests.csproj | 6 ++-- .../H.Hooks.UnitTests.csproj | 6 ++-- 11 files changed, 73 insertions(+), 33 deletions(-) create mode 100644 src/helpers/TrimmingHelper/Program.cs create mode 100644 src/helpers/TrimmingHelper/TrimmingHelper.csproj diff --git a/H.Hooks.sln b/H.Hooks.sln index f679430..4a2a712 100644 --- a/H.Hooks.sln +++ b/H.Hooks.sln @@ -33,6 +33,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "apps", "apps", "{B2D0762A-B EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "H.Hooks.ConsoleApp", "src\apps\H.Hooks.ConsoleApp\H.Hooks.ConsoleApp.csproj", "{EA9A0554-F2FD-4B42-801E-1E4676DEAFBC}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "helpers", "helpers", "{CB314486-E3AD-485C-A5FB-6022868515DB}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TrimmingHelper", "src\helpers\TrimmingHelper\TrimmingHelper.csproj", "{D504F55D-CBD6-4507-96E9-DFFCA918E8A9}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -55,6 +59,10 @@ Global {EA9A0554-F2FD-4B42-801E-1E4676DEAFBC}.Debug|Any CPU.Build.0 = Debug|Any CPU {EA9A0554-F2FD-4B42-801E-1E4676DEAFBC}.Release|Any CPU.ActiveCfg = Release|Any CPU {EA9A0554-F2FD-4B42-801E-1E4676DEAFBC}.Release|Any CPU.Build.0 = Release|Any CPU + {D504F55D-CBD6-4507-96E9-DFFCA918E8A9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D504F55D-CBD6-4507-96E9-DFFCA918E8A9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D504F55D-CBD6-4507-96E9-DFFCA918E8A9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D504F55D-CBD6-4507-96E9-DFFCA918E8A9}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -64,6 +72,7 @@ Global {F2548AE2-D736-4C21-942F-55C4F592EFF2} = {9CAA231D-7BE1-46C9-ACD6-EB2E569CEBEA} {1CD36EFB-8395-42EB-A908-A6FBBE6D9AAE} = {9CAA231D-7BE1-46C9-ACD6-EB2E569CEBEA} {EA9A0554-F2FD-4B42-801E-1E4676DEAFBC} = {B2D0762A-B0E0-4ECE-841E-0B46088E74D6} + {D504F55D-CBD6-4507-96E9-DFFCA918E8A9} = {CB314486-E3AD-485C-A5FB-6022868515DB} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {1493AEE4-9211-46E9-BFE6-8F629EAC5693} diff --git a/README.md b/README.md index f211b39..6803db6 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ [![Language](https://img.shields.io/badge/language-C%23-blue.svg?style=flat-square)](https://github.com/HavenDV/H.Hooks/search?l=C%23&o=desc&s=&type=Code) [![License](https://img.shields.io/github/license/HavenDV/H.Hooks.svg?label=License&maxAge=86400)](LICENSE.md) [![Requirements](https://img.shields.io/badge/Requirements-.NET%20Standard%202.0-blue.svg)](https://github.com/dotnet/standard/blob/master/docs/versions/netstandard2.0.md) -[![Build Status](https://github.com/HavenDV/H.Hooks/workflows/.NET/badge.svg?branch=master)](https://github.com/HavenDV/H.Hooks/actions?query=workflow%3A%22.NET%22) +[![Build Status](https://github.com/HavenDV/H.Hooks/actions/workflows/dotnet.yml/badge.svg)](https://github.com/HavenDV/H.Hooks/actions/workflows/dotnet.yml) It uses Win32 `kernel32.dll` and `user32.dll` calls inside. Contains LowLevelKeyboardHook and LowLevelMouseHook. @@ -15,6 +15,7 @@ Features: - Handle special buttons like Mouse.XButton - Optimized, runs hooks in a separate thread. Does not cause freezes when debugging the rest of the code. - By default, it delivers events from a ThreadPool instead of a hook thread, which makes it possible to do any action in event handlers without affecting system performance. +- Supports Trimming/NativeAOT, nullability, and other modern features. ### Nuget diff --git a/src/apps/H.Hooks.ConsoleApp/H.Hooks.ConsoleApp.csproj b/src/apps/H.Hooks.ConsoleApp/H.Hooks.ConsoleApp.csproj index 823f9c3..a56a2f8 100644 --- a/src/apps/H.Hooks.ConsoleApp/H.Hooks.ConsoleApp.csproj +++ b/src/apps/H.Hooks.ConsoleApp/H.Hooks.ConsoleApp.csproj @@ -2,7 +2,7 @@ Exe - net4.8;net6.0-windows + net4.8;net9.0-windows diff --git a/src/helpers/TrimmingHelper/Program.cs b/src/helpers/TrimmingHelper/Program.cs new file mode 100644 index 0000000..3b94c99 --- /dev/null +++ b/src/helpers/TrimmingHelper/Program.cs @@ -0,0 +1 @@ +Console.WriteLine("Build, rebuild or publish this app to see trimming warnings."); \ No newline at end of file diff --git a/src/helpers/TrimmingHelper/TrimmingHelper.csproj b/src/helpers/TrimmingHelper/TrimmingHelper.csproj new file mode 100644 index 0000000..122d920 --- /dev/null +++ b/src/helpers/TrimmingHelper/TrimmingHelper.csproj @@ -0,0 +1,30 @@ + + + + Exe + net9.0 + enable + + true + + + + + + + + + + + + win-x64 + osx-arm64 + + true + + + + + + + diff --git a/src/libs/Directory.Build.props b/src/libs/Directory.Build.props index f07d60b..37a77af 100644 --- a/src/libs/Directory.Build.props +++ b/src/libs/Directory.Build.props @@ -23,20 +23,22 @@ - - - + + + + + + 2.1 + v + dev + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive - - - - 1.5.0 - 0d4d39a6b78590a2434419f8c48bac41480b74bb - - @@ -51,4 +53,12 @@ All + + true + true + true + false + false + + diff --git a/src/libs/H.Hooks/H.Hooks.csproj b/src/libs/H.Hooks/H.Hooks.csproj index 345eccc..485845d 100644 --- a/src/libs/H.Hooks/H.Hooks.csproj +++ b/src/libs/H.Hooks/H.Hooks.csproj @@ -1,7 +1,7 @@  - netstandard2.0;net4.5.1;net5.0;net6.0 + netstandard2.0;net4.6.2;net8.0;net9.0 $(NoWarn);CA2217;CA1063;CA1003;CA1720;CA5392;CA1508;CA1031 @@ -31,20 +31,13 @@ hooks, low-level, SetWindowsHookEx, global, keyboard, events, clicks, keys - - + + - - - - - - - - + diff --git a/src/libs/H.Hooks/Keyboard.cs b/src/libs/H.Hooks/Keyboard.cs index c188036..8bc4abb 100644 --- a/src/libs/H.Hooks/Keyboard.cs +++ b/src/libs/H.Hooks/Keyboard.cs @@ -102,7 +102,7 @@ public static unsafe IEnumerable GetPressedKeys( #region Private methods - private static void ReplaceIfExists(ICollection keys, Key from, Key to) + private static void ReplaceIfExists(List keys, Key from, Key to) { if (!keys.Contains(from)) { diff --git a/src/libs/H.Hooks/Keys.cs b/src/libs/H.Hooks/Keys.cs index ecb1e47..796ab29 100644 --- a/src/libs/H.Hooks/Keys.cs +++ b/src/libs/H.Hooks/Keys.cs @@ -95,7 +95,7 @@ public static Keys Parse(string text) /// /// /// - public bool IsEmpty => !Values.Any(); + public bool IsEmpty => Values.Count == 0; #endregion diff --git a/src/tests/H.Hooks.IntegrationTests/H.Hooks.IntegrationTests.csproj b/src/tests/H.Hooks.IntegrationTests/H.Hooks.IntegrationTests.csproj index f78f635..71354c2 100644 --- a/src/tests/H.Hooks.IntegrationTests/H.Hooks.IntegrationTests.csproj +++ b/src/tests/H.Hooks.IntegrationTests/H.Hooks.IntegrationTests.csproj @@ -1,18 +1,16 @@ - net6.0-windows;net4.8 + net9.0-windows;net4.8 + all runtime; build; native; contentfiles; analyzers; buildtransitive - - - diff --git a/src/tests/H.Hooks.UnitTests/H.Hooks.UnitTests.csproj b/src/tests/H.Hooks.UnitTests/H.Hooks.UnitTests.csproj index 732bee7..04174fe 100644 --- a/src/tests/H.Hooks.UnitTests/H.Hooks.UnitTests.csproj +++ b/src/tests/H.Hooks.UnitTests/H.Hooks.UnitTests.csproj @@ -1,7 +1,7 @@ - net6.0;net4.8 + net9.0;net4.8 @@ -10,9 +10,7 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - - - +