diff --git a/.gitignore b/.gitignore
index 34faed3..9512394 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,3 +7,6 @@ DeftSharp.Windows.Input.sln.DotSettings.user
WPF.Playground/bin
WPF.Playground/obj
.vs
+/Test_polyfill/bin
+/Test_polyfill/obj
+DeftSharp.Windows.Input/DeftSharp.Windows.Input.csproj.user
diff --git a/DeftSharp.Windows.Input.Tests/DeftSharp.Windows.Input.Tests.csproj b/DeftSharp.Windows.Input.Tests/DeftSharp.Windows.Input.Tests.csproj
index 600f391..0ef5a4a 100644
--- a/DeftSharp.Windows.Input.Tests/DeftSharp.Windows.Input.Tests.csproj
+++ b/DeftSharp.Windows.Input.Tests/DeftSharp.Windows.Input.Tests.csproj
@@ -1,9 +1,11 @@
-
+
- net8.0-windows
+ net8.0-windows;net472
+ latest
+
enable
- enable
+ disable
false
true
@@ -32,4 +34,12 @@
-
+
+
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
+
+
\ No newline at end of file
diff --git a/DeftSharp.Windows.Input.sln b/DeftSharp.Windows.Input.sln
index 1986182..620b8e4 100644
--- a/DeftSharp.Windows.Input.sln
+++ b/DeftSharp.Windows.Input.sln
@@ -1,10 +1,15 @@
Microsoft Visual Studio Solution File, Format Version 12.00
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DeftSharp.Windows.Input", "DeftSharp.Windows.Input\DeftSharp.Windows.Input.csproj", "{3D91851D-784F-4C38-B1F9-CD1D08AA364E}"
+# Visual Studio Version 17
+VisualStudioVersion = 17.11.35327.3
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DeftSharp.Windows.Input", "DeftSharp.Windows.Input\DeftSharp.Windows.Input.csproj", "{3D91851D-784F-4C38-B1F9-CD1D08AA364E}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WPF.Playground", "WPF.Playground\WPF.Playground.csproj", "{629A70FA-AB10-42AC-917A-0E86A3EA13D2}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WPF.Playground", "WPF.Playground\WPF.Playground.csproj", "{629A70FA-AB10-42AC-917A-0E86A3EA13D2}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DeftSharp.Windows.Input.Tests", "DeftSharp.Windows.Input.Tests\DeftSharp.Windows.Input.Tests.csproj", "{841090A8-C012-4E7F-86BB-053285D3CD7C}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DeftSharp.Windows.Input.Tests", "DeftSharp.Windows.Input.Tests\DeftSharp.Windows.Input.Tests.csproj", "{CEDF1840-E75D-4E55-82D2-C9BBB0CC5C6C}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test_polyfill", "Test_polyfill\Test_polyfill.csproj", "{E19A38F1-2B3E-4419-8E22-D7B0ADF60219}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -20,9 +25,19 @@ Global
{629A70FA-AB10-42AC-917A-0E86A3EA13D2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{629A70FA-AB10-42AC-917A-0E86A3EA13D2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{629A70FA-AB10-42AC-917A-0E86A3EA13D2}.Release|Any CPU.Build.0 = Release|Any CPU
- {841090A8-C012-4E7F-86BB-053285D3CD7C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {841090A8-C012-4E7F-86BB-053285D3CD7C}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {841090A8-C012-4E7F-86BB-053285D3CD7C}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {841090A8-C012-4E7F-86BB-053285D3CD7C}.Release|Any CPU.Build.0 = Release|Any CPU
+ {CEDF1840-E75D-4E55-82D2-C9BBB0CC5C6C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {CEDF1840-E75D-4E55-82D2-C9BBB0CC5C6C}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {CEDF1840-E75D-4E55-82D2-C9BBB0CC5C6C}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {CEDF1840-E75D-4E55-82D2-C9BBB0CC5C6C}.Release|Any CPU.Build.0 = Release|Any CPU
+ {E19A38F1-2B3E-4419-8E22-D7B0ADF60219}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {E19A38F1-2B3E-4419-8E22-D7B0ADF60219}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {E19A38F1-2B3E-4419-8E22-D7B0ADF60219}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {E19A38F1-2B3E-4419-8E22-D7B0ADF60219}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {7ECB5584-E473-4ECA-BBE6-F41F1DF9B6B7}
EndGlobalSection
EndGlobal
diff --git a/DeftSharp.Windows.Input/DeftSharp.Windows.Input.csproj b/DeftSharp.Windows.Input/DeftSharp.Windows.Input.csproj
index f594d31..dd21dc2 100644
--- a/DeftSharp.Windows.Input/DeftSharp.Windows.Input.csproj
+++ b/DeftSharp.Windows.Input/DeftSharp.Windows.Input.csproj
@@ -1,7 +1,8 @@
- net8.0-windows
+ net8.0-windows;net472
+
enable
true
DeftSharp.Windows.Input
diff --git a/DeftSharp.Windows.Input/Native/API/MouseAPI.cs b/DeftSharp.Windows.Input/Native/API/MouseAPI.cs
index e6e1642..e91e5cb 100644
--- a/DeftSharp.Windows.Input/Native/API/MouseAPI.cs
+++ b/DeftSharp.Windows.Input/Native/API/MouseAPI.cs
@@ -140,7 +140,7 @@ internal static void SetMouseSpeed(int speed)
_ => speed
};
- SystemParametersInfo(setMouseSpeedInfo, 0, mouseSpeed, updateIniFile | sendChangeInfo);
+ SystemParametersInfo(setMouseSpeedInfo, 0, out mouseSpeed, updateIniFile | sendChangeInfo);
}
///
diff --git a/DeftSharp.Windows.Input/Native/Interceptors/WindowsInterceptor.cs b/DeftSharp.Windows.Input/Native/Interceptors/WindowsInterceptor.cs
index 20382ff..db00118 100644
--- a/DeftSharp.Windows.Input/Native/Interceptors/WindowsInterceptor.cs
+++ b/DeftSharp.Windows.Input/Native/Interceptors/WindowsInterceptor.cs
@@ -26,7 +26,7 @@ internal abstract class WindowsInterceptor : IRequestedInterceptor
///
/// Identifier for the installed WinAPI hook.
///
- protected nint HookId = nint.Zero;
+ protected nint HookId = (nint)0;//nint.Zero;
///
/// Initializes a new instance of the WindowsListener class.
@@ -61,7 +61,7 @@ public void Unhook()
return;
User32.UnhookWindowsHookEx(HookId);
- HookId = nint.Zero;
+ HookId = (nint)0; //nint.Zero;
_isHandled = false;
}
diff --git a/DeftSharp.Windows.Input/net472_polyFill.cs b/DeftSharp.Windows.Input/net472_polyFill.cs
new file mode 100644
index 0000000..688a346
--- /dev/null
+++ b/DeftSharp.Windows.Input/net472_polyFill.cs
@@ -0,0 +1,93 @@
+using System;
+using System.Collections.Concurrent;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Runtime.InteropServices;
+using System.Diagnostics;
+using System.Collections;
+using System.Runtime.CompilerServices;
+
+//namespace DeftSharp.Windows.Input{ }
+
+///
+/// net472_polyFill
+///
+public static partial class PolyFillExtensions
+{
+
+ //conditinal compile to get best performance..
+#if NETFRAMEWORK
+
+ ///
+ /// net472_polyFill
+ ///
+ public static IEnumerable TakeLast(this Queue queue, int count) => TakeLast_internal(queue, count);
+
+ ///
+ /// net472_polyFill
+ ///
+ public static TValue GetValueOrDefault(this ConcurrentDictionary dictionary, TKey key, TValue defaultValue)
+ => dictionary.TryGetValue(key, out var value) ? value : defaultValue;
+
+ ///
+ /// net472_polyFill
+ ///
+ public static bool TryRemove(this ConcurrentDictionary dictionary, KeyValuePair item)
+ => dictionary.TryRemove(item.Key, out _);
+
+#endif
+
+ ///
+ /// net472_polyFill - nint.Zero
+ ///
+ public static nint nint_Zero => (nint)0;
+
+
+}
+
+
+
+///
+/// net472_polyFill - not for public use, intented to be consumed in "Unit Tests".
+///
+public static partial class PolyFillExtensions
+{
+
+
+ ///
+ /// net472_polyFill - internal --- Ex: collection.TakeLast(5);
+ ///
+ internal static IEnumerable TakeLast_internal_viaSO(this IEnumerable source, int N)
+ {
+ return source.Skip(Math.Max(0, source.Count() - N));
+ }
+
+ ///
+ /// net472_polyFill - internal
+ ///
+ internal static IEnumerable TakeLast_internal(Queue queue, int count)
+ {
+ if (queue is null)
+ throw new ArgumentNullException("source is null ");
+
+ if (count <= 0 || queue.Count == 0)
+ return [];
+
+ if (count <= 0)
+ return Enumerable.Empty();
+ if (count >= queue.Count)
+ return queue.ToList();
+
+ // isStartIndexFromEnd: true, startIndex: count,
+ // isEndIndexFromEnd: true, endIndex: 0);
+ //return queue.Take(queue.Count - count).ToList();
+
+ var startIndex = queue.Count - count;
+ var take = count;
+
+ return queue.Skip(startIndex).Take(take).ToList();
+
+ }
+}
diff --git a/Test_polyfill/PolyFillTest.cs b/Test_polyfill/PolyFillTest.cs
new file mode 100644
index 0000000..c891fcd
--- /dev/null
+++ b/Test_polyfill/PolyFillTest.cs
@@ -0,0 +1,51 @@
+using System.Linq.Expressions;
+using System.Linq;
+using Xunit;
+
+namespace DeftSharp.Windows.Input;
+
+public sealed class PolyFillTest
+{
+
+ [Fact]
+ public async void TakeLast_1()
+ {
+ int TakeLast_count = 1;
+ var que = new Queue(new[] { 1, 2, 3, 4, 5 });
+
+ var val = Enumerable.TakeLast(que, TakeLast_count).ToList(); // net8 original Linq
+ var valpf = PolyFillExtensions.TakeLast(que, TakeLast_count).ToList();
+
+ Assert.True(val[0] == valpf[0]);
+ //await Task.Run(() => { });
+ }
+
+ [Fact]
+ public async void TakeLast_2()
+ {
+ int TakeLast_count = 2;
+ var que = new Queue(new[] { 1, 2, 3, 4, 5 });
+
+ var val = Enumerable.TakeLast(que, TakeLast_count).ToList(); // net8 original Linq
+ var valpf = PolyFillExtensions.TakeLast(que, TakeLast_count).ToList();
+
+ Assert.True(val[0] == valpf[0]);
+ Assert.True(val[1] == valpf[1]);
+ }
+
+ [Fact]
+ public async void TakeLast_3()
+ {
+ int TakeLast_count = 10;
+ var que = new Queue(Enumerable.Range(1,100));
+
+ var val = Enumerable.TakeLast(que, TakeLast_count).ToList(); // net8 original Linq
+ var valpf = PolyFillExtensions.TakeLast(que, TakeLast_count).ToList();
+
+ Assert.True(val[0] == valpf[0]);
+ Assert.True(val[4] == valpf[4]);
+ Assert.True(val[9] == valpf[9]);
+ }
+
+
+}
\ No newline at end of file
diff --git a/Test_polyfill/Test_polyfill.csproj b/Test_polyfill/Test_polyfill.csproj
new file mode 100644
index 0000000..da7a422
--- /dev/null
+++ b/Test_polyfill/Test_polyfill.csproj
@@ -0,0 +1,31 @@
+
+
+
+ net8.0
+ enable
+ enable
+
+ false
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+