From 314d23233c45a12d110201aabe771c7878970eea Mon Sep 17 00:00:00 2001 From: Joyless <65855333+Joy-less@users.noreply.github.com> Date: Sun, 17 Nov 2024 14:30:15 +0000 Subject: [PATCH 1/4] Update target frameworks --- LiteDB/LiteDB.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LiteDB/LiteDB.csproj b/LiteDB/LiteDB.csproj index 67eeb45f1..56adb4883 100644 --- a/LiteDB/LiteDB.csproj +++ b/LiteDB/LiteDB.csproj @@ -1,7 +1,7 @@  - net4.5;netstandard1.3;netstandard2.0 + netstandard2.0;netstandard2.1;net8.0;net9.0 5.0.21 5.0.21 5.0.21 From fc221f348d6cb7aee4cdeeac1ff55402cc94379c Mon Sep 17 00:00:00 2001 From: Joyless <65855333+Joy-less@users.noreply.github.com> Date: Sun, 17 Nov 2024 14:30:32 +0000 Subject: [PATCH 2/4] Remove redundant .NET Framework code --- LiteDB/Client/Shared/SharedEngine.cs | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/LiteDB/Client/Shared/SharedEngine.cs b/LiteDB/Client/Shared/SharedEngine.cs index c25e7d591..c18049177 100644 --- a/LiteDB/Client/Shared/SharedEngine.cs +++ b/LiteDB/Client/Shared/SharedEngine.cs @@ -3,10 +3,6 @@ using System.Collections.Generic; using System.IO; using System.Threading; -#if NETFRAMEWORK -using System.Security.AccessControl; -using System.Security.Principal; -#endif namespace LiteDB { @@ -25,17 +21,7 @@ public SharedEngine(EngineSettings settings) try { -#if NETFRAMEWORK - var allowEveryoneRule = new MutexAccessRule(new SecurityIdentifier(WellKnownSidType.WorldSid, null), - MutexRights.FullControl, AccessControlType.Allow); - - var securitySettings = new MutexSecurity(); - securitySettings.AddAccessRule(allowEveryoneRule); - - _mutex = new Mutex(false, "Global\\" + name + ".Mutex", out _, securitySettings); -#else _mutex = new Mutex(false, "Global\\" + name + ".Mutex"); -#endif } catch (NotSupportedException ex) { From b0bc6b63ddc270cbabbf97dd1e3092bdeeefca46 Mon Sep 17 00:00:00 2001 From: Joyless <65855333+Joy-less@users.noreply.github.com> Date: Sun, 17 Nov 2024 14:36:22 +0000 Subject: [PATCH 3/4] Update NuGet packages --- LiteDB.Benchmarks/LiteDB.Benchmarks.csproj | 2 +- LiteDB.Tests/LiteDB.Tests.csproj | 2 +- LiteDB/LiteDB.csproj | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/LiteDB.Benchmarks/LiteDB.Benchmarks.csproj b/LiteDB.Benchmarks/LiteDB.Benchmarks.csproj index 80a1ebdde..458601357 100644 --- a/LiteDB.Benchmarks/LiteDB.Benchmarks.csproj +++ b/LiteDB.Benchmarks/LiteDB.Benchmarks.csproj @@ -7,7 +7,7 @@ - + diff --git a/LiteDB.Tests/LiteDB.Tests.csproj b/LiteDB.Tests/LiteDB.Tests.csproj index a0bd2e807..728ab55a4 100644 --- a/LiteDB.Tests/LiteDB.Tests.csproj +++ b/LiteDB.Tests/LiteDB.Tests.csproj @@ -29,7 +29,7 @@ - + diff --git a/LiteDB/LiteDB.csproj b/LiteDB/LiteDB.csproj index 56adb4883..fe3203521 100644 --- a/LiteDB/LiteDB.csproj +++ b/LiteDB/LiteDB.csproj @@ -68,7 +68,7 @@ - + From 442d36cdab4933d681621cd696ff15812e1ed88f Mon Sep 17 00:00:00 2001 From: Joyless <65855333+Joy-less@users.noreply.github.com> Date: Sun, 17 Nov 2024 14:43:10 +0000 Subject: [PATCH 4/4] Remove redundant condition compilation --- LiteDB/Document/ObjectId.cs | 20 ++------------------ LiteDB/LiteDB.csproj | 30 ------------------------------ 2 files changed, 2 insertions(+), 48 deletions(-) diff --git a/LiteDB/Document/ObjectId.cs b/LiteDB/Document/ObjectId.cs index 84b0af12f..35f68c6e0 100644 --- a/LiteDB/Document/ObjectId.cs +++ b/LiteDB/Document/ObjectId.cs @@ -275,13 +275,7 @@ public override string ToString() // static constructor static ObjectId() { - _machine = (GetMachineHash() + -#if HAVE_APP_DOMAIN - AppDomain.CurrentDomain.Id -#else - 10000 // Magic number -#endif - ) & 0x00ffffff; + _machine = (GetMachineHash() + AppDomain.CurrentDomain.Id) & 0x00ffffff; _increment = (new Random()).Next(); try @@ -294,24 +288,14 @@ static ObjectId() } } - [MethodImpl(MethodImplOptions.NoInlining)] private static int GetCurrentProcessId() { -#if HAVE_PROCESS return Process.GetCurrentProcess().Id; -#else - return (new Random()).Next(0, 5000); // Any same number for this process -#endif } private static int GetMachineHash() { - var hostName = -#if HAVE_ENVIRONMENT - Environment.MachineName; // use instead of Dns.HostName so it will work offline -#else - "SOMENAME"; -#endif + var hostName = Environment.MachineName; // use instead of Dns.HostName so it will work offline return 0x00ffffff & hostName.GetHashCode(); // use first 3 bytes of hash } diff --git a/LiteDB/LiteDB.csproj b/LiteDB/LiteDB.csproj index fe3203521..c4eaf1562 100644 --- a/LiteDB/LiteDB.csproj +++ b/LiteDB/LiteDB.csproj @@ -30,26 +30,6 @@ true latest - - - - - TRACE;DEBUG - - - - HAVE_SHA1_MANAGED;HAVE_APP_DOMAIN;HAVE_PROCESS;HAVE_ENVIRONMENT - - - - HAVE_SHA1_MANAGED - @@ -57,16 +37,6 @@ - - - - - - - - - -