diff --git a/code/Benchmarks.BinaryDictionaryTests/BinaryDictionaryBenchmarks.cs b/code/Benchmarks.BinaryDictionaryTests/BinaryDictionaryBenchmarks.cs index 59765166..397f1b76 100644 --- a/code/Benchmarks.BinaryDictionaryTests/BinaryDictionaryBenchmarks.cs +++ b/code/Benchmarks.BinaryDictionaryTests/BinaryDictionaryBenchmarks.cs @@ -75,8 +75,8 @@ GetValueOrDefault CreateHashCode(byte[][] keys) this.functorHashCode3 = CreateHashCode(this.keys3); this.functorHashCode7 = CreateHashCode(this.keys7); - Trace.Assert(this.keys3.Select(x => x.Length).SequenceEqual(new[] { 2, 4, 7 })); - Trace.Assert(this.keys7.Select(x => x.Length).SequenceEqual(new[] { 15, 0, 14, 4, 13, 8, 12 })); + Trace.Assert(this.keys3.Select(x => x.Length).SequenceEqual([2, 4, 7])); + Trace.Assert(this.keys7.Select(x => x.Length).SequenceEqual([15, 0, 14, 4, 13, 8, 12])); Trace.Assert(Invoke(this.functorLongData3, this.keys3) == 3); Trace.Assert(Invoke(this.functorHashCode3, this.keys3) == 3); Trace.Assert(Invoke(this.functorLongData7, this.keys7) == 21); diff --git a/code/Benchmarks.CollectionDecodeTests/Models/ReflectionMethods.cs b/code/Benchmarks.CollectionDecodeTests/Models/ReflectionMethods.cs index 70498817..d30cbb93 100644 --- a/code/Benchmarks.CollectionDecodeTests/Models/ReflectionMethods.cs +++ b/code/Benchmarks.CollectionDecodeTests/Models/ReflectionMethods.cs @@ -18,7 +18,7 @@ public static Decoder GetDecoder(Converter converter, Expression(new[] { 1313 }); + this.linkedList = new LinkedList([1313]); this.dictionary = new Dictionary { [1313] = 1313 }; this.hashSetConverter = generator.GetConverter>(); diff --git a/code/Binary.SourceGeneration.CollectionTests/CompatibleTests/IntegrationTests.cs b/code/Binary.SourceGeneration.CollectionTests/CompatibleTests/IntegrationTests.cs index 9a7edb2b..0d3884f9 100644 --- a/code/Binary.SourceGeneration.CollectionTests/CompatibleTests/IntegrationTests.cs +++ b/code/Binary.SourceGeneration.CollectionTests/CompatibleTests/IntegrationTests.cs @@ -97,7 +97,7 @@ public readonly struct CustomValueEnumerable(IEnumerable? collection) : IE { public readonly IEnumerable? Collection = collection; - public IEnumerator GetEnumerator() => (this.Collection ?? Array.Empty()).GetEnumerator(); + public IEnumerator GetEnumerator() => (this.Collection ?? []).GetEnumerator(); IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); } @@ -108,7 +108,7 @@ public readonly struct CustomValueEnumerable(IEnumerable? collection) : IE internal CustomValueEnumerableInternalConstructor(IEnumerable? collection) => this.Collection = collection; - public IEnumerator GetEnumerator() => (this.Collection ?? Array.Empty()).GetEnumerator(); + public IEnumerator GetEnumerator() => (this.Collection ?? []).GetEnumerator(); IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); } diff --git a/code/Binary.SourceGeneration.CollectionTests/SupportedTypesTests/IntegrationTests.cs b/code/Binary.SourceGeneration.CollectionTests/SupportedTypesTests/IntegrationTests.cs index 63858bed..3b209e3a 100644 --- a/code/Binary.SourceGeneration.CollectionTests/SupportedTypesTests/IntegrationTests.cs +++ b/code/Binary.SourceGeneration.CollectionTests/SupportedTypesTests/IntegrationTests.cs @@ -74,8 +74,8 @@ public static IEnumerable EnumerableTypesData() yield return new object[] { new Dictionary { { 7, "8" } }, new KeyValuePair(7, "8"), "SequenceConverter`1.*Dictionary`2.*Int32.*String" }; yield return new object[] { ImmutableArray.Create(1), 1, "SpanLikeConverter`1.*ImmutableArray`1.*Int32" }; yield return new object[] { ImmutableArray.Create("2"), "2", "SpanLikeConverter`1.*ImmutableArray`1.*String" }; - yield return new object[] { new LinkedList(new[] { 3 }), 3, "LinkedListConverter`1.*Int32" }; - yield return new object[] { new LinkedList(new[] { "4" }), "4", "LinkedListConverter`1.*String" }; + yield return new object[] { new LinkedList([3]), 3, "LinkedListConverter`1.*Int32" }; + yield return new object[] { new LinkedList(["4"]), "4", "LinkedListConverter`1.*String" }; } public static IEnumerable ImmutableCollectionTypesData() diff --git a/code/Binary.SourceGeneration.NamedObjectTests/PlainObjectTests/MixedMembersTests.cs b/code/Binary.SourceGeneration.NamedObjectTests/PlainObjectTests/MixedMembersTests.cs index e5dccb44..ec733847 100644 --- a/code/Binary.SourceGeneration.NamedObjectTests/PlainObjectTests/MixedMembersTests.cs +++ b/code/Binary.SourceGeneration.NamedObjectTests/PlainObjectTests/MixedMembersTests.cs @@ -84,7 +84,7 @@ public void PlainObjectEncodeDecodeTest() var bufferSecond = converterSecond.Encode(source); var token = new Token(generator, buffer); var tokenSecond = new Token(generatorSecond, bufferSecond); - var keys = new HashSet(new[] { "PublicInstanceField", "PublicInstanceProperty" }); + var keys = new HashSet(["PublicInstanceField", "PublicInstanceProperty"]); Assert.Equal(keys, token.Children.Keys.ToHashSet()); Assert.Equal(keys, tokenSecond.Children.Keys.ToHashSet()); diff --git a/code/Binary.SourceGeneration.Tests/CompilationModule.cs b/code/Binary.SourceGeneration.Tests/CompilationModule.cs index e702564f..a107ec10 100644 --- a/code/Binary.SourceGeneration.Tests/CompilationModule.cs +++ b/code/Binary.SourceGeneration.Tests/CompilationModule.cs @@ -34,8 +34,8 @@ public static Compilation CreateCompilation(string source, ImmutableArray x.Severity is DiagnosticSeverity.Error)); diff --git a/code/Binary.SourceGeneration.Tests/DependenciesTests/MissingDependenciesTests.cs b/code/Binary.SourceGeneration.Tests/DependenciesTests/MissingDependenciesTests.cs index 66d8836f..c880f198 100644 --- a/code/Binary.SourceGeneration.Tests/DependenciesTests/MissingDependenciesTests.cs +++ b/code/Binary.SourceGeneration.Tests/DependenciesTests/MissingDependenciesTests.cs @@ -52,7 +52,7 @@ public class Plain MetadataReference.CreateFromFile(Assembly.Load(new AssemblyName("System.Runtime")).Location), ]); var generator = new SourceGenerator(); - var driver = CSharpGeneratorDriver.Create(generators: new[] { generator.AsSourceGenerator() }, parseOptions: CompilationModule.ParseOptions); + var driver = CSharpGeneratorDriver.Create(generators: [generator.AsSourceGenerator()], parseOptions: CompilationModule.ParseOptions); _ = driver.RunGeneratorsAndUpdateCompilation(compilation, out var outputCompilation, out var outputDiagnostics); var diagnostics = compilation.GetDiagnostics(); var outputCompilationDiagnostics = outputCompilation.GetDiagnostics(); diff --git a/code/Binary.SourceGeneration.Tests/DiagnosticErrorTypeTests/CompilationTests.cs b/code/Binary.SourceGeneration.Tests/DiagnosticErrorTypeTests/CompilationTests.cs index 3a3db5ae..03c39d88 100644 --- a/code/Binary.SourceGeneration.Tests/DiagnosticErrorTypeTests/CompilationTests.cs +++ b/code/Binary.SourceGeneration.Tests/DiagnosticErrorTypeTests/CompilationTests.cs @@ -99,14 +99,14 @@ public void IncludeErrorTypeTest(string source, string diagnosticId) const string AssemblyName = "TestAssembly"; var compilation = CSharpCompilation.Create( AssemblyName, - syntaxTrees: new[] { CSharpSyntaxTree.ParseText(source, CompilationModule.ParseOptions) }, + syntaxTrees: [CSharpSyntaxTree.ParseText(source, CompilationModule.ParseOptions)], references: builder.ToArray(), options: new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary, allowUnsafe: true)); var originDiagnostics = compilation.GetDiagnostics(); Assert.Equal(diagnosticId, Assert.Single(originDiagnostics.Where(x => x.Severity is DiagnosticSeverity.Error)).Id); var generator = new SourceGenerator(); - var driver = CSharpGeneratorDriver.Create(generators: new[] { generator.AsSourceGenerator() }, parseOptions: CompilationModule.ParseOptions); + var driver = CSharpGeneratorDriver.Create(generators: [generator.AsSourceGenerator()], parseOptions: CompilationModule.ParseOptions); _ = driver.RunGeneratorsAndUpdateCompilation(compilation, out var outputCompilation, out var outputDiagnostics); var outputCompilationDiagnostics = outputCompilation.GetDiagnostics(); Assert.Equal(diagnosticId, Assert.Single(outputCompilationDiagnostics.Where(x => x.Severity is DiagnosticSeverity.Error)).Id); diff --git a/code/Binary.SourceGeneration.Tests/DirectContextTests/InlineArrayContextTests.cs b/code/Binary.SourceGeneration.Tests/DirectContextTests/InlineArrayContextTests.cs index b0fbfb9f..de843dc0 100644 --- a/code/Binary.SourceGeneration.Tests/DirectContextTests/InlineArrayContextTests.cs +++ b/code/Binary.SourceGeneration.Tests/DirectContextTests/InlineArrayContextTests.cs @@ -86,10 +86,10 @@ public void InvalidInlineArrayTest(string source) }; var compilation = CSharpCompilation.Create( "TestAssembly", - syntaxTrees: new[] { CSharpSyntaxTree.ParseText(source, CompilationModule.ParseOptions) }, - references: references.ToArray(), + syntaxTrees: [CSharpSyntaxTree.ParseText(source, CompilationModule.ParseOptions)], + references: [.. references], options: new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary, allowUnsafe: true)); - var driver = CSharpGeneratorDriver.Create(generators: new ISourceGenerator[] { new SourceGenerator().AsSourceGenerator() }, parseOptions: CompilationModule.ParseOptions); + var driver = CSharpGeneratorDriver.Create(generators: [new SourceGenerator().AsSourceGenerator()], parseOptions: CompilationModule.ParseOptions); _ = driver.RunGeneratorsAndUpdateCompilation(compilation, out var outputCompilation, out var outputDiagnostics); var diagnostic = Assert.Single(outputDiagnostics); var outputCompilationDiagnostics = outputCompilation.GetDiagnostics(); diff --git a/code/Binary.SourceGeneration.TupleObjectTests/SystemTupleTypes/NamedTupleTests.cs b/code/Binary.SourceGeneration.TupleObjectTests/SystemTupleTypes/NamedTupleTests.cs index 79dda6cd..fe862115 100644 --- a/code/Binary.SourceGeneration.TupleObjectTests/SystemTupleTypes/NamedTupleTests.cs +++ b/code/Binary.SourceGeneration.TupleObjectTests/SystemTupleTypes/NamedTupleTests.cs @@ -22,7 +22,7 @@ public class NamedTupleTests public void NamedTupleTest() { var dictionary = NamedTupleSourceGeneratorContext.ConverterCreators; - var expectedTypes = new HashSet(new[] { typeof((int, string)), typeof(TypeWithNamedTuple) }); + var expectedTypes = new HashSet([typeof((int, string)), typeof(TypeWithNamedTuple)]); Assert.Equal(expectedTypes, dictionary.Keys.ToHashSet()); var generator = Generator.CreateAotBuilder().AddConverterCreators(dictionary.Values).Build(); diff --git a/code/Binary.Tests/ArgumentTests.cs b/code/Binary.Tests/ArgumentTests.cs index 3d89715c..cb2280ac 100644 --- a/code/Binary.Tests/ArgumentTests.cs +++ b/code/Binary.Tests/ArgumentTests.cs @@ -26,7 +26,7 @@ private static IEnumerable ArgumentNullUnsafeTest(M { var func = (Func)Delegate.CreateDelegate(typeof(Func), method); var a = Assert.Throws(() => func.Invoke(null!)); - return new[] { a }; + return [a]; } private static IEnumerable ArgumentNullUnsafeTest(MethodInfo method) where T : class where U : class @@ -39,7 +39,7 @@ private static IEnumerable ArgumentNullUnsafeTest(ref instance); var a = Assert.Throws(() => func.Invoke(null!, u)); var b = Assert.Throws(() => func.Invoke(t, null!)); - return new[] { a, b }; + return [a, b]; } private static IEnumerable ArgumentNullUnsafeTest(MethodInfo method) where T : class where U : class where S : class @@ -55,13 +55,13 @@ private static IEnumerable ArgumentNullUnsafeTest(() => func.Invoke(null!, u, s)); var b = Assert.Throws(() => func.Invoke(t, null!, s)); var c = Assert.Throws(() => func.Invoke(t, u, null!)); - return new[] { a, b, c }; + return [a, b, c]; } public static void ArgumentNullExceptionTest(MethodInfo method) { var parameters = method.GetParameters(); - var types = parameters.Select(x => x.ParameterType).Concat(new[] { method.ReturnType }).ToArray(); + var types = parameters.Select(x => x.ParameterType).Concat([method.ReturnType]).ToArray(); var test = ArgumentNullTestMethods[parameters.Length - 1].MakeGenericMethod(types); var errors = Assert.IsAssignableFrom>(test.Invoke(null, [method])); var expectedParameterNames = parameters.Select(x => x.Name).ToList(); diff --git a/code/Binary.Tests/Components/NamedObjectConverterTests.cs b/code/Binary.Tests/Components/NamedObjectConverterTests.cs index 7e03180b..aae512c3 100644 --- a/code/Binary.Tests/Components/NamedObjectConverterTests.cs +++ b/code/Binary.Tests/Components/NamedObjectConverterTests.cs @@ -39,8 +39,8 @@ public void ArgumentCollectionEmptyTest() { var generator = Generator.CreateAot(); var b = generator.GetConverter(); - var h = Assert.Throws(() => new FakeNamedObjectConverter(b, Array.Empty(), new[] { false })); - var i = Assert.Throws(() => new FakeNamedObjectConverter(b, new[] { string.Empty }, Array.Empty())); + var h = Assert.Throws(() => new FakeNamedObjectConverter(b, [], [false])); + var i = Assert.Throws(() => new FakeNamedObjectConverter(b, [string.Empty], [])); Assert.Null(h.ParamName); Assert.Null(i.ParamName); Assert.Equal($"Sequence contains no element.", h.Message); @@ -52,7 +52,7 @@ public void ArgumentCollectionLengthsNotMatch() { var generator = Generator.CreateAot(); var b = generator.GetConverter(); - var h = Assert.Throws(() => new FakeNamedObjectConverter(b, new[] { string.Empty }, new[] { false, true })); + var h = Assert.Throws(() => new FakeNamedObjectConverter(b, [string.Empty], [false, true])); Assert.Null(h.ParamName); Assert.Equal($"Sequence lengths not match.", h.Message); } diff --git a/code/Binary.Tests/Components/TupleObjectTests.cs b/code/Binary.Tests/Components/TupleObjectTests.cs index e561306d..c7419056 100644 --- a/code/Binary.Tests/Components/TupleObjectTests.cs +++ b/code/Binary.Tests/Components/TupleObjectTests.cs @@ -56,7 +56,7 @@ public void OverflowTest() public void SequenceNullTest() { var methodInfo = new Func, int>(TupleObject.GetConverterLength).Method; - var error = Assert.Throws(() => TupleObject.GetConverterLength(new IConverter[] { null! })); + var error = Assert.Throws(() => TupleObject.GetConverterLength([null!])); var parameters = methodInfo.GetParameters(); Assert.Equal(parameters[0].Name, error.ParamName); Assert.StartsWith("Sequence contains null or invalid element.", error.Message); @@ -66,7 +66,7 @@ public void SequenceNullTest() public void SequenceInvalidTest() { var methodInfo = new Func, int>(TupleObject.GetConverterLength).Method; - var error = Assert.Throws(() => TupleObject.GetConverterLength(new IConverter[] { new HideConverter() })); + var error = Assert.Throws(() => TupleObject.GetConverterLength([new HideConverter()])); var parameters = methodInfo.GetParameters(); Assert.Equal(parameters[0].Name, error.ParamName); Assert.StartsWith("Sequence contains null or invalid element.", error.Message); @@ -76,7 +76,7 @@ public void SequenceInvalidTest() public void SequenceEmptyTest() { var methodInfo = new Func, int>(TupleObject.GetConverterLength).Method; - var error = Assert.Throws(() => TupleObject.GetConverterLength(Array.Empty())); + var error = Assert.Throws(() => TupleObject.GetConverterLength([])); var parameters = methodInfo.GetParameters(); Assert.Equal(parameters[0].Name, error.ParamName); Assert.StartsWith("Sequence contains no element.", error.Message); diff --git a/code/Binary.Tests/Contexts/GeneratorAotTests.cs b/code/Binary.Tests/Contexts/GeneratorAotTests.cs index 12090637..7f277397 100644 --- a/code/Binary.Tests/Contexts/GeneratorAotTests.cs +++ b/code/Binary.Tests/Contexts/GeneratorAotTests.cs @@ -84,7 +84,7 @@ public void GetEnumConverterTest(T source) where T : unmanaged public void GetEnumConverterInternalTest(T source) where T : unmanaged { var method = typeof(Generator).GetMethods(BindingFlags.Static | BindingFlags.NonPublic) - .Single(x => x.Name.Contains("Invoke") && x.GetParameters().Select(x => x.ParameterType).SequenceEqual(new[] { typeof(bool) })); + .Single(x => x.Name.Contains("Invoke") && x.GetParameters().Select(x => x.ParameterType).SequenceEqual([typeof(bool)])); var invoke = (Func>)Delegate.CreateDelegate(typeof(Func>), method.MakeGenericMethod(typeof(T))); var converterNative = invoke.Invoke(true); diff --git a/code/Binary.Tests/Contexts/GeneratorBuilderExtensionsTests.cs b/code/Binary.Tests/Contexts/GeneratorBuilderExtensionsTests.cs index 010bac80..a5e3d96b 100644 --- a/code/Binary.Tests/Contexts/GeneratorBuilderExtensionsTests.cs +++ b/code/Binary.Tests/Contexts/GeneratorBuilderExtensionsTests.cs @@ -2,7 +2,6 @@ using System; using System.Collections.Generic; -using System.Linq; using Xunit; public class GeneratorBuilderExtensionsTests @@ -85,7 +84,7 @@ public void AddConvertersWithEmptyCollection() { var builder = new FakeLinkedListGeneratorBuilder(); Assert.Equal(0, builder.Id); - var returned = Assert.IsType(builder.AddConverters(Enumerable.Empty())); + var returned = Assert.IsType(builder.AddConverters([])); Assert.Equal(0, builder.Id); Assert.True(ReferenceEquals(builder, returned)); } @@ -117,7 +116,7 @@ public void AddConverterCreatorsWithEmptyCollection() { var builder = new FakeLinkedListGeneratorBuilder(); Assert.Equal(0, builder.Id); - var returned = Assert.IsType(builder.AddConverterCreators(Enumerable.Empty())); + var returned = Assert.IsType(builder.AddConverterCreators([])); Assert.Equal(0, builder.Id); Assert.True(ReferenceEquals(builder, returned)); } @@ -136,7 +135,7 @@ public void AddConverterCreatorsWithLinkedListBuilder() [Fact(DisplayName = "Add Converters (argument null)")] public void AddConvertersArgumentNull() { - var a = Assert.Throws(() => GeneratorBuilderExtensions.AddConverters(null!, Array.Empty())); + var a = Assert.Throws(() => GeneratorBuilderExtensions.AddConverters(null!, [])); var b = Assert.Throws(() => GeneratorBuilderExtensions.AddConverters(new FakeGeneratorBuilder(), null!)); var method = new Func, IGeneratorBuilder>(GeneratorBuilderExtensions.AddConverters).Method; Assert.Equal("builder", a.ParamName); @@ -148,7 +147,7 @@ public void AddConvertersArgumentNull() [Fact(DisplayName = "Add Converter Creators (argument null)")] public void AddConverterCreatorsArgumentNull() { - var a = Assert.Throws(() => GeneratorBuilderExtensions.AddConverterCreators(null!, Array.Empty())); + var a = Assert.Throws(() => GeneratorBuilderExtensions.AddConverterCreators(null!, [])); var b = Assert.Throws(() => GeneratorBuilderExtensions.AddConverterCreators(new FakeGeneratorBuilder(), null!)); var method = new Func, IGeneratorBuilder>(GeneratorBuilderExtensions.AddConverterCreators).Method; Assert.Equal("builder", a.ParamName); diff --git a/code/Binary.Tests/Converters.Constants/DecimalConverterTests.cs b/code/Binary.Tests/Converters.Constants/DecimalConverterTests.cs index 84a75f14..ccddcb50 100644 --- a/code/Binary.Tests/Converters.Constants/DecimalConverterTests.cs +++ b/code/Binary.Tests/Converters.Constants/DecimalConverterTests.cs @@ -17,14 +17,14 @@ public void GetConverter() Assert.Equal(sizeof(int) * 4, converter.Length); } - public static IEnumerable DataNumber => new List - { - new object[] { decimal.MaxValue }, - new object[] { decimal.MinusOne }, - new object[] { decimal.MinValue }, - new object[] { decimal.One }, - new object[] { decimal.Zero }, - }; + public static IEnumerable DataNumber => + [ + [decimal.MaxValue], + [decimal.MinusOne], + [decimal.MinValue], + [decimal.One], + [decimal.Zero], + ]; [Theory(DisplayName = "Encode Decode")] [MemberData(nameof(DataNumber))] diff --git a/code/Binary.Tests/Converters/BigIntegerConverterInternalTests.cs b/code/Binary.Tests/Converters/BigIntegerConverterInternalTests.cs index c2715d2c..ccdde594 100644 --- a/code/Binary.Tests/Converters/BigIntegerConverterInternalTests.cs +++ b/code/Binary.Tests/Converters/BigIntegerConverterInternalTests.cs @@ -8,12 +8,12 @@ public class BigIntegerConverterInternalTests { - public static readonly IEnumerable DataNotEnoughSpace = new List - { - new object?[] { 0, new BigInteger() }, - new object?[] { 1, new BigInteger(1024) }, - new object?[] { 3, new BigInteger(int.MaxValue) }, - }; + public static readonly IEnumerable DataNotEnoughSpace = + [ + [0, new BigInteger()], + [1, new BigInteger(1024)], + [3, new BigInteger(int.MaxValue)], + ]; [Theory(DisplayName = "Not Enough Space For Writing")] [MemberData(nameof(DataNotEnoughSpace))] diff --git a/code/Binary.Tests/Converters/BigIntegerConverterTests.cs b/code/Binary.Tests/Converters/BigIntegerConverterTests.cs index 99e791f0..4a798d96 100644 --- a/code/Binary.Tests/Converters/BigIntegerConverterTests.cs +++ b/code/Binary.Tests/Converters/BigIntegerConverterTests.cs @@ -16,14 +16,14 @@ public void GetConverter() Assert.Equal(0, converter.Length); } - public static IEnumerable DataNumber => new List - { - new object[] { new BigInteger() }, - new object[] { new BigInteger(long.MaxValue) }, - new object[] { new BigInteger(long.MinValue) }, - new object[] { BigInteger.Parse("91389681247993671255432112000000") }, - new object[] { BigInteger.Parse("-90315837410896312071002088037140000") }, - }; + public static IEnumerable DataNumber => + [ + [new BigInteger()], + [new BigInteger(long.MaxValue)], + [new BigInteger(long.MinValue)], + [BigInteger.Parse("91389681247993671255432112000000")], + [BigInteger.Parse("-90315837410896312071002088037140000")], + ]; [Theory(DisplayName = "Encode Decode")] [MemberData(nameof(DataNumber))] diff --git a/code/Binary.Tests/Converters/IPAddressConverterInternalTests.cs b/code/Binary.Tests/Converters/IPAddressConverterInternalTests.cs index b699a197..d913ab24 100644 --- a/code/Binary.Tests/Converters/IPAddressConverterInternalTests.cs +++ b/code/Binary.Tests/Converters/IPAddressConverterInternalTests.cs @@ -8,11 +8,11 @@ public class IPAddressConverterInternalTests { - public static readonly IEnumerable DataNotEnoughSpace = new List - { - new object?[] { 3, IPAddress.Loopback }, - new object?[] { 15, IPAddress.IPv6Loopback }, - }; + public static readonly IEnumerable DataNotEnoughSpace = + [ + [3, IPAddress.Loopback], + [15, IPAddress.IPv6Loopback], + ]; [Theory(DisplayName = "Not Enough Space For Writing")] [MemberData(nameof(DataNotEnoughSpace))] diff --git a/code/Binary.Tests/Converters/IPEndPointConverterInternalTests.cs b/code/Binary.Tests/Converters/IPEndPointConverterInternalTests.cs index 3a5b661b..078e8fbf 100644 --- a/code/Binary.Tests/Converters/IPEndPointConverterInternalTests.cs +++ b/code/Binary.Tests/Converters/IPEndPointConverterInternalTests.cs @@ -8,13 +8,13 @@ public class IPEndPointConverterInternalTests { - public static readonly IEnumerable DataNotEnoughSpace = new List - { - new object?[] { 5, new IPEndPoint(IPAddress.Loopback, IPEndPoint.MaxPort) }, - new object?[] { 17, new IPEndPoint(IPAddress.IPv6Loopback, IPEndPoint.MaxPort) }, - new object?[] { 5, new IPEndPoint(IPAddress.Any, IPEndPoint.MinPort) }, - new object?[] { 17, new IPEndPoint(IPAddress.IPv6Any, IPEndPoint.MinPort) }, - }; + public static readonly IEnumerable DataNotEnoughSpace = + [ + [5, new IPEndPoint(IPAddress.Loopback, IPEndPoint.MaxPort)], + [17, new IPEndPoint(IPAddress.IPv6Loopback, IPEndPoint.MaxPort)], + [5, new IPEndPoint(IPAddress.Any, IPEndPoint.MinPort)], + [17, new IPEndPoint(IPAddress.IPv6Any, IPEndPoint.MinPort)], + ]; [Theory(DisplayName = "Not Enough Space For Writing")] [MemberData(nameof(DataNotEnoughSpace))] diff --git a/code/Binary.Tests/Converters/VersionConverterInternalTests.cs b/code/Binary.Tests/Converters/VersionConverterInternalTests.cs index b01d38aa..234d29cb 100644 --- a/code/Binary.Tests/Converters/VersionConverterInternalTests.cs +++ b/code/Binary.Tests/Converters/VersionConverterInternalTests.cs @@ -7,15 +7,15 @@ public class VersionConverterInternalTests { - public static readonly IEnumerable DataNotEnoughSpace = new List - { - new object?[] { 0, null }, - new object?[] { 15, null }, - new object?[] { 0, new Version() }, - new object?[] { 11, new Version(1, 3) }, - new object?[] { 13, new Version(1, 2, 3) }, - new object?[] { 15, new Version(2, 4, 8, 16) }, - }; + public static readonly IEnumerable DataNotEnoughSpace = + [ + [0, null], + [15, null], + [0, new Version()], + [11, new Version(1, 3)], + [13, new Version(1, 2, 3)], + [15, new Version(2, 4, 8, 16)], + ]; [Theory(DisplayName = "Not Enough Space For Writing")] [MemberData(nameof(DataNotEnoughSpace))] diff --git a/code/Binary.Tests/Converters/VersionConverterTests.cs b/code/Binary.Tests/Converters/VersionConverterTests.cs index 53cfa116..26508a29 100644 --- a/code/Binary.Tests/Converters/VersionConverterTests.cs +++ b/code/Binary.Tests/Converters/VersionConverterTests.cs @@ -16,14 +16,14 @@ public void BasicInfo() Assert.Equal(0, converter.Length); } - public static readonly IEnumerable DataVersion = new List - { - new object?[] { 0, null }, - new object?[] { 8, new Version() }, - new object?[] { 8, new Version(2, 4) }, - new object?[] { 12, new Version(2, 4, 8) }, - new object?[] { 16, new Version(2, 4, 8, 16) }, - }; + public static readonly IEnumerable DataVersion = + [ + [0, null], + [8, new Version()], + [8, new Version(2, 4)], + [12, new Version(2, 4, 8)], + [16, new Version(2, 4, 8, 16)], + ]; [Theory(DisplayName = "Encode Decode")] [MemberData(nameof(DataVersion))] diff --git a/code/Binary.Tests/Creators/NullableConverterTests.cs b/code/Binary.Tests/Creators/NullableConverterTests.cs index f5239c62..7329e1aa 100644 --- a/code/Binary.Tests/Creators/NullableConverterTests.cs +++ b/code/Binary.Tests/Creators/NullableConverterTests.cs @@ -85,12 +85,12 @@ public unsafe void ItemAuto(T value) where T : unmanaged Assert.Equal(value, ra); } - public static readonly IEnumerable CollectionData = new[] - { - new object[] { new byte?[] { 2, 4, null, 8, null } }, + public static readonly IEnumerable CollectionData = + [ + [new byte?[] { 2, 4, null, 8, null }], [new List { null, 2.71F, null }], [new HashSet { 3.14, null, 1.41 }] - }; + ]; internal unsafe void CollectionFunction(TCollection collection) where T : unmanaged where TCollection : IEnumerable { @@ -120,11 +120,11 @@ public void Collection(TCollection collection) where TCollection : _ = method.Invoke(this, [collection]); } - public static readonly IEnumerable DictionaryData = new[] - { - new object[] { new Dictionary { [0] = null, [1] = 1.1, [-2] = 2.2 } }, + public static readonly IEnumerable DictionaryData = + [ + [new Dictionary { [0] = null, [1] = 1.1, [-2] = 2.2 }], [new Dictionary { [0] = null, [-3.3F] = 6L, [4.4F] = 8 }], - }; + ]; [Theory(DisplayName = "Nullable Dictionary")] [MemberData(nameof(DictionaryData))] @@ -195,13 +195,13 @@ public void VariableCollection() Assert.Equal(source, result); } - public static readonly IEnumerable OptionData = new[] - { - new object[] { 10 }, + public static readonly IEnumerable OptionData = + [ + [10], [long.MaxValue], [(-1536, "Inner text")], [("Value tuple", Guid.NewGuid())], - }; + ]; [Theory(DisplayName = "Nullable With F# Option")] [MemberData(nameof(OptionData))] diff --git a/code/Binary.Tests/Creators/UriConverterTests.cs b/code/Binary.Tests/Creators/UriConverterTests.cs index 5772c876..484ad99f 100644 --- a/code/Binary.Tests/Creators/UriConverterTests.cs +++ b/code/Binary.Tests/Creators/UriConverterTests.cs @@ -7,13 +7,13 @@ public partial class UriConverterTests { - public static readonly IEnumerable NormalData = new[] - { - new object[] { Encoding.UTF8, new Uri("https://github.com") }, + public static readonly IEnumerable NormalData = + [ + [Encoding.UTF8, new Uri("https://github.com")], [Encoding.UTF8, new Uri("https://github.com/dotnet/")], [Encoding.UTF32, new Uri("https://github.com")], [Encoding.UTF32, new Uri("https://github.com/dotnet/")], - }; + ]; [Theory(DisplayName = "Base Methods")] [MemberData(nameof(NormalData))] diff --git a/code/Binary.Tests/Features/CollectionTests.cs b/code/Binary.Tests/Features/CollectionTests.cs index c807beb6..256942ec 100644 --- a/code/Binary.Tests/Features/CollectionTests.cs +++ b/code/Binary.Tests/Features/CollectionTests.cs @@ -50,16 +50,16 @@ public void NativeTypeArrayImplementation(T data) } } - public static IEnumerable SimpleObjectData => new List - { - new object[] { DateOnly.Parse("2001-02-03") }, - new object[] { DateTimeOffset.Parse("2020-02-02T11:22:33+04:00") }, - new object[] { DateTime.Parse("2001-02-03T04:05:06") }, - new object[] { Guid.Parse("f28a5581-c80d-4d66-84cf-790d48e877d1") }, - new object[] { (Rune)'#' }, - new object[] { TimeOnly.Parse("12:34:56") }, - new object[] { TimeSpan.Parse("01:23:45.6789") }, - }; + public static IEnumerable SimpleObjectData => + [ + [DateOnly.Parse("2001-02-03")], + [DateTimeOffset.Parse("2020-02-02T11:22:33+04:00")], + [DateTime.Parse("2001-02-03T04:05:06")], + [Guid.Parse("f28a5581-c80d-4d66-84cf-790d48e877d1")], + [(Rune)'#'], + [TimeOnly.Parse("12:34:56")], + [TimeSpan.Parse("01:23:45.6789")], + ]; [Theory(DisplayName = "Common Type Array Implementation")] [MemberData(nameof(SimpleObjectData))] diff --git a/code/Binary.Tests/Features/EndiannessTests.cs b/code/Binary.Tests/Features/EndiannessTests.cs index f25ce66c..54e3ddc8 100644 --- a/code/Binary.Tests/Features/EndiannessTests.cs +++ b/code/Binary.Tests/Features/EndiannessTests.cs @@ -28,30 +28,30 @@ public struct Block32 { } [StructLayout(LayoutKind.Explicit, Size = 64)] public struct Block64 { } - public static IEnumerable EnumData => new List - { - new object[] { 4, (Enum32)0 }, - new object[] { 8, (Enum64)long.MinValue }, - new object[] { 4, (EnumU32)uint.MaxValue }, - new object[] { 8, (EnumU64)ulong.MaxValue }, - }; - - public static IEnumerable NumberData => new List - { - new object[] { 1, (byte)1 }, - new object[] { 1, (sbyte)-1 }, - new object[] { 2, (short)-3 }, - new object[] { 2, (ushort)5 }, - new object[] { 2, Half.MinValue }, - new object[] { 2, Half.MaxValue }, - new object[] { 2, Half.NaN }, - new object[] { 4, 0 }, - new object[] { 8, 0L }, - new object[] { 4, 0U }, - new object[] { 8, 0UL }, - new object[] { 4, 2.0F }, - new object[] { 8, 3.0 }, - }; + public static IEnumerable EnumData => + [ + [4, (Enum32)0], + [8, (Enum64)long.MinValue], + [4, (EnumU32)uint.MaxValue], + [8, (EnumU64)ulong.MaxValue], + ]; + + public static IEnumerable NumberData => + [ + [1, (byte)1], + [1, (sbyte)-1], + [2, (short)-3], + [2, (ushort)5], + [2, Half.MinValue], + [2, Half.MaxValue], + [2, Half.NaN], + [4, 0], + [8, 0L], + [4, 0U], + [8, 0UL], + [4, 2.0F], + [8, 3.0], + ]; [Theory(DisplayName = "Fallback Converter Info")] [MemberData(nameof(EnumData))] @@ -104,11 +104,11 @@ public void InternalLittleEndianConverterInfo(int length, T data) Assert.Equal(data, result); } - public static IEnumerable InvalidBlockData => new List - { - new object[] { 32, default(Block32) }, - new object[] { 64, default(Block64) }, - }; + public static IEnumerable InvalidBlockData => + [ + [32, default(Block32)], + [64, default(Block64)], + ]; [Theory(DisplayName = "Internal Little Endian Converter Invalid Type")] [MemberData(nameof(InvalidBlockData))] diff --git a/code/Binary.Tests/Features/IntegrationTests.cs b/code/Binary.Tests/Features/IntegrationTests.cs index 8ad07474..5a352755 100644 --- a/code/Binary.Tests/Features/IntegrationTests.cs +++ b/code/Binary.Tests/Features/IntegrationTests.cs @@ -7,17 +7,17 @@ public class IntegrationTests { - public static IEnumerable SimpleObjectData => new List - { - new object[] { 0x04, DateOnly.Parse("2001-02-03") }, - new object[] { 0x0A, DateTimeOffset.Parse("2020-02-02T11:22:33+04:00") }, - new object[] { 0x08, DateTime.Parse("2001-02-03T04:05:06") }, - new object[] { 0x10, decimal.Parse("2.71828") }, - new object[] { 0x10, Guid.Parse("f28a5581-c80d-4d66-84cf-790d48e877d1") }, - new object[] { 0x04, (Rune)'#' }, - new object[] { 0x08, TimeOnly.Parse("12:34:56") }, - new object[] { 0x08, TimeSpan.Parse("01:23:45.6789") }, - }; + public static IEnumerable SimpleObjectData => + [ + [0x04, DateOnly.Parse("2001-02-03")], + [0x0A, DateTimeOffset.Parse("2020-02-02T11:22:33+04:00")], + [0x08, DateTime.Parse("2001-02-03T04:05:06")], + [0x10, decimal.Parse("2.71828")], + [0x10, Guid.Parse("f28a5581-c80d-4d66-84cf-790d48e877d1")], + [0x04, (Rune)'#'], + [0x08, TimeOnly.Parse("12:34:56")], + [0x08, TimeSpan.Parse("01:23:45.6789")], + ]; [Theory(DisplayName = "Converter Info")] [MemberData(nameof(SimpleObjectData))] @@ -33,70 +33,70 @@ public void ConverterBasicInfo(int length, object data) Assert.Equal(data, result); } - public static IEnumerable NumberData => new List - { - new object[] { 0 }, - new object[] { int.MaxValue }, - new object[] { int.MinValue }, - new object[] { double.MaxValue }, - new object[] { double.MinValue }, - new object[] { double.NaN }, - new object[] { double.PositiveInfinity }, - new object[] { double.NegativeInfinity }, - }; + public static IEnumerable NumberData => + [ + [0], + [int.MaxValue], + [int.MinValue], + [double.MaxValue], + [double.MinValue], + [double.NaN], + [double.PositiveInfinity], + [double.NegativeInfinity], + ]; - public static IEnumerable DateOnlyData => new List - { - new object[] { DateOnly.MinValue }, - new object[] { DateOnly.MaxValue }, - new object[] { DateOnly.Parse("2000-01-01") }, - }; + public static IEnumerable DateOnlyData => + [ + [DateOnly.MinValue], + [DateOnly.MaxValue], + [DateOnly.Parse("2000-01-01")], + ]; - public static IEnumerable DateTimeOffsetData => new List - { - new object[] { DateTimeOffset.MinValue }, - new object[] { DateTimeOffset.MaxValue }, - new object[] { DateTimeOffset.UnixEpoch }, - new object[] { DateTimeOffset.Parse("2000-01-01T11:22:33+14:00") }, - new object[] { DateTimeOffset.Parse("2000-01-01T11:22:33-14:00") }, - }; + public static IEnumerable DateTimeOffsetData => + [ + [DateTimeOffset.MinValue], + [DateTimeOffset.MaxValue], + [DateTimeOffset.UnixEpoch], + [DateTimeOffset.Parse("2000-01-01T11:22:33+14:00")], + [DateTimeOffset.Parse("2000-01-01T11:22:33-14:00")], + ]; - public static IEnumerable DateTimeData => new List - { - new object[] { DateTime.MinValue }, - new object[] { DateTime.MaxValue }, - new object[] { DateTime.UnixEpoch }, - new object[] { DateTime.Parse("2000-01-01T11:22:33") }, - new object[] { DateTime.Parse("2000-01-01T23:12:01") }, - }; + public static IEnumerable DateTimeData => + [ + [DateTime.MinValue], + [DateTime.MaxValue], + [DateTime.UnixEpoch], + [DateTime.Parse("2000-01-01T11:22:33")], + [DateTime.Parse("2000-01-01T23:12:01")], + ]; - public static IEnumerable GuidData => new List - { - new object[] { Guid.Empty }, - new object[] { Guid.Parse("9b4bc529-e00d-4304-92e7-4366e0839078") }, - new object[] { Guid.Parse("600c8464-8279-4613-9b1a-dc048e250cc9") }, - }; + public static IEnumerable GuidData => + [ + [Guid.Empty], + [Guid.Parse("9b4bc529-e00d-4304-92e7-4366e0839078")], + [Guid.Parse("600c8464-8279-4613-9b1a-dc048e250cc9")], + ]; - public static IEnumerable RuneData => new List - { - new object[] { Rune.ReplacementChar }, - new object[] { (Rune)'A' }, - new object[] { (Rune)'一' }, - }; + public static IEnumerable RuneData => + [ + [Rune.ReplacementChar], + [(Rune)'A'], + [(Rune)'一'], + ]; - public static IEnumerable TimeOnlyData => new List - { - new object[] { TimeOnly.MaxValue }, - new object[] { TimeOnly.MinValue }, - new object[] { TimeOnly.Parse("20:48:00") }, - }; + public static IEnumerable TimeOnlyData => + [ + [TimeOnly.MaxValue], + [TimeOnly.MinValue], + [TimeOnly.Parse("20:48:00")], + ]; - public static IEnumerable TimeSpanData => new List - { - new object[] { TimeSpan.MaxValue }, - new object[] { TimeSpan.MinValue }, - new object[] { TimeSpan.Parse("22:10:24.4096") }, - }; + public static IEnumerable TimeSpanData => + [ + [TimeSpan.MaxValue], + [TimeSpan.MinValue], + [TimeSpan.Parse("22:10:24.4096")], + ]; [Theory(DisplayName = "Encode Decode")] [MemberData(nameof(NumberData))] diff --git a/code/Binary.Tests/Features/LargeIntegerTests.cs b/code/Binary.Tests/Features/LargeIntegerTests.cs index d59ed2fc..2e2ef56c 100644 --- a/code/Binary.Tests/Features/LargeIntegerTests.cs +++ b/code/Binary.Tests/Features/LargeIntegerTests.cs @@ -34,16 +34,16 @@ private static void BinaryIntegerBasicTest(int size, T item, Converter con Assert.Equal(expectedBuffer, buffer); } - public static IEnumerable Int128Data => new List - { - new object[] { 16, default(Int128) }, - new object[] { 16, Int128.MinValue }, - new object[] { 16, Int128.MaxValue }, - new object[] { 16, Int128.Zero }, - new object[] { 16, Int128.One }, - new object[] { 16, Int128.NegativeOne }, - new object[] { 16, Int128.Parse("11223344_55667788_99AABBCC_DDEEFF00".Replace("_", string.Empty), NumberStyles.HexNumber) }, - }; + public static IEnumerable Int128Data => + [ + [16, default(Int128)], + [16, Int128.MinValue], + [16, Int128.MaxValue], + [16, Int128.Zero], + [16, Int128.One], + [16, Int128.NegativeOne], + [16, Int128.Parse("11223344_55667788_99AABBCC_DDEEFF00".Replace("_", string.Empty), NumberStyles.HexNumber)], + ]; [Theory(DisplayName = "Int128 Converter Basic Info")] [MemberData(nameof(Int128Data))] @@ -57,15 +57,15 @@ public void Int128EncodeDecode(int size, Int128 item) BinaryIntegerBasicTest(size, item, little, "LittleEndianConverter`1"); } - public static IEnumerable UInt128Data => new List - { - new object[] { 16, default(UInt128) }, - new object[] { 16, UInt128.MinValue }, - new object[] { 16, UInt128.MaxValue }, - new object[] { 16, UInt128.Zero }, - new object[] { 16, UInt128.One }, - new object[] { 16, UInt128.Parse("11223344_55667788_99AABBCC_DDEEFF00".Replace("_", string.Empty), NumberStyles.HexNumber) }, - }; + public static IEnumerable UInt128Data => + [ + [16, default(UInt128)], + [16, UInt128.MinValue], + [16, UInt128.MaxValue], + [16, UInt128.Zero], + [16, UInt128.One], + [16, UInt128.Parse("11223344_55667788_99AABBCC_DDEEFF00".Replace("_", string.Empty), NumberStyles.HexNumber)], + ]; [Theory(DisplayName = "UInt128 Converter Basic Info")] [MemberData(nameof(UInt128Data))] diff --git a/code/Binary.Tests/Implementations/FieldTests.cs b/code/Binary.Tests/Implementations/FieldTests.cs index 03d0df39..3402b10f 100644 --- a/code/Binary.Tests/Implementations/FieldTests.cs +++ b/code/Binary.Tests/Implementations/FieldTests.cs @@ -106,7 +106,7 @@ public void ReadOnlyFieldPrivateConstructorTest() var source = ReadOnlyFieldPrivateConstructorType.Create(1333); var buffer = converter.Encode(source); var token = new Token(generator, buffer); - Assert.Equal(new string[] { "Field" }, token.Children.Keys); + Assert.Equal(["Field"], token.Children.Keys); Assert.Equal(source.Field, token["Field"].As()); var error = Assert.Throws(() => converter.Decode(buffer)); var message = $"No suitable constructor found, type: {typeof(ReadOnlyFieldPrivateConstructorType)}"; diff --git a/code/Binary.Tests/Instance/DynamicTests.cs b/code/Binary.Tests/Instance/DynamicTests.cs index 5c4b06a9..dd3d3930 100644 --- a/code/Binary.Tests/Instance/DynamicTests.cs +++ b/code/Binary.Tests/Instance/DynamicTests.cs @@ -170,7 +170,7 @@ public void DynamicKeysNullValue() var type = types.Single(x => x.Name is "MetaObject"); var instance = Assert.IsAssignableFrom(Activator.CreateInstance(type, [Expression.Parameter(typeof(Token)), null])); var keys = instance.GetDynamicMemberNames(); - Assert.Equal(Array.Empty(), keys); + Assert.Equal([], keys); Assert.Null(instance.Value); Assert.True(ReferenceEquals(keys, Array.Empty())); } diff --git a/code/Binary.Tests/Instance/RecordTests.cs b/code/Binary.Tests/Instance/RecordTests.cs index 5c54107a..3ecf7fef 100644 --- a/code/Binary.Tests/Instance/RecordTests.cs +++ b/code/Binary.Tests/Instance/RecordTests.cs @@ -9,10 +9,10 @@ record Person(int Id, string Name); record struct ValuePerson(int Id, string Name); - public static readonly IEnumerable DataRecordArguments = new[] - { - new object[] { new Person(1024, "Sharp"), new ValuePerson(1024, "Sharp") }, - }; + public static readonly IEnumerable DataRecordArguments = + [ + [new Person(1024, "Sharp"), new ValuePerson(1024, "Sharp")], + ]; [Theory(DisplayName = "Record And Record Struct Cross Test")] [MemberData(nameof(DataRecordArguments))] diff --git a/code/Binary/Internal.Contexts/ContextMethods.cs b/code/Binary/Internal.Contexts/ContextMethods.cs index 121ff4cc..2e9cff60 100644 --- a/code/Binary/Internal.Contexts/ContextMethods.cs +++ b/code/Binary/Internal.Contexts/ContextMethods.cs @@ -55,7 +55,7 @@ internal static Delegate GetDecodeDelegate(Type delegateType, ContextObjectIniti expressions.Add(Expression.Assign(item, constructor is null ? Expression.New(type) : Expression.New(constructor, objectIndexes.Select(x => targets[x]).ToList()))); expressions.AddRange(memberIndexes.Select((x, i) => Expression.Assign(members[i].Invoke(item), targets[x]))); expressions.Add(item); - var lambda = Expression.Lambda(delegateType, Expression.Block(ImmutableArray.Create(item).AddRange(targets), expressions), parameters); + var lambda = Expression.Lambda(delegateType, Expression.Block([item, .. targets], expressions), parameters); return lambda.Compile(); } } diff --git a/code/Binary/Internal/CommonModule.cs b/code/Binary/Internal/CommonModule.cs index 472df3cd..c8aab4db 100644 --- a/code/Binary/Internal/CommonModule.cs +++ b/code/Binary/Internal/CommonModule.cs @@ -53,7 +53,7 @@ internal static bool TryGetInterfaceArguments([DynamicallyAccessedMembers(Dynami { Debug.Assert(definition.IsInterface); Debug.Assert(definition.IsGenericTypeDefinition); - var interfaces = type.IsInterface ? (IEnumerable)ImmutableArray.Create(type).AddRange(type.GetInterfaces()) : type.GetInterfaces(); + var interfaces = type.IsInterface ? (IEnumerable)[type, .. type.GetInterfaces()] : type.GetInterfaces(); var types = interfaces.Where(x => x.IsGenericType && x.GetGenericTypeDefinition() == definition).ToList(); var count = types.Count; if (count > 1) diff --git a/code/Binary/Token.MetaObject.cs b/code/Binary/Token.MetaObject.cs index 39ef4651..dbf72496 100644 --- a/code/Binary/Token.MetaObject.cs +++ b/code/Binary/Token.MetaObject.cs @@ -30,6 +30,6 @@ public override DynamicMetaObject BindGetMember(GetMemberBinder binder) return new DynamicMetaObject(body, BindingRestrictions.GetTypeRestriction(Expression, LimitType)); } - public override IEnumerable GetDynamicMemberNames() => ((Token?)Value)?.Children.Keys ?? Array.Empty(); + public override IEnumerable GetDynamicMemberNames() => ((Token?)Value)?.Children.Keys ?? []; } }