Skip to content

Commit d3de4ad

Browse files
Merge pull request #110 from progaudi/feature/remove-restrictions
Feature/remove restrictions
2 parents bdbf9a8 + 04c3318 commit d3de4ad

34 files changed

+1092
-142
lines changed

.vscode/tasks.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@
1212
"isBuildCommand": true,
1313
"showOutput": "silent",
1414
"problemMatcher": "$msCompile"
15+
},
16+
{
17+
"taskName": "test",
18+
"args": [ "tests/progaudi.tarantool.tests/progaudi.tarantool.tests.csproj"],
19+
"isTestCommand": true,
20+
"showOutput": "silent",
21+
"problemMatcher": "$msCompile"
1522
}
1623
]
1724
}

T4Templates/SystemTupleConverters.tt

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<#@ assembly name="System.Core" #>
2+
<#@ import namespace="System.Linq" #>
3+
using System;
4+
using ProGaudi.MsgPack.Light;
5+
using ProGaudi.Tarantool.Client.Utils;
6+
7+
namespace ProGaudi.Tarantool.Client.Converters{
8+
<#
9+
var maxParametersCount = 8;
10+
var typeParameters = new Func<int, string>(count => string.Join(", ", System.Linq.Enumerable.Range(1, count).Select(num => $"T{num}")));
11+
for(int i=1;i < maxParametersCount; i++){
12+
#>
13+
public class SystemTupleConverter<<#= typeParameters(i)#>> :IMsgPackConverter<Tuple<<#= typeParameters(i)#>>>
14+
{
15+
private IMsgPackConverter<object> _nullConverter;
16+
<# for (int j= 1; j <= i; j++){#>
17+
private IMsgPackConverter<T<#= j #>> _t<#= j #>Converter;
18+
<#}#>
19+
public void Initialize(MsgPackContext context)
20+
{
21+
_nullConverter = context.NullConverter;
22+
<# for (int j= 1; j <= i; j++){#>
23+
_t<#= j #>Converter = context.GetConverter<T<#= j #>>();<#}#>
24+
}
25+
26+
public void Write(Tuple<<#= typeParameters(i)#>> value, IMsgPackWriter writer)
27+
{
28+
if (value == null)
29+
{
30+
_nullConverter.Write(null, writer);
31+
return;
32+
}
33+
34+
writer.WriteArrayHeader(<#= i #>);
35+
<# for (int j= 1; j <= i; j++){#>
36+
_t<#= j #>Converter.Write(value.Item<#= j #>, writer);<#}#>
37+
}
38+
39+
public Tuple<<#= typeParameters(i)#>> Read(IMsgPackReader reader)
40+
{
41+
var actual = reader.ReadArrayLength();
42+
if (actual == null)
43+
{
44+
return null;
45+
}
46+
47+
const uint expected = <#= i #>;
48+
if (actual != expected)
49+
{
50+
throw ExceptionHelper.InvalidArrayLength(expected, actual);
51+
}
52+
<# for (int j= 1; j <= i; j++){#>
53+
var item<#= j #> = _t<#= j #>Converter.Read(reader);<#}#>
54+
55+
return Tuple.Create(<# for (int j= 1; j <= i; j++){#>
56+
item<#= j #><#= j==i?"":"," #><#}#>
57+
);
58+
}
59+
}
60+
<#
61+
}#>
62+
}

T4Templates/ValueTupleConverters.tt

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<#@ assembly name="System.Core" #>
2+
<#@ import namespace="System.Linq" #>
3+
using System;
4+
using ProGaudi.MsgPack.Light;
5+
using ProGaudi.Tarantool.Client.Utils;
6+
7+
namespace ProGaudi.Tarantool.Client.Converters{
8+
<#
9+
var maxParametersCount = 8;
10+
var typeParameters = new Func<int, string>(count => string.Join(", ", System.Linq.Enumerable.Range(1, count).Select(num => $"T{num}")));
11+
for(int i=1;i < maxParametersCount; i++){
12+
#>
13+
public class ValueTupleConverter<<#= typeParameters(i)#>> :IMsgPackConverter<ValueTuple<<#= typeParameters(i)#>>>
14+
{<# for (int j= 1; j <= i; j++){#>
15+
private IMsgPackConverter<T<#= j #>> _t<#= j #>Converter;
16+
<#}#>
17+
public void Initialize(MsgPackContext context)
18+
{<# for (int j= 1; j <= i; j++){#>
19+
_t<#= j #>Converter = context.GetConverter<T<#= j #>>();<#}#>
20+
}
21+
22+
public void Write(ValueTuple<<#= typeParameters(i)#>> value, IMsgPackWriter writer)
23+
{
24+
writer.WriteArrayHeader(<#= i #>);
25+
<# for (int j= 1; j <= i; j++){#>
26+
_t<#= j #>Converter.Write(value.Item<#= j #>, writer);<#}#>
27+
}
28+
29+
public ValueTuple<<#= typeParameters(i)#>> Read(IMsgPackReader reader)
30+
{
31+
var actual = reader.ReadArrayLength();
32+
if (actual == null)
33+
{
34+
return default(ValueTuple<<#= typeParameters(i)#>>);
35+
}
36+
37+
const uint expected = <#= i #>;
38+
if (actual != expected)
39+
{
40+
throw ExceptionHelper.InvalidArrayLength(expected, actual);
41+
}
42+
<# for (int j= 1; j <= i; j++){#>
43+
var item<#= j #> = _t<#= j #>Converter.Read(reader);<#}#>
44+
45+
return ValueTuple.Create(<# for (int j= 1; j <= i; j++){#>
46+
item<#= j #><#= j==i?"":"," #><#}#>
47+
);
48+
}
49+
}
50+
<#
51+
}#>
52+
}

_T4Awesome/CodeItems/31c71f1f-2480-4de2-98a0-97a1c9b23c49/item.t4aic

Lines changed: 0 additions & 1 deletion
This file was deleted.

_T4Awesome/config.t4ac

Lines changed: 0 additions & 1 deletion
This file was deleted.

scripts/mac-prereqs.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ set -ev
44

55
brew update
66
brew install openssl jq
7-
brew install tarantool --HEAD
7+
brew install tarantool
88
brew install redis
99

1010
mkdir -p /usr/local/lib

src/progaudi.tarantool/Box.cs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,20 +69,16 @@ public async Task Call_1_6(string functionName)
6969
}
7070

7171
public async Task Call_1_6<TTuple>(string functionName, TTuple parameters)
72-
where TTuple : ITarantoolTuple
7372
{
7473
await Call_1_6<TTuple, TarantoolTuple>(functionName, parameters).ConfigureAwait(false);
7574
}
7675

7776
public Task<DataResponse<TResponse[]>> Call_1_6<TResponse>(string functionName)
78-
where TResponse : ITarantoolTuple
7977
{
8078
return Call_1_6<TarantoolTuple, TResponse>(functionName, TarantoolTuple.Empty);
8179
}
8280

8381
public async Task<DataResponse<TResponse[]>> Call_1_6<TTuple, TResponse>(string functionName, TTuple parameters)
84-
where TTuple : ITarantoolTuple
85-
where TResponse : ITarantoolTuple
8682
{
8783
var callRequest = new CallRequest<TTuple>(functionName, parameters, false);
8884
return await _logicalConnection.SendRequest<CallRequest<TTuple>, TResponse>(callRequest).ConfigureAwait(false);
@@ -94,7 +90,6 @@ public async Task Call(string functionName)
9490
}
9591

9692
public async Task Call<TTuple>(string functionName, TTuple parameters)
97-
where TTuple : ITarantoolTuple
9893
{
9994
await Call<TTuple, TarantoolTuple>(functionName, parameters).ConfigureAwait(false);
10095
}
@@ -105,14 +100,12 @@ public Task<DataResponse<TResponse[]>> Call<TResponse>(string functionName)
105100
}
106101

107102
public async Task<DataResponse<TResponse[]>> Call<TTuple, TResponse>(string functionName, TTuple parameters)
108-
where TTuple : ITarantoolTuple
109103
{
110104
var callRequest = new CallRequest<TTuple>(functionName, parameters);
111105
return await _logicalConnection.SendRequest<CallRequest<TTuple>, TResponse>(callRequest).ConfigureAwait(false);
112106
}
113107

114108
public async Task<DataResponse<TResponse[]>> Eval<TTuple, TResponse>(string expression, TTuple parameters)
115-
where TTuple : ITarantoolTuple
116109
{
117110
var evalRequest = new EvalRequest<TTuple>(expression, parameters);
118111
return await _logicalConnection.SendRequest<EvalRequest<TTuple>, TResponse>(evalRequest).ConfigureAwait(false);

src/progaudi.tarantool/Converters/CallPacketConverter.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
namespace ProGaudi.Tarantool.Client.Converters
1010
{
1111
internal class CallPacketConverter<T> : IMsgPackConverter<CallRequest<T>>
12-
where T : ITarantoolTuple
1312
{
1413
private IMsgPackConverter<Key> _keyConverter;
1514
private IMsgPackConverter<string> _stringConverter;

src/progaudi.tarantool/Converters/DeletePacketConverter.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
namespace ProGaudi.Tarantool.Client.Converters
1010
{
1111
internal class DeletePacketConverter<T> : IMsgPackConverter<DeleteRequest<T>>
12-
where T: ITarantoolTuple
1312
{
1413
private IMsgPackConverter<Key> _keyConverter;
1514
private IMsgPackConverter<uint> _uintConverter;

src/progaudi.tarantool/Converters/EvalPacketConverter.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
namespace ProGaudi.Tarantool.Client.Converters
1010
{
1111
internal class EvalPacketConverter<T> : IMsgPackConverter<EvalRequest<T>>
12-
where T:ITarantoolTuple
1312
{
1413
private IMsgPackConverter<Key> _keyConverter;
1514
private IMsgPackConverter<string> _stringConverter;

src/progaudi.tarantool/Converters/InsertReplacePacketConverter.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
namespace ProGaudi.Tarantool.Client.Converters
1010
{
1111
internal class InsertReplacePacketConverter<T> : IMsgPackConverter<InsertReplaceRequest<T>>
12-
where T : ITarantoolTuple
1312
{
1413
private IMsgPackConverter<Key> _keyConverter;
1514
private IMsgPackConverter<uint> _uintConverter;

src/progaudi.tarantool/Converters/SelectPacketConverter.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
namespace ProGaudi.Tarantool.Client.Converters
1010
{
1111
internal class SelectPacketConverter<T> : IMsgPackConverter<SelectRequest<T>>
12-
where T : ITarantoolTuple
1312
{
1413
private IMsgPackConverter<T> _selectKeyConverter;
1514
private IMsgPackConverter<Key> _keyConverter;

0 commit comments

Comments
 (0)