Skip to content

Commit

Permalink
Fix warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
dnwpark committed Jan 31, 2025
1 parent 07c2ab5 commit 50694ac
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 26 deletions.
6 changes: 4 additions & 2 deletions examples/EdgeDB.Examples.CSharp/Examples/JsonResults.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Microsoft.Extensions.Logging;
using EdgeDB.DataTypes;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;

namespace EdgeDB.ExampleApp.Examples;
Expand All @@ -11,7 +12,8 @@ public async Task ExecuteAsync(EdgeDBClient client)
{
var result = await client.QueryJsonAsync("select Person {name, email}");

var people = JsonConvert.DeserializeObject<Person[]>(result)!;
var people = JsonConvert.DeserializeObject<Person[]>(result);
if (people is null) { return; }

Logger!.LogInformation("People from json: {@People}", people);
}
Expand Down
9 changes: 8 additions & 1 deletion src/EdgeDB.Net.Driver/Clients/EdgeDBBinaryClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,14 @@ public override async Task<IReadOnlyCollection<Json>> QueryJsonElementsAsync(str
token: token);

return result.ProtocolResult.Data.Any()
? result.ProtocolResult.Data.Select(x => new Json((string?)result.ProtocolResult.OutCodecInfo.Codec.Deserialize(this, in x)))
? result.ProtocolResult.Data
.Select(x =>
{
object? text = result.ProtocolResult.OutCodecInfo.Codec.Deserialize(this, in x);
return text is string
? new Json((string)text)
: throw new EdgeDBException("Error parsing JsonElements.");
})
.ToImmutableArray()
: ImmutableArray<Json>.Empty;
}
Expand Down
8 changes: 4 additions & 4 deletions src/EdgeDB.Net.Driver/Models/DataTypes/Json.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ public readonly struct Json
/// <summary>
/// Gets or sets the raw json value.
/// </summary>
public readonly string? Value;
public readonly string Value;

/// <summary>
/// Creates a new json type with a provided value.
/// </summary>
/// <param name="value">The raw json value of this json object.</param>
public Json(string? value)
public Json(string value)
{
Value = value;
}
Expand All @@ -42,6 +42,6 @@ public Json(string? value)
? serializer.Deserialize<T>(new JsonTextReader(new StringReader(Value)))
: EdgeDBConfig.JsonSerializer.DeserializeObject<T>(Value);

public static implicit operator string?(Json j) => j.Value;
public static implicit operator Json(string? value) => new(value);
public static implicit operator string(Json j) => j.Value;
public static implicit operator Json(string value) => new(value);
}
11 changes: 0 additions & 11 deletions tests/EdgeDB.Tests.Benchmarks/CodecVisitorBenchmarks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,4 @@ namespace EdgeDB.Tests.Benchmarks;

public class CodecVisitorBenchmarks
{


public async Task BenchmarkArgumentVisitor()
{

}

public async Task BenchmarkResultVisitor()
{

}
}
6 changes: 2 additions & 4 deletions tests/EdgeDB.Tests.Benchmarks/Utils/MockQueryClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ private class MockQueryClientStream : Stream
{
private byte[]? _nextBuffer;
private int _pos;
private bool _trigger;
public override bool CanRead => true;

public override bool CanSeek => true;
Expand All @@ -93,7 +92,7 @@ public override int Read(byte[] buffer, int offset, int count)
_pos += count;
return count;
}
catch (Exception x)
catch (Exception)
{
return 0;
}
Expand All @@ -108,7 +107,7 @@ public override ValueTask<int> ReadAsync(Memory<byte> buffer, CancellationToken
_pos += buffer.Length;
return ValueTask.FromResult(buffer.Length);
}
catch (Exception x)
catch (Exception)
{
return ValueTask.FromResult(0);
}
Expand Down Expand Up @@ -142,7 +141,6 @@ public override void Write(byte[] buffer, int offset, int count)
_ => throw new Exception($"unknown message type {type}")
};
_pos = 0;
_trigger = true;
}
}
}
6 changes: 3 additions & 3 deletions tools/EdgeDB.DocGenerator/Parser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ internal class Parser
{
public static DocMember[] Load(string file)
{
var serializer = new XmlSerializer(typeof(doc));
var serializer = new XmlSerializer(typeof(Doc));
using var reader = new StreamReader(file);
var t = (doc)serializer.Deserialize(reader)!;
var t = (Doc)serializer.Deserialize(reader)!;

var members = t.members!.Select(x => DocMember.FromMember(x)).OrderByDescending(x => x.Type).ToArray();

Expand Down Expand Up @@ -437,7 +437,7 @@ public enum MemberType
[DesignerCategory("code")]
[XmlTypeAttribute(AnonymousType = true)]
[XmlRootAttribute(Namespace = "", IsNullable = false)]
public class doc
public class Doc
{
private docAssembly? assemblyField;

Expand Down
2 changes: 1 addition & 1 deletion tools/EdgeDB.QueryBuilder.OperatorGenerator/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ void BuildSingleOperator(string section, EdgeQLOperator op)
writer.AppendLine("using System.Linq.Expressions;");
writer.AppendLine();

var cleanedName = Regex.Replace(op.Name, @"(<.*?>)", x => "");
var cleanedName = Regex.Replace(op.Name!, @"(<.*?>)", x => "");

using (var _ = writer.BeginScope("namespace EdgeDB.Operators"))
{
Expand Down

0 comments on commit 50694ac

Please sign in to comment.