From ffd45fbd7080908c3e59d44e0a2413e035baf694 Mon Sep 17 00:00:00 2001 From: Mark Cilia Vincenti Date: Sat, 21 Sep 2024 09:19:55 +0200 Subject: [PATCH] Minor optimizations. --- .../Backport.System.Threading.Lock.csproj | 10 +++++----- Backport.System.Threading.Lock/Lock.cs | 4 ++-- Backport.System.Threading.Lock/LockFactory.cs | 7 ++++++- Backport.System.Threading.Lock/PreNet5Lock.cs | 2 ++ Directory.Packages.props | 6 +++--- 5 files changed, 18 insertions(+), 11 deletions(-) diff --git a/Backport.System.Threading.Lock/Backport.System.Threading.Lock.csproj b/Backport.System.Threading.Lock/Backport.System.Threading.Lock.csproj index 66ac044..fc489b1 100644 --- a/Backport.System.Threading.Lock/Backport.System.Threading.Lock.csproj +++ b/Backport.System.Threading.Lock/Backport.System.Threading.Lock.csproj @@ -7,21 +7,21 @@ https://github.com/MarkCiliaVincenti/Backport.System.Threading.Lock MIT MIT - 2.0.0 + 2.0.2 logo.png - Breaking change that requires different usage for projects targeting frameworks prior to .NET 5.0 in order to cater for potential thread aborts. + Minor optimizations. A micro-library that backports .NET 9.0+'s System.Threading.Lock to prior framework versions (from .NET Framework 3.5 up to .NET 8.0), providing as much backward compatibility as possible. © 2024 Mark Cilia Vincenti System.Threading.Lock,lock,backport,backward,compatible,compatibility,synchronization,synchronisation git false - 2.0.0.0 - 2.0.0.0 + 2.0.2.0 + 2.0.2.0 README.md true True True - latest + preview True Backport.System.Threading.Lock.snk true diff --git a/Backport.System.Threading.Lock/Lock.cs b/Backport.System.Threading.Lock/Lock.cs index 1b6169c..614ae8c 100644 --- a/Backport.System.Threading.Lock/Lock.cs +++ b/Backport.System.Threading.Lock/Lock.cs @@ -1,6 +1,6 @@ -using System.Runtime.CompilerServices; +#if NET5_0_OR_GREATER && !NET9_0_OR_GREATER +using System.Runtime.CompilerServices; -#if NET5_0_OR_GREATER && !NET9_0_OR_GREATER namespace System.Threading; /// diff --git a/Backport.System.Threading.Lock/LockFactory.cs b/Backport.System.Threading.Lock/LockFactory.cs index fd8ac84..7bab2fd 100644 --- a/Backport.System.Threading.Lock/LockFactory.cs +++ b/Backport.System.Threading.Lock/LockFactory.cs @@ -1,4 +1,5 @@ -using FrameworkNamespace = System.Threading; +using System.Runtime.CompilerServices; +using FrameworkNamespace = System.Threading; namespace Backport.System.Threading; @@ -14,6 +15,7 @@ public static class LockFactory /// If your project does not target anything before .NET 5.0, you do not need to use this; simply use . /// /// An instance of . + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static FrameworkNamespace.Lock Create() => new(); } #else @@ -28,6 +30,9 @@ public static class LockFactory /// If your project does not target anything before .NET 5.0, you do not need to use this; simply use System.Threading.Lock. /// /// An instance of . +#if !PRE_NETSTANDARD + [MethodImpl(MethodImplOptions.AggressiveInlining)] +#endif public static Lock Create() => new(); } #endif \ No newline at end of file diff --git a/Backport.System.Threading.Lock/PreNet5Lock.cs b/Backport.System.Threading.Lock/PreNet5Lock.cs index db4710e..9c5aa1f 100644 --- a/Backport.System.Threading.Lock/PreNet5Lock.cs +++ b/Backport.System.Threading.Lock/PreNet5Lock.cs @@ -1,6 +1,8 @@ #if !NET9_0_OR_GREATER using System; +#if !PRE_NETSTANDARD using System.Runtime.CompilerServices; +#endif using System.Threading; namespace Backport.System.Threading; diff --git a/Directory.Packages.props b/Directory.Packages.props index ad37531..0c00d9e 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -5,9 +5,9 @@ - - - + + +