Skip to content

Target .NET Standard 2.0 #89

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

Merged
merged 42 commits into from
Mar 15, 2023
Merged
Show file tree
Hide file tree
Changes from 38 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
5a3aaef
Target .NET Standard 2.0
shacharPash Mar 9, 2023
353053a
add condition
shacharPash Mar 9, 2023
d1299c2
update to the latest version of System.Text.Json
shacharPash Mar 12, 2023
8233ccd
adjustments to run in .NET Framework, adding job to run tests for .NE…
slorello89 Mar 13, 2023
a4fcf10
adjustments to run in .NET Framework, adding job to run tests for .NE…
slorello89 Mar 13, 2023
6fee86d
syntax fix
chayim Mar 13, 2023
afc8d70
Merge branch 'Target2.0' of https://github.com/redis/NRedisStack into…
slorello89 Mar 13, 2023
ba18d97
trying to manually switch to linux containers
slorello89 Mar 13, 2023
cb6d25f
trying other format
slorello89 Mar 13, 2023
249c59e
fixing syntax
slorello89 Mar 13, 2023
cc96c41
swapping flags
slorello89 Mar 13, 2023
4769cc7
nixing windows job
slorello89 Mar 13, 2023
91186b5
try dropping framework restrictions
slorello89 Mar 13, 2023
5e4ade5
dropping 462
slorello89 Mar 13, 2023
cf0bf17
trying to test on windows using WSL 2
slorello89 Mar 14, 2023
a825792
adding curl install
slorello89 Mar 14, 2023
9057a87
also installing gpg. . .
slorello89 Mar 14, 2023
1456dd5
and lsb-release...
slorello89 Mar 14, 2023
3b109c0
trying to log start
slorello89 Mar 14, 2023
c01249b
switching to ubuntu
slorello89 Mar 14, 2023
c532b10
change test name
shacharPash Mar 14, 2023
bf0bf8a
delete distribution: Ubuntu-20.04 line
shacharPash Mar 14, 2023
cfcc786
experiment
shacharPash Mar 14, 2023
9488210
trying with direct tar download
slorello89 Mar 14, 2023
b0a524c
ok let's actually add it this time
slorello89 Mar 14, 2023
7137f09
resetting as a jammy instance, adding a ls for debugging
slorello89 Mar 14, 2023
3121220
removing mv
slorello89 Mar 14, 2023
72d2d0c
removing process spinoff
slorello89 Mar 14, 2023
b56c34f
fixing syntax
slorello89 Mar 14, 2023
4d5dde2
libgomp1?
slorello89 Mar 14, 2023
e206725
spin off again
slorello89 Mar 14, 2023
ae849fc
trying a new tact for spinning off process
slorello89 Mar 14, 2023
f193985
old school spin off?
slorello89 Mar 14, 2023
6dde211
renaming
slorello89 Mar 15, 2023
05c580d
versioning
slorello89 Mar 15, 2023
e4f6a6b
newline
slorello89 Mar 15, 2023
dd9e835
PS variable access
slorello89 Mar 15, 2023
4094afe
reverting
slorello89 Mar 15, 2023
1b20013
other means of seeding env vars?
slorello89 Mar 15, 2023
4643fbf
add sleep to HSETandSearch test
shacharPash Mar 15, 2023
e10b00e
add sleep to TestQueryCommandBuilderScore Test
shacharPash Mar 15, 2023
3e1f598
conditional framework usage based on platform
slorello89 Mar 15, 2023
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
34 changes: 29 additions & 5 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@ on:
- cron: "0 1 * * *"

env:
redis_stack_version: 6.2.2-v5
redis_stack_version: 6.2.6-v6

jobs:

build_and_test:
build_and_Test:
name: Build and test
runs-on: ubuntu-latest
steps:
Expand All @@ -36,12 +35,37 @@ jobs:
- name: Build
run: dotnet build --no-restore /p:ContinuousIntegrationBuild=true
- name: Test
run: dotnet test --no-build --verbosity normal /p:CollectCoverage=true /p:CoverletOutputFormat=opencover
run: dotnet test -f net6.0 --no-build --verbosity normal /p:CollectCoverage=true /p:CoverletOutputFormat=opencover
- name: Test
run: dotnet test -f net7.0 --no-build --verbosity normal /p:CollectCoverage=true /p:CoverletOutputFormat=opencover
- name: Codecov
uses: codecov/codecov-action@v3
with:
token: ${{secrets.CODECOV_TOKEN}}
verbose: true

- name: Build
run: dotnet pack -c Release
build_and_test_windows:
name: Build and Test on Windows
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- uses: Vampire/setup-wsl@v2
with:
distribution: Ubuntu-22.04
- name: Install Redis
shell: wsl-bash {0}
run: |
sudo apt-get update
sudo apt-get install curl -y && sudo apt-get install gpg -y && apt-get install lsb-release -y && apt-get install libgomp1 -y
curl https://packages.redis.io/redis-stack/redis-stack-server-6.2.6-v6.jammy.x86_64.tar.gz -o redis-stack.tar.gz
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: ${{env.redis_stack_version}}

tar xf redis-stack.tar.gz
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore /p:ContinuousIntegrationBuild=true
- name: Test
shell: cmd
run: |
START wsl ./redis-stack-server-6.2.6-v6/bin/redis-stack-server &
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same ${{env.redis_stack_version}}

dotnet test -f net481 --no-build --verbosity normal
12 changes: 10 additions & 2 deletions src/NRedisStack/Graph/Header.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ internal Header(RedisResult result)
SchemaTypes = new List<ResultSetColumnTypes>();
SchemaNames = new List<string>();

foreach(RedisResult[] tuple in (RedisResult[])result)
foreach (RedisResult[] tuple in (RedisResult[])result)
{
SchemaTypes.Add((ResultSetColumnTypes)(int)tuple[0]);
SchemaNames.Add((string)tuple[1]);
Expand Down Expand Up @@ -63,9 +63,17 @@ public override bool Equals(object? obj)

public override int GetHashCode()
{
return HashCode.Combine(SchemaTypes, SchemaNames);
unchecked
{
int hash = 17;
hash = hash * 23 + SchemaTypes.GetHashCode();
hash = hash * 23 + SchemaNames.GetHashCode();
return hash;
}
}



public override string ToString() =>
$"Header{{schemaTypes=[{string.Join(", ", SchemaTypes)}], schemaNames=[{string.Join(", ", SchemaNames)}]}}";
}
Expand Down
10 changes: 5 additions & 5 deletions src/NRedisStack/Json/JsonCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ public bool Set(RedisKey key, RedisValue path, RedisValue json, When when = When
/// <inheritdoc/>
public bool SetFromFile(RedisKey key, RedisValue path, string filePath, When when = When.Always)
{
if(!File.Exists(filePath))
if (!File.Exists(filePath))
{
throw new FileNotFoundException($"File {filePath} not found.");
}

string fileContent = File.ReadAllText(filePath);
string fileContent = File.ReadAllText(filePath);
return Set(key, path, fileContent, when);
}

Expand All @@ -60,7 +60,7 @@ public int SetFromDirectory(RedisValue path, string filesPath, When when = When.
foreach (var filePath in files)
{
key = filePath.Substring(0, filePath.IndexOf("."));
if(SetFromFile(key, path, filePath, when))
if (SetFromFile(key, path, filePath, when))
{
inserted++;
}
Expand Down Expand Up @@ -111,12 +111,12 @@ public JsonType[] Type(RedisKey key, string? path = null)

if (result.Type == ResultType.MultiBulk)
{
return ((RedisResult[])result!).Select(x => Enum.Parse<JsonType>(x.ToString()!.ToUpper())).ToArray();
return ((RedisResult[])result!).Select(x => (JsonType)Enum.Parse(typeof(JsonType), x.ToString()!.ToUpper())).ToArray();
}

if (result.Type == ResultType.BulkString)
{
return new[] { Enum.Parse<JsonType>(result.ToString()!.ToUpper()) };
return new[] { (JsonType)Enum.Parse(typeof(JsonType), result.ToString()!.ToUpper()) };
}

return Array.Empty<JsonType>();
Expand Down
4 changes: 2 additions & 2 deletions src/NRedisStack/Json/JsonCommandsAsync.cs
Original file line number Diff line number Diff line change
Expand Up @@ -209,12 +209,12 @@ public async Task<JsonType[]> TypeAsync(RedisKey key, string? path = null)

if (result.Type == ResultType.MultiBulk)
{
return ((RedisResult[])result!).Select(x => Enum.Parse<JsonType>(x.ToString()!.ToUpper())).ToArray();
return ((RedisResult[])result!).Select(x => (JsonType)Enum.Parse(typeof(JsonType), x.ToString()!.ToUpper())).ToArray();
}

if (result.Type == ResultType.BulkString)
{
return new[] { Enum.Parse<JsonType>(result.ToString()!.ToUpper()) };
return new[] { (JsonType)Enum.Parse(typeof(JsonType), result.ToString()!.ToUpper()) };
}

return Array.Empty<JsonType>();
Expand Down
8 changes: 5 additions & 3 deletions src/NRedisStack/NRedisStack.csproj
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Nullable>enable</Nullable>
<TargetFrameworks>netstandard2.0;net6.0;net7.0</TargetFrameworks>
<LangVersion>latest</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
<Authors>Redis Open Source</Authors>
<Owners>Redis OSS</Owners>
<Description>.Net Client for Redis Stack</Description>
Expand All @@ -14,6 +15,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="System.Text.Json" Version="7.0.2" Condition="'$(TargetFramework)' == 'netstandard2.0'" />
<PackageReference Include="StackExchange.Redis" Version="2.6.90" />
<None Include="..\..\README.md" Pack="true" PackagePath="\" />
</ItemGroup>
Expand Down
4 changes: 3 additions & 1 deletion src/NRedisStack/ResponseParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ public static long ToLong(this RedisResult result)

public static double ToDouble(this RedisResult result)
{
if (result.ToString() == "nan")
return double.NaN;
if ((double?)result == null)
throw new ArgumentNullException(nameof(result));
return (double)result;
Expand Down Expand Up @@ -591,7 +593,7 @@ public static IEnumerable<HashSet<string>> ToHashSets(this RedisResult result)
if (res.All(x => x.Type != ResultType.MultiBulk))
{
var keys = res.Select(x => x.ToString()!);
sets.Add(keys.ToHashSet());
sets.Add(new HashSet<string>(keys));
return sets;
}

Expand Down
4 changes: 3 additions & 1 deletion src/NRedisStack/Tdigest/TdigestCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ public double Max(RedisKey key)
/// <inheritdoc/>
public double Min(RedisKey key)
{
return _db.Execute(TdigestCommandBuilder.Min(key)).ToDouble();
var cmd = TdigestCommandBuilder.Min(key);
var res =_db.Execute(cmd);
return res.ToDouble();
}

/// <inheritdoc/>
Expand Down
3 changes: 2 additions & 1 deletion tests/NRedisStack.Tests/NRedisStack.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
<TargetFrameworks>net6.0;net7.0;net481</TargetFrameworks>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question for my own knowledge 481 because it's the latest in 4?

Copy link
Member

@slorello89 slorello89 Mar 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes - .NET Framework 4.8.1 is the latest (and likely final) framework version. It's also one of two framework versions that ship natively on the windows-latest image

<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<LangVersion>latest</LangVersion>

<IsPackable>false</IsPackable>
</PropertyGroup>
Expand Down
8 changes: 6 additions & 2 deletions tests/NRedisStack.Tests/Tdigest/TdigestTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,7 @@ static Tuple<double, long> RandomValueWeight()
{
Random random = new Random();

return new Tuple<double, long>(random.NextDouble() * 10000, random.NextInt64() + 1);
return new Tuple<double, long>(random.NextDouble() * 10000, random.Next() + 1);
}

static Tuple<double, long>[] RandomValueWeightArray(int count)
Expand All @@ -687,7 +687,11 @@ static Tuple<double, long> DefinedValueWeight(double value, long weight)
private static double[] WeightedValue(double value, int weight)
{
double[] values = new double[weight];
Array.Fill(values, value);
for (var i = 0; i < values.Length; i++)
{
values[i] = value;
}

return values;
}
}
3 changes: 2 additions & 1 deletion tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMADD.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using NRedisStack.DataTypes;
using NRedisStack.Literals.Enums;
using NRedisStack.RedisStackCommands;
using StackExchange.Redis;
using Xunit;
Expand Down Expand Up @@ -88,7 +89,7 @@ public void TestOverrideMADD()

foreach (string key in keys)
{
ts.Create(key);
ts.Create(key, duplicatePolicy: TsDuplicatePolicy.MAX);
}

List<DateTime> oldTimeStamps = new List<DateTime>();
Expand Down
3 changes: 2 additions & 1 deletion tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMAddAsync.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using NRedisStack.DataTypes;
using NRedisStack.Literals.Enums;
using NRedisStack.RedisStackCommands;
using StackExchange.Redis;
using Xunit;
Expand Down Expand Up @@ -82,7 +83,7 @@ public async Task TestOverrideMAdd()

foreach (var key in keys)
{
await ts.CreateAsync(key);
await ts.CreateAsync(key, duplicatePolicy: TsDuplicatePolicy.MAX);
}

var oldTimeStamps = new List<DateTime>();
Expand Down