Skip to content

Commit

Permalink
Merge branch 'net48' into dev-70-net-framework-support
Browse files Browse the repository at this point in the history
  • Loading branch information
w1am committed Jan 18, 2024
2 parents e624b94 + 64610d0 commit 0176cb8
Show file tree
Hide file tree
Showing 20 changed files with 165 additions and 138 deletions.
10 changes: 4 additions & 6 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@
<GrpcToolsPackageVersion>2.59.0</GrpcToolsPackageVersion>
</PropertyGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net48'">
<Reference Include="System.Net.Http"/>
<Reference Include="System.Web"/>
<!--<PackageReference Include="IndexRange" Version="1.0.0" />-->
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0" PrivateAssets="All" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net48'">
<Reference Include="System.Net.Http"/>
<Reference Include="System.Web"/>
</ItemGroup>
</Project>
34 changes: 15 additions & 19 deletions src/EventStore.Client.Common/EpochExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,25 +1,21 @@
using System;

namespace EventStore.Client {
internal static class EpochExtensions {
private const long TicksPerMillisecond = 10000;
private const long TicksPerSecond = TicksPerMillisecond * 1000;
private const long TicksPerMinute = TicksPerSecond * 60;
private const long TicksPerHour = TicksPerMinute * 60;
private const long TicksPerDay = TicksPerHour * 24;
private const int DaysPerYear = 365;
private const int DaysPer4Years = DaysPerYear * 4 + 1;
private const int DaysPer100Years = DaysPer4Years * 25 - 1;
private const int DaysPer400Years = DaysPer100Years * 4 + 1;
private const int DaysTo1970 = DaysPer400Years * 4 + DaysPer100Years * 3 + DaysPer4Years * 17 + DaysPerYear;
private const long UnixEpochTicks = DaysTo1970 * TicksPerDay;
static class EpochExtensions {
private const long TicksPerMillisecond = 10000;
private const long TicksPerSecond = TicksPerMillisecond * 1000;
private const long TicksPerMinute = TicksPerSecond * 60;
private const long TicksPerHour = TicksPerMinute * 60;
private const long TicksPerDay = TicksPerHour * 24;
private const int DaysPerYear = 365;
private const int DaysPer4Years = DaysPerYear * 4 + 1;
private const int DaysPer100Years = DaysPer4Years * 25 - 1;
private const int DaysPer400Years = DaysPer100Years * 4 + 1;
private const int DaysTo1970 = DaysPer400Years * 4 + DaysPer100Years * 3 + DaysPer4Years * 17 + DaysPerYear;
private const long UnixEpochTicks = DaysTo1970 * TicksPerDay;

private static readonly DateTime UnixEpoch = new(UnixEpochTicks, DateTimeKind.Utc);
private static readonly DateTime UnixEpoch = new(UnixEpochTicks, DateTimeKind.Utc);

public static DateTime FromTicksSinceEpoch(this long value) =>
new DateTime(UnixEpoch.Ticks + value, DateTimeKind.Utc);
private static readonly DateTime UnixEpoch = new(UnixEpochTicks, DateTimeKind.Utc);

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.ProjectionManagement/ubuntu-latest/net48/lts

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.ProjectionManagement/ubuntu-latest/net48/lts

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.Operations/ubuntu-latest/net6.0/previous-lts

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.Operations/ubuntu-latest/net6.0/previous-lts

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.ProjectionManagement/ubuntu-latest/net6.0/lts

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.ProjectionManagement/ubuntu-latest/net6.0/lts

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.Streams/ubuntu-latest/net48/lts

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.Streams/ubuntu-latest/net48/lts

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.PersistentSubscriptions/ubuntu-latest/net48/lts

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.PersistentSubscriptions/ubuntu-latest/net48/lts

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.Streams/ubuntu-latest/net6.0/lts

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.Streams/ubuntu-latest/net6.0/lts

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.Streams/ubuntu-latest/net8.0/previous-lts

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.Streams/ubuntu-latest/net8.0/previous-lts

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.PersistentSubscriptions/ubuntu-latest/net6.0/lts

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.PersistentSubscriptions/ubuntu-latest/net6.0/lts

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.UserManagement/ubuntu-latest/net48/previous-lts

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.UserManagement/ubuntu-latest/net48/previous-lts

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.UserManagement/ubuntu-latest/net48/ci

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.UserManagement/ubuntu-latest/net48/ci

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.ProjectionManagement/ubuntu-latest/net8.0/lts

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.ProjectionManagement/ubuntu-latest/net8.0/lts

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test/EventStore.Client/ubuntu-latest/net48

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test/EventStore.Client/ubuntu-latest/net48

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.PersistentSubscriptions/ubuntu-latest/net8.0/previous-lts

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.PersistentSubscriptions/ubuntu-latest/net8.0/previous-lts

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.Streams/ubuntu-latest/net7.0/previous-lts

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.Streams/ubuntu-latest/net7.0/previous-lts

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test/EventStore.Client/ubuntu-latest/net7.0

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test/EventStore.Client/ubuntu-latest/net7.0

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.ProjectionManagement/ubuntu-latest/net8.0/previous-lts

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.ProjectionManagement/ubuntu-latest/net8.0/previous-lts

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.PersistentSubscriptions/ubuntu-latest/net7.0/previous-lts

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.PersistentSubscriptions/ubuntu-latest/net7.0/previous-lts

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.ProjectionManagement/ubuntu-latest/net48/previous-lts

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.ProjectionManagement/ubuntu-latest/net48/previous-lts

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.UserManagement/ubuntu-latest/net48/lts

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.UserManagement/ubuntu-latest/net48/lts

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.PersistentSubscriptions/ubuntu-latest/net48/ci

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.PersistentSubscriptions/ubuntu-latest/net48/ci

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.ProjectionManagement/ubuntu-latest/net7.0/lts

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.ProjectionManagement/ubuntu-latest/net7.0/lts

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test/EventStore.Client/ubuntu-latest/net6.0

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test/EventStore.Client/ubuntu-latest/net6.0

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.UserManagement/ubuntu-latest/net8.0/lts

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.UserManagement/ubuntu-latest/net8.0/lts

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / build-samples/ubuntu-latest/net6.0

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / build-samples/ubuntu-latest/net6.0

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / build-samples/ubuntu-latest/net6.0

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / build-samples/ubuntu-latest/net6.0

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.Streams/ubuntu-latest/net7.0/lts

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.Streams/ubuntu-latest/net7.0/lts

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.PersistentSubscriptions/ubuntu-latest/net8.0/lts

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.PersistentSubscriptions/ubuntu-latest/net8.0/lts

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.ProjectionManagement/ubuntu-latest/net6.0/previous-lts

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.ProjectionManagement/ubuntu-latest/net6.0/previous-lts

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.ProjectionManagement/ubuntu-latest/net6.0/ci

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.ProjectionManagement/ubuntu-latest/net6.0/ci

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.ProjectionManagement/ubuntu-latest/net7.0/previous-lts

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.ProjectionManagement/ubuntu-latest/net7.0/previous-lts

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.Operations/ubuntu-latest/net8.0/previous-lts

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.Operations/ubuntu-latest/net8.0/previous-lts

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.UserManagement/ubuntu-latest/net6.0/lts

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.UserManagement/ubuntu-latest/net6.0/lts

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.UserManagement/ubuntu-latest/net7.0/lts

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.UserManagement/ubuntu-latest/net7.0/lts

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.Operations/ubuntu-latest/net7.0/lts

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.Operations/ubuntu-latest/net7.0/lts

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.PersistentSubscriptions/ubuntu-latest/net7.0/lts

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.PersistentSubscriptions/ubuntu-latest/net7.0/lts

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.Operations/ubuntu-latest/net48/lts

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.Operations/ubuntu-latest/net48/lts

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.Operations/ubuntu-latest/net48/previous-lts

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.Operations/ubuntu-latest/net48/previous-lts

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.Streams/ubuntu-latest/net6.0/ci

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.Streams/ubuntu-latest/net6.0/ci

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.UserManagement/ubuntu-latest/net8.0/previous-lts

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.UserManagement/ubuntu-latest/net8.0/previous-lts

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.Operations/ubuntu-latest/net8.0/lts

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.Operations/ubuntu-latest/net8.0/lts

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.PersistentSubscriptions/ubuntu-latest/net6.0/ci

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.PersistentSubscriptions/ubuntu-latest/net6.0/ci

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.Streams/ubuntu-latest/net6.0/previous-lts

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.Streams/ubuntu-latest/net6.0/previous-lts

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.Operations/ubuntu-latest/net7.0/previous-lts

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.Operations/ubuntu-latest/net7.0/previous-lts

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / build-samples/ubuntu-latest/net7.0

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / build-samples/ubuntu-latest/net7.0

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / build-samples/ubuntu-latest/net7.0

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / build-samples/ubuntu-latest/net7.0

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / build-samples/ubuntu-latest/net48

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / build-samples/ubuntu-latest/net48

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / build-samples/ubuntu-latest/net48

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / build-samples/ubuntu-latest/net48

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.Streams/ubuntu-latest/net48/previous-lts

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.Streams/ubuntu-latest/net48/previous-lts

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.PersistentSubscriptions/ubuntu-latest/net6.0/previous-lts

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.PersistentSubscriptions/ubuntu-latest/net6.0/previous-lts

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.Operations/ubuntu-latest/net48/ci

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.Operations/ubuntu-latest/net48/ci

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.Streams/ubuntu-latest/net48/ci

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.Streams/ubuntu-latest/net48/ci

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.ProjectionManagement/ubuntu-latest/net48/ci

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.ProjectionManagement/ubuntu-latest/net48/ci

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.UserManagement/ubuntu-latest/net7.0/previous-lts

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.UserManagement/ubuntu-latest/net7.0/previous-lts

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.Operations/ubuntu-latest/net6.0/ci

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.Operations/ubuntu-latest/net6.0/ci

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.UserManagement/ubuntu-latest/net6.0/previous-lts

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.UserManagement/ubuntu-latest/net6.0/previous-lts

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.PersistentSubscriptions/ubuntu-latest/net48/previous-lts

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.PersistentSubscriptions/ubuntu-latest/net48/previous-lts

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.Operations/ubuntu-latest/net6.0/lts

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.Operations/ubuntu-latest/net6.0/lts

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / build-samples/ubuntu-latest/net8.0

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / build-samples/ubuntu-latest/net8.0

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / build-samples/ubuntu-latest/net8.0

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / build-samples/ubuntu-latest/net8.0

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.Operations/ubuntu-latest/net8.0/ci

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.Operations/ubuntu-latest/net8.0/ci

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.PersistentSubscriptions/ubuntu-latest/net8.0/ci

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.PersistentSubscriptions/ubuntu-latest/net8.0/ci

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.ProjectionManagement/ubuntu-latest/net8.0/ci

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.ProjectionManagement/ubuntu-latest/net8.0/ci

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.ProjectionManagement/ubuntu-latest/net7.0/ci

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.ProjectionManagement/ubuntu-latest/net7.0/ci

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.Streams/ubuntu-latest/net7.0/ci

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.Streams/ubuntu-latest/net7.0/ci

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.Operations/ubuntu-latest/net7.0/ci

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.Operations/ubuntu-latest/net7.0/ci

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.UserManagement/ubuntu-latest/net6.0/ci

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.UserManagement/ubuntu-latest/net6.0/ci

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.PersistentSubscriptions/ubuntu-latest/net7.0/ci

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.PersistentSubscriptions/ubuntu-latest/net7.0/ci

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.Streams/ubuntu-latest/net8.0/ci

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.Streams/ubuntu-latest/net8.0/ci

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.Streams/ubuntu-latest/net8.0/lts

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.Streams/ubuntu-latest/net8.0/lts

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.UserManagement/ubuntu-latest/net8.0/ci

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.UserManagement/ubuntu-latest/net8.0/ci

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.UserManagement/ubuntu-latest/net7.0/ci

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test / EventStore.Client.UserManagement/ubuntu-latest/net7.0/ci

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test/EventStore.Client/windows-latest/net48

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test/EventStore.Client/windows-latest/net48

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test/EventStore.Client/windows-latest/net7.0

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test/EventStore.Client/windows-latest/net7.0

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test/EventStore.Client/windows-latest/net6.0

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

Check failure on line 18 in src/EventStore.Client.Common/EpochExtensions.cs

View workflow job for this annotation

GitHub Actions / test/EventStore.Client/windows-latest/net6.0

The type 'EpochExtensions' already contains a definition for 'UnixEpoch'

public static long ToTicksSinceEpoch(this DateTime value) =>
(value - UnixEpoch).Ticks;
}
public static long ToTicksSinceEpoch(this DateTime value) => (value - UnixEpoch).Ticks;
}
2 changes: 1 addition & 1 deletion src/EventStore.Client.Common/Shims/TaskCompletionSource.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#if !NET
namespace System.Threading.Tasks;
namespace System.Threading.Tasks;

internal class TaskCompletionSource : TaskCompletionSource<object?> {
public void SetResult() => base.SetResult(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ public async Task<JsonDocument> GetResultAsync(string name, string? partition =
#else
using var stream = new MemoryStream();
#endif

await using var writer = new Utf8JsonWriter(stream);
var serializer = new ValueSerializer();
serializer.Write(writer, value, DefaultJsonSerializerOptions);
Expand All @@ -58,13 +57,11 @@ public async Task<T> GetResultAsync<T>(string name, string? partition = null,
CancellationToken cancellationToken = default) {
var value = await GetResultInternalAsync(name, partition, deadline, userCredentials, cancellationToken)
.ConfigureAwait(false);

#if NET
await using var stream = new MemoryStream();
#else
using var stream = new MemoryStream();
#endif

await using var writer = new Utf8JsonWriter(stream);
var serializer = new ValueSerializer();
serializer.Write(writer, value, DefaultJsonSerializerOptions);
Expand Down Expand Up @@ -109,7 +106,6 @@ public async Task<JsonDocument> GetStateAsync(string name, string? partition = n
#else
using var stream = new MemoryStream();
#endif

await using var writer = new Utf8JsonWriter(stream);
var serializer = new ValueSerializer();
serializer.Write(writer, value, DefaultJsonSerializerOptions);
Expand Down Expand Up @@ -141,7 +137,6 @@ public async Task<T> GetStateAsync<T>(string name, string? partition = null,
#else
using var stream = new MemoryStream();
#endif

await using var writer = new Utf8JsonWriter(stream);
var serializer = new ValueSerializer();
serializer.Write(writer, value, DefaultJsonSerializerOptions);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@
<PropertyGroup>
<Description>The GRPC client API for Event Store Streams. Get the open source or commercial versions of Event Store server from https://eventstore.com/</Description>
</PropertyGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net48'">
<PackageReference Include="System.Threading.Channels" Version="7.0.0"/>
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="8.0.0" />
</ItemGroup>
<ItemGroup>
<InternalsVisibleTo Include="EventStore.Client.Streams.Tests"/>
Expand Down
23 changes: 12 additions & 11 deletions src/EventStore.Client.Streams/EventStoreClient.Append.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
using EventStore.Client.Streams;
using Grpc.Core;
using Microsoft.Extensions.Logging;
using System.Runtime.CompilerServices;

namespace EventStore.Client {
public partial class EventStoreClient {
/// <summary>
Expand Down Expand Up @@ -340,16 +342,15 @@ public void Dispose() {
_channel.Writer.TryComplete();
}
}

private static async IAsyncEnumerable<T> ReadAllAsync<T>(ChannelReader<T> reader, [EnumeratorCancellation] CancellationToken cancellationToken = default)
{
while (await reader.WaitToReadAsync(cancellationToken).ConfigureAwait(false))
{
while (reader.TryRead(out T? item))
{
yield return item;
}
}
}
private static async IAsyncEnumerable<T> ReadAllAsync<T>(ChannelReader<T> reader, [EnumeratorCancellation] CancellationToken cancellationToken = default)
{
while (await reader.WaitToReadAsync(cancellationToken).ConfigureAwait(false))
{
while (reader.TryRead(out T? item))
{
yield return item;
}
}
}
}
}
31 changes: 18 additions & 13 deletions src/EventStore.Client/EventStoreClientSettings.ConnectionString.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,13 @@ public static EventStoreClientSettings Parse(string connectionString) {
return CreateSettings(scheme, userInfo, hosts, options);
}

private static EventStoreClientSettings CreateSettings(string scheme, (string user, string pass)? userInfo,
EndPoint[] hosts, Dictionary<string, string> options) {
private static EventStoreClientSettings CreateSettings(
string scheme, (string user, string pass)? userInfo,
EndPoint[] hosts, Dictionary<string, string> options
) {
var settings = new EventStoreClientSettings {
ConnectivitySettings = EventStoreClientConnectivitySettings.Default,
OperationOptions = EventStoreClientOperationOptions.Default
OperationOptions = EventStoreClientOperationOptions.Default
};

if (userInfo.HasValue)
Expand All @@ -119,13 +121,16 @@ private static EventStoreClientSettings CreateSettings(string scheme, (string us
foreach (var kv in options) {
if (!SettingsType.TryGetValue(kv.Key, out var type))
throw new InvalidSettingException($"Unknown option: {kv.Key}");

if (type == typeof(int)) {
if (!int.TryParse(kv.Value, out var intValue))
throw new InvalidSettingException($"{kv.Key} must be an integer value");

typedOptions.Add(kv.Key, intValue);
} else if (type == typeof(bool)) {
if (!bool.TryParse(kv.Value, out var boolValue))
throw new InvalidSettingException($"{kv.Key} must be either true or false");

typedOptions.Add(kv.Key, boolValue);
} else if (type == typeof(string)) {
typedOptions.Add(kv.Key, kv.Value);
Expand Down Expand Up @@ -199,11 +204,11 @@ private static EventStoreClientSettings CreateSettings(string scheme, (string us
settings.ConnectivitySettings.TlsVerifyCert = (bool)tlsVerifyCert;
}

settings.CreateHttpMessageHandler = CreateDefaultHandler;
settings.CreateHttpMessageHandler = CreateDefaultHandler;

return settings;

HttpMessageHandler CreateDefaultHandler() {
HttpMessageHandler CreateDefaultHandler() {
#if NET
var handler = new SocketsHttpHandler {
KeepAlivePingDelay = settings.ConnectivitySettings.KeepAliveInterval,
Expand All @@ -215,19 +220,19 @@ HttpMessageHandler CreateDefaultHandler() {
handler.SslOptions.RemoteCertificateValidationCallback = delegate { return true; };
}
#else
var handler = new WinHttpHandler {
TcpKeepAliveEnabled = true,
TcpKeepAliveTime = settings.ConnectivitySettings.KeepAliveTimeout,
TcpKeepAliveInterval = settings.ConnectivitySettings.KeepAliveInterval,
EnableMultipleHttp2Connections = true
};
var handler = new WinHttpHandler {
TcpKeepAliveEnabled = true,
TcpKeepAliveTime = settings.ConnectivitySettings.KeepAliveTimeout,
TcpKeepAliveInterval = settings.ConnectivitySettings.KeepAliveInterval,
EnableMultipleHttp2Connections = true
};

if (!settings.ConnectivitySettings.TlsVerifyCert) {
handler.ServerCertificateValidationCallback = delegate { return true; };
}
#endif
return handler;
}
}
}

private static string ParseScheme(string s) =>
Expand Down
34 changes: 28 additions & 6 deletions src/EventStore.Client/Uuid.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,11 @@ private Uuid(Guid value) {
_lsb = BitConverterToInt64(data[8..]);
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static long BitConverterToInt64(ReadOnlySpan<byte> value)
=> Unsafe.ReadUnaligned<long>(ref MemoryMarshal.GetReference(value));
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static long BitConverterToInt64(ReadOnlySpan<byte> value)
=> Unsafe.ReadUnaligned<long>(ref MemoryMarshal.GetReference(value));

private Uuid(string value) : this(value == null
private Uuid(string value) : this(value == null
? throw new ArgumentNullException(nameof(value))
: Guid.Parse(value)) {
}
Expand All @@ -104,7 +104,7 @@ public UUID ToDto() =>
new UUID {
Structured = new UUID.Types.Structured {
LeastSignificantBits = _lsb,
MostSignificantBits = _msb
MostSignificantBits = _msb
}
};

Expand Down Expand Up @@ -168,7 +168,29 @@ public Guid ToGuid() {
#if NET
return new Guid(data);
#else
return new Guid(data.ToArray());
return new Guid(data.ToArray());
#endif
}
private static bool TryWriteBytes(Span<byte> destination, long value)
{
if (destination.Length < sizeof(long))
return false;

Unsafe.WriteUnaligned(ref MemoryMarshal.GetReference(destination), value);
return true;
}

private bool TryWriteGuidBytes(Guid value, Span<byte> destination)
{
#if NET
return value.TryWriteBytes(destination);
#else
if (destination.Length < 16)
return false;

var bytes = value.ToByteArray();
bytes.CopyTo(destination);
return true;
#endif
}

Expand Down
10 changes: 7 additions & 3 deletions test/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@
<Using Include="JetBrains.Annotations" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net48'">
<Compile Include="..\..\src\EventStore.Client.Common\Shims\*.cs" LinkBase="Shims"/>
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net48'">
<PackageReference Include="Microsoft.Bcl.HashCode" Version="1.1.1" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net48'">
<Compile Include="..\src\EventStore.Client.Common\Shims\*.cs" LinkBase="Shims"/>
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -164,14 +164,14 @@ await Client.SubscribeToAllAsync(
(s, e, r, ct) => {
counter++;
switch (counter) {
case 1: s.Nack(PersistentSubscriptionNakEventAction.Park, "Test", e);
break;
case > 10:
tcs.TrySetResult();
break;
}
return Task.CompletedTask;
switch (counter) {
case 1: s.Nack(PersistentSubscriptionNakEventAction.Park, "Test", e);
break;
case > 10:
tcs.TrySetResult();
break;
}
return Task.CompletedTask;
},
userCredentials: TestCredentials.Root
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<ItemGroup>
<None Remove="EventStore.Client.Streams.Tests.csproj.DotSettings" />
</ItemGroup>
<ItemGroup>
<Compile Remove="..\..\src\EventStore.Client.Common\Shims\**" />
</ItemGroup>
<ItemGroup>
<Compile Remove="..\..\src\EventStore.Client.Common\Shims\**" />
</ItemGroup>
</Project>
12 changes: 6 additions & 6 deletions test/EventStore.Client.Tests.Common/ApplicationInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@ static Application() {

Environment = GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") ?? Environments.Development;

var builder = new ConfigurationBuilder()
.AddJsonFile("appsettings.json", true)
.AddJsonFile($"appsettings.{Environment}.json", true) // Accept default naming convention
.AddJsonFile($"appsettings.{Environment.ToLowerInvariant()}.json", true) // Linux is case sensitive
.AddEnvironmentVariables();
var builder = new ConfigurationBuilder()
.AddJsonFile("appsettings.json", true)
.AddJsonFile($"appsettings.{Environment}.json", true) // Accept default naming convention
.AddJsonFile($"appsettings.{Environment.ToLowerInvariant()}.json", true) // Linux is case sensitive
.AddEnvironmentVariables();

Configuration = builder.Build();

WriteLine($"APP: {Environment} configuration loaded "
+ $"with {Configuration.AsEnumerable().Count()} entries "
+ $"from {builder.Sources.Count} sources.");
+ $"from {builder.Sources.Count()} sources.");

IsDevelopment = IsEnvironment(Environments.Development);
IsStaging = IsEnvironment(Environments.Staging);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
<PackageReference Include="Serilog.Sinks.Seq" Version="6.0.0" />
<PackageReference Include="System.Reactive" Version="6.0.0" />
<PackageReference Include="xunit.categories" Version="2.0.8" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="8.0.0" />
</ItemGroup>

<!-- Vulnerable Transitive Packages -->
Expand Down
Loading

0 comments on commit 0176cb8

Please sign in to comment.