Skip to content

Commit

Permalink
feat: Added net9 explicit support.
Browse files Browse the repository at this point in the history
  • Loading branch information
HavenDV committed Dec 10, 2024
1 parent 21eef4f commit 3c701f4
Show file tree
Hide file tree
Showing 11 changed files with 73 additions and 33 deletions.
9 changes: 9 additions & 0 deletions H.Hooks.sln
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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}
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/apps/H.Hooks.ConsoleApp/H.Hooks.ConsoleApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net4.8;net6.0-windows</TargetFrameworks>
<TargetFrameworks>net4.8;net9.0-windows</TargetFrameworks>
</PropertyGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net4.8'">
Expand Down
1 change: 1 addition & 0 deletions src/helpers/TrimmingHelper/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Console.WriteLine("Build, rebuild or publish this app to see trimming warnings.");
30 changes: 30 additions & 0 deletions src/helpers/TrimmingHelper/TrimmingHelper.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>

<PublishTrimmed>true</PublishTrimmed>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\libs\H.Hooks\H.Hooks.csproj" />
</ItemGroup>

<ItemGroup>
<TrimmerRootAssembly Include="H.Hooks" />
</ItemGroup>

<PropertyGroup Label="Publish">
<RuntimeIdentifier Condition="$([MSBuild]::IsOSPlatform('windows'))">win-x64</RuntimeIdentifier>
<RuntimeIdentifier Condition="!$([MSBuild]::IsOSPlatform('windows'))">osx-arm64</RuntimeIdentifier>

<SelfContained>true</SelfContained>
</PropertyGroup>

<Target Name="ProduceTrimmingWarnings" AfterTargets="Build">
<CallTarget Targets="Publish"/>
</Target>

</Project>
30 changes: 20 additions & 10 deletions src/libs/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,22 @@
</PropertyGroup>

<ItemGroup Label="Nuget">
<None Include="$(SolutionDir)assets\nuget_icon.png" Pack="true" PackagePath="\"/>
<None Include="$(SolutionDir)README.md" Pack="true" PackagePath="\"/>
<PackageReference Include="ConventionalCommitsGitInfo" Version="0.3.6">
<None Include="$(MSBuildThisFileDirectory)../../assets/nuget_icon.png" Pack="true" PackagePath="\" Visible="false" />
<None Include="$(MSBuildThisFileDirectory)../../README.md" Pack="true" PackagePath="\" Visible="false" />
</ItemGroup>

<PropertyGroup Label="Versioning">
<MinVerMinimumMajorMinor>2.1</MinVerMinimumMajorMinor>
<MinVerTagPrefix>v</MinVerTagPrefix>
<MinVerDefaultPreReleaseIdentifiers>dev</MinVerDefaultPreReleaseIdentifiers>
</PropertyGroup>

<ItemGroup Label="Versioning">
<PackageReference Include="MinVer" Version="6.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<Target Name="SetSemanticVersionSettings" BeforeTargets="SetSemanticVersion">
<PropertyGroup>
<ConventionalCommitsGitInfo_BaseVersion>1.5.0</ConventionalCommitsGitInfo_BaseVersion>
<ConventionalCommitsGitInfo_BaseCommit>0d4d39a6b78590a2434419f8c48bac41480b74bb</ConventionalCommitsGitInfo_BaseCommit>
</PropertyGroup>
</Target>

<ItemGroup Label="Source Link">
<PackageReference Include="DotNet.ReproducibleBuilds" Version="1.2.25">
Expand All @@ -51,4 +53,12 @@
<AnalysisMode>All</AnalysisMode>
</PropertyGroup>

<PropertyGroup Label="Trimmable" Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net6.0'))">
<IsAotCompatible>true</IsAotCompatible>
<EnableTrimAnalyzer>true</EnableTrimAnalyzer>
<IsTrimmable>true</IsTrimmable>
<SuppressTrimAnalysisWarnings>false</SuppressTrimAnalysisWarnings>
<TrimmerSingleWarn>false</TrimmerSingleWarn>
</PropertyGroup>

</Project>
15 changes: 4 additions & 11 deletions src/libs/H.Hooks/H.Hooks.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0;net4.5.1;net5.0;net6.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;net4.6.2;net8.0;net9.0</TargetFrameworks>
<NoWarn>$(NoWarn);CA2217;CA1063;CA1003;CA1720;CA5392;CA1508;CA1031</NoWarn>
</PropertyGroup>

Expand Down Expand Up @@ -31,20 +31,13 @@
<PackageTags>hooks, low-level, SetWindowsHookEx, global, keyboard, events, clicks, keys</PackageTags>
</PropertyGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net4.5.1'">
<Reference Include="System.Net.Http" />
<ItemGroup Condition="'$(TargetFramework)' == 'net4.6.2'">
<PackageReference Include="System.Memory" Version="4.6.0" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<PackageReference Include="Microsoft.Win32.Registry" Version="5.0.0" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net5.0'">
<PackageReference Include="Microsoft.Win32.Registry" Version="5.0.0" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
<PackageReference Include="Microsoft.Win32.Registry" Version="5.0.0" />
<PackageReference Include="System.Memory" Version="4.6.0" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion src/libs/H.Hooks/Keyboard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public static unsafe IEnumerable<Key> GetPressedKeys(

#region Private methods

private static void ReplaceIfExists(ICollection<Key> keys, Key from, Key to)
private static void ReplaceIfExists(List<Key> keys, Key from, Key to)
{
if (!keys.Contains(from))
{
Expand Down
2 changes: 1 addition & 1 deletion src/libs/H.Hooks/Keys.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public static Keys Parse(string text)
/// <summary>
///
/// </summary>
public bool IsEmpty => !Values.Any();
public bool IsEmpty => Values.Count == 0;

#endregion

Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0-windows;net4.8</TargetFrameworks>
<TargetFrameworks>net9.0-windows;net4.8</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="MSTest" Version="3.6.4" />
<PackageReference Include="GitHubActionsTestLogger" Version="2.4.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="H.Tests" Version="1.1.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageReference Include="MSTest.TestAdapter" Version="3.6.4" />
<PackageReference Include="MSTest.TestFramework" Version="3.6.4" />
</ItemGroup>

<ItemGroup Label="GlobalUsings">
Expand Down
6 changes: 2 additions & 4 deletions src/tests/H.Hooks.UnitTests/H.Hooks.UnitTests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0;net4.8</TargetFrameworks>
<TargetFrameworks>net9.0;net4.8</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
Expand All @@ -10,9 +10,7 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageReference Include="MSTest.TestAdapter" Version="3.6.4" />
<PackageReference Include="MSTest.TestFramework" Version="3.6.4" />
<PackageReference Include="MSTest" Version="3.6.4" />
</ItemGroup>

<ItemGroup Label="GlobalUsings">
Expand Down

0 comments on commit 3c701f4

Please sign in to comment.