-
Notifications
You must be signed in to change notification settings - Fork 46
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
Changes from 1 commit
5a3aaef
353053a
d1299c2
8233ccd
a4fcf10
6fee86d
afc8d70
ba18d97
cb6d25f
249c59e
cc96c41
4769cc7
91186b5
5e4ade5
cf0bf17
a825792
9057a87
1456dd5
3b109c0
c01249b
c532b10
bf0bf8a
cfcc786
9488210
b0a524c
7137f09
3121220
72d2d0c
b56c34f
4d5dde2
e206725
ae849fc
f193985
6dde211
05c580d
e4f6a6b
dd9e835
4094afe
1b20013
4643fbf
e10b00e
3e1f598
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
@@ -1,6 +1,6 @@ | ||||
using StackExchange.Redis; | ||||
using System.Text.Json; | ||||
using System.Text.Json.Nodes; | ||||
// using System.Text.Json.Nodes; | ||||
|
||||
namespace NRedisStack; | ||||
|
||||
|
@@ -82,8 +82,8 @@ public async Task<RedisResult> GetAsync(RedisKey key, string[] paths, RedisValue | |||
var res = await _db.ExecuteAsync(JsonCommandBuilder.Get<T>(key, path)); | ||||
if (res.Type == ResultType.BulkString) | ||||
{ | ||||
var arr = JsonSerializer.Deserialize<JsonArray>(res.ToString()!); | ||||
if (arr?.Count > 0) | ||||
var arr = JsonSerializer.Deserialize<JsonElement[]>(res.ToString()!); | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a reason to move this to a JsonElement[] as opposed to a JsonArray? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. After I added There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's because you are using an older version of System.Text.Json - I think you SHOULD be able to switch it to 7.0.2 (current version) without breaking compatibility. The best way to validate that would be to make sure that
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do you mean to change the Version in this line: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No - so in this case we want to also test against an additional framework (just to make sure that the library is going to be fully compatible with that framework) .NET 4.5.2 is the oldest supported framework in .NET Standard 2.0 - so you just add |
||||
if (arr?.Length > 0) | ||||
{ | ||||
return JsonSerializer.Deserialize<T>(JsonSerializer.Serialize(arr[0])); | ||||
} | ||||
|
@@ -92,6 +92,7 @@ public async Task<RedisResult> GetAsync(RedisKey key, string[] paths, RedisValue | |||
return default; | ||||
} | ||||
|
||||
|
||||
/// <inheritdoc/> | ||||
public async Task<IEnumerable<T?>> GetEnumerableAsync<T>(RedisKey key, string path = "$") | ||||
{ | ||||
|
@@ -209,12 +210,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>(); | ||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Type change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above