Skip to content

Commit b17ef64

Browse files
Merge pull request #370 from linksplatform/csharp/feature/use_generic_math
csharp/feature/use generic math
2 parents cf469b6 + 7e83d30 commit b17ef64

File tree

129 files changed

+9485
-25890
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

129 files changed

+9485
-25890
lines changed
Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

3-
<PropertyGroup>
4-
<OutputType>Exe</OutputType>
5-
<TargetFramework>net7</TargetFramework>
6-
<IsPackable>false</IsPackable>
7-
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
8-
<LangVersion>latest</LangVersion>
9-
<Nullable>enable</Nullable>
10-
</PropertyGroup>
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net7</TargetFramework>
6+
<IsPackable>false</IsPackable>
7+
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
8+
<LangVersion>latest</LangVersion>
9+
<Nullable>enable</Nullable>
10+
</PropertyGroup>
1111

12-
<ItemGroup>
13-
<PackageReference Include="BenchmarkDotNet" Version="0.13.1" />
14-
</ItemGroup>
12+
<ItemGroup>
13+
<PackageReference Include="BenchmarkDotNet" Version="0.13.1"/>
14+
</ItemGroup>
1515

16-
<ItemGroup>
17-
<ProjectReference Include="..\Platform.Data.Doublets\Platform.Data.Doublets.csproj" />
18-
</ItemGroup>
16+
<ItemGroup>
17+
<ProjectReference Include="..\Platform.Data.Doublets\Platform.Data.Doublets.csproj"/>
18+
</ItemGroup>
1919

2020
</Project>

csharp/Platform.Data.Doublets.Tests/GenericLinksTests.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.IO;
3+
using System.Numerics;
34
using Platform.Data.Doublets.Decorators;
45
using Xunit;
56

@@ -37,7 +38,7 @@ public static void MultipleRandomCreationsAndDeletionsTest()
3738
Using<uint>(links => links.DecorateWithAutomaticUniquenessAndUsagesResolution().TestMultipleRandomCreationsAndDeletions(100));
3839
Using<ulong>(links => links.DecorateWithAutomaticUniquenessAndUsagesResolution().TestMultipleRandomCreationsAndDeletions(100));
3940
}
40-
private static void Using<TLinkAddress>(Action<ILinks<TLinkAddress>> action)
41+
private static void Using<TLinkAddress>(Action<ILinks<TLinkAddress>> action) where TLinkAddress : IUnsignedNumber<TLinkAddress> , IShiftOperators<TLinkAddress,int,TLinkAddress>, IBitwiseOperators<TLinkAddress,TLinkAddress,TLinkAddress>, IMinMaxValue<TLinkAddress>, IComparisonOperators<TLinkAddress, TLinkAddress, bool>
4142
{
4243
var unitedMemoryLinks = new UnitedMemoryLinks<TLinkAddress>(new HeapResizableDirectMemory());
4344
using (var logFile = File.Open("linksLogger.txt", FileMode.Create, FileAccess.Write))
Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

3-
<PropertyGroup>
4-
<TargetFramework>net7</TargetFramework>
5-
<IsPackable>false</IsPackable>
6-
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
7-
<LangVersion>latest</LangVersion>
8-
<Nullable>enable</Nullable>
9-
</PropertyGroup>
3+
<PropertyGroup>
4+
<TargetFramework>net7</TargetFramework>
5+
<IsPackable>false</IsPackable>
6+
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
7+
<LangVersion>latest</LangVersion>
8+
<Nullable>enable</Nullable>
9+
</PropertyGroup>
1010

11-
<ItemGroup>
12-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
13-
<PackageReference Include="xunit" Version="2.4.1" />
14-
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3" PrivateAssets="All" />
15-
<PackageReference Include="coverlet.collector" Version="3.1.2" PrivateAssets="All" />
16-
</ItemGroup>
11+
<ItemGroup>
12+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
13+
<PackageReference Include="xunit" Version="2.4.1" />
14+
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3" PrivateAssets="All" />
15+
<PackageReference Include="coverlet.collector" Version="3.1.2" PrivateAssets="All" />
16+
</ItemGroup>
1717

18-
<ItemGroup>
19-
<ProjectReference Include="..\Platform.Data.Doublets\Platform.Data.Doublets.csproj" />
20-
</ItemGroup>
18+
<ItemGroup>
19+
<ProjectReference Include="..\Platform.Data.Doublets\Platform.Data.Doublets.csproj" />
20+
</ItemGroup>
2121

22-
<ItemGroup>
23-
<PackageReference Include="Platform.Counters" Version="0.0.2" />
24-
<PackageReference Include="Platform.Diagnostics" Version="0.1.0" />
25-
<PackageReference Include="Platform.Scopes" Version="0.1.0" />
26-
</ItemGroup>
22+
<ItemGroup>
23+
<PackageReference Include="Platform.Counters" Version="0.0.2" />
24+
<PackageReference Include="Platform.Diagnostics" Version="0.1.0" />
25+
<PackageReference Include="Platform.Scopes" Version="0.1.0" />
26+
</ItemGroup>
2727

2828
</Project>

csharp/Platform.Data.Doublets.Tests/ResizableDirectMemoryLinksTests.cs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
using Xunit;
33
using Platform.Singletons;
44
using Platform.Memory;
5-
using Platform.Data.Doublets.Memory.United.Specific;
5+
using Platform.Data.Doublets.Memory.United.Generic;
66

77
namespace Platform.Data.Doublets.Tests
88
{
@@ -14,18 +14,21 @@ public static class ResizableDirectMemoryLinksTests
1414
public static void BasicFileMappedMemoryTest()
1515
{
1616
var tempFilename = Path.GetTempFileName();
17-
using (var memoryAdapter = new UInt64UnitedMemoryLinks(tempFilename))
17+
using (var memoryAdapter = new TemporaryFileMappedResizableDirectMemory())
1818
{
19-
memoryAdapter.TestBasicMemoryOperations();
19+
using (var unitedMemoryLinksStorage = new UnitedMemoryLinks<ulong>(memoryAdapter))
20+
{
21+
unitedMemoryLinksStorage.TestBasicMemoryOperations();
22+
}
2023
}
2124
File.Delete(tempFilename);
2225
}
2326

2427
[Fact]
2528
public static void BasicHeapMemoryTest()
2629
{
27-
using (var memory = new HeapResizableDirectMemory(UInt64UnitedMemoryLinks.DefaultLinksSizeStep))
28-
using (var memoryAdapter = new UInt64UnitedMemoryLinks(memory, UInt64UnitedMemoryLinks.DefaultLinksSizeStep))
30+
using (var memory = new HeapResizableDirectMemory(UnitedMemoryLinks<ulong>.DefaultLinksSizeStep))
31+
using (var memoryAdapter = new UnitedMemoryLinks<ulong>(memory, UnitedMemoryLinks<ulong>.DefaultLinksSizeStep))
2932
{
3033
memoryAdapter.TestBasicMemoryOperations();
3134
}
@@ -39,8 +42,8 @@ private static void TestBasicMemoryOperations(this ILinks<ulong> memoryAdapter)
3942
[Fact]
4043
public static void NonexistentReferencesHeapMemoryTest()
4144
{
42-
using (var memory = new HeapResizableDirectMemory(UInt64UnitedMemoryLinks.DefaultLinksSizeStep))
43-
using (var memoryAdapter = new UInt64UnitedMemoryLinks(memory, UInt64UnitedMemoryLinks.DefaultLinksSizeStep))
45+
using (var memory = new HeapResizableDirectMemory(UnitedMemoryLinks<ulong>.DefaultLinksSizeStep))
46+
using (var memoryAdapter = new UnitedMemoryLinks<ulong>(memory, UnitedMemoryLinks<ulong>.DefaultLinksSizeStep))
4447
{
4548
memoryAdapter.TestNonexistentReferences();
4649
}

csharp/Platform.Data.Doublets.Tests/ScopeTests.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
using Platform.Data.Doublets.Decorators;
55
using Platform.Reflection;
66
using Platform.Data.Doublets.Memory.United.Generic;
7-
using Platform.Data.Doublets.Memory.United.Specific;
7+
using TLinkAddress = System.UInt64;
88

99
namespace Platform.Data.Doublets.Tests
1010
{
@@ -27,9 +27,9 @@ public static void CascadeDependencyTest()
2727
using (var scope = new Scope())
2828
{
2929
scope.Include<TemporaryFileMappedResizableDirectMemory>();
30-
scope.Include<UInt64UnitedMemoryLinks>();
31-
var instance = scope.Use<ILinks<ulong>>();
32-
Assert.IsType<UInt64UnitedMemoryLinks>(instance);
30+
scope.Include<UnitedMemoryLinks<TLinkAddress>>();
31+
var instance = scope.Use<ILinks<TLinkAddress>>();
32+
Assert.IsType<UnitedMemoryLinks<TLinkAddress>>(instance);
3333
}
3434
}
3535

@@ -38,18 +38,18 @@ public static void FullAutoResolutionTest()
3838
{
3939
using (var scope = new Scope(autoInclude: true, autoExplore: true))
4040
{
41-
var instance = scope.Use<UInt64Links>();
42-
Assert.IsType<UInt64Links>(instance);
41+
var instance = scope.Use<CombinedDecorator<TLinkAddress>>();
42+
Assert.IsType<TLinkAddress>(instance);
4343
}
4444
}
4545

4646
[Fact]
4747
public static void TypeParametersTest()
4848
{
49-
using (var scope = new Scope<Types<HeapResizableDirectMemory, UnitedMemoryLinks<ulong>>>())
49+
using (var scope = new Scope<Types<HeapResizableDirectMemory, UnitedMemoryLinks<TLinkAddress>>>())
5050
{
51-
var links = scope.Use<ILinks<ulong>>();
52-
Assert.IsType<UnitedMemoryLinks<ulong>>(links);
51+
var links = scope.Use<ILinks<TLinkAddress>>();
52+
Assert.IsType<UnitedMemoryLinks<TLinkAddress>>(links);
5353
}
5454
}
5555
}

csharp/Platform.Data.Doublets.Tests/SplitMemoryGenericLinksTests.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Numerics;
23
using Xunit;
34
using Platform.Memory;
45
using Platform.Data.Doublets.Memory.Split.Generic;
@@ -34,7 +35,7 @@ public static void MultipleRandomCreationsAndDeletionsTest()
3435
Using<uint>(links => links.DecorateWithAutomaticUniquenessAndUsagesResolution().TestMultipleRandomCreationsAndDeletions(100));
3536
Using<ulong>(links => links.DecorateWithAutomaticUniquenessAndUsagesResolution().TestMultipleRandomCreationsAndDeletions(100));
3637
}
37-
private static void Using<TLinkAddress>(Action<ILinks<TLinkAddress>> action)
38+
private static void Using<TLinkAddress> (Action<ILinks<TLinkAddress>> action) where TLinkAddress : IUnsignedNumber<TLinkAddress>, IComparisonOperators<TLinkAddress, TLinkAddress, bool>
3839
{
3940
using (var dataMemory = new HeapResizableDirectMemory())
4041
using (var indexMemory = new HeapResizableDirectMemory())
@@ -43,7 +44,7 @@ private static void Using<TLinkAddress>(Action<ILinks<TLinkAddress>> action)
4344
action(memory);
4445
}
4546
}
46-
private static void UsingWithExternalReferences<TLinkAddress>(Action<ILinks<TLinkAddress>> action)
47+
private static void UsingWithExternalReferences<TLinkAddress>(Action<ILinks<TLinkAddress>> action) where TLinkAddress : IUnsignedNumber<TLinkAddress>, IComparisonOperators<TLinkAddress, TLinkAddress, bool>
4748
{
4849
var contants = new LinksConstants<TLinkAddress>(enableExternalReferencesSupport: true);
4950
using (var dataMemory = new HeapResizableDirectMemory())

csharp/Platform.Data.Doublets.Tests/SplitMemoryUInt32LinksTests.cs

Lines changed: 0 additions & 48 deletions
This file was deleted.

csharp/Platform.Data.Doublets.Tests/SplitMemoryUInt64LinksTests.cs

Lines changed: 0 additions & 48 deletions
This file was deleted.

csharp/Platform.Data.Doublets.Tests/Uint64LinksExtensionsTests.cs

Lines changed: 0 additions & 37 deletions
This file was deleted.

csharp/Platform.Data.Doublets.Tests/UnitedMemoryUInt32LinksTests.cs

Lines changed: 0 additions & 38 deletions
This file was deleted.

0 commit comments

Comments
 (0)