Skip to content

Commit

Permalink
warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
shacharPash committed Sep 11, 2023
1 parent 34e7b35 commit c01f7ee
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/NRedisStack/Graph/DataTypes/Edge.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class Edge : GraphEntity
/// The relationship type.
/// </summary>
/// <value></value>
public string RelationshipType { get; set; }
public string? RelationshipType { get; set; }

/// <summary>
/// The ID of the source node.
Expand Down
34 changes: 17 additions & 17 deletions src/NRedisStack/Search/DataTypes/InfoResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ public class InfoResult
{
private readonly Dictionary<string, RedisResult> _all = new Dictionary<string, RedisResult>();

public string IndexName => GetString("index_name");
public Dictionary<string, RedisResult> IndexOption => GetRedisResultDictionary("index_options");
public string IndexName => GetString("index_name")!;
public Dictionary<string, RedisResult> IndexOption => GetRedisResultDictionary("index_options")!;

public Dictionary<string, RedisResult>[] Attributes => GetRedisResultDictionaryArray("attributes");
public Dictionary<string, RedisResult>[] Attributes => GetRedisResultDictionaryArray("attributes")!;


public long NumDocs => GetLong("num_docs");

public string MaxDocId => GetString("max_doc_id");
public string MaxDocId => GetString("max_doc_id")!;

public long NumTerms => GetLong("num_terms");

Expand Down Expand Up @@ -59,32 +59,32 @@ public class InfoResult
public long NumberOfUses => GetLong("number_of_uses");


public Dictionary<string, RedisResult> GcStats => GetRedisResultDictionary("gc_stats");
public Dictionary<string, RedisResult> GcStats => GetRedisResultDictionary("gc_stats")!;

public Dictionary<string, RedisResult> CursorStats => GetRedisResultDictionary("cursor_stats");
public Dictionary<string, RedisResult> CursorStats => GetRedisResultDictionary("cursor_stats")!;

public InfoResult(RedisResult result)
{
var results = (RedisResult[])result;
var results = (RedisResult[])result!;

for (var i = 0; i < results.Length; i += 2)
{
var key = (string)results[i];
var key = (string)results[i]!;
var value = results[i + 1];

_all.Add(key, value);
}
}

private string GetString(string key) => _all.TryGetValue(key, out var value) ? (string)value : default;
private string? GetString(string key) => _all.TryGetValue(key, out var value) ? (string)value! : default;

private long GetLong(string key) => _all.TryGetValue(key, out var value) ? (long)value : default;

private double GetDouble(string key)
{
if (_all.TryGetValue(key, out var value))
{
if ((string)value == "-nan")
if ((string)value! == "-nan")
{
return default;
}
Expand All @@ -99,16 +99,16 @@ private double GetDouble(string key)
}
}

private Dictionary<string, RedisResult> GetRedisResultDictionary(string key)
private Dictionary<string, RedisResult>? GetRedisResultDictionary(string key)
{
if (_all.TryGetValue(key, out var value))
{
var values = (RedisResult[])value;
var values = (RedisResult[])value!;
var result = new Dictionary<string, RedisResult>();

for (var ii = 0; ii < values.Length; ii += 2)
{
result.Add((string)values[ii], values[ii + 1]);
result.Add((string)values[ii]!, values[ii + 1]);
}

return result;
Expand All @@ -119,19 +119,19 @@ private Dictionary<string, RedisResult> GetRedisResultDictionary(string key)
}
}

private Dictionary<string, RedisResult>[] GetRedisResultDictionaryArray(string key)
private Dictionary<string, RedisResult>[]? GetRedisResultDictionaryArray(string key)
{
if (_all.TryGetValue(key, out var value))
{
var values = (RedisResult[])value;
var values = (RedisResult[])value!;
var result = new Dictionary<string, RedisResult>[values.Length];
for (int i = 0; i < values.Length; i++)
{
var fv = (RedisResult[])values[i];
var fv = (RedisResult[])values[i]!;
var dict = new Dictionary<string, RedisResult>();
for (int j = 0; j < fv.Length; j += 2)
{
dict.Add((string)fv[j], fv[j + 1]);
dict.Add((string)fv[j]!, fv[j + 1]);
}
result[i] = dict;
}
Expand Down

0 comments on commit c01f7ee

Please sign in to comment.