diff --git a/examples/EdgeDB.Examples.CSharp/Examples/JsonResults.cs b/examples/EdgeDB.Examples.CSharp/Examples/JsonResults.cs index e5333469..8bb8c2db 100644 --- a/examples/EdgeDB.Examples.CSharp/Examples/JsonResults.cs +++ b/examples/EdgeDB.Examples.CSharp/Examples/JsonResults.cs @@ -1,4 +1,5 @@ -using Microsoft.Extensions.Logging; +using EdgeDB.DataTypes; +using Microsoft.Extensions.Logging; using Newtonsoft.Json; namespace EdgeDB.ExampleApp.Examples; @@ -11,7 +12,8 @@ public async Task ExecuteAsync(EdgeDBClient client) { var result = await client.QueryJsonAsync("select Person {name, email}"); - var people = JsonConvert.DeserializeObject(result)!; + var people = JsonConvert.DeserializeObject(result); + if (people is null) { return; } Logger!.LogInformation("People from json: {@People}", people); } diff --git a/src/EdgeDB.Net.Driver/Clients/EdgeDBBinaryClient.cs b/src/EdgeDB.Net.Driver/Clients/EdgeDBBinaryClient.cs index 5432f273..c2be3eb8 100644 --- a/src/EdgeDB.Net.Driver/Clients/EdgeDBBinaryClient.cs +++ b/src/EdgeDB.Net.Driver/Clients/EdgeDBBinaryClient.cs @@ -421,7 +421,14 @@ public override async Task> 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.Empty; } diff --git a/src/EdgeDB.Net.Driver/Models/DataTypes/Json.cs b/src/EdgeDB.Net.Driver/Models/DataTypes/Json.cs index 2687e584..bf8d306b 100644 --- a/src/EdgeDB.Net.Driver/Models/DataTypes/Json.cs +++ b/src/EdgeDB.Net.Driver/Models/DataTypes/Json.cs @@ -10,13 +10,13 @@ public readonly struct Json /// /// Gets or sets the raw json value. /// - public readonly string? Value; + public readonly string Value; /// /// Creates a new json type with a provided value. /// /// The raw json value of this json object. - public Json(string? value) + public Json(string value) { Value = value; } @@ -42,6 +42,6 @@ public Json(string? value) ? serializer.Deserialize(new JsonTextReader(new StringReader(Value))) : EdgeDBConfig.JsonSerializer.DeserializeObject(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); } diff --git a/tests/EdgeDB.Tests.Benchmarks/CodecVisitorBenchmarks.cs b/tests/EdgeDB.Tests.Benchmarks/CodecVisitorBenchmarks.cs index e1b93026..d52d3552 100644 --- a/tests/EdgeDB.Tests.Benchmarks/CodecVisitorBenchmarks.cs +++ b/tests/EdgeDB.Tests.Benchmarks/CodecVisitorBenchmarks.cs @@ -2,15 +2,4 @@ namespace EdgeDB.Tests.Benchmarks; public class CodecVisitorBenchmarks { - - - public async Task BenchmarkArgumentVisitor() - { - - } - - public async Task BenchmarkResultVisitor() - { - - } } diff --git a/tests/EdgeDB.Tests.Benchmarks/Utils/MockQueryClient.cs b/tests/EdgeDB.Tests.Benchmarks/Utils/MockQueryClient.cs index 23c066b5..149d8116 100644 --- a/tests/EdgeDB.Tests.Benchmarks/Utils/MockQueryClient.cs +++ b/tests/EdgeDB.Tests.Benchmarks/Utils/MockQueryClient.cs @@ -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; @@ -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; } @@ -108,7 +107,7 @@ public override ValueTask ReadAsync(Memory buffer, CancellationToken _pos += buffer.Length; return ValueTask.FromResult(buffer.Length); } - catch (Exception x) + catch (Exception) { return ValueTask.FromResult(0); } @@ -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; } } } diff --git a/tools/EdgeDB.DocGenerator/Parser.cs b/tools/EdgeDB.DocGenerator/Parser.cs index 85f95391..8040ce47 100644 --- a/tools/EdgeDB.DocGenerator/Parser.cs +++ b/tools/EdgeDB.DocGenerator/Parser.cs @@ -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(); @@ -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; diff --git a/tools/EdgeDB.QueryBuilder.OperatorGenerator/Program.cs b/tools/EdgeDB.QueryBuilder.OperatorGenerator/Program.cs index d91c35cb..800770d2 100644 --- a/tools/EdgeDB.QueryBuilder.OperatorGenerator/Program.cs +++ b/tools/EdgeDB.QueryBuilder.OperatorGenerator/Program.cs @@ -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")) {