Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update target frameworks. #2564

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion LiteDB.Benchmarks/LiteDB.Benchmarks.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.13.12" />
<PackageReference Include="BenchmarkDotNet" Version="0.14.0" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion LiteDB.Tests/LiteDB.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="FluentAssertions" Version="6.12.1" />
<PackageReference Include="FluentAssertions" Version="6.12.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageReference Include="xunit" Version="2.9.2" />
<PackageReference Include="xunit.runner.console" Version="2.9.2">
Expand Down
14 changes: 0 additions & 14 deletions LiteDB/Client/Shared/SharedEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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)
{
Expand Down
20 changes: 2 additions & 18 deletions LiteDB/Document/ObjectId.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}

Expand Down
34 changes: 2 additions & 32 deletions LiteDB/LiteDB.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net4.5;netstandard1.3;netstandard2.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;netstandard2.1;net8.0;net9.0</TargetFrameworks>
<AssemblyVersion>5.0.21</AssemblyVersion>
<FileVersion>5.0.21</FileVersion>
<VersionPrefix>5.0.21</VersionPrefix>
Expand Down Expand Up @@ -30,45 +30,15 @@
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<LangVersion>latest</LangVersion>
</PropertyGroup>

<!--
== All variables ==
HAVE_APP_DOMAIN
HAVE_PROCESS
HAVE_ENVIRONMENT
HAVE_SHA1_MANAGED
-->

<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
<DefineConstants>TRACE;DEBUG</DefineConstants>
</PropertyGroup>

<PropertyGroup Condition="'$(TargetFramework)' == 'net45'">
<DefineConstants>HAVE_SHA1_MANAGED;HAVE_APP_DOMAIN;HAVE_PROCESS;HAVE_ENVIRONMENT</DefineConstants>
</PropertyGroup>

<PropertyGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<DefineConstants>HAVE_SHA1_MANAGED</DefineConstants>
</PropertyGroup>

<!-- Begin References -->
<ItemGroup>
<None Include="..\LICENSE" Pack="true" PackagePath="" />
<None Include="..\icon_64x64.png" Pack="true" PackagePath="\" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net45'">
<Reference Include="System" />
<Reference Include="System.Runtime" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netstandard1.3'">
<PackageReference Include="System.Reflection.TypeExtensions" Version="4.5.1" />
<PackageReference Include="System.Security.Cryptography.Algorithms" Version="4.3.1" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="System.Buffers" Version="4.5.1" />
<PackageReference Include="System.Buffers" Version="4.6.0" />
</ItemGroup>

<!-- End References -->
Expand Down