From dbc67360b497840ebd763e22753da53d29a4ad17 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 27 Jun 2026 12:57:06 +0200 Subject: [PATCH] fix(strawberryshake): preserve entity fields across differing selection sets Strawberry Shake lost data after deserialization when an entity was referenced more than once in a query with different selection sets, including the inline-fragment ordering case in #8063. The JSON result builder filled the entity store recursively: a nested reference wrote the entity first, then the outer reference overwrote it, replacing the fields it had not selected with defaults. The result factory then read those defaulted fields (or hit a non-null constructor) and surfaced the data as missing or as Value cannot be null. The fix changes the generated entity deserializer so that, when an entity is about to be created, the constructor arguments are evaluated first (which is what triggers any recursive write of the same entity), and the store is then re-checked. If the entity now exists, the already-deserialized fields are preserved instead of being overwritten with defaults. JsonResultBuilderGenerator_UpdateEntity now hoists each response-derived argument into a local and, in the new-entity branch, re-runs TryGetEntity and merges. MethodCallBuilder.AddOutArgument gains a null type reference to emit `out entity` when reusing the existing out variable. Adds two runtime tests driven through the in-memory transport: - RecursiveEntitySelfReference reproduces the loss (red before this change: bestFriend.Age came back 0 instead of 42) and now passes. - InlineFragmentOrder covers the exact #8063 shape (an interface field selected twice with different inline-fragment coverage). All affected generator snapshots and integration client outputs were regenerated. Fixes ChilliCream/graphql-platform#8063 --- .../Builders/MethodCallBuilder.cs | 7 +- ...JsonResultBuilderGenerator_UpdateEntity.cs | 73 +- .../Integration/EntityIdOrDataTest.Client.cs | 28 +- .../InlineFragmentOrderTest.Client.cs | 2128 +++++++++++++++++ .../Integration/InlineFragmentOrderTest.cs | 104 + .../Integration/MultiProfileTest.Client.cs | 58 +- ...RecursiveEntitySelfReferenceTest.Client.cs | 923 +++++++ .../RecursiveEntitySelfReferenceTest.cs | 75 + ...tarWarsGetFriendsDeferInListTest.Client.cs | 54 +- .../StarWarsGetFriendsDeferredTest.Client.cs | 58 +- .../StarWarsGetFriendsTest.Client.cs | 58 +- .../Integration/StarWarsGetHeroTest.Client.cs | 28 +- .../StarWarsGetHeroTraitsTest.Client.cs | 32 +- ...gmentIncludeAndSkipDirectiveTest.Client.cs | 32 +- ...StarWarsTypeNameOnInterfacesTest.Client.cs | 28 +- .../StarWarsTypeNameOnUnionsTest.Client.cs | 41 +- .../StarWarsUnionListTest.Client.cs | 65 +- .../Integration/TestGeneration.cs | 121 + ...ectionGeneratorTests.Default_Combined.snap | 39 +- ...sts.Default_DifferentTransportMethods.snap | 39 +- ...ectionGeneratorTests.Default_InMemory.snap | 39 +- ...onGeneratorTests.Default_MultiProfile.snap | 39 +- ...ectionGeneratorTests.Default_Mutation.snap | 13 +- ...InjectionGeneratorTests.Default_Query.snap | 13 +- ...onGeneratorTests.Default_Subscription.snap | 13 +- ...ookClient_DataInEntity_UnionDataTypes.snap | 17 +- ...aInEntity_UnionDataTypes_With_Records.snap | 17 +- ...rate_ChatClient_ConnectionNotAnEntity.snap | 17 +- ...nt_ConnectionNotAnEntity_With_Records.snap | 17 +- ...lient_MapperMapsEntityOnRootCorrectly.snap | 71 +- ...apsEntityOnRootCorrectly_With_Records.snap | 71 +- ...ryGeneratorTests.Simple_ComplexEntity.snap | 15 +- ...torTests.Simple_DateTimeOffset_Entity.snap | 15 +- ...FactoryGeneratorTests.Simple_IdEntity.snap | 15 +- ...toryGeneratorTests.Simple_UUID_Entity.snap | 15 +- ...tityOrIdGeneratorTests.InterfaceField.snap | 30 +- ...ntityOrIdGeneratorTests.InterfaceList.snap | 30 +- ...GeneratorTests.NonNullableValueTypeId.snap | 26 +- .../EntityOrIdGeneratorTests.UnionField.snap | 26 +- .../EntityOrIdGeneratorTests.UnionList.snap | 26 +- ...yOrIdGeneratorTests.UnionListInEntity.snap | 39 +- ...dGeneratorTests.UnionWithNestedObject.snap | 13 +- ....Generate_ChatClient_InvalidNullCheck.snap | 30 +- ...ErrorGeneratorTests.Generate_NoErrors.snap | 30 +- ...pe_Fields_Are_Inspected_For_LeafTypes.snap | 13 +- ...InputGeneratorTests.KeywordCollisions.snap | 15 +- ...sts.Generate_ChatClient_AllOperations.snap | 262 +- ...esultTypeGeneratorTests.Nested_Entity.snap | 42 +- ...omplete_Schema_With_UUID_And_DateTime.snap | 25 +- ...rGeneratorTests.Duration_Not_Detected.snap | 13 +- ...hemaGeneratorTests.Create_GetFeatById.snap | 32 +- ...emaGeneratorTests.Create_GetFeatsPage.snap | 32 +- ...pleSearch_From_ActiveDirectory_Schema.snap | 59 +- ...atorTests.Create_Query_With_Skip_Take.snap | 17 +- ...eratorTests.FieldsWithUnderlineInName.snap | 73 +- ...eneratorTests.LowerCaseScalarArgument.snap | 17 +- ...aGeneratorTests.NodeTypenameCollision.snap | 15 +- ...chemaGeneratorTests.QueryInterference.snap | 85 +- ..._Client_With_Internal_Access_Modifier.snap | 30 +- ...torTests.Interface_With_Default_Names.snap | 30 +- ...e_With_Fragment_Definition_Two_Models.snap | 60 +- ...torTests.Operation_With_Leaf_Argument.snap | 30 +- ...neratorTests.StarWarsTypeNameOnUnions.snap | 39 +- ...rWarsGeneratorTests.StarWarsUnionList.snap | 35 +- ...azorGeneratorTests.Query_And_Mutation.snap | 30 +- 65 files changed, 5281 insertions(+), 301 deletions(-) create mode 100644 src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/InlineFragmentOrderTest.Client.cs create mode 100644 src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/InlineFragmentOrderTest.cs create mode 100644 src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/RecursiveEntitySelfReferenceTest.Client.cs create mode 100644 src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/RecursiveEntitySelfReferenceTest.cs diff --git a/src/StrawberryShake/CodeGeneration/src/CodeGeneration.CSharp/Builders/MethodCallBuilder.cs b/src/StrawberryShake/CodeGeneration/src/CodeGeneration.CSharp/Builders/MethodCallBuilder.cs index f62f4b0b1a0..06e41a3f4d4 100644 --- a/src/StrawberryShake/CodeGeneration/src/CodeGeneration.CSharp/Builders/MethodCallBuilder.cs +++ b/src/StrawberryShake/CodeGeneration/src/CodeGeneration.CSharp/Builders/MethodCallBuilder.cs @@ -71,9 +71,12 @@ public MethodCallBuilder AddArgument(string value) public MethodCallBuilder AddOutArgument( string value, - string typeReference) + string? typeReference) { - _arguments.Add(CodeInlineBuilder.New().SetText($"out {typeReference}? {value}")); + var code = typeReference is null + ? $"out {value}" + : $"out {typeReference}? {value}"; + _arguments.Add(CodeInlineBuilder.New().SetText(code)); return this; } diff --git a/src/StrawberryShake/CodeGeneration/src/CodeGeneration.CSharp/Generators/JsonResultBuilderGenerator_UpdateEntity.cs b/src/StrawberryShake/CodeGeneration/src/CodeGeneration.CSharp/Generators/JsonResultBuilderGenerator_UpdateEntity.cs index 278698482ad..251b79cca67 100644 --- a/src/StrawberryShake/CodeGeneration/src/CodeGeneration.CSharp/Generators/JsonResultBuilderGenerator_UpdateEntity.cs +++ b/src/StrawberryShake/CodeGeneration/src/CodeGeneration.CSharp/Generators/JsonResultBuilderGenerator_UpdateEntity.cs @@ -109,21 +109,78 @@ private static ICode CreateEntityConstructorCall( } } - var newEntity = MethodCallBuilder - .Inline() - .SetNew() - .SetMethodName(objectType.EntityTypeDescriptor.RuntimeType.ToString()); + var codeBlock = GenerateArgumentsFromResponse(objectType, propertyLookup, fragments); + if (assignDefault) + { + // Evaluating the arguments above may have written the same entity to the store + // (an entity can reference itself with a different selection set). Re-check the + // store so those already deserialized fields are preserved instead of being + // overwritten with defaults. + codeBlock.AddCode( + BuildTryGetEntityIf(null) + .AddCode(CreateSetEntityMethodCall(objectType, false, propertyLookup, fragments)) + .AddElse(CreateSetEntityMethodCall(objectType, true, propertyLookup, fragments))); + } + else + { + codeBlock.AddCode( + CreateSetEntityMethodCall(objectType, assignDefault, propertyLookup, fragments)); + } + + return codeBlock; + } + + private static CodeBlockBuilder GenerateArgumentsFromResponse( + ObjectTypeDescriptor objectType, + Dictionary propertyLookup, + Dictionary fragments) + { + var codeBlockBuilder = CodeBlockBuilder.New(); + var argumentIndex = 0; foreach (var property in objectType.EntityTypeDescriptor.Properties.Values) { if (propertyLookup.TryGetValue(property.Name, out var prop)) { - newEntity.AddArgument(BuildUpdateMethodCall(prop)); + codeBlockBuilder.AddCode( + AssignmentBuilder + .New() + .SetLeftHandSide($"var arg{argumentIndex++}") + .SetRightHandSide(BuildUpdateMethodCall(prop))); } else if (fragments.TryGetValue(property.Name, out var frag)) { - newEntity.AddArgument(BuildFragmentMethodCall(frag)); + codeBlockBuilder.AddCode( + AssignmentBuilder + .New() + .SetLeftHandSide($"var arg{argumentIndex++}") + .SetRightHandSide(BuildFragmentMethodCall(frag))); + } + } + + return codeBlockBuilder; + } + + private static MethodCallBuilder CreateSetEntityMethodCall( + ObjectTypeDescriptor objectType, + bool assignDefault, + Dictionary propertyLookup, + Dictionary fragments) + { + var newEntity = MethodCallBuilder + .Inline() + .SetNew() + .SetMethodName(objectType.EntityTypeDescriptor.RuntimeType.ToString()); + + var argumentIndex = 0; + foreach (var property in + objectType.EntityTypeDescriptor.Properties.Values) + { + if (propertyLookup.ContainsKey(property.Name) + || fragments.ContainsKey(property.Name)) + { + newEntity.AddArgument($"arg{argumentIndex++}"); } else if (assignDefault) { @@ -142,7 +199,7 @@ private static ICode CreateEntityConstructorCall( .AddArgument(newEntity); } - private static IfBuilder BuildTryGetEntityIf(RuntimeTypeInfo entityType) + private static IfBuilder BuildTryGetEntityIf(RuntimeTypeInfo? entityType) { return IfBuilder .New() @@ -150,7 +207,7 @@ private static IfBuilder BuildTryGetEntityIf(RuntimeTypeInfo entityType) .Inline() .SetMethodName(Session, "CurrentSnapshot", "TryGetEntity") .AddArgument(EntityId) - .AddOutArgument(Entity, entityType.ToString())); + .AddOutArgument(Entity, entityType?.ToString())); } private static PropertyDescriptor EnsureDeferredFieldIsNullable(PropertyDescriptor property) diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/EntityIdOrDataTest.Client.cs b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/EntityIdOrDataTest.Client.cs index 11c1125af34..b1d56c7ad2f 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/EntityIdOrDataTest.Client.cs +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/EntityIdOrDataTest.Client.cs @@ -1,4 +1,4 @@ -// ReSharper disable ArrangeObjectCreationWhenTypeEvident +// ReSharper disable ArrangeObjectCreationWhenTypeEvident // ReSharper disable BuiltInTypeReferenceStyle // ReSharper disable ConvertToAutoProperty // ReSharper disable InconsistentNaming @@ -944,11 +944,20 @@ public GetFooBuilder(global::StrawberryShake.IEntityStore entityStore, global::S { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::StrawberryShake.CodeGeneration.CSharp.Integration.EntityIdOrData.State.BazEntity? entity)) { - session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.EntityIdOrData.State.BazEntity(Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")))); + var arg0 = Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")); + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.EntityIdOrData.State.BazEntity(arg0)); } else { - session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.EntityIdOrData.State.BazEntity(Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")))); + var arg0 = Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.EntityIdOrData.State.BazEntity(arg0)); + } + else + { + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.EntityIdOrData.State.BazEntity(arg0)); + } } return new global::StrawberryShake.EntityIdOrData(entityId); @@ -967,11 +976,20 @@ public GetFooBuilder(global::StrawberryShake.IEntityStore entityStore, global::S { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::StrawberryShake.CodeGeneration.CSharp.Integration.EntityIdOrData.State.Baz2Entity? entity)) { - session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.EntityIdOrData.State.Baz2Entity(Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")))); + var arg0 = Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")); + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.EntityIdOrData.State.Baz2Entity(arg0)); } else { - session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.EntityIdOrData.State.Baz2Entity(Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")))); + var arg0 = Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.EntityIdOrData.State.Baz2Entity(arg0)); + } + else + { + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.EntityIdOrData.State.Baz2Entity(arg0)); + } } return new global::StrawberryShake.EntityIdOrData(entityId); diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/InlineFragmentOrderTest.Client.cs b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/InlineFragmentOrderTest.Client.cs new file mode 100644 index 00000000000..958cb194db0 --- /dev/null +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/InlineFragmentOrderTest.Client.cs @@ -0,0 +1,2128 @@ +// ReSharper disable ArrangeObjectCreationWhenTypeEvident +// ReSharper disable BuiltInTypeReferenceStyle +// ReSharper disable ConvertToAutoProperty +// ReSharper disable InconsistentNaming +// ReSharper disable PartialTypeWithSinglePart +// ReSharper disable PreferConcreteValueOverDefault +// ReSharper disable RedundantNameQualifier +// ReSharper disable SuggestVarOrType_SimpleTypes +// ReSharper disable UnusedMember.Global +// ReSharper disable UnusedMethodReturnValue.Local +// ReSharper disable UnusedType.Global +// ReSharper disable UnusedVariable + +// InlineFragmentOrderClient + +// +#nullable enable annotations +#nullable disable warnings + +namespace Microsoft.Extensions.DependencyInjection +{ + // StrawberryShake.CodeGeneration.CSharp.Generators.DependencyInjectionGenerator + [global::System.CodeDom.Compiler.GeneratedCode("StrawberryShake", "11.0.0")] + public static partial class InlineFragmentOrderClientServiceCollectionExtensions + { + public static global::StrawberryShake.IClientBuilder AddInlineFragmentOrderClient(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection services, global::StrawberryShake.ExecutionStrategy strategy = global::StrawberryShake.ExecutionStrategy.NetworkOnly) + { + var serviceCollection = new global::Microsoft.Extensions.DependencyInjection.ServiceCollection(); + global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton(services, sp => + { + ConfigureClientDefault(sp, serviceCollection, strategy); + return new ClientServiceProvider(global::Microsoft.Extensions.DependencyInjection.ServiceCollectionContainerBuilderExtensions.BuildServiceProvider(serviceCollection)); + }); + global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton(services, sp => new global::StrawberryShake.CodeGeneration.CSharp.Integration.InlineFragmentOrder.State.InlineFragmentOrderClientStoreAccessor(global::Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(global::Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(sp)), global::Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(global::Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(sp)), global::Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(global::Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(sp)), global::Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService>(global::Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(sp)), global::Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService>(global::Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(sp)))); + global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton(services, sp => global::Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(global::Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(sp))); + global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton(services, sp => global::Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(global::Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(sp))); + global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton(services, sp => global::Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(global::Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(sp))); + global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton(services, sp => global::Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(global::Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(sp))); + return new global::StrawberryShake.ClientBuilder("InlineFragmentOrderClient", services, serviceCollection); + } + + private static global::Microsoft.Extensions.DependencyInjection.IServiceCollection ConfigureClientDefault(global::System.IServiceProvider parentServices, global::Microsoft.Extensions.DependencyInjection.ServiceCollection services, global::StrawberryShake.ExecutionStrategy strategy = global::StrawberryShake.ExecutionStrategy.NetworkOnly) + { + global::Microsoft.Extensions.DependencyInjection.Extensions.ServiceCollectionDescriptorExtensions.TryAddSingleton(services); + global::Microsoft.Extensions.DependencyInjection.Extensions.ServiceCollectionDescriptorExtensions.TryAddSingleton(services, sp => new global::StrawberryShake.OperationStore(global::Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(sp))); + global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton(services, sp => + { + var clientFactory = global::Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(parentServices); + return new global::StrawberryShake.Transport.InMemory.InMemoryConnection(async ct => await clientFactory.CreateAsync("InlineFragmentOrderClient", ct)); + }); + global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton, global::StrawberryShake.CodeGeneration.CSharp.Integration.InlineFragmentOrder.State.NotWorkingQuery_People_PersonFromPersonEntityMapper>(services); + global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton, global::StrawberryShake.CodeGeneration.CSharp.Integration.InlineFragmentOrder.State.NotWorkingQuery_Shelters_ShelterFromShelterEntityMapper>(services); + global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton, global::StrawberryShake.CodeGeneration.CSharp.Integration.InlineFragmentOrder.State.NotWorkingQuery_People_Pet_DogFromDogEntityMapper>(services); + global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton, global::StrawberryShake.CodeGeneration.CSharp.Integration.InlineFragmentOrder.State.NotWorkingQuery_People_Pet_CatFromCatEntityMapper>(services); + global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton, global::StrawberryShake.CodeGeneration.CSharp.Integration.InlineFragmentOrder.State.NotWorkingQuery_People_Pet_BirdFromBirdEntityMapper>(services); + global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton, global::StrawberryShake.CodeGeneration.CSharp.Integration.InlineFragmentOrder.State.NotWorkingQuery_Shelters_Pet_DogFromDogEntityMapper>(services); + global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton, global::StrawberryShake.CodeGeneration.CSharp.Integration.InlineFragmentOrder.State.NotWorkingQuery_Shelters_Pet_CatFromCatEntityMapper>(services); + global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton, global::StrawberryShake.CodeGeneration.CSharp.Integration.InlineFragmentOrder.State.NotWorkingQuery_Shelters_Pet_BirdFromBirdEntityMapper>(services); + global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton(services); + global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton(services); + global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton(services); + global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton(services); + global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton(services); + global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton(services); + global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton(services); + global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton(services); + global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton(services); + global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton(services); + global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton(services); + global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton(services); + global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton(services); + global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton(services); + global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton(services); + global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton(services); + global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton(services); + global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton(services); + global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton(services); + global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton(services); + global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton(services); + global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton(services); + global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton(services); + global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton(services); + global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton(services); + global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton(services, sp => new global::StrawberryShake.Serialization.SerializerResolver(global::System.Linq.Enumerable.Concat(global::Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService>(parentServices), global::Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService>(sp)))); + global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton, global::StrawberryShake.CodeGeneration.CSharp.Integration.InlineFragmentOrder.State.NotWorkingQueryResultFactory>(services); + global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton(services, sp => global::Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService>(sp)); + global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton(services, sp => global::Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(sp)); + global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton, global::StrawberryShake.CodeGeneration.CSharp.Integration.InlineFragmentOrder.State.NotWorkingQueryBuilder>(services); + global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton>(services, sp => new global::StrawberryShake.OperationExecutor(global::Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(sp), () => global::Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService>(sp), () => global::Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService>(sp), global::Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(sp), strategy)); + global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton, global::StrawberryShake.Json.JsonResultPatcher>(services); + global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton(services); + global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton(services, sp => global::Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(sp)); + global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton(services); + global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton(services); + global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton(services, sp => global::Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(sp)); + return services; + } + + private sealed class ClientServiceProvider : System.IServiceProvider, System.IDisposable + { + private readonly System.IServiceProvider _provider; + public ClientServiceProvider(System.IServiceProvider provider) + { + _provider = provider; + } + + public object? GetService(System.Type serviceType) + { + return _provider.GetService(serviceType); + } + + public void Dispose() + { + if (_provider is System.IDisposable d) + { + d.Dispose(); + } + } + } + } +} + +namespace StrawberryShake.CodeGeneration.CSharp.Integration.InlineFragmentOrder +{ + // StrawberryShake.CodeGeneration.CSharp.Generators.ResultTypeGenerator + [global::System.CodeDom.Compiler.GeneratedCode("StrawberryShake", "11.0.0")] + public partial class NotWorkingQueryResult : global::System.IEquatable, INotWorkingQueryResult + { + public NotWorkingQueryResult(global::System.Collections.Generic.IReadOnlyList people, global::System.Collections.Generic.IReadOnlyList shelters) + { + People = people; + Shelters = shelters; + } + + public global::System.Collections.Generic.IReadOnlyList People { get; } + public global::System.Collections.Generic.IReadOnlyList Shelters { get; } + + public virtual global::System.Boolean Equals(NotWorkingQueryResult? other) + { + if (ReferenceEquals(null, other)) + { + return false; + } + + if (ReferenceEquals(this, other)) + { + return true; + } + + if (other.GetType() != GetType()) + { + return false; + } + + return (global::StrawberryShake.Internal.ComparisonHelper.SequenceEqual(People, other.People)) && global::StrawberryShake.Internal.ComparisonHelper.SequenceEqual(Shelters, other.Shelters); + } + + public override global::System.Boolean Equals(global::System.Object? obj) + { + if (ReferenceEquals(null, obj)) + { + return false; + } + + if (ReferenceEquals(this, obj)) + { + return true; + } + + if (obj.GetType() != GetType()) + { + return false; + } + + return Equals((NotWorkingQueryResult)obj); + } + + public override global::System.Int32 GetHashCode() + { + unchecked + { + int hash = 5; + foreach (var People_elm in People) + { + hash ^= 397 * People_elm.GetHashCode(); + } + + foreach (var Shelters_elm in Shelters) + { + hash ^= 397 * Shelters_elm.GetHashCode(); + } + + return hash; + } + } + } + + // StrawberryShake.CodeGeneration.CSharp.Generators.ResultTypeGenerator + [global::System.CodeDom.Compiler.GeneratedCode("StrawberryShake", "11.0.0")] + public partial class NotWorkingQuery_People_Person : global::System.IEquatable, INotWorkingQuery_People_Person + { + public NotWorkingQuery_People_Person(global::System.Int32 id, global::System.String name, global::StrawberryShake.CodeGeneration.CSharp.Integration.InlineFragmentOrder.INotWorkingQuery_People_Pet? pet) + { + Id = id; + Name = name; + Pet = pet; + } + + public global::System.Int32 Id { get; } + public global::System.String Name { get; } + public global::StrawberryShake.CodeGeneration.CSharp.Integration.InlineFragmentOrder.INotWorkingQuery_People_Pet? Pet { get; } + + public virtual global::System.Boolean Equals(NotWorkingQuery_People_Person? other) + { + if (ReferenceEquals(null, other)) + { + return false; + } + + if (ReferenceEquals(this, other)) + { + return true; + } + + if (other.GetType() != GetType()) + { + return false; + } + + return (global::System.Object.Equals(Id, other.Id)) && Name.Equals(other.Name) && ((Pet is null && other.Pet is null) || Pet != null && Pet.Equals(other.Pet)); + } + + public override global::System.Boolean Equals(global::System.Object? obj) + { + if (ReferenceEquals(null, obj)) + { + return false; + } + + if (ReferenceEquals(this, obj)) + { + return true; + } + + if (obj.GetType() != GetType()) + { + return false; + } + + return Equals((NotWorkingQuery_People_Person)obj); + } + + public override global::System.Int32 GetHashCode() + { + unchecked + { + int hash = 5; + hash ^= 397 * Id.GetHashCode(); + hash ^= 397 * Name.GetHashCode(); + if (Pet != null) + { + hash ^= 397 * Pet.GetHashCode(); + } + + return hash; + } + } + } + + // StrawberryShake.CodeGeneration.CSharp.Generators.ResultTypeGenerator + [global::System.CodeDom.Compiler.GeneratedCode("StrawberryShake", "11.0.0")] + public partial class NotWorkingQuery_Shelters_Shelter : global::System.IEquatable, INotWorkingQuery_Shelters_Shelter + { + public NotWorkingQuery_Shelters_Shelter(global::System.Int32 id, global::System.String location, global::StrawberryShake.CodeGeneration.CSharp.Integration.InlineFragmentOrder.INotWorkingQuery_Shelters_Pet? pet) + { + Id = id; + Location = location; + Pet = pet; + } + + public global::System.Int32 Id { get; } + public global::System.String Location { get; } + public global::StrawberryShake.CodeGeneration.CSharp.Integration.InlineFragmentOrder.INotWorkingQuery_Shelters_Pet? Pet { get; } + + public virtual global::System.Boolean Equals(NotWorkingQuery_Shelters_Shelter? other) + { + if (ReferenceEquals(null, other)) + { + return false; + } + + if (ReferenceEquals(this, other)) + { + return true; + } + + if (other.GetType() != GetType()) + { + return false; + } + + return (global::System.Object.Equals(Id, other.Id)) && Location.Equals(other.Location) && ((Pet is null && other.Pet is null) || Pet != null && Pet.Equals(other.Pet)); + } + + public override global::System.Boolean Equals(global::System.Object? obj) + { + if (ReferenceEquals(null, obj)) + { + return false; + } + + if (ReferenceEquals(this, obj)) + { + return true; + } + + if (obj.GetType() != GetType()) + { + return false; + } + + return Equals((NotWorkingQuery_Shelters_Shelter)obj); + } + + public override global::System.Int32 GetHashCode() + { + unchecked + { + int hash = 5; + hash ^= 397 * Id.GetHashCode(); + hash ^= 397 * Location.GetHashCode(); + if (Pet != null) + { + hash ^= 397 * Pet.GetHashCode(); + } + + return hash; + } + } + } + + // StrawberryShake.CodeGeneration.CSharp.Generators.ResultTypeGenerator + [global::System.CodeDom.Compiler.GeneratedCode("StrawberryShake", "11.0.0")] + public partial class NotWorkingQuery_People_Pet_Dog : global::System.IEquatable, INotWorkingQuery_People_Pet_Dog + { + public NotWorkingQuery_People_Pet_Dog(global::System.Int32 id, global::System.String __typename, global::System.String breed) + { + Id = id; + this.__typename = __typename; + Breed = breed; + } + + public global::System.Int32 Id { get; } + /// + /// The name of the current Object type at runtime. + /// + public global::System.String __typename { get; } + public global::System.String Breed { get; } + + public virtual global::System.Boolean Equals(NotWorkingQuery_People_Pet_Dog? other) + { + if (ReferenceEquals(null, other)) + { + return false; + } + + if (ReferenceEquals(this, other)) + { + return true; + } + + if (other.GetType() != GetType()) + { + return false; + } + + return (global::System.Object.Equals(Id, other.Id)) && __typename.Equals(other.__typename) && Breed.Equals(other.Breed); + } + + public override global::System.Boolean Equals(global::System.Object? obj) + { + if (ReferenceEquals(null, obj)) + { + return false; + } + + if (ReferenceEquals(this, obj)) + { + return true; + } + + if (obj.GetType() != GetType()) + { + return false; + } + + return Equals((NotWorkingQuery_People_Pet_Dog)obj); + } + + public override global::System.Int32 GetHashCode() + { + unchecked + { + int hash = 5; + hash ^= 397 * Id.GetHashCode(); + hash ^= 397 * __typename.GetHashCode(); + hash ^= 397 * Breed.GetHashCode(); + return hash; + } + } + } + + // StrawberryShake.CodeGeneration.CSharp.Generators.ResultTypeGenerator + [global::System.CodeDom.Compiler.GeneratedCode("StrawberryShake", "11.0.0")] + public partial class NotWorkingQuery_People_Pet_Cat : global::System.IEquatable, INotWorkingQuery_People_Pet_Cat + { + public NotWorkingQuery_People_Pet_Cat(global::System.Int32 id, global::System.String __typename, global::System.String furColor) + { + Id = id; + this.__typename = __typename; + FurColor = furColor; + } + + public global::System.Int32 Id { get; } + /// + /// The name of the current Object type at runtime. + /// + public global::System.String __typename { get; } + public global::System.String FurColor { get; } + + public virtual global::System.Boolean Equals(NotWorkingQuery_People_Pet_Cat? other) + { + if (ReferenceEquals(null, other)) + { + return false; + } + + if (ReferenceEquals(this, other)) + { + return true; + } + + if (other.GetType() != GetType()) + { + return false; + } + + return (global::System.Object.Equals(Id, other.Id)) && __typename.Equals(other.__typename) && FurColor.Equals(other.FurColor); + } + + public override global::System.Boolean Equals(global::System.Object? obj) + { + if (ReferenceEquals(null, obj)) + { + return false; + } + + if (ReferenceEquals(this, obj)) + { + return true; + } + + if (obj.GetType() != GetType()) + { + return false; + } + + return Equals((NotWorkingQuery_People_Pet_Cat)obj); + } + + public override global::System.Int32 GetHashCode() + { + unchecked + { + int hash = 5; + hash ^= 397 * Id.GetHashCode(); + hash ^= 397 * __typename.GetHashCode(); + hash ^= 397 * FurColor.GetHashCode(); + return hash; + } + } + } + + // StrawberryShake.CodeGeneration.CSharp.Generators.ResultTypeGenerator + [global::System.CodeDom.Compiler.GeneratedCode("StrawberryShake", "11.0.0")] + public partial class NotWorkingQuery_People_Pet_Bird : global::System.IEquatable, INotWorkingQuery_People_Pet_Bird + { + public NotWorkingQuery_People_Pet_Bird(global::System.Int32 id, global::System.String __typename) + { + Id = id; + this.__typename = __typename; + } + + public global::System.Int32 Id { get; } + /// + /// The name of the current Object type at runtime. + /// + public global::System.String __typename { get; } + + public virtual global::System.Boolean Equals(NotWorkingQuery_People_Pet_Bird? other) + { + if (ReferenceEquals(null, other)) + { + return false; + } + + if (ReferenceEquals(this, other)) + { + return true; + } + + if (other.GetType() != GetType()) + { + return false; + } + + return (global::System.Object.Equals(Id, other.Id)) && __typename.Equals(other.__typename); + } + + public override global::System.Boolean Equals(global::System.Object? obj) + { + if (ReferenceEquals(null, obj)) + { + return false; + } + + if (ReferenceEquals(this, obj)) + { + return true; + } + + if (obj.GetType() != GetType()) + { + return false; + } + + return Equals((NotWorkingQuery_People_Pet_Bird)obj); + } + + public override global::System.Int32 GetHashCode() + { + unchecked + { + int hash = 5; + hash ^= 397 * Id.GetHashCode(); + hash ^= 397 * __typename.GetHashCode(); + return hash; + } + } + } + + // StrawberryShake.CodeGeneration.CSharp.Generators.ResultTypeGenerator + [global::System.CodeDom.Compiler.GeneratedCode("StrawberryShake", "11.0.0")] + public partial class NotWorkingQuery_Shelters_Pet_Dog : global::System.IEquatable, INotWorkingQuery_Shelters_Pet_Dog + { + public NotWorkingQuery_Shelters_Pet_Dog(global::System.Int32 id, global::System.String __typename, global::System.String breed) + { + Id = id; + this.__typename = __typename; + Breed = breed; + } + + public global::System.Int32 Id { get; } + /// + /// The name of the current Object type at runtime. + /// + public global::System.String __typename { get; } + public global::System.String Breed { get; } + + public virtual global::System.Boolean Equals(NotWorkingQuery_Shelters_Pet_Dog? other) + { + if (ReferenceEquals(null, other)) + { + return false; + } + + if (ReferenceEquals(this, other)) + { + return true; + } + + if (other.GetType() != GetType()) + { + return false; + } + + return (global::System.Object.Equals(Id, other.Id)) && __typename.Equals(other.__typename) && Breed.Equals(other.Breed); + } + + public override global::System.Boolean Equals(global::System.Object? obj) + { + if (ReferenceEquals(null, obj)) + { + return false; + } + + if (ReferenceEquals(this, obj)) + { + return true; + } + + if (obj.GetType() != GetType()) + { + return false; + } + + return Equals((NotWorkingQuery_Shelters_Pet_Dog)obj); + } + + public override global::System.Int32 GetHashCode() + { + unchecked + { + int hash = 5; + hash ^= 397 * Id.GetHashCode(); + hash ^= 397 * __typename.GetHashCode(); + hash ^= 397 * Breed.GetHashCode(); + return hash; + } + } + } + + // StrawberryShake.CodeGeneration.CSharp.Generators.ResultTypeGenerator + [global::System.CodeDom.Compiler.GeneratedCode("StrawberryShake", "11.0.0")] + public partial class NotWorkingQuery_Shelters_Pet_Cat : global::System.IEquatable, INotWorkingQuery_Shelters_Pet_Cat + { + public NotWorkingQuery_Shelters_Pet_Cat(global::System.Int32 id, global::System.String __typename, global::System.String furColor) + { + Id = id; + this.__typename = __typename; + FurColor = furColor; + } + + public global::System.Int32 Id { get; } + /// + /// The name of the current Object type at runtime. + /// + public global::System.String __typename { get; } + public global::System.String FurColor { get; } + + public virtual global::System.Boolean Equals(NotWorkingQuery_Shelters_Pet_Cat? other) + { + if (ReferenceEquals(null, other)) + { + return false; + } + + if (ReferenceEquals(this, other)) + { + return true; + } + + if (other.GetType() != GetType()) + { + return false; + } + + return (global::System.Object.Equals(Id, other.Id)) && __typename.Equals(other.__typename) && FurColor.Equals(other.FurColor); + } + + public override global::System.Boolean Equals(global::System.Object? obj) + { + if (ReferenceEquals(null, obj)) + { + return false; + } + + if (ReferenceEquals(this, obj)) + { + return true; + } + + if (obj.GetType() != GetType()) + { + return false; + } + + return Equals((NotWorkingQuery_Shelters_Pet_Cat)obj); + } + + public override global::System.Int32 GetHashCode() + { + unchecked + { + int hash = 5; + hash ^= 397 * Id.GetHashCode(); + hash ^= 397 * __typename.GetHashCode(); + hash ^= 397 * FurColor.GetHashCode(); + return hash; + } + } + } + + // StrawberryShake.CodeGeneration.CSharp.Generators.ResultTypeGenerator + [global::System.CodeDom.Compiler.GeneratedCode("StrawberryShake", "11.0.0")] + public partial class NotWorkingQuery_Shelters_Pet_Bird : global::System.IEquatable, INotWorkingQuery_Shelters_Pet_Bird + { + public NotWorkingQuery_Shelters_Pet_Bird(global::System.Int32 id, global::System.String __typename, global::System.Int32 wingSpan) + { + Id = id; + this.__typename = __typename; + WingSpan = wingSpan; + } + + public global::System.Int32 Id { get; } + /// + /// The name of the current Object type at runtime. + /// + public global::System.String __typename { get; } + public global::System.Int32 WingSpan { get; } + + public virtual global::System.Boolean Equals(NotWorkingQuery_Shelters_Pet_Bird? other) + { + if (ReferenceEquals(null, other)) + { + return false; + } + + if (ReferenceEquals(this, other)) + { + return true; + } + + if (other.GetType() != GetType()) + { + return false; + } + + return (global::System.Object.Equals(Id, other.Id)) && __typename.Equals(other.__typename) && global::System.Object.Equals(WingSpan, other.WingSpan); + } + + public override global::System.Boolean Equals(global::System.Object? obj) + { + if (ReferenceEquals(null, obj)) + { + return false; + } + + if (ReferenceEquals(this, obj)) + { + return true; + } + + if (obj.GetType() != GetType()) + { + return false; + } + + return Equals((NotWorkingQuery_Shelters_Pet_Bird)obj); + } + + public override global::System.Int32 GetHashCode() + { + unchecked + { + int hash = 5; + hash ^= 397 * Id.GetHashCode(); + hash ^= 397 * __typename.GetHashCode(); + hash ^= 397 * WingSpan.GetHashCode(); + return hash; + } + } + } + + // StrawberryShake.CodeGeneration.CSharp.Generators.ResultInterfaceGenerator + [global::System.CodeDom.Compiler.GeneratedCode("StrawberryShake", "11.0.0")] + public partial interface INotWorkingQueryResult + { + public global::System.Collections.Generic.IReadOnlyList People { get; } + public global::System.Collections.Generic.IReadOnlyList Shelters { get; } + } + + // StrawberryShake.CodeGeneration.CSharp.Generators.ResultInterfaceGenerator + [global::System.CodeDom.Compiler.GeneratedCode("StrawberryShake", "11.0.0")] + public partial interface INotWorkingQuery_People + { + public global::System.Int32 Id { get; } + public global::System.String Name { get; } + public global::StrawberryShake.CodeGeneration.CSharp.Integration.InlineFragmentOrder.INotWorkingQuery_People_Pet? Pet { get; } + } + + // StrawberryShake.CodeGeneration.CSharp.Generators.ResultInterfaceGenerator + [global::System.CodeDom.Compiler.GeneratedCode("StrawberryShake", "11.0.0")] + public partial interface INotWorkingQuery_People_Person : INotWorkingQuery_People + { + } + + // StrawberryShake.CodeGeneration.CSharp.Generators.ResultInterfaceGenerator + [global::System.CodeDom.Compiler.GeneratedCode("StrawberryShake", "11.0.0")] + public partial interface INotWorkingQuery_Shelters + { + public global::System.Int32 Id { get; } + public global::System.String Location { get; } + public global::StrawberryShake.CodeGeneration.CSharp.Integration.InlineFragmentOrder.INotWorkingQuery_Shelters_Pet? Pet { get; } + } + + // StrawberryShake.CodeGeneration.CSharp.Generators.ResultInterfaceGenerator + [global::System.CodeDom.Compiler.GeneratedCode("StrawberryShake", "11.0.0")] + public partial interface INotWorkingQuery_Shelters_Shelter : INotWorkingQuery_Shelters + { + } + + // StrawberryShake.CodeGeneration.CSharp.Generators.ResultInterfaceGenerator + [global::System.CodeDom.Compiler.GeneratedCode("StrawberryShake", "11.0.0")] + public partial interface INotWorkingQuery_People_Pet + { + public global::System.Int32 Id { get; } + public global::System.String __typename { get; } + } + + // StrawberryShake.CodeGeneration.CSharp.Generators.ResultInterfaceGenerator + [global::System.CodeDom.Compiler.GeneratedCode("StrawberryShake", "11.0.0")] + public partial interface INotWorkingQuery_People_Pet_Dog : INotWorkingQuery_People_Pet + { + public global::System.String Breed { get; } + } + + // StrawberryShake.CodeGeneration.CSharp.Generators.ResultInterfaceGenerator + [global::System.CodeDom.Compiler.GeneratedCode("StrawberryShake", "11.0.0")] + public partial interface INotWorkingQuery_People_Pet_Cat : INotWorkingQuery_People_Pet + { + public global::System.String FurColor { get; } + } + + // StrawberryShake.CodeGeneration.CSharp.Generators.ResultInterfaceGenerator + [global::System.CodeDom.Compiler.GeneratedCode("StrawberryShake", "11.0.0")] + public partial interface INotWorkingQuery_People_Pet_Bird : INotWorkingQuery_People_Pet + { + } + + // StrawberryShake.CodeGeneration.CSharp.Generators.ResultInterfaceGenerator + [global::System.CodeDom.Compiler.GeneratedCode("StrawberryShake", "11.0.0")] + public partial interface INotWorkingQuery_Shelters_Pet + { + public global::System.Int32 Id { get; } + public global::System.String __typename { get; } + } + + // StrawberryShake.CodeGeneration.CSharp.Generators.ResultInterfaceGenerator + [global::System.CodeDom.Compiler.GeneratedCode("StrawberryShake", "11.0.0")] + public partial interface INotWorkingQuery_Shelters_Pet_Dog : INotWorkingQuery_Shelters_Pet + { + public global::System.String Breed { get; } + } + + // StrawberryShake.CodeGeneration.CSharp.Generators.ResultInterfaceGenerator + [global::System.CodeDom.Compiler.GeneratedCode("StrawberryShake", "11.0.0")] + public partial interface INotWorkingQuery_Shelters_Pet_Cat : INotWorkingQuery_Shelters_Pet + { + public global::System.String FurColor { get; } + } + + // StrawberryShake.CodeGeneration.CSharp.Generators.ResultInterfaceGenerator + [global::System.CodeDom.Compiler.GeneratedCode("StrawberryShake", "11.0.0")] + public partial interface INotWorkingQuery_Shelters_Pet_Bird : INotWorkingQuery_Shelters_Pet + { + public global::System.Int32 WingSpan { get; } + } + + // StrawberryShake.CodeGeneration.CSharp.Generators.OperationDocumentGenerator + /// + /// Represents the operation service of the NotWorkingQuery GraphQL operation + /// + /// query NotWorkingQuery { + /// people { + /// __typename + /// id + /// name + /// pet { + /// id + /// __typename + /// ... on Cat { + /// furColor + /// } + /// ... on Dog { + /// breed + /// } + /// ... on Dog { + /// id + /// } + /// ... on Cat { + /// id + /// } + /// ... on Bird { + /// id + /// } + /// } + /// ... on Person { + /// id + /// } + /// } + /// shelters { + /// __typename + /// id + /// location + /// pet { + /// id + /// __typename + /// ... on Bird { + /// wingSpan + /// } + /// ... on Cat { + /// furColor + /// } + /// ... on Dog { + /// breed + /// } + /// ... on Dog { + /// id + /// } + /// ... on Cat { + /// id + /// } + /// ... on Bird { + /// id + /// } + /// } + /// ... on Shelter { + /// id + /// } + /// } + /// } + /// + /// + [global::System.CodeDom.Compiler.GeneratedCode("StrawberryShake", "11.0.0")] + public partial class NotWorkingQueryQueryDocument : global::StrawberryShake.IDocument + { + private NotWorkingQueryQueryDocument() + { + } + + public static NotWorkingQueryQueryDocument Instance { get; } = new NotWorkingQueryQueryDocument(); + public global::StrawberryShake.OperationKind Kind => global::StrawberryShake.OperationKind.Query; + public global::System.ReadOnlySpan Body => "query NotWorkingQuery { people { __typename id name pet { id __typename ... on Cat { furColor } ... on Dog { breed } ... on Dog { id } ... on Cat { id } ... on Bird { id } } ... on Person { id } } shelters { __typename id location pet { id __typename ... on Bird { wingSpan } ... on Cat { furColor } ... on Dog { breed } ... on Dog { id } ... on Cat { id } ... on Bird { id } } ... on Shelter { id } } }"u8; + public global::StrawberryShake.DocumentHash Hash { get; } = new global::StrawberryShake.DocumentHash("sha1Hash", "7697a5a1fc027b74e6eddf84d83ea7189f657e0b"); + + public override global::System.String ToString() + { +#if NETCOREAPP3_1_OR_GREATER + return global::System.Text.Encoding.UTF8.GetString(Body); +#else + return global::System.Text.Encoding.UTF8.GetString(Body.ToArray()); +#endif + } + } + + // StrawberryShake.CodeGeneration.CSharp.Generators.OperationServiceGenerator + /// + /// Represents the operation service of the NotWorkingQuery GraphQL operation + /// + /// query NotWorkingQuery { + /// people { + /// __typename + /// id + /// name + /// pet { + /// id + /// __typename + /// ... on Cat { + /// furColor + /// } + /// ... on Dog { + /// breed + /// } + /// ... on Dog { + /// id + /// } + /// ... on Cat { + /// id + /// } + /// ... on Bird { + /// id + /// } + /// } + /// ... on Person { + /// id + /// } + /// } + /// shelters { + /// __typename + /// id + /// location + /// pet { + /// id + /// __typename + /// ... on Bird { + /// wingSpan + /// } + /// ... on Cat { + /// furColor + /// } + /// ... on Dog { + /// breed + /// } + /// ... on Dog { + /// id + /// } + /// ... on Cat { + /// id + /// } + /// ... on Bird { + /// id + /// } + /// } + /// ... on Shelter { + /// id + /// } + /// } + /// } + /// + /// + [global::System.CodeDom.Compiler.GeneratedCode("StrawberryShake", "11.0.0")] + public partial class NotWorkingQueryQuery : global::StrawberryShake.CodeGeneration.CSharp.Integration.InlineFragmentOrder.INotWorkingQueryQuery + { + private readonly global::StrawberryShake.IOperationExecutor _operationExecutor; + private readonly global::System.Collections.Immutable.ImmutableArray> _configure = global::System.Collections.Immutable.ImmutableArray>.Empty; + public NotWorkingQueryQuery(global::StrawberryShake.IOperationExecutor operationExecutor) + { + _operationExecutor = operationExecutor ?? throw new global::System.ArgumentNullException(nameof(operationExecutor)); + } + + private NotWorkingQueryQuery(global::StrawberryShake.IOperationExecutor operationExecutor, global::System.Collections.Immutable.ImmutableArray> configure) + { + _operationExecutor = operationExecutor; + _configure = configure; + } + + global::System.Type global::StrawberryShake.IOperationRequestFactory.ResultType => typeof(INotWorkingQueryResult); + + public global::StrawberryShake.CodeGeneration.CSharp.Integration.InlineFragmentOrder.INotWorkingQueryQuery With(global::System.Action configure) + { + return new global::StrawberryShake.CodeGeneration.CSharp.Integration.InlineFragmentOrder.NotWorkingQueryQuery(_operationExecutor, _configure.Add(configure)); + } + + public global::StrawberryShake.CodeGeneration.CSharp.Integration.InlineFragmentOrder.INotWorkingQueryQuery WithRequestUri(global::System.Uri requestUri) + { + return With(r => r.ContextData["StrawberryShake.Transport.Http.HttpConnection.RequestUri"] = requestUri); + } + + public global::StrawberryShake.CodeGeneration.CSharp.Integration.InlineFragmentOrder.INotWorkingQueryQuery WithHttpClient(global::System.Net.Http.HttpClient httpClient) + { + return With(r => r.ContextData["StrawberryShake.Transport.Http.HttpConnection.HttpClient"] = httpClient); + } + + public async global::System.Threading.Tasks.Task> ExecuteAsync(global::System.Threading.CancellationToken cancellationToken = default) + { + var request = CreateRequest(); + foreach (var configure in _configure) + { + configure(request); + } + + return await _operationExecutor.ExecuteAsync(request, cancellationToken).ConfigureAwait(false); + } + + public global::System.IObservable> Watch(global::StrawberryShake.ExecutionStrategy? strategy = null) + { + var request = CreateRequest(); + return _operationExecutor.Watch(request, strategy); + } + + private global::StrawberryShake.OperationRequest CreateRequest() + { + return CreateRequest(null); + } + + private global::StrawberryShake.OperationRequest CreateRequest(global::System.Collections.Generic.IReadOnlyDictionary? variables) + { + return new global::StrawberryShake.OperationRequest(id: NotWorkingQueryQueryDocument.Instance.Hash.Value, name: "NotWorkingQuery", document: NotWorkingQueryQueryDocument.Instance, strategy: global::StrawberryShake.RequestStrategy.Default); + } + + global::StrawberryShake.OperationRequest global::StrawberryShake.IOperationRequestFactory.Create(global::System.Collections.Generic.IReadOnlyDictionary? variables) + { + return CreateRequest(); + } + } + + // StrawberryShake.CodeGeneration.CSharp.Generators.OperationServiceInterfaceGenerator + /// + /// Represents the operation service of the NotWorkingQuery GraphQL operation + /// + /// query NotWorkingQuery { + /// people { + /// __typename + /// id + /// name + /// pet { + /// id + /// __typename + /// ... on Cat { + /// furColor + /// } + /// ... on Dog { + /// breed + /// } + /// ... on Dog { + /// id + /// } + /// ... on Cat { + /// id + /// } + /// ... on Bird { + /// id + /// } + /// } + /// ... on Person { + /// id + /// } + /// } + /// shelters { + /// __typename + /// id + /// location + /// pet { + /// id + /// __typename + /// ... on Bird { + /// wingSpan + /// } + /// ... on Cat { + /// furColor + /// } + /// ... on Dog { + /// breed + /// } + /// ... on Dog { + /// id + /// } + /// ... on Cat { + /// id + /// } + /// ... on Bird { + /// id + /// } + /// } + /// ... on Shelter { + /// id + /// } + /// } + /// } + /// + /// + [global::System.CodeDom.Compiler.GeneratedCode("StrawberryShake", "11.0.0")] + public partial interface INotWorkingQueryQuery : global::StrawberryShake.IOperationRequestFactory + { + global::StrawberryShake.CodeGeneration.CSharp.Integration.InlineFragmentOrder.INotWorkingQueryQuery With(global::System.Action configure); + global::StrawberryShake.CodeGeneration.CSharp.Integration.InlineFragmentOrder.INotWorkingQueryQuery WithRequestUri(global::System.Uri requestUri); + global::StrawberryShake.CodeGeneration.CSharp.Integration.InlineFragmentOrder.INotWorkingQueryQuery WithHttpClient(global::System.Net.Http.HttpClient httpClient); + global::System.Threading.Tasks.Task> ExecuteAsync(global::System.Threading.CancellationToken cancellationToken = default); + global::System.IObservable> Watch(global::StrawberryShake.ExecutionStrategy? strategy = null); + } + + // StrawberryShake.CodeGeneration.CSharp.Generators.ClientGenerator + /// + /// Represents the InlineFragmentOrderClient GraphQL client + /// + [global::System.CodeDom.Compiler.GeneratedCode("StrawberryShake", "11.0.0")] + public partial class InlineFragmentOrderClient : global::StrawberryShake.CodeGeneration.CSharp.Integration.InlineFragmentOrder.IInlineFragmentOrderClient + { + private readonly global::StrawberryShake.CodeGeneration.CSharp.Integration.InlineFragmentOrder.INotWorkingQueryQuery _notWorkingQuery; + public InlineFragmentOrderClient(global::StrawberryShake.CodeGeneration.CSharp.Integration.InlineFragmentOrder.INotWorkingQueryQuery notWorkingQuery) + { + _notWorkingQuery = notWorkingQuery ?? throw new global::System.ArgumentNullException(nameof(notWorkingQuery)); + } + + public static global::System.String ClientName => "InlineFragmentOrderClient"; + public global::StrawberryShake.CodeGeneration.CSharp.Integration.InlineFragmentOrder.INotWorkingQueryQuery NotWorkingQuery => _notWorkingQuery; + } + + // StrawberryShake.CodeGeneration.CSharp.Generators.ClientInterfaceGenerator + /// + /// Represents the InlineFragmentOrderClient GraphQL client + /// + [global::System.CodeDom.Compiler.GeneratedCode("StrawberryShake", "11.0.0")] + public partial interface IInlineFragmentOrderClient + { + global::StrawberryShake.CodeGeneration.CSharp.Integration.InlineFragmentOrder.INotWorkingQueryQuery NotWorkingQuery { get; } + } +} + +namespace StrawberryShake.CodeGeneration.CSharp.Integration.InlineFragmentOrder.State +{ + // StrawberryShake.CodeGeneration.CSharp.Generators.EntityTypeGenerator + [global::System.CodeDom.Compiler.GeneratedCode("StrawberryShake", "0.0.0.0")] + public partial class PersonEntity + { + public PersonEntity(global::System.Int32 id = default !, global::System.String name = default !, global::StrawberryShake.EntityId? pet = default !) + { + Id = id; + Name = name; + Pet = pet; + } + + public global::System.Int32 Id { get; } + public global::System.String Name { get; } + public global::StrawberryShake.EntityId? Pet { get; } + } + + // StrawberryShake.CodeGeneration.CSharp.Generators.EntityTypeGenerator + [global::System.CodeDom.Compiler.GeneratedCode("StrawberryShake", "0.0.0.0")] + public partial class ShelterEntity + { + public ShelterEntity(global::System.Int32 id = default !, global::System.String location = default !, global::StrawberryShake.EntityId? pet = default !) + { + Id = id; + Location = location; + Pet = pet; + } + + public global::System.Int32 Id { get; } + public global::System.String Location { get; } + public global::StrawberryShake.EntityId? Pet { get; } + } + + // StrawberryShake.CodeGeneration.CSharp.Generators.EntityTypeGenerator + [global::System.CodeDom.Compiler.GeneratedCode("StrawberryShake", "0.0.0.0")] + public partial class DogEntity + { + public DogEntity(global::System.Int32 id = default !, global::System.String __typename = default !, global::System.String breed = default !) + { + Id = id; + this.__typename = __typename; + Breed = breed; + } + + public global::System.Int32 Id { get; } + ///The name of the current Object type at runtime. + public global::System.String __typename { get; } + public global::System.String Breed { get; } + } + + // StrawberryShake.CodeGeneration.CSharp.Generators.EntityTypeGenerator + [global::System.CodeDom.Compiler.GeneratedCode("StrawberryShake", "0.0.0.0")] + public partial class CatEntity + { + public CatEntity(global::System.Int32 id = default !, global::System.String __typename = default !, global::System.String furColor = default !) + { + Id = id; + this.__typename = __typename; + FurColor = furColor; + } + + public global::System.Int32 Id { get; } + ///The name of the current Object type at runtime. + public global::System.String __typename { get; } + public global::System.String FurColor { get; } + } + + // StrawberryShake.CodeGeneration.CSharp.Generators.EntityTypeGenerator + [global::System.CodeDom.Compiler.GeneratedCode("StrawberryShake", "0.0.0.0")] + public partial class BirdEntity + { + public BirdEntity(global::System.Int32 id = default !, global::System.String __typename = default !, global::System.Int32 wingSpan = default !) + { + Id = id; + this.__typename = __typename; + WingSpan = wingSpan; + } + + public global::System.Int32 Id { get; } + ///The name of the current Object type at runtime. + public global::System.String __typename { get; } + public global::System.Int32 WingSpan { get; } + } + + // StrawberryShake.CodeGeneration.CSharp.Generators.ResultDataFactoryGenerator + [global::System.CodeDom.Compiler.GeneratedCode("StrawberryShake", "11.0.0")] + public partial class NotWorkingQueryResultFactory : global::StrawberryShake.IOperationResultDataFactory + { + private readonly global::StrawberryShake.IEntityStore _entityStore; + private readonly global::StrawberryShake.IEntityMapper _notWorkingQuery_People_PersonFromPersonEntityMapper; + private readonly global::StrawberryShake.IEntityMapper _notWorkingQuery_Shelters_ShelterFromShelterEntityMapper; + public NotWorkingQueryResultFactory(global::StrawberryShake.IEntityStore entityStore, global::StrawberryShake.IEntityMapper notWorkingQuery_People_PersonFromPersonEntityMapper, global::StrawberryShake.IEntityMapper notWorkingQuery_Shelters_ShelterFromShelterEntityMapper) + { + _entityStore = entityStore ?? throw new global::System.ArgumentNullException(nameof(entityStore)); + _notWorkingQuery_People_PersonFromPersonEntityMapper = notWorkingQuery_People_PersonFromPersonEntityMapper ?? throw new global::System.ArgumentNullException(nameof(notWorkingQuery_People_PersonFromPersonEntityMapper)); + _notWorkingQuery_Shelters_ShelterFromShelterEntityMapper = notWorkingQuery_Shelters_ShelterFromShelterEntityMapper ?? throw new global::System.ArgumentNullException(nameof(notWorkingQuery_Shelters_ShelterFromShelterEntityMapper)); + } + + global::System.Type global::StrawberryShake.IOperationResultDataFactory.ResultType => typeof(global::StrawberryShake.CodeGeneration.CSharp.Integration.InlineFragmentOrder.INotWorkingQueryResult); + + public NotWorkingQueryResult Create(global::StrawberryShake.IOperationResultDataInfo dataInfo, global::StrawberryShake.IEntityStoreSnapshot? snapshot = null) + { + if (snapshot is null) + { + snapshot = _entityStore.CurrentSnapshot; + } + + if (dataInfo is NotWorkingQueryResultInfo info) + { + return new NotWorkingQueryResult(MapNonNullableINotWorkingQuery_PeopleNonNullableArray(info.People, snapshot), MapNonNullableINotWorkingQuery_SheltersNonNullableArray(info.Shelters, snapshot)); + } + + throw new global::System.ArgumentException("NotWorkingQueryResultInfo expected."); + } + + private global::System.Collections.Generic.IReadOnlyList MapNonNullableINotWorkingQuery_PeopleNonNullableArray(global::System.Collections.Generic.IReadOnlyList? list, global::StrawberryShake.IEntityStoreSnapshot snapshot) + { + if (list is null) + { + throw new global::System.ArgumentNullException(); + } + + var persons = new global::System.Collections.Generic.List(); + foreach (global::StrawberryShake.EntityId child in list) + { + persons.Add(MapNonNullableINotWorkingQuery_People(child, snapshot)); + } + + return persons; + } + + private global::StrawberryShake.CodeGeneration.CSharp.Integration.InlineFragmentOrder.INotWorkingQuery_People MapNonNullableINotWorkingQuery_People(global::StrawberryShake.EntityId entityId, global::StrawberryShake.IEntityStoreSnapshot snapshot) + { + if (entityId.Name.Equals("Person", global::System.StringComparison.Ordinal)) + { + return _notWorkingQuery_People_PersonFromPersonEntityMapper.Map(snapshot.GetEntity(entityId) ?? throw new global::StrawberryShake.GraphQLClientException()); + } + + throw new global::System.NotSupportedException(); + } + + private global::System.Collections.Generic.IReadOnlyList MapNonNullableINotWorkingQuery_SheltersNonNullableArray(global::System.Collections.Generic.IReadOnlyList? list, global::StrawberryShake.IEntityStoreSnapshot snapshot) + { + if (list is null) + { + throw new global::System.ArgumentNullException(); + } + + var shelters = new global::System.Collections.Generic.List(); + foreach (global::StrawberryShake.EntityId child in list) + { + shelters.Add(MapNonNullableINotWorkingQuery_Shelters(child, snapshot)); + } + + return shelters; + } + + private global::StrawberryShake.CodeGeneration.CSharp.Integration.InlineFragmentOrder.INotWorkingQuery_Shelters MapNonNullableINotWorkingQuery_Shelters(global::StrawberryShake.EntityId entityId, global::StrawberryShake.IEntityStoreSnapshot snapshot) + { + if (entityId.Name.Equals("Shelter", global::System.StringComparison.Ordinal)) + { + return _notWorkingQuery_Shelters_ShelterFromShelterEntityMapper.Map(snapshot.GetEntity(entityId) ?? throw new global::StrawberryShake.GraphQLClientException()); + } + + throw new global::System.NotSupportedException(); + } + + global::System.Object global::StrawberryShake.IOperationResultDataFactory.Create(global::StrawberryShake.IOperationResultDataInfo dataInfo, global::StrawberryShake.IEntityStoreSnapshot? snapshot) + { + return Create(dataInfo, snapshot); + } + } + + // StrawberryShake.CodeGeneration.CSharp.Generators.ResultInfoGenerator + [global::System.CodeDom.Compiler.GeneratedCode("StrawberryShake", "11.0.0")] + public partial class NotWorkingQueryResultInfo : global::StrawberryShake.IOperationResultDataInfo + { + private readonly global::System.Collections.Generic.IReadOnlyCollection _entityIds; + private readonly global::System.UInt64 _version; + public NotWorkingQueryResultInfo(global::System.Collections.Generic.IReadOnlyList people, global::System.Collections.Generic.IReadOnlyList shelters, global::System.Collections.Generic.IReadOnlyCollection entityIds, global::System.UInt64 version) + { + People = people; + Shelters = shelters; + _entityIds = entityIds ?? throw new global::System.ArgumentNullException(nameof(entityIds)); + _version = version; + } + + public global::System.Collections.Generic.IReadOnlyList People { get; } + public global::System.Collections.Generic.IReadOnlyList Shelters { get; } + public global::System.Collections.Generic.IReadOnlyCollection EntityIds => _entityIds; + public global::System.UInt64 Version => _version; + + public global::StrawberryShake.IOperationResultDataInfo WithVersion(global::System.UInt64 version) + { + return new NotWorkingQueryResultInfo(People, Shelters, _entityIds, version); + } + } + + // StrawberryShake.CodeGeneration.CSharp.Generators.JsonResultBuilderGenerator + [global::System.CodeDom.Compiler.GeneratedCode("StrawberryShake", "11.0.0")] + public partial class NotWorkingQueryBuilder : global::StrawberryShake.OperationResultBuilder + { + private readonly global::StrawberryShake.IEntityStore _entityStore; + private readonly global::StrawberryShake.IEntityIdSerializer _idSerializer; + private readonly global::StrawberryShake.Serialization.ILeafValueParser _intParser; + private readonly global::StrawberryShake.Serialization.ILeafValueParser _stringParser; + public NotWorkingQueryBuilder(global::StrawberryShake.IEntityStore entityStore, global::StrawberryShake.IEntityIdSerializer idSerializer, global::StrawberryShake.IOperationResultDataFactory resultDataFactory, global::StrawberryShake.Serialization.ISerializerResolver serializerResolver) + { + _entityStore = entityStore ?? throw new global::System.ArgumentNullException(nameof(entityStore)); + _idSerializer = idSerializer ?? throw new global::System.ArgumentNullException(nameof(idSerializer)); + ResultDataFactory = resultDataFactory ?? throw new global::System.ArgumentNullException(nameof(resultDataFactory)); + _intParser = serializerResolver.GetLeafValueParser("Int") ?? throw new global::System.ArgumentException("No serializer for type `Int` found."); + _stringParser = serializerResolver.GetLeafValueParser("String") ?? throw new global::System.ArgumentException("No serializer for type `String` found."); + } + + protected override global::StrawberryShake.IOperationResultDataFactory ResultDataFactory { get; } + + protected override global::StrawberryShake.IOperationResultDataInfo BuildData(global::System.Text.Json.JsonElement obj) + { + var entityIds = new global::System.Collections.Generic.HashSet(); + global::StrawberryShake.IEntityStoreSnapshot snapshot = default !; + global::System.Collections.Generic.IReadOnlyList peopleId = default !; + global::System.Collections.Generic.IReadOnlyList sheltersId = default !; + _entityStore.Update(session => + { + peopleId = Update_NonNullableINotWorkingQuery_PeopleEntityNonNullableArray(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "people"), entityIds); + sheltersId = Update_NonNullableINotWorkingQuery_SheltersEntityNonNullableArray(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "shelters"), entityIds); + snapshot = session.CurrentSnapshot; + }); + return new NotWorkingQueryResultInfo(peopleId, sheltersId, entityIds, snapshot.Version); + } + + private global::System.Collections.Generic.IReadOnlyList Update_NonNullableINotWorkingQuery_PeopleEntityNonNullableArray(global::StrawberryShake.IEntityStoreUpdateSession session, global::System.Text.Json.JsonElement? obj, global::System.Collections.Generic.ISet entityIds) + { + if (!obj.HasValue) + { + throw new global::System.ArgumentNullException(); + } + + if (obj.Value.ValueKind == global::System.Text.Json.JsonValueKind.Null) + { + throw new global::System.ArgumentNullException(); + } + + var persons = new global::System.Collections.Generic.List(); + foreach (global::System.Text.Json.JsonElement child in obj.Value.EnumerateArray()) + { + persons.Add(Update_NonNullableINotWorkingQuery_PeopleEntity(session, child, entityIds)); + } + + return persons; + } + + private global::StrawberryShake.EntityId Update_NonNullableINotWorkingQuery_PeopleEntity(global::StrawberryShake.IEntityStoreUpdateSession session, global::System.Text.Json.JsonElement? obj, global::System.Collections.Generic.ISet entityIds) + { + if (!obj.HasValue) + { + throw new global::System.ArgumentNullException(); + } + + if (obj.Value.ValueKind == global::System.Text.Json.JsonValueKind.Null) + { + throw new global::System.ArgumentNullException(); + } + + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); + if (entityId.Name.Equals("Person", global::System.StringComparison.Ordinal)) + { + if (session.CurrentSnapshot.TryGetEntity(entityId, out global::StrawberryShake.CodeGeneration.CSharp.Integration.InlineFragmentOrder.State.PersonEntity? entity)) + { + var arg0 = Deserialize_NonNullableInt32(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")); + var arg1 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + var arg2 = Update_INotWorkingQuery_People_PetEntity(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "pet"), entityIds); + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.InlineFragmentOrder.State.PersonEntity(arg0, arg1, arg2)); + } + else + { + var arg0 = Deserialize_NonNullableInt32(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")); + var arg1 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + var arg2 = Update_INotWorkingQuery_People_PetEntity(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "pet"), entityIds); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.InlineFragmentOrder.State.PersonEntity(arg0, arg1, arg2)); + } + else + { + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.InlineFragmentOrder.State.PersonEntity(arg0, arg1, arg2)); + } + } + + return entityId; + } + + throw new global::System.NotSupportedException(); + } + + private global::System.Int32 Deserialize_NonNullableInt32(global::System.Text.Json.JsonElement? obj) + { + if (!obj.HasValue) + { + throw new global::System.ArgumentNullException(); + } + + if (obj.Value.ValueKind == global::System.Text.Json.JsonValueKind.Null) + { + throw new global::System.ArgumentNullException(); + } + + return _intParser.Parse(obj.Value.GetInt32()!); + } + + private global::System.String Deserialize_NonNullableString(global::System.Text.Json.JsonElement? obj) + { + if (!obj.HasValue) + { + throw new global::System.ArgumentNullException(); + } + + if (obj.Value.ValueKind == global::System.Text.Json.JsonValueKind.Null) + { + throw new global::System.ArgumentNullException(); + } + + return _stringParser.Parse(obj.Value.GetString()!); + } + + private global::StrawberryShake.EntityId? Update_INotWorkingQuery_People_PetEntity(global::StrawberryShake.IEntityStoreUpdateSession session, global::System.Text.Json.JsonElement? obj, global::System.Collections.Generic.ISet entityIds) + { + if (!obj.HasValue) + { + return null; + } + + if (obj.Value.ValueKind == global::System.Text.Json.JsonValueKind.Null) + { + return null; + } + + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); + if (entityId.Name.Equals("Dog", global::System.StringComparison.Ordinal)) + { + if (session.CurrentSnapshot.TryGetEntity(entityId, out global::StrawberryShake.CodeGeneration.CSharp.Integration.InlineFragmentOrder.State.DogEntity? entity)) + { + var arg0 = Deserialize_NonNullableInt32(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")); + var arg1 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "__typename")); + var arg2 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "breed")); + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.InlineFragmentOrder.State.DogEntity(arg0, arg1, arg2)); + } + else + { + var arg0 = Deserialize_NonNullableInt32(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")); + var arg1 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "__typename")); + var arg2 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "breed")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.InlineFragmentOrder.State.DogEntity(arg0, arg1, arg2)); + } + else + { + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.InlineFragmentOrder.State.DogEntity(arg0, arg1, arg2)); + } + } + + return entityId; + } + + if (entityId.Name.Equals("Cat", global::System.StringComparison.Ordinal)) + { + if (session.CurrentSnapshot.TryGetEntity(entityId, out global::StrawberryShake.CodeGeneration.CSharp.Integration.InlineFragmentOrder.State.CatEntity? entity)) + { + var arg0 = Deserialize_NonNullableInt32(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")); + var arg1 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "__typename")); + var arg2 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "furColor")); + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.InlineFragmentOrder.State.CatEntity(arg0, arg1, arg2)); + } + else + { + var arg0 = Deserialize_NonNullableInt32(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")); + var arg1 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "__typename")); + var arg2 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "furColor")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.InlineFragmentOrder.State.CatEntity(arg0, arg1, arg2)); + } + else + { + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.InlineFragmentOrder.State.CatEntity(arg0, arg1, arg2)); + } + } + + return entityId; + } + + if (entityId.Name.Equals("Bird", global::System.StringComparison.Ordinal)) + { + if (session.CurrentSnapshot.TryGetEntity(entityId, out global::StrawberryShake.CodeGeneration.CSharp.Integration.InlineFragmentOrder.State.BirdEntity? entity)) + { + var arg0 = Deserialize_NonNullableInt32(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")); + var arg1 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "__typename")); + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.InlineFragmentOrder.State.BirdEntity(arg0, arg1, entity.WingSpan)); + } + else + { + var arg0 = Deserialize_NonNullableInt32(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")); + var arg1 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "__typename")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.InlineFragmentOrder.State.BirdEntity(arg0, arg1, entity.WingSpan)); + } + else + { + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.InlineFragmentOrder.State.BirdEntity(arg0, arg1, default !)); + } + } + + return entityId; + } + + throw new global::System.NotSupportedException(); + } + + private global::System.Collections.Generic.IReadOnlyList Update_NonNullableINotWorkingQuery_SheltersEntityNonNullableArray(global::StrawberryShake.IEntityStoreUpdateSession session, global::System.Text.Json.JsonElement? obj, global::System.Collections.Generic.ISet entityIds) + { + if (!obj.HasValue) + { + throw new global::System.ArgumentNullException(); + } + + if (obj.Value.ValueKind == global::System.Text.Json.JsonValueKind.Null) + { + throw new global::System.ArgumentNullException(); + } + + var shelters = new global::System.Collections.Generic.List(); + foreach (global::System.Text.Json.JsonElement child in obj.Value.EnumerateArray()) + { + shelters.Add(Update_NonNullableINotWorkingQuery_SheltersEntity(session, child, entityIds)); + } + + return shelters; + } + + private global::StrawberryShake.EntityId Update_NonNullableINotWorkingQuery_SheltersEntity(global::StrawberryShake.IEntityStoreUpdateSession session, global::System.Text.Json.JsonElement? obj, global::System.Collections.Generic.ISet entityIds) + { + if (!obj.HasValue) + { + throw new global::System.ArgumentNullException(); + } + + if (obj.Value.ValueKind == global::System.Text.Json.JsonValueKind.Null) + { + throw new global::System.ArgumentNullException(); + } + + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); + if (entityId.Name.Equals("Shelter", global::System.StringComparison.Ordinal)) + { + if (session.CurrentSnapshot.TryGetEntity(entityId, out global::StrawberryShake.CodeGeneration.CSharp.Integration.InlineFragmentOrder.State.ShelterEntity? entity)) + { + var arg0 = Deserialize_NonNullableInt32(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")); + var arg1 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "location")); + var arg2 = Update_INotWorkingQuery_Shelters_PetEntity(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "pet"), entityIds); + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.InlineFragmentOrder.State.ShelterEntity(arg0, arg1, arg2)); + } + else + { + var arg0 = Deserialize_NonNullableInt32(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")); + var arg1 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "location")); + var arg2 = Update_INotWorkingQuery_Shelters_PetEntity(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "pet"), entityIds); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.InlineFragmentOrder.State.ShelterEntity(arg0, arg1, arg2)); + } + else + { + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.InlineFragmentOrder.State.ShelterEntity(arg0, arg1, arg2)); + } + } + + return entityId; + } + + throw new global::System.NotSupportedException(); + } + + private global::StrawberryShake.EntityId? Update_INotWorkingQuery_Shelters_PetEntity(global::StrawberryShake.IEntityStoreUpdateSession session, global::System.Text.Json.JsonElement? obj, global::System.Collections.Generic.ISet entityIds) + { + if (!obj.HasValue) + { + return null; + } + + if (obj.Value.ValueKind == global::System.Text.Json.JsonValueKind.Null) + { + return null; + } + + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); + if (entityId.Name.Equals("Dog", global::System.StringComparison.Ordinal)) + { + if (session.CurrentSnapshot.TryGetEntity(entityId, out global::StrawberryShake.CodeGeneration.CSharp.Integration.InlineFragmentOrder.State.DogEntity? entity)) + { + var arg0 = Deserialize_NonNullableInt32(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")); + var arg1 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "__typename")); + var arg2 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "breed")); + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.InlineFragmentOrder.State.DogEntity(arg0, arg1, arg2)); + } + else + { + var arg0 = Deserialize_NonNullableInt32(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")); + var arg1 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "__typename")); + var arg2 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "breed")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.InlineFragmentOrder.State.DogEntity(arg0, arg1, arg2)); + } + else + { + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.InlineFragmentOrder.State.DogEntity(arg0, arg1, arg2)); + } + } + + return entityId; + } + + if (entityId.Name.Equals("Cat", global::System.StringComparison.Ordinal)) + { + if (session.CurrentSnapshot.TryGetEntity(entityId, out global::StrawberryShake.CodeGeneration.CSharp.Integration.InlineFragmentOrder.State.CatEntity? entity)) + { + var arg0 = Deserialize_NonNullableInt32(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")); + var arg1 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "__typename")); + var arg2 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "furColor")); + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.InlineFragmentOrder.State.CatEntity(arg0, arg1, arg2)); + } + else + { + var arg0 = Deserialize_NonNullableInt32(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")); + var arg1 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "__typename")); + var arg2 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "furColor")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.InlineFragmentOrder.State.CatEntity(arg0, arg1, arg2)); + } + else + { + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.InlineFragmentOrder.State.CatEntity(arg0, arg1, arg2)); + } + } + + return entityId; + } + + if (entityId.Name.Equals("Bird", global::System.StringComparison.Ordinal)) + { + if (session.CurrentSnapshot.TryGetEntity(entityId, out global::StrawberryShake.CodeGeneration.CSharp.Integration.InlineFragmentOrder.State.BirdEntity? entity)) + { + var arg0 = Deserialize_NonNullableInt32(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")); + var arg1 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "__typename")); + var arg2 = Deserialize_NonNullableInt32(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "wingSpan")); + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.InlineFragmentOrder.State.BirdEntity(arg0, arg1, arg2)); + } + else + { + var arg0 = Deserialize_NonNullableInt32(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")); + var arg1 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "__typename")); + var arg2 = Deserialize_NonNullableInt32(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "wingSpan")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.InlineFragmentOrder.State.BirdEntity(arg0, arg1, arg2)); + } + else + { + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.InlineFragmentOrder.State.BirdEntity(arg0, arg1, arg2)); + } + } + + return entityId; + } + + throw new global::System.NotSupportedException(); + } + } + + // StrawberryShake.CodeGeneration.CSharp.Generators.ResultFromEntityTypeMapperGenerator + [global::System.CodeDom.Compiler.GeneratedCode("StrawberryShake", "11.0.0")] + public partial class NotWorkingQuery_People_PersonFromPersonEntityMapper : global::StrawberryShake.IEntityMapper + { + private readonly global::StrawberryShake.IEntityStore _entityStore; + private readonly global::StrawberryShake.IEntityMapper _notWorkingQuery_People_Pet_DogFromDogEntityMapper; + private readonly global::StrawberryShake.IEntityMapper _notWorkingQuery_People_Pet_CatFromCatEntityMapper; + private readonly global::StrawberryShake.IEntityMapper _notWorkingQuery_People_Pet_BirdFromBirdEntityMapper; + public NotWorkingQuery_People_PersonFromPersonEntityMapper(global::StrawberryShake.IEntityStore entityStore, global::StrawberryShake.IEntityMapper notWorkingQuery_People_Pet_DogFromDogEntityMapper, global::StrawberryShake.IEntityMapper notWorkingQuery_People_Pet_CatFromCatEntityMapper, global::StrawberryShake.IEntityMapper notWorkingQuery_People_Pet_BirdFromBirdEntityMapper) + { + _entityStore = entityStore ?? throw new global::System.ArgumentNullException(nameof(entityStore)); + _notWorkingQuery_People_Pet_DogFromDogEntityMapper = notWorkingQuery_People_Pet_DogFromDogEntityMapper ?? throw new global::System.ArgumentNullException(nameof(notWorkingQuery_People_Pet_DogFromDogEntityMapper)); + _notWorkingQuery_People_Pet_CatFromCatEntityMapper = notWorkingQuery_People_Pet_CatFromCatEntityMapper ?? throw new global::System.ArgumentNullException(nameof(notWorkingQuery_People_Pet_CatFromCatEntityMapper)); + _notWorkingQuery_People_Pet_BirdFromBirdEntityMapper = notWorkingQuery_People_Pet_BirdFromBirdEntityMapper ?? throw new global::System.ArgumentNullException(nameof(notWorkingQuery_People_Pet_BirdFromBirdEntityMapper)); + } + + public NotWorkingQuery_People_Person Map(global::StrawberryShake.CodeGeneration.CSharp.Integration.InlineFragmentOrder.State.PersonEntity entity, global::StrawberryShake.IEntityStoreSnapshot? snapshot = null) + { + if (snapshot is null) + { + snapshot = _entityStore.CurrentSnapshot; + } + + return new NotWorkingQuery_People_Person(entity.Id, entity.Name, MapINotWorkingQuery_People_Pet(entity.Pet, snapshot)); + } + + private global::StrawberryShake.CodeGeneration.CSharp.Integration.InlineFragmentOrder.INotWorkingQuery_People_Pet? MapINotWorkingQuery_People_Pet(global::StrawberryShake.EntityId? entityId, global::StrawberryShake.IEntityStoreSnapshot snapshot) + { + if (entityId is null) + { + return null; + } + + if (entityId.Value.Name.Equals("Dog", global::System.StringComparison.Ordinal)) + { + return _notWorkingQuery_People_Pet_DogFromDogEntityMapper.Map(snapshot.GetEntity(entityId.Value) ?? throw new global::StrawberryShake.GraphQLClientException()); + } + + if (entityId.Value.Name.Equals("Cat", global::System.StringComparison.Ordinal)) + { + return _notWorkingQuery_People_Pet_CatFromCatEntityMapper.Map(snapshot.GetEntity(entityId.Value) ?? throw new global::StrawberryShake.GraphQLClientException()); + } + + if (entityId.Value.Name.Equals("Bird", global::System.StringComparison.Ordinal)) + { + return _notWorkingQuery_People_Pet_BirdFromBirdEntityMapper.Map(snapshot.GetEntity(entityId.Value) ?? throw new global::StrawberryShake.GraphQLClientException()); + } + + throw new global::System.NotSupportedException(); + } + } + + // StrawberryShake.CodeGeneration.CSharp.Generators.ResultFromEntityTypeMapperGenerator + [global::System.CodeDom.Compiler.GeneratedCode("StrawberryShake", "11.0.0")] + public partial class NotWorkingQuery_Shelters_ShelterFromShelterEntityMapper : global::StrawberryShake.IEntityMapper + { + private readonly global::StrawberryShake.IEntityStore _entityStore; + private readonly global::StrawberryShake.IEntityMapper _notWorkingQuery_Shelters_Pet_DogFromDogEntityMapper; + private readonly global::StrawberryShake.IEntityMapper _notWorkingQuery_Shelters_Pet_CatFromCatEntityMapper; + private readonly global::StrawberryShake.IEntityMapper _notWorkingQuery_Shelters_Pet_BirdFromBirdEntityMapper; + public NotWorkingQuery_Shelters_ShelterFromShelterEntityMapper(global::StrawberryShake.IEntityStore entityStore, global::StrawberryShake.IEntityMapper notWorkingQuery_Shelters_Pet_DogFromDogEntityMapper, global::StrawberryShake.IEntityMapper notWorkingQuery_Shelters_Pet_CatFromCatEntityMapper, global::StrawberryShake.IEntityMapper notWorkingQuery_Shelters_Pet_BirdFromBirdEntityMapper) + { + _entityStore = entityStore ?? throw new global::System.ArgumentNullException(nameof(entityStore)); + _notWorkingQuery_Shelters_Pet_DogFromDogEntityMapper = notWorkingQuery_Shelters_Pet_DogFromDogEntityMapper ?? throw new global::System.ArgumentNullException(nameof(notWorkingQuery_Shelters_Pet_DogFromDogEntityMapper)); + _notWorkingQuery_Shelters_Pet_CatFromCatEntityMapper = notWorkingQuery_Shelters_Pet_CatFromCatEntityMapper ?? throw new global::System.ArgumentNullException(nameof(notWorkingQuery_Shelters_Pet_CatFromCatEntityMapper)); + _notWorkingQuery_Shelters_Pet_BirdFromBirdEntityMapper = notWorkingQuery_Shelters_Pet_BirdFromBirdEntityMapper ?? throw new global::System.ArgumentNullException(nameof(notWorkingQuery_Shelters_Pet_BirdFromBirdEntityMapper)); + } + + public NotWorkingQuery_Shelters_Shelter Map(global::StrawberryShake.CodeGeneration.CSharp.Integration.InlineFragmentOrder.State.ShelterEntity entity, global::StrawberryShake.IEntityStoreSnapshot? snapshot = null) + { + if (snapshot is null) + { + snapshot = _entityStore.CurrentSnapshot; + } + + return new NotWorkingQuery_Shelters_Shelter(entity.Id, entity.Location, MapINotWorkingQuery_Shelters_Pet(entity.Pet, snapshot)); + } + + private global::StrawberryShake.CodeGeneration.CSharp.Integration.InlineFragmentOrder.INotWorkingQuery_Shelters_Pet? MapINotWorkingQuery_Shelters_Pet(global::StrawberryShake.EntityId? entityId, global::StrawberryShake.IEntityStoreSnapshot snapshot) + { + if (entityId is null) + { + return null; + } + + if (entityId.Value.Name.Equals("Dog", global::System.StringComparison.Ordinal)) + { + return _notWorkingQuery_Shelters_Pet_DogFromDogEntityMapper.Map(snapshot.GetEntity(entityId.Value) ?? throw new global::StrawberryShake.GraphQLClientException()); + } + + if (entityId.Value.Name.Equals("Cat", global::System.StringComparison.Ordinal)) + { + return _notWorkingQuery_Shelters_Pet_CatFromCatEntityMapper.Map(snapshot.GetEntity(entityId.Value) ?? throw new global::StrawberryShake.GraphQLClientException()); + } + + if (entityId.Value.Name.Equals("Bird", global::System.StringComparison.Ordinal)) + { + return _notWorkingQuery_Shelters_Pet_BirdFromBirdEntityMapper.Map(snapshot.GetEntity(entityId.Value) ?? throw new global::StrawberryShake.GraphQLClientException()); + } + + throw new global::System.NotSupportedException(); + } + } + + // StrawberryShake.CodeGeneration.CSharp.Generators.ResultFromEntityTypeMapperGenerator + [global::System.CodeDom.Compiler.GeneratedCode("StrawberryShake", "11.0.0")] + public partial class NotWorkingQuery_People_Pet_DogFromDogEntityMapper : global::StrawberryShake.IEntityMapper + { + private readonly global::StrawberryShake.IEntityStore _entityStore; + public NotWorkingQuery_People_Pet_DogFromDogEntityMapper(global::StrawberryShake.IEntityStore entityStore) + { + _entityStore = entityStore ?? throw new global::System.ArgumentNullException(nameof(entityStore)); + } + + public NotWorkingQuery_People_Pet_Dog Map(global::StrawberryShake.CodeGeneration.CSharp.Integration.InlineFragmentOrder.State.DogEntity entity, global::StrawberryShake.IEntityStoreSnapshot? snapshot = null) + { + if (snapshot is null) + { + snapshot = _entityStore.CurrentSnapshot; + } + + return new NotWorkingQuery_People_Pet_Dog(entity.Id, entity.__typename, entity.Breed); + } + } + + // StrawberryShake.CodeGeneration.CSharp.Generators.ResultFromEntityTypeMapperGenerator + [global::System.CodeDom.Compiler.GeneratedCode("StrawberryShake", "11.0.0")] + public partial class NotWorkingQuery_People_Pet_CatFromCatEntityMapper : global::StrawberryShake.IEntityMapper + { + private readonly global::StrawberryShake.IEntityStore _entityStore; + public NotWorkingQuery_People_Pet_CatFromCatEntityMapper(global::StrawberryShake.IEntityStore entityStore) + { + _entityStore = entityStore ?? throw new global::System.ArgumentNullException(nameof(entityStore)); + } + + public NotWorkingQuery_People_Pet_Cat Map(global::StrawberryShake.CodeGeneration.CSharp.Integration.InlineFragmentOrder.State.CatEntity entity, global::StrawberryShake.IEntityStoreSnapshot? snapshot = null) + { + if (snapshot is null) + { + snapshot = _entityStore.CurrentSnapshot; + } + + return new NotWorkingQuery_People_Pet_Cat(entity.Id, entity.__typename, entity.FurColor); + } + } + + // StrawberryShake.CodeGeneration.CSharp.Generators.ResultFromEntityTypeMapperGenerator + [global::System.CodeDom.Compiler.GeneratedCode("StrawberryShake", "11.0.0")] + public partial class NotWorkingQuery_People_Pet_BirdFromBirdEntityMapper : global::StrawberryShake.IEntityMapper + { + private readonly global::StrawberryShake.IEntityStore _entityStore; + public NotWorkingQuery_People_Pet_BirdFromBirdEntityMapper(global::StrawberryShake.IEntityStore entityStore) + { + _entityStore = entityStore ?? throw new global::System.ArgumentNullException(nameof(entityStore)); + } + + public NotWorkingQuery_People_Pet_Bird Map(global::StrawberryShake.CodeGeneration.CSharp.Integration.InlineFragmentOrder.State.BirdEntity entity, global::StrawberryShake.IEntityStoreSnapshot? snapshot = null) + { + if (snapshot is null) + { + snapshot = _entityStore.CurrentSnapshot; + } + + return new NotWorkingQuery_People_Pet_Bird(entity.Id, entity.__typename); + } + } + + // StrawberryShake.CodeGeneration.CSharp.Generators.ResultFromEntityTypeMapperGenerator + [global::System.CodeDom.Compiler.GeneratedCode("StrawberryShake", "11.0.0")] + public partial class NotWorkingQuery_Shelters_Pet_DogFromDogEntityMapper : global::StrawberryShake.IEntityMapper + { + private readonly global::StrawberryShake.IEntityStore _entityStore; + public NotWorkingQuery_Shelters_Pet_DogFromDogEntityMapper(global::StrawberryShake.IEntityStore entityStore) + { + _entityStore = entityStore ?? throw new global::System.ArgumentNullException(nameof(entityStore)); + } + + public NotWorkingQuery_Shelters_Pet_Dog Map(global::StrawberryShake.CodeGeneration.CSharp.Integration.InlineFragmentOrder.State.DogEntity entity, global::StrawberryShake.IEntityStoreSnapshot? snapshot = null) + { + if (snapshot is null) + { + snapshot = _entityStore.CurrentSnapshot; + } + + return new NotWorkingQuery_Shelters_Pet_Dog(entity.Id, entity.__typename, entity.Breed); + } + } + + // StrawberryShake.CodeGeneration.CSharp.Generators.ResultFromEntityTypeMapperGenerator + [global::System.CodeDom.Compiler.GeneratedCode("StrawberryShake", "11.0.0")] + public partial class NotWorkingQuery_Shelters_Pet_CatFromCatEntityMapper : global::StrawberryShake.IEntityMapper + { + private readonly global::StrawberryShake.IEntityStore _entityStore; + public NotWorkingQuery_Shelters_Pet_CatFromCatEntityMapper(global::StrawberryShake.IEntityStore entityStore) + { + _entityStore = entityStore ?? throw new global::System.ArgumentNullException(nameof(entityStore)); + } + + public NotWorkingQuery_Shelters_Pet_Cat Map(global::StrawberryShake.CodeGeneration.CSharp.Integration.InlineFragmentOrder.State.CatEntity entity, global::StrawberryShake.IEntityStoreSnapshot? snapshot = null) + { + if (snapshot is null) + { + snapshot = _entityStore.CurrentSnapshot; + } + + return new NotWorkingQuery_Shelters_Pet_Cat(entity.Id, entity.__typename, entity.FurColor); + } + } + + // StrawberryShake.CodeGeneration.CSharp.Generators.ResultFromEntityTypeMapperGenerator + [global::System.CodeDom.Compiler.GeneratedCode("StrawberryShake", "11.0.0")] + public partial class NotWorkingQuery_Shelters_Pet_BirdFromBirdEntityMapper : global::StrawberryShake.IEntityMapper + { + private readonly global::StrawberryShake.IEntityStore _entityStore; + public NotWorkingQuery_Shelters_Pet_BirdFromBirdEntityMapper(global::StrawberryShake.IEntityStore entityStore) + { + _entityStore = entityStore ?? throw new global::System.ArgumentNullException(nameof(entityStore)); + } + + public NotWorkingQuery_Shelters_Pet_Bird Map(global::StrawberryShake.CodeGeneration.CSharp.Integration.InlineFragmentOrder.State.BirdEntity entity, global::StrawberryShake.IEntityStoreSnapshot? snapshot = null) + { + if (snapshot is null) + { + snapshot = _entityStore.CurrentSnapshot; + } + + return new NotWorkingQuery_Shelters_Pet_Bird(entity.Id, entity.__typename, entity.WingSpan); + } + } + + // StrawberryShake.CodeGeneration.CSharp.Generators.EntityIdFactoryGenerator + [global::System.CodeDom.Compiler.GeneratedCode("StrawberryShake", "11.0.0")] + public partial class InlineFragmentOrderClientEntityIdFactory : global::StrawberryShake.IEntityIdSerializer + { + private static readonly global::System.Text.Json.JsonWriterOptions _options = new global::System.Text.Json.JsonWriterOptions() + { + Indented = false + }; + public global::StrawberryShake.EntityId Parse(global::System.Text.Json.JsonElement obj) + { + global::System.String __typename = obj.GetProperty("__typename").GetString()!; + return __typename switch + { + "Person" => ParsePersonEntityId(obj, __typename), + "Shelter" => ParseShelterEntityId(obj, __typename), + "Dog" => ParseDogEntityId(obj, __typename), + "Cat" => ParseCatEntityId(obj, __typename), + "Bird" => ParseBirdEntityId(obj, __typename), + _ => throw new global::System.NotSupportedException()}; + } + + public global::System.String Format(global::StrawberryShake.EntityId entityId) + { + return entityId.Name switch + { + "Person" => FormatPersonEntityId(entityId), + "Shelter" => FormatShelterEntityId(entityId), + "Dog" => FormatDogEntityId(entityId), + "Cat" => FormatCatEntityId(entityId), + "Bird" => FormatBirdEntityId(entityId), + _ => throw new global::System.NotSupportedException()}; + } + + private global::StrawberryShake.EntityId ParsePersonEntityId(global::System.Text.Json.JsonElement obj, global::System.String type) + { + return new global::StrawberryShake.EntityId(type, obj.GetProperty("id").GetInt32()!); + } + + private global::System.String FormatPersonEntityId(global::StrawberryShake.EntityId entityId) + { + using var writer = new global::StrawberryShake.Internal.ArrayWriter(); + using var jsonWriter = new global::System.Text.Json.Utf8JsonWriter(writer, _options); + jsonWriter.WriteStartObject(); + jsonWriter.WriteString("__typename", entityId.Name); + jsonWriter.WriteNumber("id", (global::System.Int32)entityId.Value); + jsonWriter.WriteEndObject(); + jsonWriter.Flush(); + return global::System.Text.Encoding.UTF8.GetString(writer.GetInternalBuffer(), 0, writer.Length); + } + + private global::StrawberryShake.EntityId ParseShelterEntityId(global::System.Text.Json.JsonElement obj, global::System.String type) + { + return new global::StrawberryShake.EntityId(type, obj.GetProperty("id").GetInt32()!); + } + + private global::System.String FormatShelterEntityId(global::StrawberryShake.EntityId entityId) + { + using var writer = new global::StrawberryShake.Internal.ArrayWriter(); + using var jsonWriter = new global::System.Text.Json.Utf8JsonWriter(writer, _options); + jsonWriter.WriteStartObject(); + jsonWriter.WriteString("__typename", entityId.Name); + jsonWriter.WriteNumber("id", (global::System.Int32)entityId.Value); + jsonWriter.WriteEndObject(); + jsonWriter.Flush(); + return global::System.Text.Encoding.UTF8.GetString(writer.GetInternalBuffer(), 0, writer.Length); + } + + private global::StrawberryShake.EntityId ParseDogEntityId(global::System.Text.Json.JsonElement obj, global::System.String type) + { + return new global::StrawberryShake.EntityId(type, obj.GetProperty("id").GetInt32()!); + } + + private global::System.String FormatDogEntityId(global::StrawberryShake.EntityId entityId) + { + using var writer = new global::StrawberryShake.Internal.ArrayWriter(); + using var jsonWriter = new global::System.Text.Json.Utf8JsonWriter(writer, _options); + jsonWriter.WriteStartObject(); + jsonWriter.WriteString("__typename", entityId.Name); + jsonWriter.WriteNumber("id", (global::System.Int32)entityId.Value); + jsonWriter.WriteEndObject(); + jsonWriter.Flush(); + return global::System.Text.Encoding.UTF8.GetString(writer.GetInternalBuffer(), 0, writer.Length); + } + + private global::StrawberryShake.EntityId ParseCatEntityId(global::System.Text.Json.JsonElement obj, global::System.String type) + { + return new global::StrawberryShake.EntityId(type, obj.GetProperty("id").GetInt32()!); + } + + private global::System.String FormatCatEntityId(global::StrawberryShake.EntityId entityId) + { + using var writer = new global::StrawberryShake.Internal.ArrayWriter(); + using var jsonWriter = new global::System.Text.Json.Utf8JsonWriter(writer, _options); + jsonWriter.WriteStartObject(); + jsonWriter.WriteString("__typename", entityId.Name); + jsonWriter.WriteNumber("id", (global::System.Int32)entityId.Value); + jsonWriter.WriteEndObject(); + jsonWriter.Flush(); + return global::System.Text.Encoding.UTF8.GetString(writer.GetInternalBuffer(), 0, writer.Length); + } + + private global::StrawberryShake.EntityId ParseBirdEntityId(global::System.Text.Json.JsonElement obj, global::System.String type) + { + return new global::StrawberryShake.EntityId(type, obj.GetProperty("id").GetInt32()!); + } + + private global::System.String FormatBirdEntityId(global::StrawberryShake.EntityId entityId) + { + using var writer = new global::StrawberryShake.Internal.ArrayWriter(); + using var jsonWriter = new global::System.Text.Json.Utf8JsonWriter(writer, _options); + jsonWriter.WriteStartObject(); + jsonWriter.WriteString("__typename", entityId.Name); + jsonWriter.WriteNumber("id", (global::System.Int32)entityId.Value); + jsonWriter.WriteEndObject(); + jsonWriter.Flush(); + return global::System.Text.Encoding.UTF8.GetString(writer.GetInternalBuffer(), 0, writer.Length); + } + } + + // StrawberryShake.CodeGeneration.CSharp.Generators.StoreAccessorGenerator + [global::System.CodeDom.Compiler.GeneratedCode("StrawberryShake", "11.0.0")] + public partial class InlineFragmentOrderClientStoreAccessor : global::StrawberryShake.StoreAccessor + { + public InlineFragmentOrderClientStoreAccessor(global::StrawberryShake.IOperationStore operationStore, global::StrawberryShake.IEntityStore entityStore, global::StrawberryShake.IEntityIdSerializer entityIdSerializer, global::System.Collections.Generic.IEnumerable requestFactories, global::System.Collections.Generic.IEnumerable resultDataFactories) : base(operationStore, entityStore, entityIdSerializer, requestFactories, resultDataFactories) + { + } + } +} + + diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/InlineFragmentOrderTest.cs b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/InlineFragmentOrderTest.cs new file mode 100644 index 00000000000..0c306f4dff7 --- /dev/null +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/InlineFragmentOrderTest.cs @@ -0,0 +1,104 @@ +using HotChocolate.AspNetCore.Tests.Utilities; +using HotChocolate.Types; +using Microsoft.Extensions.DependencyInjection; + +namespace StrawberryShake.CodeGeneration.CSharp.Integration.InlineFragmentOrder; + +public class InlineFragmentOrderTest : ServerTestBase +{ + public InlineFragmentOrderTest(TestServerFactory serverFactory) : base(serverFactory) + { + } + + [Fact] + public async Task Execute_InlineFragmentOrder_Should_Map_Bird_When_Fragment_Only_In_Second_Field() + { + // arrange + // The query requests the Bird inline fragment only under "shelters" (the second + // top-level field). "people" is processed first and omits the Bird fragment. + // The first shelter's pet is a Bird, so its WingSpan must survive deserialization. + var ct = new CancellationTokenSource(20_000).Token; + var serviceCollection = new ServiceCollection(); + serviceCollection + .AddGraphQLServer() + .AddQueryType() + .AddType() + .AddType() + .AddType() + .AddType(); + serviceCollection.AddInlineFragmentOrderClient().ConfigureInMemoryClient(); + IServiceProvider services = serviceCollection.BuildServiceProvider(); + var client = services.GetRequiredService(); + + // act + var result = await client.NotWorkingQuery.ExecuteAsync(ct); + + // assert + result.EnsureNoErrors(); + var firstShelterPet = + Assert.IsType( + result.Data!.Shelters[0].Pet, + exactMatch: false); + Assert.Equal(42, firstShelterPet.WingSpan); + } + + public class Query + { + public Person[] GetPeople() => + [ + new Person { Id = 1, Name = "Alice", Pet = new Dog { Id = 101, Breed = "Bulldog" } }, + new Person { Id = 2, Name = "Bob", Pet = new Cat { Id = 102, FurColor = "Black" } } + ]; + + public Shelter[] GetShelters() => + [ + new Shelter { Id = 1, Location = "Downtown", Pet = new Bird { Id = 201, WingSpan = 42 } }, + new Shelter { Id = 2, Location = "Uptown", Pet = new Dog { Id = 202, Breed = "Labrador" } } + ]; + } + + [InterfaceType("IPet")] + public interface IPet + { + int Id { get; } + } + + public class Dog : IPet + { + public int Id { get; set; } + + public string Breed { get; set; } = null!; + } + + public class Cat : IPet + { + public int Id { get; set; } + + public string FurColor { get; set; } = null!; + } + + public class Bird : IPet + { + public int Id { get; set; } + + public int WingSpan { get; set; } + } + + public class Person + { + public int Id { get; set; } + + public string Name { get; set; } = null!; + + public IPet? Pet { get; set; } + } + + public class Shelter + { + public int Id { get; set; } + + public string Location { get; set; } = null!; + + public IPet? Pet { get; set; } + } +} diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/MultiProfileTest.Client.cs b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/MultiProfileTest.Client.cs index a2488ca3500..def40d77b44 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/MultiProfileTest.Client.cs +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/MultiProfileTest.Client.cs @@ -1,4 +1,4 @@ -// ReSharper disable ArrangeObjectCreationWhenTypeEvident +// ReSharper disable ArrangeObjectCreationWhenTypeEvident // ReSharper disable BuiltInTypeReferenceStyle // ReSharper disable ConvertToAutoProperty // ReSharper disable InconsistentNaming @@ -2003,11 +2003,22 @@ public GetHeroBuilder(global::StrawberryShake.IEntityStore entityStore, global:: { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::StrawberryShake.CodeGeneration.CSharp.Integration.MultiProfile.State.DroidEntity? entity)) { - session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.MultiProfile.State.DroidEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_IGetHero_Hero_Friends(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "friends"), entityIds))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + var arg1 = Deserialize_IGetHero_Hero_Friends(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "friends"), entityIds); + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.MultiProfile.State.DroidEntity(arg0, arg1)); } else { - session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.MultiProfile.State.DroidEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_IGetHero_Hero_Friends(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "friends"), entityIds))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + var arg1 = Deserialize_IGetHero_Hero_Friends(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "friends"), entityIds); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.MultiProfile.State.DroidEntity(arg0, arg1)); + } + else + { + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.MultiProfile.State.DroidEntity(arg0, arg1)); + } } return entityId; @@ -2017,11 +2028,22 @@ public GetHeroBuilder(global::StrawberryShake.IEntityStore entityStore, global:: { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::StrawberryShake.CodeGeneration.CSharp.Integration.MultiProfile.State.HumanEntity? entity)) { - session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.MultiProfile.State.HumanEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_IGetHero_Hero_Friends(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "friends"), entityIds))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + var arg1 = Deserialize_IGetHero_Hero_Friends(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "friends"), entityIds); + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.MultiProfile.State.HumanEntity(arg0, arg1)); } else { - session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.MultiProfile.State.HumanEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_IGetHero_Hero_Friends(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "friends"), entityIds))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + var arg1 = Deserialize_IGetHero_Hero_Friends(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "friends"), entityIds); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.MultiProfile.State.HumanEntity(arg0, arg1)); + } + else + { + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.MultiProfile.State.HumanEntity(arg0, arg1)); + } } return entityId; @@ -2105,11 +2127,20 @@ public GetHeroBuilder(global::StrawberryShake.IEntityStore entityStore, global:: { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::StrawberryShake.CodeGeneration.CSharp.Integration.MultiProfile.State.DroidEntity? entity)) { - session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.MultiProfile.State.DroidEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), entity.Friends)); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.MultiProfile.State.DroidEntity(arg0, entity.Friends)); } else { - session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.MultiProfile.State.DroidEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), default !)); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.MultiProfile.State.DroidEntity(arg0, entity.Friends)); + } + else + { + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.MultiProfile.State.DroidEntity(arg0, default !)); + } } return entityId; @@ -2119,11 +2150,20 @@ public GetHeroBuilder(global::StrawberryShake.IEntityStore entityStore, global:: { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::StrawberryShake.CodeGeneration.CSharp.Integration.MultiProfile.State.HumanEntity? entity)) { - session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.MultiProfile.State.HumanEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), entity.Friends)); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.MultiProfile.State.HumanEntity(arg0, entity.Friends)); } else { - session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.MultiProfile.State.HumanEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), default !)); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.MultiProfile.State.HumanEntity(arg0, entity.Friends)); + } + else + { + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.MultiProfile.State.HumanEntity(arg0, default !)); + } } return entityId; diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/RecursiveEntitySelfReferenceTest.Client.cs b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/RecursiveEntitySelfReferenceTest.Client.cs new file mode 100644 index 00000000000..55bd9cb27aa --- /dev/null +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/RecursiveEntitySelfReferenceTest.Client.cs @@ -0,0 +1,923 @@ +// ReSharper disable ArrangeObjectCreationWhenTypeEvident +// ReSharper disable BuiltInTypeReferenceStyle +// ReSharper disable ConvertToAutoProperty +// ReSharper disable InconsistentNaming +// ReSharper disable PartialTypeWithSinglePart +// ReSharper disable PreferConcreteValueOverDefault +// ReSharper disable RedundantNameQualifier +// ReSharper disable SuggestVarOrType_SimpleTypes +// ReSharper disable UnusedMember.Global +// ReSharper disable UnusedMethodReturnValue.Local +// ReSharper disable UnusedType.Global +// ReSharper disable UnusedVariable + +// RecursiveEntitySelfReferenceClient + +// +#nullable enable annotations +#nullable disable warnings + +namespace Microsoft.Extensions.DependencyInjection +{ + // StrawberryShake.CodeGeneration.CSharp.Generators.DependencyInjectionGenerator + [global::System.CodeDom.Compiler.GeneratedCode("StrawberryShake", "11.0.0")] + public static partial class RecursiveEntitySelfReferenceClientServiceCollectionExtensions + { + public static global::StrawberryShake.IClientBuilder AddRecursiveEntitySelfReferenceClient(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection services, global::StrawberryShake.ExecutionStrategy strategy = global::StrawberryShake.ExecutionStrategy.NetworkOnly) + { + var serviceCollection = new global::Microsoft.Extensions.DependencyInjection.ServiceCollection(); + global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton(services, sp => + { + ConfigureClientDefault(sp, serviceCollection, strategy); + return new ClientServiceProvider(global::Microsoft.Extensions.DependencyInjection.ServiceCollectionContainerBuilderExtensions.BuildServiceProvider(serviceCollection)); + }); + global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton(services, sp => new global::StrawberryShake.CodeGeneration.CSharp.Integration.RecursiveEntitySelfReference.State.RecursiveEntitySelfReferenceClientStoreAccessor(global::Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(global::Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(sp)), global::Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(global::Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(sp)), global::Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(global::Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(sp)), global::Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService>(global::Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(sp)), global::Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService>(global::Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(sp)))); + global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton(services, sp => global::Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(global::Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(sp))); + global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton(services, sp => global::Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(global::Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(sp))); + global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton(services, sp => global::Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(global::Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(sp))); + global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton(services, sp => global::Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(global::Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(sp))); + return new global::StrawberryShake.ClientBuilder("RecursiveEntitySelfReferenceClient", services, serviceCollection); + } + + private static global::Microsoft.Extensions.DependencyInjection.IServiceCollection ConfigureClientDefault(global::System.IServiceProvider parentServices, global::Microsoft.Extensions.DependencyInjection.ServiceCollection services, global::StrawberryShake.ExecutionStrategy strategy = global::StrawberryShake.ExecutionStrategy.NetworkOnly) + { + global::Microsoft.Extensions.DependencyInjection.Extensions.ServiceCollectionDescriptorExtensions.TryAddSingleton(services); + global::Microsoft.Extensions.DependencyInjection.Extensions.ServiceCollectionDescriptorExtensions.TryAddSingleton(services, sp => new global::StrawberryShake.OperationStore(global::Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(sp))); + global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton(services, sp => + { + var clientFactory = global::Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(parentServices); + return new global::StrawberryShake.Transport.InMemory.InMemoryConnection(async ct => await clientFactory.CreateAsync("RecursiveEntitySelfReferenceClient", ct)); + }); + global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton, global::StrawberryShake.CodeGeneration.CSharp.Integration.RecursiveEntitySelfReference.State.GetSelfishGuy_SelfishGuy_PersonFromPersonEntityMapper>(services); + global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton, global::StrawberryShake.CodeGeneration.CSharp.Integration.RecursiveEntitySelfReference.State.GetSelfishGuy_SelfishGuy_BestFriend_PersonFromPersonEntityMapper>(services); + global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton(services); + global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton(services); + global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton(services); + global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton(services); + global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton(services); + global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton(services); + global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton(services); + global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton(services); + global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton(services); + global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton(services); + global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton(services); + global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton(services); + global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton(services); + global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton(services); + global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton(services); + global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton(services); + global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton(services); + global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton(services); + global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton(services); + global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton(services); + global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton(services); + global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton(services); + global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton(services); + global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton(services); + global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton(services); + global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton(services, sp => new global::StrawberryShake.Serialization.SerializerResolver(global::System.Linq.Enumerable.Concat(global::Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService>(parentServices), global::Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService>(sp)))); + global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton, global::StrawberryShake.CodeGeneration.CSharp.Integration.RecursiveEntitySelfReference.State.GetSelfishGuyResultFactory>(services); + global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton(services, sp => global::Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService>(sp)); + global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton(services, sp => global::Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(sp)); + global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton, global::StrawberryShake.CodeGeneration.CSharp.Integration.RecursiveEntitySelfReference.State.GetSelfishGuyBuilder>(services); + global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton>(services, sp => new global::StrawberryShake.OperationExecutor(global::Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(sp), () => global::Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService>(sp), () => global::Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService>(sp), global::Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(sp), strategy)); + global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton, global::StrawberryShake.Json.JsonResultPatcher>(services); + global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton(services); + global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton(services, sp => global::Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(sp)); + global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton(services); + global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton(services); + global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton(services, sp => global::Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(sp)); + return services; + } + + private sealed class ClientServiceProvider : System.IServiceProvider, System.IDisposable + { + private readonly System.IServiceProvider _provider; + public ClientServiceProvider(System.IServiceProvider provider) + { + _provider = provider; + } + + public object? GetService(System.Type serviceType) + { + return _provider.GetService(serviceType); + } + + public void Dispose() + { + if (_provider is System.IDisposable d) + { + d.Dispose(); + } + } + } + } +} + +namespace StrawberryShake.CodeGeneration.CSharp.Integration.RecursiveEntitySelfReference +{ + // StrawberryShake.CodeGeneration.CSharp.Generators.ResultTypeGenerator + [global::System.CodeDom.Compiler.GeneratedCode("StrawberryShake", "11.0.0")] + public partial class GetSelfishGuyResult : global::System.IEquatable, IGetSelfishGuyResult + { + public GetSelfishGuyResult(global::StrawberryShake.CodeGeneration.CSharp.Integration.RecursiveEntitySelfReference.IGetSelfishGuy_SelfishGuy selfishGuy) + { + SelfishGuy = selfishGuy; + } + + public global::StrawberryShake.CodeGeneration.CSharp.Integration.RecursiveEntitySelfReference.IGetSelfishGuy_SelfishGuy SelfishGuy { get; } + + public virtual global::System.Boolean Equals(GetSelfishGuyResult? other) + { + if (ReferenceEquals(null, other)) + { + return false; + } + + if (ReferenceEquals(this, other)) + { + return true; + } + + if (other.GetType() != GetType()) + { + return false; + } + + return (SelfishGuy.Equals(other.SelfishGuy)); + } + + public override global::System.Boolean Equals(global::System.Object? obj) + { + if (ReferenceEquals(null, obj)) + { + return false; + } + + if (ReferenceEquals(this, obj)) + { + return true; + } + + if (obj.GetType() != GetType()) + { + return false; + } + + return Equals((GetSelfishGuyResult)obj); + } + + public override global::System.Int32 GetHashCode() + { + unchecked + { + int hash = 5; + hash ^= 397 * SelfishGuy.GetHashCode(); + return hash; + } + } + } + + // StrawberryShake.CodeGeneration.CSharp.Generators.ResultTypeGenerator + [global::System.CodeDom.Compiler.GeneratedCode("StrawberryShake", "11.0.0")] + public partial class GetSelfishGuy_SelfishGuy_Person : global::System.IEquatable, IGetSelfishGuy_SelfishGuy_Person + { + public GetSelfishGuy_SelfishGuy_Person(global::System.String id, global::System.String firstName, global::System.String lastName, global::StrawberryShake.CodeGeneration.CSharp.Integration.RecursiveEntitySelfReference.IGetSelfishGuy_SelfishGuy_BestFriend? bestFriend) + { + Id = id; + FirstName = firstName; + LastName = lastName; + BestFriend = bestFriend; + } + + public global::System.String Id { get; } + public global::System.String FirstName { get; } + public global::System.String LastName { get; } + public global::StrawberryShake.CodeGeneration.CSharp.Integration.RecursiveEntitySelfReference.IGetSelfishGuy_SelfishGuy_BestFriend? BestFriend { get; } + + public virtual global::System.Boolean Equals(GetSelfishGuy_SelfishGuy_Person? other) + { + if (ReferenceEquals(null, other)) + { + return false; + } + + if (ReferenceEquals(this, other)) + { + return true; + } + + if (other.GetType() != GetType()) + { + return false; + } + + return (Id.Equals(other.Id)) && FirstName.Equals(other.FirstName) && LastName.Equals(other.LastName) && ((BestFriend is null && other.BestFriend is null) || BestFriend != null && BestFriend.Equals(other.BestFriend)); + } + + public override global::System.Boolean Equals(global::System.Object? obj) + { + if (ReferenceEquals(null, obj)) + { + return false; + } + + if (ReferenceEquals(this, obj)) + { + return true; + } + + if (obj.GetType() != GetType()) + { + return false; + } + + return Equals((GetSelfishGuy_SelfishGuy_Person)obj); + } + + public override global::System.Int32 GetHashCode() + { + unchecked + { + int hash = 5; + hash ^= 397 * Id.GetHashCode(); + hash ^= 397 * FirstName.GetHashCode(); + hash ^= 397 * LastName.GetHashCode(); + if (BestFriend != null) + { + hash ^= 397 * BestFriend.GetHashCode(); + } + + return hash; + } + } + } + + // StrawberryShake.CodeGeneration.CSharp.Generators.ResultTypeGenerator + [global::System.CodeDom.Compiler.GeneratedCode("StrawberryShake", "11.0.0")] + public partial class GetSelfishGuy_SelfishGuy_BestFriend_Person : global::System.IEquatable, IGetSelfishGuy_SelfishGuy_BestFriend_Person + { + public GetSelfishGuy_SelfishGuy_BestFriend_Person(global::System.String firstName, global::System.Int32 age, global::System.String phone) + { + FirstName = firstName; + Age = age; + Phone = phone; + } + + public global::System.String FirstName { get; } + public global::System.Int32 Age { get; } + public global::System.String Phone { get; } + + public virtual global::System.Boolean Equals(GetSelfishGuy_SelfishGuy_BestFriend_Person? other) + { + if (ReferenceEquals(null, other)) + { + return false; + } + + if (ReferenceEquals(this, other)) + { + return true; + } + + if (other.GetType() != GetType()) + { + return false; + } + + return (FirstName.Equals(other.FirstName)) && global::System.Object.Equals(Age, other.Age) && Phone.Equals(other.Phone); + } + + public override global::System.Boolean Equals(global::System.Object? obj) + { + if (ReferenceEquals(null, obj)) + { + return false; + } + + if (ReferenceEquals(this, obj)) + { + return true; + } + + if (obj.GetType() != GetType()) + { + return false; + } + + return Equals((GetSelfishGuy_SelfishGuy_BestFriend_Person)obj); + } + + public override global::System.Int32 GetHashCode() + { + unchecked + { + int hash = 5; + hash ^= 397 * FirstName.GetHashCode(); + hash ^= 397 * Age.GetHashCode(); + hash ^= 397 * Phone.GetHashCode(); + return hash; + } + } + } + + // StrawberryShake.CodeGeneration.CSharp.Generators.ResultInterfaceGenerator + [global::System.CodeDom.Compiler.GeneratedCode("StrawberryShake", "11.0.0")] + public partial interface IGetSelfishGuyResult + { + public global::StrawberryShake.CodeGeneration.CSharp.Integration.RecursiveEntitySelfReference.IGetSelfishGuy_SelfishGuy SelfishGuy { get; } + } + + // StrawberryShake.CodeGeneration.CSharp.Generators.ResultInterfaceGenerator + [global::System.CodeDom.Compiler.GeneratedCode("StrawberryShake", "11.0.0")] + public partial interface IGetSelfishGuy_SelfishGuy + { + public global::System.String Id { get; } + public global::System.String FirstName { get; } + public global::System.String LastName { get; } + public global::StrawberryShake.CodeGeneration.CSharp.Integration.RecursiveEntitySelfReference.IGetSelfishGuy_SelfishGuy_BestFriend? BestFriend { get; } + } + + // StrawberryShake.CodeGeneration.CSharp.Generators.ResultInterfaceGenerator + [global::System.CodeDom.Compiler.GeneratedCode("StrawberryShake", "11.0.0")] + public partial interface IGetSelfishGuy_SelfishGuy_Person : IGetSelfishGuy_SelfishGuy + { + } + + // StrawberryShake.CodeGeneration.CSharp.Generators.ResultInterfaceGenerator + [global::System.CodeDom.Compiler.GeneratedCode("StrawberryShake", "11.0.0")] + public partial interface IGetSelfishGuy_SelfishGuy_BestFriend + { + public global::System.String FirstName { get; } + public global::System.Int32 Age { get; } + public global::System.String Phone { get; } + } + + // StrawberryShake.CodeGeneration.CSharp.Generators.ResultInterfaceGenerator + [global::System.CodeDom.Compiler.GeneratedCode("StrawberryShake", "11.0.0")] + public partial interface IGetSelfishGuy_SelfishGuy_BestFriend_Person : IGetSelfishGuy_SelfishGuy_BestFriend + { + } + + // StrawberryShake.CodeGeneration.CSharp.Generators.OperationDocumentGenerator + /// + /// Represents the operation service of the GetSelfishGuy GraphQL operation + /// + /// query GetSelfishGuy { + /// selfishGuy { + /// __typename + /// id + /// firstName + /// lastName + /// bestFriend { + /// __typename + /// firstName + /// age + /// phone + /// ... on Person { + /// id + /// } + /// } + /// ... on Person { + /// id + /// } + /// } + /// } + /// + /// + [global::System.CodeDom.Compiler.GeneratedCode("StrawberryShake", "11.0.0")] + public partial class GetSelfishGuyQueryDocument : global::StrawberryShake.IDocument + { + private GetSelfishGuyQueryDocument() + { + } + + public static GetSelfishGuyQueryDocument Instance { get; } = new GetSelfishGuyQueryDocument(); + public global::StrawberryShake.OperationKind Kind => global::StrawberryShake.OperationKind.Query; + public global::System.ReadOnlySpan Body => "query GetSelfishGuy { selfishGuy { __typename id firstName lastName bestFriend { __typename firstName age phone ... on Person { id } } ... on Person { id } } }"u8; + public global::StrawberryShake.DocumentHash Hash { get; } = new global::StrawberryShake.DocumentHash("sha1Hash", "81e08beba7005d9d50ad6cf52ef325aa054f30b9"); + + public override global::System.String ToString() + { +#if NETCOREAPP3_1_OR_GREATER + return global::System.Text.Encoding.UTF8.GetString(Body); +#else + return global::System.Text.Encoding.UTF8.GetString(Body.ToArray()); +#endif + } + } + + // StrawberryShake.CodeGeneration.CSharp.Generators.OperationServiceGenerator + /// + /// Represents the operation service of the GetSelfishGuy GraphQL operation + /// + /// query GetSelfishGuy { + /// selfishGuy { + /// __typename + /// id + /// firstName + /// lastName + /// bestFriend { + /// __typename + /// firstName + /// age + /// phone + /// ... on Person { + /// id + /// } + /// } + /// ... on Person { + /// id + /// } + /// } + /// } + /// + /// + [global::System.CodeDom.Compiler.GeneratedCode("StrawberryShake", "11.0.0")] + public partial class GetSelfishGuyQuery : global::StrawberryShake.CodeGeneration.CSharp.Integration.RecursiveEntitySelfReference.IGetSelfishGuyQuery + { + private readonly global::StrawberryShake.IOperationExecutor _operationExecutor; + private readonly global::System.Collections.Immutable.ImmutableArray> _configure = global::System.Collections.Immutable.ImmutableArray>.Empty; + public GetSelfishGuyQuery(global::StrawberryShake.IOperationExecutor operationExecutor) + { + _operationExecutor = operationExecutor ?? throw new global::System.ArgumentNullException(nameof(operationExecutor)); + } + + private GetSelfishGuyQuery(global::StrawberryShake.IOperationExecutor operationExecutor, global::System.Collections.Immutable.ImmutableArray> configure) + { + _operationExecutor = operationExecutor; + _configure = configure; + } + + global::System.Type global::StrawberryShake.IOperationRequestFactory.ResultType => typeof(IGetSelfishGuyResult); + + public global::StrawberryShake.CodeGeneration.CSharp.Integration.RecursiveEntitySelfReference.IGetSelfishGuyQuery With(global::System.Action configure) + { + return new global::StrawberryShake.CodeGeneration.CSharp.Integration.RecursiveEntitySelfReference.GetSelfishGuyQuery(_operationExecutor, _configure.Add(configure)); + } + + public global::StrawberryShake.CodeGeneration.CSharp.Integration.RecursiveEntitySelfReference.IGetSelfishGuyQuery WithRequestUri(global::System.Uri requestUri) + { + return With(r => r.ContextData["StrawberryShake.Transport.Http.HttpConnection.RequestUri"] = requestUri); + } + + public global::StrawberryShake.CodeGeneration.CSharp.Integration.RecursiveEntitySelfReference.IGetSelfishGuyQuery WithHttpClient(global::System.Net.Http.HttpClient httpClient) + { + return With(r => r.ContextData["StrawberryShake.Transport.Http.HttpConnection.HttpClient"] = httpClient); + } + + public async global::System.Threading.Tasks.Task> ExecuteAsync(global::System.Threading.CancellationToken cancellationToken = default) + { + var request = CreateRequest(); + foreach (var configure in _configure) + { + configure(request); + } + + return await _operationExecutor.ExecuteAsync(request, cancellationToken).ConfigureAwait(false); + } + + public global::System.IObservable> Watch(global::StrawberryShake.ExecutionStrategy? strategy = null) + { + var request = CreateRequest(); + return _operationExecutor.Watch(request, strategy); + } + + private global::StrawberryShake.OperationRequest CreateRequest() + { + return CreateRequest(null); + } + + private global::StrawberryShake.OperationRequest CreateRequest(global::System.Collections.Generic.IReadOnlyDictionary? variables) + { + return new global::StrawberryShake.OperationRequest(id: GetSelfishGuyQueryDocument.Instance.Hash.Value, name: "GetSelfishGuy", document: GetSelfishGuyQueryDocument.Instance, strategy: global::StrawberryShake.RequestStrategy.Default); + } + + global::StrawberryShake.OperationRequest global::StrawberryShake.IOperationRequestFactory.Create(global::System.Collections.Generic.IReadOnlyDictionary? variables) + { + return CreateRequest(); + } + } + + // StrawberryShake.CodeGeneration.CSharp.Generators.OperationServiceInterfaceGenerator + /// + /// Represents the operation service of the GetSelfishGuy GraphQL operation + /// + /// query GetSelfishGuy { + /// selfishGuy { + /// __typename + /// id + /// firstName + /// lastName + /// bestFriend { + /// __typename + /// firstName + /// age + /// phone + /// ... on Person { + /// id + /// } + /// } + /// ... on Person { + /// id + /// } + /// } + /// } + /// + /// + [global::System.CodeDom.Compiler.GeneratedCode("StrawberryShake", "11.0.0")] + public partial interface IGetSelfishGuyQuery : global::StrawberryShake.IOperationRequestFactory + { + global::StrawberryShake.CodeGeneration.CSharp.Integration.RecursiveEntitySelfReference.IGetSelfishGuyQuery With(global::System.Action configure); + global::StrawberryShake.CodeGeneration.CSharp.Integration.RecursiveEntitySelfReference.IGetSelfishGuyQuery WithRequestUri(global::System.Uri requestUri); + global::StrawberryShake.CodeGeneration.CSharp.Integration.RecursiveEntitySelfReference.IGetSelfishGuyQuery WithHttpClient(global::System.Net.Http.HttpClient httpClient); + global::System.Threading.Tasks.Task> ExecuteAsync(global::System.Threading.CancellationToken cancellationToken = default); + global::System.IObservable> Watch(global::StrawberryShake.ExecutionStrategy? strategy = null); + } + + // StrawberryShake.CodeGeneration.CSharp.Generators.ClientGenerator + /// + /// Represents the RecursiveEntitySelfReferenceClient GraphQL client + /// + [global::System.CodeDom.Compiler.GeneratedCode("StrawberryShake", "11.0.0")] + public partial class RecursiveEntitySelfReferenceClient : global::StrawberryShake.CodeGeneration.CSharp.Integration.RecursiveEntitySelfReference.IRecursiveEntitySelfReferenceClient + { + private readonly global::StrawberryShake.CodeGeneration.CSharp.Integration.RecursiveEntitySelfReference.IGetSelfishGuyQuery _getSelfishGuy; + public RecursiveEntitySelfReferenceClient(global::StrawberryShake.CodeGeneration.CSharp.Integration.RecursiveEntitySelfReference.IGetSelfishGuyQuery getSelfishGuy) + { + _getSelfishGuy = getSelfishGuy ?? throw new global::System.ArgumentNullException(nameof(getSelfishGuy)); + } + + public static global::System.String ClientName => "RecursiveEntitySelfReferenceClient"; + public global::StrawberryShake.CodeGeneration.CSharp.Integration.RecursiveEntitySelfReference.IGetSelfishGuyQuery GetSelfishGuy => _getSelfishGuy; + } + + // StrawberryShake.CodeGeneration.CSharp.Generators.ClientInterfaceGenerator + /// + /// Represents the RecursiveEntitySelfReferenceClient GraphQL client + /// + [global::System.CodeDom.Compiler.GeneratedCode("StrawberryShake", "11.0.0")] + public partial interface IRecursiveEntitySelfReferenceClient + { + global::StrawberryShake.CodeGeneration.CSharp.Integration.RecursiveEntitySelfReference.IGetSelfishGuyQuery GetSelfishGuy { get; } + } +} + +namespace StrawberryShake.CodeGeneration.CSharp.Integration.RecursiveEntitySelfReference.State +{ + // StrawberryShake.CodeGeneration.CSharp.Generators.EntityTypeGenerator + [global::System.CodeDom.Compiler.GeneratedCode("StrawberryShake", "0.0.0.0")] + public partial class PersonEntity + { + public PersonEntity(global::System.String id = default !, global::System.String firstName = default !, global::System.String lastName = default !, global::StrawberryShake.EntityId? bestFriend = default !, global::System.Int32 age = default !, global::System.String phone = default !) + { + Id = id; + FirstName = firstName; + LastName = lastName; + BestFriend = bestFriend; + Age = age; + Phone = phone; + } + + public global::System.String Id { get; } + public global::System.String FirstName { get; } + public global::System.String LastName { get; } + public global::StrawberryShake.EntityId? BestFriend { get; } + public global::System.Int32 Age { get; } + public global::System.String Phone { get; } + } + + // StrawberryShake.CodeGeneration.CSharp.Generators.ResultDataFactoryGenerator + [global::System.CodeDom.Compiler.GeneratedCode("StrawberryShake", "11.0.0")] + public partial class GetSelfishGuyResultFactory : global::StrawberryShake.IOperationResultDataFactory + { + private readonly global::StrawberryShake.IEntityStore _entityStore; + private readonly global::StrawberryShake.IEntityMapper _getSelfishGuy_SelfishGuy_PersonFromPersonEntityMapper; + public GetSelfishGuyResultFactory(global::StrawberryShake.IEntityStore entityStore, global::StrawberryShake.IEntityMapper getSelfishGuy_SelfishGuy_PersonFromPersonEntityMapper) + { + _entityStore = entityStore ?? throw new global::System.ArgumentNullException(nameof(entityStore)); + _getSelfishGuy_SelfishGuy_PersonFromPersonEntityMapper = getSelfishGuy_SelfishGuy_PersonFromPersonEntityMapper ?? throw new global::System.ArgumentNullException(nameof(getSelfishGuy_SelfishGuy_PersonFromPersonEntityMapper)); + } + + global::System.Type global::StrawberryShake.IOperationResultDataFactory.ResultType => typeof(global::StrawberryShake.CodeGeneration.CSharp.Integration.RecursiveEntitySelfReference.IGetSelfishGuyResult); + + public GetSelfishGuyResult Create(global::StrawberryShake.IOperationResultDataInfo dataInfo, global::StrawberryShake.IEntityStoreSnapshot? snapshot = null) + { + if (snapshot is null) + { + snapshot = _entityStore.CurrentSnapshot; + } + + if (dataInfo is GetSelfishGuyResultInfo info) + { + return new GetSelfishGuyResult(MapNonNullableIGetSelfishGuy_SelfishGuy(info.SelfishGuy, snapshot)); + } + + throw new global::System.ArgumentException("GetSelfishGuyResultInfo expected."); + } + + private global::StrawberryShake.CodeGeneration.CSharp.Integration.RecursiveEntitySelfReference.IGetSelfishGuy_SelfishGuy MapNonNullableIGetSelfishGuy_SelfishGuy(global::StrawberryShake.EntityId entityId, global::StrawberryShake.IEntityStoreSnapshot snapshot) + { + if (entityId.Name.Equals("Person", global::System.StringComparison.Ordinal)) + { + return _getSelfishGuy_SelfishGuy_PersonFromPersonEntityMapper.Map(snapshot.GetEntity(entityId) ?? throw new global::StrawberryShake.GraphQLClientException()); + } + + throw new global::System.NotSupportedException(); + } + + global::System.Object global::StrawberryShake.IOperationResultDataFactory.Create(global::StrawberryShake.IOperationResultDataInfo dataInfo, global::StrawberryShake.IEntityStoreSnapshot? snapshot) + { + return Create(dataInfo, snapshot); + } + } + + // StrawberryShake.CodeGeneration.CSharp.Generators.ResultInfoGenerator + [global::System.CodeDom.Compiler.GeneratedCode("StrawberryShake", "11.0.0")] + public partial class GetSelfishGuyResultInfo : global::StrawberryShake.IOperationResultDataInfo + { + private readonly global::System.Collections.Generic.IReadOnlyCollection _entityIds; + private readonly global::System.UInt64 _version; + public GetSelfishGuyResultInfo(global::StrawberryShake.EntityId selfishGuy, global::System.Collections.Generic.IReadOnlyCollection entityIds, global::System.UInt64 version) + { + SelfishGuy = selfishGuy; + _entityIds = entityIds ?? throw new global::System.ArgumentNullException(nameof(entityIds)); + _version = version; + } + + public global::StrawberryShake.EntityId SelfishGuy { get; } + public global::System.Collections.Generic.IReadOnlyCollection EntityIds => _entityIds; + public global::System.UInt64 Version => _version; + + public global::StrawberryShake.IOperationResultDataInfo WithVersion(global::System.UInt64 version) + { + return new GetSelfishGuyResultInfo(SelfishGuy, _entityIds, version); + } + } + + // StrawberryShake.CodeGeneration.CSharp.Generators.JsonResultBuilderGenerator + [global::System.CodeDom.Compiler.GeneratedCode("StrawberryShake", "11.0.0")] + public partial class GetSelfishGuyBuilder : global::StrawberryShake.OperationResultBuilder + { + private readonly global::StrawberryShake.IEntityStore _entityStore; + private readonly global::StrawberryShake.IEntityIdSerializer _idSerializer; + private readonly global::StrawberryShake.Serialization.ILeafValueParser _stringParser; + private readonly global::StrawberryShake.Serialization.ILeafValueParser _intParser; + public GetSelfishGuyBuilder(global::StrawberryShake.IEntityStore entityStore, global::StrawberryShake.IEntityIdSerializer idSerializer, global::StrawberryShake.IOperationResultDataFactory resultDataFactory, global::StrawberryShake.Serialization.ISerializerResolver serializerResolver) + { + _entityStore = entityStore ?? throw new global::System.ArgumentNullException(nameof(entityStore)); + _idSerializer = idSerializer ?? throw new global::System.ArgumentNullException(nameof(idSerializer)); + ResultDataFactory = resultDataFactory ?? throw new global::System.ArgumentNullException(nameof(resultDataFactory)); + _stringParser = serializerResolver.GetLeafValueParser("String") ?? throw new global::System.ArgumentException("No serializer for type `String` found."); + _intParser = serializerResolver.GetLeafValueParser("Int") ?? throw new global::System.ArgumentException("No serializer for type `Int` found."); + } + + protected override global::StrawberryShake.IOperationResultDataFactory ResultDataFactory { get; } + + protected override global::StrawberryShake.IOperationResultDataInfo BuildData(global::System.Text.Json.JsonElement obj) + { + var entityIds = new global::System.Collections.Generic.HashSet(); + global::StrawberryShake.IEntityStoreSnapshot snapshot = default !; + global::StrawberryShake.EntityId selfishGuyId = default !; + _entityStore.Update(session => + { + selfishGuyId = Update_NonNullableIGetSelfishGuy_SelfishGuyEntity(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "selfishGuy"), entityIds); + snapshot = session.CurrentSnapshot; + }); + return new GetSelfishGuyResultInfo(selfishGuyId, entityIds, snapshot.Version); + } + + private global::StrawberryShake.EntityId Update_NonNullableIGetSelfishGuy_SelfishGuyEntity(global::StrawberryShake.IEntityStoreUpdateSession session, global::System.Text.Json.JsonElement? obj, global::System.Collections.Generic.ISet entityIds) + { + if (!obj.HasValue) + { + throw new global::System.ArgumentNullException(); + } + + if (obj.Value.ValueKind == global::System.Text.Json.JsonValueKind.Null) + { + throw new global::System.ArgumentNullException(); + } + + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); + if (entityId.Name.Equals("Person", global::System.StringComparison.Ordinal)) + { + if (session.CurrentSnapshot.TryGetEntity(entityId, out global::StrawberryShake.CodeGeneration.CSharp.Integration.RecursiveEntitySelfReference.State.PersonEntity? entity)) + { + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")); + var arg1 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "firstName")); + var arg2 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "lastName")); + var arg3 = Update_IGetSelfishGuy_SelfishGuy_BestFriendEntity(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "bestFriend"), entityIds); + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.RecursiveEntitySelfReference.State.PersonEntity(arg0, arg1, arg2, arg3, entity.Age, entity.Phone)); + } + else + { + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")); + var arg1 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "firstName")); + var arg2 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "lastName")); + var arg3 = Update_IGetSelfishGuy_SelfishGuy_BestFriendEntity(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "bestFriend"), entityIds); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.RecursiveEntitySelfReference.State.PersonEntity(arg0, arg1, arg2, arg3, entity.Age, entity.Phone)); + } + else + { + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.RecursiveEntitySelfReference.State.PersonEntity(arg0, arg1, arg2, arg3, default !, default !)); + } + } + + return entityId; + } + + throw new global::System.NotSupportedException(); + } + + private global::System.String Deserialize_NonNullableString(global::System.Text.Json.JsonElement? obj) + { + if (!obj.HasValue) + { + throw new global::System.ArgumentNullException(); + } + + if (obj.Value.ValueKind == global::System.Text.Json.JsonValueKind.Null) + { + throw new global::System.ArgumentNullException(); + } + + return _stringParser.Parse(obj.Value.GetString()!); + } + + private global::StrawberryShake.EntityId? Update_IGetSelfishGuy_SelfishGuy_BestFriendEntity(global::StrawberryShake.IEntityStoreUpdateSession session, global::System.Text.Json.JsonElement? obj, global::System.Collections.Generic.ISet entityIds) + { + if (!obj.HasValue) + { + return null; + } + + if (obj.Value.ValueKind == global::System.Text.Json.JsonValueKind.Null) + { + return null; + } + + global::StrawberryShake.EntityId entityId = _idSerializer.Parse(obj.Value); + entityIds.Add(entityId); + if (entityId.Name.Equals("Person", global::System.StringComparison.Ordinal)) + { + if (session.CurrentSnapshot.TryGetEntity(entityId, out global::StrawberryShake.CodeGeneration.CSharp.Integration.RecursiveEntitySelfReference.State.PersonEntity? entity)) + { + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "firstName")); + var arg1 = Deserialize_NonNullableInt32(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "age")); + var arg2 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "phone")); + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.RecursiveEntitySelfReference.State.PersonEntity(entity.Id, arg0, entity.LastName, entity.BestFriend, arg1, arg2)); + } + else + { + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "firstName")); + var arg1 = Deserialize_NonNullableInt32(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "age")); + var arg2 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "phone")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.RecursiveEntitySelfReference.State.PersonEntity(entity.Id, arg0, entity.LastName, entity.BestFriend, arg1, arg2)); + } + else + { + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.RecursiveEntitySelfReference.State.PersonEntity(default !, arg0, default !, default !, arg1, arg2)); + } + } + + return entityId; + } + + throw new global::System.NotSupportedException(); + } + + private global::System.Int32 Deserialize_NonNullableInt32(global::System.Text.Json.JsonElement? obj) + { + if (!obj.HasValue) + { + throw new global::System.ArgumentNullException(); + } + + if (obj.Value.ValueKind == global::System.Text.Json.JsonValueKind.Null) + { + throw new global::System.ArgumentNullException(); + } + + return _intParser.Parse(obj.Value.GetInt32()!); + } + } + + // StrawberryShake.CodeGeneration.CSharp.Generators.ResultFromEntityTypeMapperGenerator + [global::System.CodeDom.Compiler.GeneratedCode("StrawberryShake", "11.0.0")] + public partial class GetSelfishGuy_SelfishGuy_PersonFromPersonEntityMapper : global::StrawberryShake.IEntityMapper + { + private readonly global::StrawberryShake.IEntityStore _entityStore; + private readonly global::StrawberryShake.IEntityMapper _getSelfishGuy_SelfishGuy_BestFriend_PersonFromPersonEntityMapper; + public GetSelfishGuy_SelfishGuy_PersonFromPersonEntityMapper(global::StrawberryShake.IEntityStore entityStore, global::StrawberryShake.IEntityMapper getSelfishGuy_SelfishGuy_BestFriend_PersonFromPersonEntityMapper) + { + _entityStore = entityStore ?? throw new global::System.ArgumentNullException(nameof(entityStore)); + _getSelfishGuy_SelfishGuy_BestFriend_PersonFromPersonEntityMapper = getSelfishGuy_SelfishGuy_BestFriend_PersonFromPersonEntityMapper ?? throw new global::System.ArgumentNullException(nameof(getSelfishGuy_SelfishGuy_BestFriend_PersonFromPersonEntityMapper)); + } + + public GetSelfishGuy_SelfishGuy_Person Map(global::StrawberryShake.CodeGeneration.CSharp.Integration.RecursiveEntitySelfReference.State.PersonEntity entity, global::StrawberryShake.IEntityStoreSnapshot? snapshot = null) + { + if (snapshot is null) + { + snapshot = _entityStore.CurrentSnapshot; + } + + return new GetSelfishGuy_SelfishGuy_Person(entity.Id, entity.FirstName, entity.LastName, MapIGetSelfishGuy_SelfishGuy_BestFriend(entity.BestFriend, snapshot)); + } + + private global::StrawberryShake.CodeGeneration.CSharp.Integration.RecursiveEntitySelfReference.IGetSelfishGuy_SelfishGuy_BestFriend? MapIGetSelfishGuy_SelfishGuy_BestFriend(global::StrawberryShake.EntityId? entityId, global::StrawberryShake.IEntityStoreSnapshot snapshot) + { + if (entityId is null) + { + return null; + } + + if (entityId.Value.Name.Equals("Person", global::System.StringComparison.Ordinal)) + { + return _getSelfishGuy_SelfishGuy_BestFriend_PersonFromPersonEntityMapper.Map(snapshot.GetEntity(entityId.Value) ?? throw new global::StrawberryShake.GraphQLClientException()); + } + + throw new global::System.NotSupportedException(); + } + } + + // StrawberryShake.CodeGeneration.CSharp.Generators.ResultFromEntityTypeMapperGenerator + [global::System.CodeDom.Compiler.GeneratedCode("StrawberryShake", "11.0.0")] + public partial class GetSelfishGuy_SelfishGuy_BestFriend_PersonFromPersonEntityMapper : global::StrawberryShake.IEntityMapper + { + private readonly global::StrawberryShake.IEntityStore _entityStore; + public GetSelfishGuy_SelfishGuy_BestFriend_PersonFromPersonEntityMapper(global::StrawberryShake.IEntityStore entityStore) + { + _entityStore = entityStore ?? throw new global::System.ArgumentNullException(nameof(entityStore)); + } + + public GetSelfishGuy_SelfishGuy_BestFriend_Person Map(global::StrawberryShake.CodeGeneration.CSharp.Integration.RecursiveEntitySelfReference.State.PersonEntity entity, global::StrawberryShake.IEntityStoreSnapshot? snapshot = null) + { + if (snapshot is null) + { + snapshot = _entityStore.CurrentSnapshot; + } + + return new GetSelfishGuy_SelfishGuy_BestFriend_Person(entity.FirstName, entity.Age, entity.Phone); + } + } + + // StrawberryShake.CodeGeneration.CSharp.Generators.EntityIdFactoryGenerator + [global::System.CodeDom.Compiler.GeneratedCode("StrawberryShake", "11.0.0")] + public partial class RecursiveEntitySelfReferenceClientEntityIdFactory : global::StrawberryShake.IEntityIdSerializer + { + private static readonly global::System.Text.Json.JsonWriterOptions _options = new global::System.Text.Json.JsonWriterOptions() + { + Indented = false + }; + public global::StrawberryShake.EntityId Parse(global::System.Text.Json.JsonElement obj) + { + global::System.String __typename = obj.GetProperty("__typename").GetString()!; + return __typename switch + { + "Person" => ParsePersonEntityId(obj, __typename), + _ => throw new global::System.NotSupportedException()}; + } + + public global::System.String Format(global::StrawberryShake.EntityId entityId) + { + return entityId.Name switch + { + "Person" => FormatPersonEntityId(entityId), + _ => throw new global::System.NotSupportedException()}; + } + + private global::StrawberryShake.EntityId ParsePersonEntityId(global::System.Text.Json.JsonElement obj, global::System.String type) + { + return new global::StrawberryShake.EntityId(type, obj.GetProperty("id").GetString()!); + } + + private global::System.String FormatPersonEntityId(global::StrawberryShake.EntityId entityId) + { + using var writer = new global::StrawberryShake.Internal.ArrayWriter(); + using var jsonWriter = new global::System.Text.Json.Utf8JsonWriter(writer, _options); + jsonWriter.WriteStartObject(); + jsonWriter.WriteString("__typename", entityId.Name); + jsonWriter.WriteString("id", (global::System.String)entityId.Value); + jsonWriter.WriteEndObject(); + jsonWriter.Flush(); + return global::System.Text.Encoding.UTF8.GetString(writer.GetInternalBuffer(), 0, writer.Length); + } + } + + // StrawberryShake.CodeGeneration.CSharp.Generators.StoreAccessorGenerator + [global::System.CodeDom.Compiler.GeneratedCode("StrawberryShake", "11.0.0")] + public partial class RecursiveEntitySelfReferenceClientStoreAccessor : global::StrawberryShake.StoreAccessor + { + public RecursiveEntitySelfReferenceClientStoreAccessor(global::StrawberryShake.IOperationStore operationStore, global::StrawberryShake.IEntityStore entityStore, global::StrawberryShake.IEntityIdSerializer entityIdSerializer, global::System.Collections.Generic.IEnumerable requestFactories, global::System.Collections.Generic.IEnumerable resultDataFactories) : base(operationStore, entityStore, entityIdSerializer, requestFactories, resultDataFactories) + { + } + } +} + + diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/RecursiveEntitySelfReferenceTest.cs b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/RecursiveEntitySelfReferenceTest.cs new file mode 100644 index 00000000000..9730e4b5c54 --- /dev/null +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/RecursiveEntitySelfReferenceTest.cs @@ -0,0 +1,75 @@ +using HotChocolate.AspNetCore.Tests.Utilities; +using Microsoft.Extensions.DependencyInjection; + +namespace StrawberryShake.CodeGeneration.CSharp.Integration.RecursiveEntitySelfReference; + +public class RecursiveEntitySelfReferenceTest : ServerTestBase +{ + public RecursiveEntitySelfReferenceTest(TestServerFactory serverFactory) : base(serverFactory) + { + } + + [Fact] + public async Task Execute_SelfReference_Should_Keep_BestFriend_Fields_When_SelectionSets_Differ() + { + // arrange + // selfishGuy.bestFriend points back to selfishGuy (same entity id), but the two + // selection sets differ: the outer set has id/firstName/lastName, the inner set has + // firstName/age/phone. The outer write must not overwrite the inner write's + // age/phone fields with defaults. + var ct = new CancellationTokenSource(20_000).Token; + var serviceCollection = new ServiceCollection(); + serviceCollection + .AddGraphQLServer() + .AddQueryType(); + serviceCollection.AddRecursiveEntitySelfReferenceClient().ConfigureInMemoryClient(); + IServiceProvider services = serviceCollection.BuildServiceProvider(); + var client = services.GetRequiredService(); + + // act + var result = await client.GetSelfishGuy.ExecuteAsync(ct); + + // assert + result.EnsureNoErrors(); + var bestFriend = result.Data!.SelfishGuy.BestFriend!; + Assert.Equal(42, bestFriend.Age); + Assert.Equal("123-456-7890", bestFriend.Phone); + } + + public class Query + { + public Person GetSelfishGuy() + { + var selfishGuy = new Person + { + Id = "1", + FirstName = "John", + LastName = "Doe", + Age = 42, + Phone = "123-456-7890", + ZipCode = "12345" + }; + + selfishGuy.BestFriend = selfishGuy; + + return selfishGuy; + } + } + + public class Person + { + public string Id { get; set; } = null!; + + public string FirstName { get; set; } = null!; + + public string LastName { get; set; } = null!; + + public int Age { get; set; } + + public string Phone { get; set; } = null!; + + public string ZipCode { get; set; } = null!; + + public Person? BestFriend { get; set; } + } +} diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsGetFriendsDeferInListTest.Client.cs b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsGetFriendsDeferInListTest.Client.cs index 96f61381aa0..03aa104cdb0 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsGetFriendsDeferInListTest.Client.cs +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsGetFriendsDeferInListTest.Client.cs @@ -1,4 +1,4 @@ -// ReSharper disable ArrangeObjectCreationWhenTypeEvident +// ReSharper disable ArrangeObjectCreationWhenTypeEvident // ReSharper disable BuiltInTypeReferenceStyle // ReSharper disable ConvertToAutoProperty // ReSharper disable InconsistentNaming @@ -980,11 +980,20 @@ public GetHeroBuilder(global::StrawberryShake.IEntityStore entityStore, global:: { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriendsDeferInList.State.DroidEntity? entity)) { - session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriendsDeferInList.State.DroidEntity(Deserialize_IGetHero_Hero_Friends(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "friends"), entityIds), entity.Name)); + var arg0 = Deserialize_IGetHero_Hero_Friends(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "friends"), entityIds); + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriendsDeferInList.State.DroidEntity(arg0, entity.Name)); } else { - session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriendsDeferInList.State.DroidEntity(Deserialize_IGetHero_Hero_Friends(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "friends"), entityIds), default !)); + var arg0 = Deserialize_IGetHero_Hero_Friends(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "friends"), entityIds); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriendsDeferInList.State.DroidEntity(arg0, entity.Name)); + } + else + { + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriendsDeferInList.State.DroidEntity(arg0, default !)); + } } return entityId; @@ -994,11 +1003,20 @@ public GetHeroBuilder(global::StrawberryShake.IEntityStore entityStore, global:: { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriendsDeferInList.State.HumanEntity? entity)) { - session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriendsDeferInList.State.HumanEntity(Deserialize_IGetHero_Hero_Friends(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "friends"), entityIds), entity.Name)); + var arg0 = Deserialize_IGetHero_Hero_Friends(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "friends"), entityIds); + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriendsDeferInList.State.HumanEntity(arg0, entity.Name)); } else { - session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriendsDeferInList.State.HumanEntity(Deserialize_IGetHero_Hero_Friends(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "friends"), entityIds), default !)); + var arg0 = Deserialize_IGetHero_Hero_Friends(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "friends"), entityIds); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriendsDeferInList.State.HumanEntity(arg0, entity.Name)); + } + else + { + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriendsDeferInList.State.HumanEntity(arg0, default !)); + } } return entityId; @@ -1067,11 +1085,20 @@ public GetHeroBuilder(global::StrawberryShake.IEntityStore entityStore, global:: { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriendsDeferInList.State.DroidEntity? entity)) { - session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriendsDeferInList.State.DroidEntity(entity.Friends, Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriendsDeferInList.State.DroidEntity(entity.Friends, arg0)); } else { - session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriendsDeferInList.State.DroidEntity(default !, Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriendsDeferInList.State.DroidEntity(entity.Friends, arg0)); + } + else + { + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriendsDeferInList.State.DroidEntity(default !, arg0)); + } } return entityId; @@ -1081,11 +1108,20 @@ public GetHeroBuilder(global::StrawberryShake.IEntityStore entityStore, global:: { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriendsDeferInList.State.HumanEntity? entity)) { - session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriendsDeferInList.State.HumanEntity(entity.Friends, Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriendsDeferInList.State.HumanEntity(entity.Friends, arg0)); } else { - session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriendsDeferInList.State.HumanEntity(default !, Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriendsDeferInList.State.HumanEntity(entity.Friends, arg0)); + } + else + { + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriendsDeferInList.State.HumanEntity(default !, arg0)); + } } return entityId; diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsGetFriendsDeferredTest.Client.cs b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsGetFriendsDeferredTest.Client.cs index 7d3abc4f7c5..4d915b0a8ff 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsGetFriendsDeferredTest.Client.cs +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsGetFriendsDeferredTest.Client.cs @@ -1,4 +1,4 @@ -// ReSharper disable ArrangeObjectCreationWhenTypeEvident +// ReSharper disable ArrangeObjectCreationWhenTypeEvident // ReSharper disable BuiltInTypeReferenceStyle // ReSharper disable ConvertToAutoProperty // ReSharper disable InconsistentNaming @@ -990,11 +990,22 @@ public GetHeroBuilder(global::StrawberryShake.IEntityStore entityStore, global:: { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriendsDeferred.State.DroidEntity? entity)) { - session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriendsDeferred.State.DroidEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_IGetHero_Hero_Friends(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "friends"), entityIds))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + var arg1 = Deserialize_IGetHero_Hero_Friends(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "friends"), entityIds); + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriendsDeferred.State.DroidEntity(arg0, arg1)); } else { - session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriendsDeferred.State.DroidEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_IGetHero_Hero_Friends(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "friends"), entityIds))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + var arg1 = Deserialize_IGetHero_Hero_Friends(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "friends"), entityIds); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriendsDeferred.State.DroidEntity(arg0, arg1)); + } + else + { + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriendsDeferred.State.DroidEntity(arg0, arg1)); + } } return entityId; @@ -1004,11 +1015,22 @@ public GetHeroBuilder(global::StrawberryShake.IEntityStore entityStore, global:: { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriendsDeferred.State.HumanEntity? entity)) { - session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriendsDeferred.State.HumanEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_IGetHero_Hero_Friends(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "friends"), entityIds))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + var arg1 = Deserialize_IGetHero_Hero_Friends(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "friends"), entityIds); + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriendsDeferred.State.HumanEntity(arg0, arg1)); } else { - session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriendsDeferred.State.HumanEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_IGetHero_Hero_Friends(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "friends"), entityIds))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + var arg1 = Deserialize_IGetHero_Hero_Friends(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "friends"), entityIds); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriendsDeferred.State.HumanEntity(arg0, arg1)); + } + else + { + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriendsDeferred.State.HumanEntity(arg0, arg1)); + } } return entityId; @@ -1092,11 +1114,20 @@ public GetHeroBuilder(global::StrawberryShake.IEntityStore entityStore, global:: { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriendsDeferred.State.DroidEntity? entity)) { - session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriendsDeferred.State.DroidEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), entity.Friends)); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriendsDeferred.State.DroidEntity(arg0, entity.Friends)); } else { - session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriendsDeferred.State.DroidEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), default !)); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriendsDeferred.State.DroidEntity(arg0, entity.Friends)); + } + else + { + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriendsDeferred.State.DroidEntity(arg0, default !)); + } } return entityId; @@ -1106,11 +1137,20 @@ public GetHeroBuilder(global::StrawberryShake.IEntityStore entityStore, global:: { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriendsDeferred.State.HumanEntity? entity)) { - session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriendsDeferred.State.HumanEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), entity.Friends)); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriendsDeferred.State.HumanEntity(arg0, entity.Friends)); } else { - session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriendsDeferred.State.HumanEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), default !)); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriendsDeferred.State.HumanEntity(arg0, entity.Friends)); + } + else + { + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriendsDeferred.State.HumanEntity(arg0, default !)); + } } return entityId; diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsGetFriendsTest.Client.cs b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsGetFriendsTest.Client.cs index e5d6e404cc1..5c7f183d252 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsGetFriendsTest.Client.cs +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsGetFriendsTest.Client.cs @@ -1,4 +1,4 @@ -// ReSharper disable ArrangeObjectCreationWhenTypeEvident +// ReSharper disable ArrangeObjectCreationWhenTypeEvident // ReSharper disable BuiltInTypeReferenceStyle // ReSharper disable ConvertToAutoProperty // ReSharper disable InconsistentNaming @@ -969,11 +969,22 @@ public GetHeroBuilder(global::StrawberryShake.IEntityStore entityStore, global:: { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriends.State.DroidEntity? entity)) { - session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriends.State.DroidEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_IGetHero_Hero_Friends(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "friends"), entityIds))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + var arg1 = Deserialize_IGetHero_Hero_Friends(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "friends"), entityIds); + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriends.State.DroidEntity(arg0, arg1)); } else { - session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriends.State.DroidEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_IGetHero_Hero_Friends(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "friends"), entityIds))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + var arg1 = Deserialize_IGetHero_Hero_Friends(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "friends"), entityIds); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriends.State.DroidEntity(arg0, arg1)); + } + else + { + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriends.State.DroidEntity(arg0, arg1)); + } } return entityId; @@ -983,11 +994,22 @@ public GetHeroBuilder(global::StrawberryShake.IEntityStore entityStore, global:: { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriends.State.HumanEntity? entity)) { - session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriends.State.HumanEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_IGetHero_Hero_Friends(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "friends"), entityIds))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + var arg1 = Deserialize_IGetHero_Hero_Friends(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "friends"), entityIds); + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriends.State.HumanEntity(arg0, arg1)); } else { - session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriends.State.HumanEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_IGetHero_Hero_Friends(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "friends"), entityIds))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + var arg1 = Deserialize_IGetHero_Hero_Friends(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "friends"), entityIds); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriends.State.HumanEntity(arg0, arg1)); + } + else + { + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriends.State.HumanEntity(arg0, arg1)); + } } return entityId; @@ -1071,11 +1093,20 @@ public GetHeroBuilder(global::StrawberryShake.IEntityStore entityStore, global:: { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriends.State.DroidEntity? entity)) { - session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriends.State.DroidEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), entity.Friends)); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriends.State.DroidEntity(arg0, entity.Friends)); } else { - session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriends.State.DroidEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), default !)); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriends.State.DroidEntity(arg0, entity.Friends)); + } + else + { + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriends.State.DroidEntity(arg0, default !)); + } } return entityId; @@ -1085,11 +1116,20 @@ public GetHeroBuilder(global::StrawberryShake.IEntityStore entityStore, global:: { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriends.State.HumanEntity? entity)) { - session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriends.State.HumanEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), entity.Friends)); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriends.State.HumanEntity(arg0, entity.Friends)); } else { - session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriends.State.HumanEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), default !)); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriends.State.HumanEntity(arg0, entity.Friends)); + } + else + { + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriends.State.HumanEntity(arg0, default !)); + } } return entityId; diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsGetHeroTest.Client.cs b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsGetHeroTest.Client.cs index 04963147937..36b4583e105 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsGetHeroTest.Client.cs +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsGetHeroTest.Client.cs @@ -1,4 +1,4 @@ -// ReSharper disable ArrangeObjectCreationWhenTypeEvident +// ReSharper disable ArrangeObjectCreationWhenTypeEvident // ReSharper disable BuiltInTypeReferenceStyle // ReSharper disable ConvertToAutoProperty // ReSharper disable InconsistentNaming @@ -666,11 +666,20 @@ public GetHeroBuilder(global::StrawberryShake.IEntityStore entityStore, global:: { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetHero.State.DroidEntity? entity)) { - session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetHero.State.DroidEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetHero.State.DroidEntity(arg0)); } else { - session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetHero.State.DroidEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetHero.State.DroidEntity(arg0)); + } + else + { + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetHero.State.DroidEntity(arg0)); + } } return entityId; @@ -680,11 +689,20 @@ public GetHeroBuilder(global::StrawberryShake.IEntityStore entityStore, global:: { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetHero.State.HumanEntity? entity)) { - session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetHero.State.HumanEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetHero.State.HumanEntity(arg0)); } else { - session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetHero.State.HumanEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetHero.State.HumanEntity(arg0)); + } + else + { + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetHero.State.HumanEntity(arg0)); + } } return entityId; diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsGetHeroTraitsTest.Client.cs b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsGetHeroTraitsTest.Client.cs index 72e53f7fd4f..b702b3a6be6 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsGetHeroTraitsTest.Client.cs +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsGetHeroTraitsTest.Client.cs @@ -1,4 +1,4 @@ -// ReSharper disable ArrangeObjectCreationWhenTypeEvident +// ReSharper disable ArrangeObjectCreationWhenTypeEvident // ReSharper disable BuiltInTypeReferenceStyle // ReSharper disable ConvertToAutoProperty // ReSharper disable InconsistentNaming @@ -691,11 +691,22 @@ public GetHeroBuilder(global::StrawberryShake.IEntityStore entityStore, global:: { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetHeroTraits.State.DroidEntity? entity)) { - session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetHeroTraits.State.DroidEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_JsonElement(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "traits")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + var arg1 = Deserialize_JsonElement(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "traits")); + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetHeroTraits.State.DroidEntity(arg0, arg1)); } else { - session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetHeroTraits.State.DroidEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_JsonElement(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "traits")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + var arg1 = Deserialize_JsonElement(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "traits")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetHeroTraits.State.DroidEntity(arg0, arg1)); + } + else + { + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetHeroTraits.State.DroidEntity(arg0, arg1)); + } } return entityId; @@ -705,11 +716,22 @@ public GetHeroBuilder(global::StrawberryShake.IEntityStore entityStore, global:: { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetHeroTraits.State.HumanEntity? entity)) { - session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetHeroTraits.State.HumanEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_JsonElement(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "traits")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + var arg1 = Deserialize_JsonElement(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "traits")); + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetHeroTraits.State.HumanEntity(arg0, arg1)); } else { - session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetHeroTraits.State.HumanEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_JsonElement(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "traits")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + var arg1 = Deserialize_JsonElement(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "traits")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetHeroTraits.State.HumanEntity(arg0, arg1)); + } + else + { + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetHeroTraits.State.HumanEntity(arg0, arg1)); + } } return entityId; diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsGetHeroWithFragmentIncludeAndSkipDirectiveTest.Client.cs b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsGetHeroWithFragmentIncludeAndSkipDirectiveTest.Client.cs index 04fbd020dbb..822ff432acb 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsGetHeroWithFragmentIncludeAndSkipDirectiveTest.Client.cs +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsGetHeroWithFragmentIncludeAndSkipDirectiveTest.Client.cs @@ -1,4 +1,4 @@ -// ReSharper disable ArrangeObjectCreationWhenTypeEvident +// ReSharper disable ArrangeObjectCreationWhenTypeEvident // ReSharper disable BuiltInTypeReferenceStyle // ReSharper disable ConvertToAutoProperty // ReSharper disable InconsistentNaming @@ -1103,11 +1103,22 @@ public GetHeroWithFragmentIncludeAndSkipDirectiveBuilder(global::StrawberryShake { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetHeroWithFragmentIncludeAndSkipDirective.State.DroidEntity? entity)) { - session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetHeroWithFragmentIncludeAndSkipDirective.State.DroidEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")), Deserialize_IGetHeroWithFragmentIncludeAndSkipDirective_Hero_Friends(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "friends")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")); + var arg1 = Deserialize_IGetHeroWithFragmentIncludeAndSkipDirective_Hero_Friends(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "friends")); + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetHeroWithFragmentIncludeAndSkipDirective.State.DroidEntity(arg0, arg1)); } else { - session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetHeroWithFragmentIncludeAndSkipDirective.State.DroidEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")), Deserialize_IGetHeroWithFragmentIncludeAndSkipDirective_Hero_Friends(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "friends")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")); + var arg1 = Deserialize_IGetHeroWithFragmentIncludeAndSkipDirective_Hero_Friends(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "friends")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetHeroWithFragmentIncludeAndSkipDirective.State.DroidEntity(arg0, arg1)); + } + else + { + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetHeroWithFragmentIncludeAndSkipDirective.State.DroidEntity(arg0, arg1)); + } } return entityId; @@ -1117,11 +1128,22 @@ public GetHeroWithFragmentIncludeAndSkipDirectiveBuilder(global::StrawberryShake { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetHeroWithFragmentIncludeAndSkipDirective.State.HumanEntity? entity)) { - session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetHeroWithFragmentIncludeAndSkipDirective.State.HumanEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")), Deserialize_IGetHeroWithFragmentIncludeAndSkipDirective_Hero_Friends(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "friends")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")); + var arg1 = Deserialize_IGetHeroWithFragmentIncludeAndSkipDirective_Hero_Friends(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "friends")); + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetHeroWithFragmentIncludeAndSkipDirective.State.HumanEntity(arg0, arg1)); } else { - session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetHeroWithFragmentIncludeAndSkipDirective.State.HumanEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")), Deserialize_IGetHeroWithFragmentIncludeAndSkipDirective_Hero_Friends(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "friends")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")); + var arg1 = Deserialize_IGetHeroWithFragmentIncludeAndSkipDirective_Hero_Friends(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "friends")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetHeroWithFragmentIncludeAndSkipDirective.State.HumanEntity(arg0, arg1)); + } + else + { + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetHeroWithFragmentIncludeAndSkipDirective.State.HumanEntity(arg0, arg1)); + } } return entityId; diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsTypeNameOnInterfacesTest.Client.cs b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsTypeNameOnInterfacesTest.Client.cs index 8d3dbdf5cbd..69ee5e778c1 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsTypeNameOnInterfacesTest.Client.cs +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsTypeNameOnInterfacesTest.Client.cs @@ -1,4 +1,4 @@ -// ReSharper disable ArrangeObjectCreationWhenTypeEvident +// ReSharper disable ArrangeObjectCreationWhenTypeEvident // ReSharper disable BuiltInTypeReferenceStyle // ReSharper disable ConvertToAutoProperty // ReSharper disable InconsistentNaming @@ -671,11 +671,20 @@ public GetHeroBuilder(global::StrawberryShake.IEntityStore entityStore, global:: { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsTypeNameOnInterfaces.State.DroidEntity? entity)) { - session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsTypeNameOnInterfaces.State.DroidEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "__typename")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "__typename")); + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsTypeNameOnInterfaces.State.DroidEntity(arg0)); } else { - session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsTypeNameOnInterfaces.State.DroidEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "__typename")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "__typename")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsTypeNameOnInterfaces.State.DroidEntity(arg0)); + } + else + { + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsTypeNameOnInterfaces.State.DroidEntity(arg0)); + } } return entityId; @@ -685,11 +694,20 @@ public GetHeroBuilder(global::StrawberryShake.IEntityStore entityStore, global:: { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsTypeNameOnInterfaces.State.HumanEntity? entity)) { - session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsTypeNameOnInterfaces.State.HumanEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "__typename")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "__typename")); + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsTypeNameOnInterfaces.State.HumanEntity(arg0)); } else { - session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsTypeNameOnInterfaces.State.HumanEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "__typename")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "__typename")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsTypeNameOnInterfaces.State.HumanEntity(arg0)); + } + else + { + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsTypeNameOnInterfaces.State.HumanEntity(arg0)); + } } return entityId; diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsTypeNameOnUnionsTest.Client.cs b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsTypeNameOnUnionsTest.Client.cs index 8ad4327cfd3..f635eeb1c84 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsTypeNameOnUnionsTest.Client.cs +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsTypeNameOnUnionsTest.Client.cs @@ -1,4 +1,4 @@ -// ReSharper disable ArrangeObjectCreationWhenTypeEvident +// ReSharper disable ArrangeObjectCreationWhenTypeEvident // ReSharper disable BuiltInTypeReferenceStyle // ReSharper disable ConvertToAutoProperty // ReSharper disable InconsistentNaming @@ -815,11 +815,20 @@ public SearchHeroBuilder(global::StrawberryShake.IEntityStore entityStore, globa { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsTypeNameOnUnions.State.StarshipEntity? entity)) { - session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsTypeNameOnUnions.State.StarshipEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "__typename")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "__typename")); + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsTypeNameOnUnions.State.StarshipEntity(arg0)); } else { - session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsTypeNameOnUnions.State.StarshipEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "__typename")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "__typename")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsTypeNameOnUnions.State.StarshipEntity(arg0)); + } + else + { + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsTypeNameOnUnions.State.StarshipEntity(arg0)); + } } return entityId; @@ -829,11 +838,20 @@ public SearchHeroBuilder(global::StrawberryShake.IEntityStore entityStore, globa { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsTypeNameOnUnions.State.HumanEntity? entity)) { - session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsTypeNameOnUnions.State.HumanEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "__typename")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "__typename")); + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsTypeNameOnUnions.State.HumanEntity(arg0)); } else { - session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsTypeNameOnUnions.State.HumanEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "__typename")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "__typename")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsTypeNameOnUnions.State.HumanEntity(arg0)); + } + else + { + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsTypeNameOnUnions.State.HumanEntity(arg0)); + } } return entityId; @@ -843,11 +861,20 @@ public SearchHeroBuilder(global::StrawberryShake.IEntityStore entityStore, globa { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsTypeNameOnUnions.State.DroidEntity? entity)) { - session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsTypeNameOnUnions.State.DroidEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "__typename")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "__typename")); + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsTypeNameOnUnions.State.DroidEntity(arg0)); } else { - session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsTypeNameOnUnions.State.DroidEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "__typename")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "__typename")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsTypeNameOnUnions.State.DroidEntity(arg0)); + } + else + { + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsTypeNameOnUnions.State.DroidEntity(arg0)); + } } return entityId; diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsUnionListTest.Client.cs b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsUnionListTest.Client.cs index 0286ba234e3..b823981d9be 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsUnionListTest.Client.cs +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsUnionListTest.Client.cs @@ -1,4 +1,4 @@ -// ReSharper disable ArrangeObjectCreationWhenTypeEvident +// ReSharper disable ArrangeObjectCreationWhenTypeEvident // ReSharper disable BuiltInTypeReferenceStyle // ReSharper disable ConvertToAutoProperty // ReSharper disable InconsistentNaming @@ -1110,7 +1110,14 @@ public SearchHeroBuilder(global::StrawberryShake.IEntityStore entityStore, globa } else { - session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsUnionList.State.StarshipEntity()); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsUnionList.State.StarshipEntity()); + } + else + { + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsUnionList.State.StarshipEntity()); + } } return entityId; @@ -1120,11 +1127,22 @@ public SearchHeroBuilder(global::StrawberryShake.IEntityStore entityStore, globa { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsUnionList.State.HumanEntity? entity)) { - session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsUnionList.State.HumanEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_ISearchHero_Search_Friends(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "friends"), entityIds))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + var arg1 = Deserialize_ISearchHero_Search_Friends(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "friends"), entityIds); + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsUnionList.State.HumanEntity(arg0, arg1)); } else { - session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsUnionList.State.HumanEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_ISearchHero_Search_Friends(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "friends"), entityIds))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + var arg1 = Deserialize_ISearchHero_Search_Friends(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "friends"), entityIds); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsUnionList.State.HumanEntity(arg0, arg1)); + } + else + { + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsUnionList.State.HumanEntity(arg0, arg1)); + } } return entityId; @@ -1134,11 +1152,20 @@ public SearchHeroBuilder(global::StrawberryShake.IEntityStore entityStore, globa { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsUnionList.State.DroidEntity? entity)) { - session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsUnionList.State.DroidEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsUnionList.State.DroidEntity(arg0)); } else { - session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsUnionList.State.DroidEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsUnionList.State.DroidEntity(arg0)); + } + else + { + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsUnionList.State.DroidEntity(arg0)); + } } return entityId; @@ -1222,11 +1249,20 @@ public SearchHeroBuilder(global::StrawberryShake.IEntityStore entityStore, globa { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsUnionList.State.DroidEntity? entity)) { - session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsUnionList.State.DroidEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsUnionList.State.DroidEntity(arg0)); } else { - session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsUnionList.State.DroidEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsUnionList.State.DroidEntity(arg0)); + } + else + { + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsUnionList.State.DroidEntity(arg0)); + } } return entityId; @@ -1236,11 +1272,20 @@ public SearchHeroBuilder(global::StrawberryShake.IEntityStore entityStore, globa { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsUnionList.State.HumanEntity? entity)) { - session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsUnionList.State.HumanEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), entity.Friends)); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsUnionList.State.HumanEntity(arg0, entity.Friends)); } else { - session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsUnionList.State.HumanEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), default !)); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsUnionList.State.HumanEntity(arg0, entity.Friends)); + } + else + { + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsUnionList.State.HumanEntity(arg0, default !)); + } } return entityId; diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/TestGeneration.cs b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/TestGeneration.cs index 62544fe22cc..cd0513372c6 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/TestGeneration.cs +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/TestGeneration.cs @@ -226,6 +226,127 @@ type Quox2 { ", "extend schema @key(fields: \"id\")"); + [Fact] + public void InlineFragmentOrder() => + AssertResult( + CreateIntegrationTest(profiles: + [ + new TransportProfile("Default", TransportType.InMemory) + ]), + skipWarnings: true, + """ + query NotWorkingQuery { + people { + id + name + pet { + id + __typename + ... on Cat { + furColor + } + ... on Dog { + breed + } + } + } + shelters { + id + location + pet { + id + __typename + ... on Bird { + wingSpan + } + ... on Cat { + furColor + } + ... on Dog { + breed + } + } + } + } + """, + """ + type Query { + people: [Person!]! + shelters: [Shelter!]! + } + + interface IPet { + id: Int! + } + + type Dog implements IPet { + id: Int! + breed: String! + } + + type Cat implements IPet { + id: Int! + furColor: String! + } + + type Bird implements IPet { + id: Int! + wingSpan: Int! + } + + type Person { + id: Int! + name: String! + pet: IPet + } + + type Shelter { + id: Int! + location: String! + pet: IPet + } + """, + "extend schema @key(fields: \"id\")"); + + [Fact] + public void RecursiveEntitySelfReference() => + AssertResult( + CreateIntegrationTest(profiles: + [ + new TransportProfile("Default", TransportType.InMemory) + ]), + skipWarnings: true, + """ + query GetSelfishGuy { + selfishGuy { + id + firstName + lastName + bestFriend { + firstName + age + phone + } + } + } + """, + """ + type Query { + selfishGuy: Person! + } + + type Person { + id: String! + firstName: String! + lastName: String! + age: Int! + phone: String! + zipCode: String! + bestFriend: Person + } + """, + "extend schema @key(fields: \"id\")"); + [Fact] public void StarWarsIntrospection() => AssertStarWarsResult( diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/DependencyInjectionGeneratorTests.Default_Combined.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/DependencyInjectionGeneratorTests.Default_Combined.snap index 6baeceff14d..a5d73972d6e 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/DependencyInjectionGeneratorTests.Default_Combined.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/DependencyInjectionGeneratorTests.Default_Combined.snap @@ -1174,11 +1174,20 @@ namespace Foo.Bar.State { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.PersonEntity? entity)) { - session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0)); } else { - session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0)); + } + else + { + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0)); + } } return entityId; @@ -1251,11 +1260,20 @@ namespace Foo.Bar.State { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.PersonEntity? entity)) { - session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0)); } else { - session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0)); + } + else + { + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0)); + } } return entityId; @@ -1328,11 +1346,20 @@ namespace Foo.Bar.State { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.PersonEntity? entity)) { - session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0)); } else { - session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0)); + } + else + { + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0)); + } } return entityId; diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/DependencyInjectionGeneratorTests.Default_DifferentTransportMethods.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/DependencyInjectionGeneratorTests.Default_DifferentTransportMethods.snap index de079a5e8db..92a50e42924 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/DependencyInjectionGeneratorTests.Default_DifferentTransportMethods.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/DependencyInjectionGeneratorTests.Default_DifferentTransportMethods.snap @@ -1174,11 +1174,20 @@ namespace Foo.Bar.State { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.PersonEntity? entity)) { - session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0)); } else { - session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0)); + } + else + { + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0)); + } } return entityId; @@ -1251,11 +1260,20 @@ namespace Foo.Bar.State { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.PersonEntity? entity)) { - session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0)); } else { - session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0)); + } + else + { + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0)); + } } return entityId; @@ -1328,11 +1346,20 @@ namespace Foo.Bar.State { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.PersonEntity? entity)) { - session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0)); } else { - session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0)); + } + else + { + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0)); + } } return entityId; diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/DependencyInjectionGeneratorTests.Default_InMemory.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/DependencyInjectionGeneratorTests.Default_InMemory.snap index a9ddef7a02f..bc006200992 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/DependencyInjectionGeneratorTests.Default_InMemory.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/DependencyInjectionGeneratorTests.Default_InMemory.snap @@ -1174,11 +1174,20 @@ namespace Foo.Bar.State { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.PersonEntity? entity)) { - session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0)); } else { - session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0)); + } + else + { + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0)); + } } return entityId; @@ -1251,11 +1260,20 @@ namespace Foo.Bar.State { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.PersonEntity? entity)) { - session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0)); } else { - session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0)); + } + else + { + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0)); + } } return entityId; @@ -1328,11 +1346,20 @@ namespace Foo.Bar.State { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.PersonEntity? entity)) { - session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0)); } else { - session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0)); + } + else + { + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0)); + } } return entityId; diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/DependencyInjectionGeneratorTests.Default_MultiProfile.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/DependencyInjectionGeneratorTests.Default_MultiProfile.snap index 3cc1ef6a957..ca7aeb02ae6 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/DependencyInjectionGeneratorTests.Default_MultiProfile.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/DependencyInjectionGeneratorTests.Default_MultiProfile.snap @@ -1182,11 +1182,20 @@ namespace Foo.Bar.State { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.PersonEntity? entity)) { - session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0)); } else { - session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0)); + } + else + { + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0)); + } } return entityId; @@ -1259,11 +1268,20 @@ namespace Foo.Bar.State { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.PersonEntity? entity)) { - session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0)); } else { - session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0)); + } + else + { + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0)); + } } return entityId; @@ -1336,11 +1354,20 @@ namespace Foo.Bar.State { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.PersonEntity? entity)) { - session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0)); } else { - session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0)); + } + else + { + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0)); + } } return entityId; diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/DependencyInjectionGeneratorTests.Default_Mutation.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/DependencyInjectionGeneratorTests.Default_Mutation.snap index 325cb15fa9b..a8a0126df55 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/DependencyInjectionGeneratorTests.Default_Mutation.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/DependencyInjectionGeneratorTests.Default_Mutation.snap @@ -473,11 +473,20 @@ namespace Foo.Bar.State { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.PersonEntity? entity)) { - session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0)); } else { - session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0)); + } + else + { + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0)); + } } return entityId; diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/DependencyInjectionGeneratorTests.Default_Query.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/DependencyInjectionGeneratorTests.Default_Query.snap index 9369837b4f9..edd55c1e5c8 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/DependencyInjectionGeneratorTests.Default_Query.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/DependencyInjectionGeneratorTests.Default_Query.snap @@ -473,11 +473,20 @@ namespace Foo.Bar.State { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.PersonEntity? entity)) { - session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0)); } else { - session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0)); + } + else + { + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0)); + } } return entityId; diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/DependencyInjectionGeneratorTests.Default_Subscription.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/DependencyInjectionGeneratorTests.Default_Subscription.snap index 21bf4add349..580a656023d 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/DependencyInjectionGeneratorTests.Default_Subscription.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/DependencyInjectionGeneratorTests.Default_Subscription.snap @@ -436,11 +436,20 @@ namespace Foo.Bar.State { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.PersonEntity? entity)) { - session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0)); } else { - session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0)); + } + else + { + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0)); + } } return entityId; diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityGeneratorTests.Generate_BookClient_DataInEntity_UnionDataTypes.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityGeneratorTests.Generate_BookClient_DataInEntity_UnionDataTypes.snap index 9819ac52eeb..b0e87d374f5 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityGeneratorTests.Generate_BookClient_DataInEntity_UnionDataTypes.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityGeneratorTests.Generate_BookClient_DataInEntity_UnionDataTypes.snap @@ -748,11 +748,24 @@ namespace Foo.Bar.State { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.SearchableStoreEntity? entity)) { - session.SetEntity(entityId, new global::Foo.Bar.State.SearchableStoreEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")), Deserialize_IGetStore2_SearchableStore_BooksArray(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "books")), Deserialize_ISearchResultData(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "search")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")); + var arg1 = Deserialize_IGetStore2_SearchableStore_BooksArray(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "books")); + var arg2 = Deserialize_ISearchResultData(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "search")); + session.SetEntity(entityId, new global::Foo.Bar.State.SearchableStoreEntity(arg0, arg1, arg2)); } else { - session.SetEntity(entityId, new global::Foo.Bar.State.SearchableStoreEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")), Deserialize_IGetStore2_SearchableStore_BooksArray(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "books")), Deserialize_ISearchResultData(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "search")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")); + var arg1 = Deserialize_IGetStore2_SearchableStore_BooksArray(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "books")); + var arg2 = Deserialize_ISearchResultData(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "search")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::Foo.Bar.State.SearchableStoreEntity(arg0, arg1, arg2)); + } + else + { + session.SetEntity(entityId, new global::Foo.Bar.State.SearchableStoreEntity(arg0, arg1, arg2)); + } } return entityId; diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityGeneratorTests.Generate_BookClient_DataInEntity_UnionDataTypes_With_Records.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityGeneratorTests.Generate_BookClient_DataInEntity_UnionDataTypes_With_Records.snap index c3ab353d047..2dc2191d0c0 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityGeneratorTests.Generate_BookClient_DataInEntity_UnionDataTypes_With_Records.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityGeneratorTests.Generate_BookClient_DataInEntity_UnionDataTypes_With_Records.snap @@ -748,11 +748,24 @@ namespace Foo.Bar.State { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.SearchableStoreEntity? entity)) { - session.SetEntity(entityId, new global::Foo.Bar.State.SearchableStoreEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")), Deserialize_IGetStore2_SearchableStore_BooksArray(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "books")), Deserialize_ISearchResultData(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "search")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")); + var arg1 = Deserialize_IGetStore2_SearchableStore_BooksArray(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "books")); + var arg2 = Deserialize_ISearchResultData(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "search")); + session.SetEntity(entityId, new global::Foo.Bar.State.SearchableStoreEntity(arg0, arg1, arg2)); } else { - session.SetEntity(entityId, new global::Foo.Bar.State.SearchableStoreEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")), Deserialize_IGetStore2_SearchableStore_BooksArray(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "books")), Deserialize_ISearchResultData(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "search")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")); + var arg1 = Deserialize_IGetStore2_SearchableStore_BooksArray(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "books")); + var arg2 = Deserialize_ISearchResultData(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "search")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::Foo.Bar.State.SearchableStoreEntity(arg0, arg1, arg2)); + } + else + { + session.SetEntity(entityId, new global::Foo.Bar.State.SearchableStoreEntity(arg0, arg1, arg2)); + } } return entityId; diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityGeneratorTests.Generate_ChatClient_ConnectionNotAnEntity.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityGeneratorTests.Generate_ChatClient_ConnectionNotAnEntity.snap index 27988b6ea3b..115a6f5fd79 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityGeneratorTests.Generate_ChatClient_ConnectionNotAnEntity.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityGeneratorTests.Generate_ChatClient_ConnectionNotAnEntity.snap @@ -726,11 +726,24 @@ namespace Foo.Bar.State { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.PersonEntity? entity)) { - session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "email")), Deserialize_NonNullableBoolean(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "isOnline")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + var arg1 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "email")); + var arg2 = Deserialize_NonNullableBoolean(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "isOnline")); + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0, arg1, arg2)); } else { - session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "email")), Deserialize_NonNullableBoolean(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "isOnline")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + var arg1 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "email")); + var arg2 = Deserialize_NonNullableBoolean(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "isOnline")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0, arg1, arg2)); + } + else + { + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0, arg1, arg2)); + } } return entityId; diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityGeneratorTests.Generate_ChatClient_ConnectionNotAnEntity_With_Records.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityGeneratorTests.Generate_ChatClient_ConnectionNotAnEntity_With_Records.snap index f789e89b715..0d03cd67583 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityGeneratorTests.Generate_ChatClient_ConnectionNotAnEntity_With_Records.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityGeneratorTests.Generate_ChatClient_ConnectionNotAnEntity_With_Records.snap @@ -726,11 +726,24 @@ namespace Foo.Bar.State { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.PersonEntity? entity)) { - session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "email")), Deserialize_NonNullableBoolean(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "isOnline")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + var arg1 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "email")); + var arg2 = Deserialize_NonNullableBoolean(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "isOnline")); + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0, arg1, arg2)); } else { - session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "email")), Deserialize_NonNullableBoolean(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "isOnline")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + var arg1 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "email")); + var arg2 = Deserialize_NonNullableBoolean(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "isOnline")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0, arg1, arg2)); + } + else + { + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0, arg1, arg2)); + } } return entityId; diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityGeneratorTests.Generate_ChatClient_MapperMapsEntityOnRootCorrectly.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityGeneratorTests.Generate_ChatClient_MapperMapsEntityOnRootCorrectly.snap index 05bead7ebfa..c64f660df0d 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityGeneratorTests.Generate_ChatClient_MapperMapsEntityOnRootCorrectly.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityGeneratorTests.Generate_ChatClient_MapperMapsEntityOnRootCorrectly.snap @@ -1845,11 +1845,22 @@ namespace Foo.Bar.State { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.PersonEntity? entity)) { - session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_IGetPeople_People_Nodes_Messages(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "messages"), entityIds))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + var arg1 = Deserialize_IGetPeople_People_Nodes_Messages(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "messages"), entityIds); + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0, arg1)); } else { - session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_IGetPeople_People_Nodes_Messages(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "messages"), entityIds))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + var arg1 = Deserialize_IGetPeople_People_Nodes_Messages(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "messages"), entityIds); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0, arg1)); + } + else + { + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0, arg1)); + } } return entityId; @@ -1933,11 +1944,22 @@ namespace Foo.Bar.State { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.MessageEntity? entity)) { - session.SetEntity(entityId, new global::Foo.Bar.State.MessageEntity(Update_NonNullableIGetPeople_People_Nodes_Messages_Nodes_SenderEntity(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "sender"), entityIds), Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "text")))); + var arg0 = Update_NonNullableIGetPeople_People_Nodes_Messages_Nodes_SenderEntity(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "sender"), entityIds); + var arg1 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "text")); + session.SetEntity(entityId, new global::Foo.Bar.State.MessageEntity(arg0, arg1)); } else { - session.SetEntity(entityId, new global::Foo.Bar.State.MessageEntity(Update_NonNullableIGetPeople_People_Nodes_Messages_Nodes_SenderEntity(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "sender"), entityIds), Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "text")))); + var arg0 = Update_NonNullableIGetPeople_People_Nodes_Messages_Nodes_SenderEntity(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "sender"), entityIds); + var arg1 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "text")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::Foo.Bar.State.MessageEntity(arg0, arg1)); + } + else + { + session.SetEntity(entityId, new global::Foo.Bar.State.MessageEntity(arg0, arg1)); + } } return entityId; @@ -1964,11 +1986,20 @@ namespace Foo.Bar.State { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.PersonEntity? entity)) { - session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), entity.Messages)); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0, entity.Messages)); } else { - session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), default !)); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0, entity.Messages)); + } + else + { + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0, default !)); + } } return entityId; @@ -2047,11 +2078,22 @@ namespace Foo.Bar.State { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.MessageEntity? entity)) { - session.SetEntity(entityId, new global::Foo.Bar.State.MessageEntity(Update_NonNullableIGetPeople_People_Nodes_Messages_Nodes_SenderEntity(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "sender"), entityIds), Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "text")))); + var arg0 = Update_NonNullableIGetPeople_People_Nodes_Messages_Nodes_SenderEntity(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "sender"), entityIds); + var arg1 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "text")); + session.SetEntity(entityId, new global::Foo.Bar.State.MessageEntity(arg0, arg1)); } else { - session.SetEntity(entityId, new global::Foo.Bar.State.MessageEntity(Update_NonNullableIGetPeople_People_Nodes_Messages_Nodes_SenderEntity(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "sender"), entityIds), Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "text")))); + var arg0 = Update_NonNullableIGetPeople_People_Nodes_Messages_Nodes_SenderEntity(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "sender"), entityIds); + var arg1 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "text")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::Foo.Bar.State.MessageEntity(arg0, arg1)); + } + else + { + session.SetEntity(entityId, new global::Foo.Bar.State.MessageEntity(arg0, arg1)); + } } return entityId; @@ -2078,11 +2120,20 @@ namespace Foo.Bar.State { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.PersonEntity? entity)) { - session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), entity.Messages)); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0, entity.Messages)); } else { - session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), default !)); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0, entity.Messages)); + } + else + { + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0, default !)); + } } return entityId; diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityGeneratorTests.Generate_ChatClient_MapperMapsEntityOnRootCorrectly_With_Records.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityGeneratorTests.Generate_ChatClient_MapperMapsEntityOnRootCorrectly_With_Records.snap index 1372c8c91fd..7d23a97cf91 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityGeneratorTests.Generate_ChatClient_MapperMapsEntityOnRootCorrectly_With_Records.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityGeneratorTests.Generate_ChatClient_MapperMapsEntityOnRootCorrectly_With_Records.snap @@ -1845,11 +1845,22 @@ namespace Foo.Bar.State { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.PersonEntity? entity)) { - session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_IGetPeople_People_Nodes_Messages(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "messages"), entityIds))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + var arg1 = Deserialize_IGetPeople_People_Nodes_Messages(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "messages"), entityIds); + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0, arg1)); } else { - session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_IGetPeople_People_Nodes_Messages(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "messages"), entityIds))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + var arg1 = Deserialize_IGetPeople_People_Nodes_Messages(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "messages"), entityIds); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0, arg1)); + } + else + { + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0, arg1)); + } } return entityId; @@ -1933,11 +1944,22 @@ namespace Foo.Bar.State { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.MessageEntity? entity)) { - session.SetEntity(entityId, new global::Foo.Bar.State.MessageEntity(Update_NonNullableIGetPeople_People_Nodes_Messages_Nodes_SenderEntity(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "sender"), entityIds), Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "text")))); + var arg0 = Update_NonNullableIGetPeople_People_Nodes_Messages_Nodes_SenderEntity(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "sender"), entityIds); + var arg1 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "text")); + session.SetEntity(entityId, new global::Foo.Bar.State.MessageEntity(arg0, arg1)); } else { - session.SetEntity(entityId, new global::Foo.Bar.State.MessageEntity(Update_NonNullableIGetPeople_People_Nodes_Messages_Nodes_SenderEntity(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "sender"), entityIds), Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "text")))); + var arg0 = Update_NonNullableIGetPeople_People_Nodes_Messages_Nodes_SenderEntity(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "sender"), entityIds); + var arg1 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "text")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::Foo.Bar.State.MessageEntity(arg0, arg1)); + } + else + { + session.SetEntity(entityId, new global::Foo.Bar.State.MessageEntity(arg0, arg1)); + } } return entityId; @@ -1964,11 +1986,20 @@ namespace Foo.Bar.State { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.PersonEntity? entity)) { - session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), entity.Messages)); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0, entity.Messages)); } else { - session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), default !)); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0, entity.Messages)); + } + else + { + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0, default !)); + } } return entityId; @@ -2047,11 +2078,22 @@ namespace Foo.Bar.State { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.MessageEntity? entity)) { - session.SetEntity(entityId, new global::Foo.Bar.State.MessageEntity(Update_NonNullableIGetPeople_People_Nodes_Messages_Nodes_SenderEntity(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "sender"), entityIds), Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "text")))); + var arg0 = Update_NonNullableIGetPeople_People_Nodes_Messages_Nodes_SenderEntity(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "sender"), entityIds); + var arg1 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "text")); + session.SetEntity(entityId, new global::Foo.Bar.State.MessageEntity(arg0, arg1)); } else { - session.SetEntity(entityId, new global::Foo.Bar.State.MessageEntity(Update_NonNullableIGetPeople_People_Nodes_Messages_Nodes_SenderEntity(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "sender"), entityIds), Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "text")))); + var arg0 = Update_NonNullableIGetPeople_People_Nodes_Messages_Nodes_SenderEntity(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "sender"), entityIds); + var arg1 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "text")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::Foo.Bar.State.MessageEntity(arg0, arg1)); + } + else + { + session.SetEntity(entityId, new global::Foo.Bar.State.MessageEntity(arg0, arg1)); + } } return entityId; @@ -2078,11 +2120,20 @@ namespace Foo.Bar.State { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.PersonEntity? entity)) { - session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), entity.Messages)); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0, entity.Messages)); } else { - session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), default !)); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0, entity.Messages)); + } + else + { + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0, default !)); + } } return entityId; diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityIdFactoryGeneratorTests.Simple_ComplexEntity.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityIdFactoryGeneratorTests.Simple_ComplexEntity.snap index 1dd8dd4b862..eafe0c1fb2c 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityIdFactoryGeneratorTests.Simple_ComplexEntity.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityIdFactoryGeneratorTests.Simple_ComplexEntity.snap @@ -489,11 +489,22 @@ namespace Foo.Bar.State { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.PersonEntity? entity)) { - session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")), Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "email")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")); + var arg1 = Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "email")); + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0, arg1)); } else { - session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")), Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "email")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")); + var arg1 = Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "email")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0, arg1)); + } + else + { + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0, arg1)); + } } return entityId; diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityIdFactoryGeneratorTests.Simple_DateTimeOffset_Entity.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityIdFactoryGeneratorTests.Simple_DateTimeOffset_Entity.snap index e6ba0f9acea..5da418da6f2 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityIdFactoryGeneratorTests.Simple_DateTimeOffset_Entity.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityIdFactoryGeneratorTests.Simple_DateTimeOffset_Entity.snap @@ -488,11 +488,22 @@ namespace Foo.Bar.State { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.PersonEntity? entity)) { - session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableDateTimeOffset(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")), Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "email")))); + var arg0 = Deserialize_NonNullableDateTimeOffset(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")); + var arg1 = Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "email")); + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0, arg1)); } else { - session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableDateTimeOffset(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")), Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "email")))); + var arg0 = Deserialize_NonNullableDateTimeOffset(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")); + var arg1 = Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "email")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0, arg1)); + } + else + { + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0, arg1)); + } } return entityId; diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityIdFactoryGeneratorTests.Simple_IdEntity.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityIdFactoryGeneratorTests.Simple_IdEntity.snap index 465dc69f74e..c7212663f49 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityIdFactoryGeneratorTests.Simple_IdEntity.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityIdFactoryGeneratorTests.Simple_IdEntity.snap @@ -486,11 +486,22 @@ namespace Foo.Bar.State { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.PersonEntity? entity)) { - session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")), Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "email")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")); + var arg1 = Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "email")); + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0, arg1)); } else { - session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")), Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "email")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")); + var arg1 = Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "email")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0, arg1)); + } + else + { + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0, arg1)); + } } return entityId; diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityIdFactoryGeneratorTests.Simple_UUID_Entity.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityIdFactoryGeneratorTests.Simple_UUID_Entity.snap index 7832a5f1f7b..000d542ac47 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityIdFactoryGeneratorTests.Simple_UUID_Entity.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityIdFactoryGeneratorTests.Simple_UUID_Entity.snap @@ -488,11 +488,22 @@ namespace Foo.Bar.State { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.PersonEntity? entity)) { - session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableGuid(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")), Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "email")))); + var arg0 = Deserialize_NonNullableGuid(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")); + var arg1 = Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "email")); + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0, arg1)); } else { - session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableGuid(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")), Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "email")))); + var arg0 = Deserialize_NonNullableGuid(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")); + var arg1 = Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "email")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0, arg1)); + } + else + { + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0, arg1)); + } } return entityId; diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityOrIdGeneratorTests.InterfaceField.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityOrIdGeneratorTests.InterfaceField.snap index 6738a6af715..b60b1ad6982 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityOrIdGeneratorTests.InterfaceField.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityOrIdGeneratorTests.InterfaceField.snap @@ -840,11 +840,22 @@ namespace Foo.Bar.State { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.BazEntity? entity)) { - session.SetEntity(entityId, new global::Foo.Bar.State.BazEntity(Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "foo")), Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")))); + var arg0 = Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "foo")); + var arg1 = Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")); + session.SetEntity(entityId, new global::Foo.Bar.State.BazEntity(arg0, arg1)); } else { - session.SetEntity(entityId, new global::Foo.Bar.State.BazEntity(Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "foo")), Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")))); + var arg0 = Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "foo")); + var arg1 = Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::Foo.Bar.State.BazEntity(arg0, arg1)); + } + else + { + session.SetEntity(entityId, new global::Foo.Bar.State.BazEntity(arg0, arg1)); + } } return new global::StrawberryShake.EntityIdOrData(entityId); @@ -858,11 +869,22 @@ namespace Foo.Bar.State { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.Baz2Entity? entity)) { - session.SetEntity(entityId, new global::Foo.Bar.State.Baz2Entity(Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "foo")), Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")))); + var arg0 = Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "foo")); + var arg1 = Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")); + session.SetEntity(entityId, new global::Foo.Bar.State.Baz2Entity(arg0, arg1)); } else { - session.SetEntity(entityId, new global::Foo.Bar.State.Baz2Entity(Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "foo")), Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")))); + var arg0 = Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "foo")); + var arg1 = Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::Foo.Bar.State.Baz2Entity(arg0, arg1)); + } + else + { + session.SetEntity(entityId, new global::Foo.Bar.State.Baz2Entity(arg0, arg1)); + } } return new global::StrawberryShake.EntityIdOrData(entityId); diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityOrIdGeneratorTests.InterfaceList.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityOrIdGeneratorTests.InterfaceList.snap index 95b898a8414..2794573533a 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityOrIdGeneratorTests.InterfaceList.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityOrIdGeneratorTests.InterfaceList.snap @@ -883,11 +883,22 @@ namespace Foo.Bar.State { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.BazEntity? entity)) { - session.SetEntity(entityId, new global::Foo.Bar.State.BazEntity(Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "foo")), Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")))); + var arg0 = Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "foo")); + var arg1 = Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")); + session.SetEntity(entityId, new global::Foo.Bar.State.BazEntity(arg0, arg1)); } else { - session.SetEntity(entityId, new global::Foo.Bar.State.BazEntity(Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "foo")), Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")))); + var arg0 = Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "foo")); + var arg1 = Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::Foo.Bar.State.BazEntity(arg0, arg1)); + } + else + { + session.SetEntity(entityId, new global::Foo.Bar.State.BazEntity(arg0, arg1)); + } } return new global::StrawberryShake.EntityIdOrData(entityId); @@ -901,11 +912,22 @@ namespace Foo.Bar.State { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.Baz2Entity? entity)) { - session.SetEntity(entityId, new global::Foo.Bar.State.Baz2Entity(Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "foo")), Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")))); + var arg0 = Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "foo")); + var arg1 = Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")); + session.SetEntity(entityId, new global::Foo.Bar.State.Baz2Entity(arg0, arg1)); } else { - session.SetEntity(entityId, new global::Foo.Bar.State.Baz2Entity(Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "foo")), Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")))); + var arg0 = Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "foo")); + var arg1 = Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::Foo.Bar.State.Baz2Entity(arg0, arg1)); + } + else + { + session.SetEntity(entityId, new global::Foo.Bar.State.Baz2Entity(arg0, arg1)); + } } return new global::StrawberryShake.EntityIdOrData(entityId); diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityOrIdGeneratorTests.NonNullableValueTypeId.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityOrIdGeneratorTests.NonNullableValueTypeId.snap index 72ca087590e..b03197a9ef0 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityOrIdGeneratorTests.NonNullableValueTypeId.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityOrIdGeneratorTests.NonNullableValueTypeId.snap @@ -841,11 +841,20 @@ namespace Foo.Bar.State { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.BazEntity? entity)) { - session.SetEntity(entityId, new global::Foo.Bar.State.BazEntity(Deserialize_NonNullableInt32(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")))); + var arg0 = Deserialize_NonNullableInt32(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")); + session.SetEntity(entityId, new global::Foo.Bar.State.BazEntity(arg0)); } else { - session.SetEntity(entityId, new global::Foo.Bar.State.BazEntity(Deserialize_NonNullableInt32(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")))); + var arg0 = Deserialize_NonNullableInt32(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::Foo.Bar.State.BazEntity(arg0)); + } + else + { + session.SetEntity(entityId, new global::Foo.Bar.State.BazEntity(arg0)); + } } return new global::StrawberryShake.EntityIdOrData(entityId); @@ -864,11 +873,20 @@ namespace Foo.Bar.State { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.Baz2Entity? entity)) { - session.SetEntity(entityId, new global::Foo.Bar.State.Baz2Entity(Deserialize_NonNullableInt32(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")))); + var arg0 = Deserialize_NonNullableInt32(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")); + session.SetEntity(entityId, new global::Foo.Bar.State.Baz2Entity(arg0)); } else { - session.SetEntity(entityId, new global::Foo.Bar.State.Baz2Entity(Deserialize_NonNullableInt32(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")))); + var arg0 = Deserialize_NonNullableInt32(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::Foo.Bar.State.Baz2Entity(arg0)); + } + else + { + session.SetEntity(entityId, new global::Foo.Bar.State.Baz2Entity(arg0)); + } } return new global::StrawberryShake.EntityIdOrData(entityId); diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityOrIdGeneratorTests.UnionField.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityOrIdGeneratorTests.UnionField.snap index d74a7f4f0d9..eee211473a1 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityOrIdGeneratorTests.UnionField.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityOrIdGeneratorTests.UnionField.snap @@ -804,11 +804,20 @@ namespace Foo.Bar.State { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.BazEntity? entity)) { - session.SetEntity(entityId, new global::Foo.Bar.State.BazEntity(Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")))); + var arg0 = Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")); + session.SetEntity(entityId, new global::Foo.Bar.State.BazEntity(arg0)); } else { - session.SetEntity(entityId, new global::Foo.Bar.State.BazEntity(Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")))); + var arg0 = Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::Foo.Bar.State.BazEntity(arg0)); + } + else + { + session.SetEntity(entityId, new global::Foo.Bar.State.BazEntity(arg0)); + } } return new global::StrawberryShake.EntityIdOrData(entityId); @@ -827,11 +836,20 @@ namespace Foo.Bar.State { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.Baz2Entity? entity)) { - session.SetEntity(entityId, new global::Foo.Bar.State.Baz2Entity(Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")))); + var arg0 = Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")); + session.SetEntity(entityId, new global::Foo.Bar.State.Baz2Entity(arg0)); } else { - session.SetEntity(entityId, new global::Foo.Bar.State.Baz2Entity(Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")))); + var arg0 = Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::Foo.Bar.State.Baz2Entity(arg0)); + } + else + { + session.SetEntity(entityId, new global::Foo.Bar.State.Baz2Entity(arg0)); + } } return new global::StrawberryShake.EntityIdOrData(entityId); diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityOrIdGeneratorTests.UnionList.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityOrIdGeneratorTests.UnionList.snap index 536cc8bcbb8..59dfa2eb9ba 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityOrIdGeneratorTests.UnionList.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityOrIdGeneratorTests.UnionList.snap @@ -847,11 +847,20 @@ namespace Foo.Bar.State { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.BazEntity? entity)) { - session.SetEntity(entityId, new global::Foo.Bar.State.BazEntity(Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")))); + var arg0 = Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")); + session.SetEntity(entityId, new global::Foo.Bar.State.BazEntity(arg0)); } else { - session.SetEntity(entityId, new global::Foo.Bar.State.BazEntity(Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")))); + var arg0 = Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::Foo.Bar.State.BazEntity(arg0)); + } + else + { + session.SetEntity(entityId, new global::Foo.Bar.State.BazEntity(arg0)); + } } return new global::StrawberryShake.EntityIdOrData(entityId); @@ -870,11 +879,20 @@ namespace Foo.Bar.State { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.Baz2Entity? entity)) { - session.SetEntity(entityId, new global::Foo.Bar.State.Baz2Entity(Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")))); + var arg0 = Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")); + session.SetEntity(entityId, new global::Foo.Bar.State.Baz2Entity(arg0)); } else { - session.SetEntity(entityId, new global::Foo.Bar.State.Baz2Entity(Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")))); + var arg0 = Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::Foo.Bar.State.Baz2Entity(arg0)); + } + else + { + session.SetEntity(entityId, new global::Foo.Bar.State.Baz2Entity(arg0)); + } } return new global::StrawberryShake.EntityIdOrData(entityId); diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityOrIdGeneratorTests.UnionListInEntity.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityOrIdGeneratorTests.UnionListInEntity.snap index 0ccd16f9067..a933b9edd05 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityOrIdGeneratorTests.UnionListInEntity.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityOrIdGeneratorTests.UnionListInEntity.snap @@ -865,11 +865,20 @@ namespace Foo.Bar.State { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.TestEntity? entity)) { - session.SetEntity(entityId, new global::Foo.Bar.State.TestEntity(Deserialize_IBarDataArray(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "foo"), entityIds))); + var arg0 = Deserialize_IBarDataArray(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "foo"), entityIds); + session.SetEntity(entityId, new global::Foo.Bar.State.TestEntity(arg0)); } else { - session.SetEntity(entityId, new global::Foo.Bar.State.TestEntity(Deserialize_IBarDataArray(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "foo"), entityIds))); + var arg0 = Deserialize_IBarDataArray(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "foo"), entityIds); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::Foo.Bar.State.TestEntity(arg0)); + } + else + { + session.SetEntity(entityId, new global::Foo.Bar.State.TestEntity(arg0)); + } } return entityId; @@ -919,11 +928,20 @@ namespace Foo.Bar.State { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.BazEntity? entity)) { - session.SetEntity(entityId, new global::Foo.Bar.State.BazEntity(Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")))); + var arg0 = Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")); + session.SetEntity(entityId, new global::Foo.Bar.State.BazEntity(arg0)); } else { - session.SetEntity(entityId, new global::Foo.Bar.State.BazEntity(Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")))); + var arg0 = Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::Foo.Bar.State.BazEntity(arg0)); + } + else + { + session.SetEntity(entityId, new global::Foo.Bar.State.BazEntity(arg0)); + } } return new global::StrawberryShake.EntityIdOrData(entityId); @@ -942,11 +960,20 @@ namespace Foo.Bar.State { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.Baz2Entity? entity)) { - session.SetEntity(entityId, new global::Foo.Bar.State.Baz2Entity(Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")))); + var arg0 = Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")); + session.SetEntity(entityId, new global::Foo.Bar.State.Baz2Entity(arg0)); } else { - session.SetEntity(entityId, new global::Foo.Bar.State.Baz2Entity(Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")))); + var arg0 = Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::Foo.Bar.State.Baz2Entity(arg0)); + } + else + { + session.SetEntity(entityId, new global::Foo.Bar.State.Baz2Entity(arg0)); + } } return new global::StrawberryShake.EntityIdOrData(entityId); diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityOrIdGeneratorTests.UnionWithNestedObject.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityOrIdGeneratorTests.UnionWithNestedObject.snap index f3815c2fba6..3a68dae5da2 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityOrIdGeneratorTests.UnionWithNestedObject.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityOrIdGeneratorTests.UnionWithNestedObject.snap @@ -966,11 +966,20 @@ namespace Foo.Bar.State { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.UserSettingSuccessEntity? entity)) { - session.SetEntity(entityId, new global::Foo.Bar.State.UserSettingSuccessEntity(Deserialize_NonNullableInt32(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")))); + var arg0 = Deserialize_NonNullableInt32(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")); + session.SetEntity(entityId, new global::Foo.Bar.State.UserSettingSuccessEntity(arg0)); } else { - session.SetEntity(entityId, new global::Foo.Bar.State.UserSettingSuccessEntity(Deserialize_NonNullableInt32(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")))); + var arg0 = Deserialize_NonNullableInt32(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::Foo.Bar.State.UserSettingSuccessEntity(arg0)); + } + else + { + session.SetEntity(entityId, new global::Foo.Bar.State.UserSettingSuccessEntity(arg0)); + } } return new global::StrawberryShake.EntityIdOrData(entityId); diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/ErrorGeneratorTests.Generate_ChatClient_InvalidNullCheck.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/ErrorGeneratorTests.Generate_ChatClient_InvalidNullCheck.snap index 4c661812b71..050564515b7 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/ErrorGeneratorTests.Generate_ChatClient_InvalidNullCheck.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/ErrorGeneratorTests.Generate_ChatClient_InvalidNullCheck.snap @@ -754,11 +754,20 @@ namespace Foo.Bar.State { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.PersonEntity? entity)) { - session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_IGetPeople_Me_Friends(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "friends"), entityIds), entity.Name, entity.Email, entity.IsOnline)); + var arg0 = Deserialize_IGetPeople_Me_Friends(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "friends"), entityIds); + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0, entity.Name, entity.Email, entity.IsOnline)); } else { - session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_IGetPeople_Me_Friends(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "friends"), entityIds), default !, default !, default !)); + var arg0 = Deserialize_IGetPeople_Me_Friends(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "friends"), entityIds); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0, entity.Name, entity.Email, entity.IsOnline)); + } + else + { + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0, default !, default !, default !)); + } } return entityId; @@ -827,11 +836,24 @@ namespace Foo.Bar.State { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.PersonEntity? entity)) { - session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(entity.Friends, Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "email")), Deserialize_NonNullableBoolean(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "isOnline")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + var arg1 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "email")); + var arg2 = Deserialize_NonNullableBoolean(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "isOnline")); + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(entity.Friends, arg0, arg1, arg2)); } else { - session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(default !, Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "email")), Deserialize_NonNullableBoolean(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "isOnline")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + var arg1 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "email")); + var arg2 = Deserialize_NonNullableBoolean(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "isOnline")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(entity.Friends, arg0, arg1, arg2)); + } + else + { + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(default !, arg0, arg1, arg2)); + } } return entityId; diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/ErrorGeneratorTests.Generate_NoErrors.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/ErrorGeneratorTests.Generate_NoErrors.snap index 7a7f81f32aa..83ef8c212c3 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/ErrorGeneratorTests.Generate_NoErrors.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/ErrorGeneratorTests.Generate_NoErrors.snap @@ -641,11 +641,22 @@ namespace Foo.Bar.State { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.DroidEntity? entity)) { - session.SetEntity(entityId, new global::Foo.Bar.State.DroidEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_EpisodeArray(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "appearsIn")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + var arg1 = Deserialize_EpisodeArray(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "appearsIn")); + session.SetEntity(entityId, new global::Foo.Bar.State.DroidEntity(arg0, arg1)); } else { - session.SetEntity(entityId, new global::Foo.Bar.State.DroidEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_EpisodeArray(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "appearsIn")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + var arg1 = Deserialize_EpisodeArray(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "appearsIn")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::Foo.Bar.State.DroidEntity(arg0, arg1)); + } + else + { + session.SetEntity(entityId, new global::Foo.Bar.State.DroidEntity(arg0, arg1)); + } } return entityId; @@ -655,11 +666,22 @@ namespace Foo.Bar.State { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.HumanEntity? entity)) { - session.SetEntity(entityId, new global::Foo.Bar.State.HumanEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_EpisodeArray(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "appearsIn")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + var arg1 = Deserialize_EpisodeArray(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "appearsIn")); + session.SetEntity(entityId, new global::Foo.Bar.State.HumanEntity(arg0, arg1)); } else { - session.SetEntity(entityId, new global::Foo.Bar.State.HumanEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_EpisodeArray(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "appearsIn")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + var arg1 = Deserialize_EpisodeArray(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "appearsIn")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::Foo.Bar.State.HumanEntity(arg0, arg1)); + } + else + { + session.SetEntity(entityId, new global::Foo.Bar.State.HumanEntity(arg0, arg1)); + } } return entityId; diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/InputGeneratorTests.Input_Type_Fields_Are_Inspected_For_LeafTypes.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/InputGeneratorTests.Input_Type_Fields_Are_Inspected_For_LeafTypes.snap index 9fb2a4f0291..fe1318b0e46 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/InputGeneratorTests.Input_Type_Fields_Are_Inspected_For_LeafTypes.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/InputGeneratorTests.Input_Type_Fields_Are_Inspected_For_LeafTypes.snap @@ -773,11 +773,20 @@ namespace Foo.Bar.State { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.HumanEntity? entity)) { - session.SetEntity(entityId, new global::Foo.Bar.State.HumanEntity(Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "homePlanet")))); + var arg0 = Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "homePlanet")); + session.SetEntity(entityId, new global::Foo.Bar.State.HumanEntity(arg0)); } else { - session.SetEntity(entityId, new global::Foo.Bar.State.HumanEntity(Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "homePlanet")))); + var arg0 = Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "homePlanet")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::Foo.Bar.State.HumanEntity(arg0)); + } + else + { + session.SetEntity(entityId, new global::Foo.Bar.State.HumanEntity(arg0)); + } } return entityId; diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/InputGeneratorTests.KeywordCollisions.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/InputGeneratorTests.KeywordCollisions.snap index e66e9273f84..a90189d198e 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/InputGeneratorTests.KeywordCollisions.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/InputGeneratorTests.KeywordCollisions.snap @@ -792,11 +792,22 @@ namespace Foo.Bar.State { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.readonlyEntityEntity? entity)) { - session.SetEntity(entityId, new global::Foo.Bar.State.readonlyEntityEntity(Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")), Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "abstract")))); + var arg0 = Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")); + var arg1 = Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "abstract")); + session.SetEntity(entityId, new global::Foo.Bar.State.readonlyEntityEntity(arg0, arg1)); } else { - session.SetEntity(entityId, new global::Foo.Bar.State.readonlyEntityEntity(Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")), Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "abstract")))); + var arg0 = Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")); + var arg1 = Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "abstract")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::Foo.Bar.State.readonlyEntityEntity(arg0, arg1)); + } + else + { + session.SetEntity(entityId, new global::Foo.Bar.State.readonlyEntityEntity(arg0, arg1)); + } } return entityId; diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/OperationGeneratorTests.Generate_ChatClient_AllOperations.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/OperationGeneratorTests.Generate_ChatClient_AllOperations.snap index 391a47f4b27..a6ba79dd74b 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/OperationGeneratorTests.Generate_ChatClient_AllOperations.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/OperationGeneratorTests.Generate_ChatClient_AllOperations.snap @@ -4397,11 +4397,28 @@ namespace Foo.Bar.State { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.PersonEntity? entity)) { - session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "email")), Deserialize_NonNullableBoolean(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "isOnline")), Deserialize_Uri(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "imageUri")), Deserialize_NonNullableDateTimeOffset(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "lastSeen")), entity.Messages)); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + var arg1 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "email")); + var arg2 = Deserialize_NonNullableBoolean(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "isOnline")); + var arg3 = Deserialize_Uri(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "imageUri")); + var arg4 = Deserialize_NonNullableDateTimeOffset(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "lastSeen")); + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0, arg1, arg2, arg3, arg4, entity.Messages)); } else { - session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "email")), Deserialize_NonNullableBoolean(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "isOnline")), Deserialize_Uri(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "imageUri")), Deserialize_NonNullableDateTimeOffset(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "lastSeen")), default !)); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + var arg1 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "email")); + var arg2 = Deserialize_NonNullableBoolean(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "isOnline")); + var arg3 = Deserialize_Uri(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "imageUri")); + var arg4 = Deserialize_NonNullableDateTimeOffset(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "lastSeen")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0, arg1, arg2, arg3, arg4, entity.Messages)); + } + else + { + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0, arg1, arg2, arg3, arg4, default !)); + } } return entityId; @@ -4527,11 +4544,20 @@ namespace Foo.Bar.State { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.PersonEntity? entity)) { - session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(entity.Name, entity.Email, entity.IsOnline, entity.ImageUri, entity.LastSeen, Deserialize_IGetMessages_PersonByEmail_Messages(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "messages"), entityIds))); + var arg0 = Deserialize_IGetMessages_PersonByEmail_Messages(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "messages"), entityIds); + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(entity.Name, entity.Email, entity.IsOnline, entity.ImageUri, entity.LastSeen, arg0)); } else { - session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(default !, default !, default !, default !, default !, Deserialize_IGetMessages_PersonByEmail_Messages(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "messages"), entityIds))); + var arg0 = Deserialize_IGetMessages_PersonByEmail_Messages(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "messages"), entityIds); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(entity.Name, entity.Email, entity.IsOnline, entity.ImageUri, entity.LastSeen, arg0)); + } + else + { + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(default !, default !, default !, default !, default !, arg0)); + } } return entityId; @@ -4600,11 +4626,30 @@ namespace Foo.Bar.State { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.MessageEntity? entity)) { - session.SetEntity(entityId, new global::Foo.Bar.State.MessageEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")), Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "text")), Deserialize_NonNullableDirection(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "direction")), Update_NonNullableIGetMessages_PersonByEmail_Messages_Nodes_RecipientEntity(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "recipient"), entityIds), Update_NonNullableIGetMessages_PersonByEmail_Messages_Nodes_SenderEntity(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "sender"), entityIds), Deserialize_NonNullableDateTimeOffset(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "sent")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")); + var arg1 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "text")); + var arg2 = Deserialize_NonNullableDirection(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "direction")); + var arg3 = Update_NonNullableIGetMessages_PersonByEmail_Messages_Nodes_RecipientEntity(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "recipient"), entityIds); + var arg4 = Update_NonNullableIGetMessages_PersonByEmail_Messages_Nodes_SenderEntity(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "sender"), entityIds); + var arg5 = Deserialize_NonNullableDateTimeOffset(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "sent")); + session.SetEntity(entityId, new global::Foo.Bar.State.MessageEntity(arg0, arg1, arg2, arg3, arg4, arg5)); } else { - session.SetEntity(entityId, new global::Foo.Bar.State.MessageEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")), Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "text")), Deserialize_NonNullableDirection(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "direction")), Update_NonNullableIGetMessages_PersonByEmail_Messages_Nodes_RecipientEntity(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "recipient"), entityIds), Update_NonNullableIGetMessages_PersonByEmail_Messages_Nodes_SenderEntity(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "sender"), entityIds), Deserialize_NonNullableDateTimeOffset(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "sent")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")); + var arg1 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "text")); + var arg2 = Deserialize_NonNullableDirection(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "direction")); + var arg3 = Update_NonNullableIGetMessages_PersonByEmail_Messages_Nodes_RecipientEntity(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "recipient"), entityIds); + var arg4 = Update_NonNullableIGetMessages_PersonByEmail_Messages_Nodes_SenderEntity(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "sender"), entityIds); + var arg5 = Deserialize_NonNullableDateTimeOffset(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "sent")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::Foo.Bar.State.MessageEntity(arg0, arg1, arg2, arg3, arg4, arg5)); + } + else + { + session.SetEntity(entityId, new global::Foo.Bar.State.MessageEntity(arg0, arg1, arg2, arg3, arg4, arg5)); + } } return entityId; @@ -4661,11 +4706,24 @@ namespace Foo.Bar.State { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.PersonEntity? entity)) { - session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "email")), Deserialize_NonNullableBoolean(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "isOnline")), entity.ImageUri, entity.LastSeen, entity.Messages)); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + var arg1 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "email")); + var arg2 = Deserialize_NonNullableBoolean(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "isOnline")); + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0, arg1, arg2, entity.ImageUri, entity.LastSeen, entity.Messages)); } else { - session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "email")), Deserialize_NonNullableBoolean(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "isOnline")), default !, default !, default !)); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + var arg1 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "email")); + var arg2 = Deserialize_NonNullableBoolean(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "isOnline")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0, arg1, arg2, entity.ImageUri, entity.LastSeen, entity.Messages)); + } + else + { + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0, arg1, arg2, default !, default !, default !)); + } } return entityId; @@ -4707,11 +4765,24 @@ namespace Foo.Bar.State { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.PersonEntity? entity)) { - session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "email")), Deserialize_NonNullableBoolean(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "isOnline")), entity.ImageUri, entity.LastSeen, entity.Messages)); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + var arg1 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "email")); + var arg2 = Deserialize_NonNullableBoolean(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "isOnline")); + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0, arg1, arg2, entity.ImageUri, entity.LastSeen, entity.Messages)); } else { - session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "email")), Deserialize_NonNullableBoolean(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "isOnline")), default !, default !, default !)); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + var arg1 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "email")); + var arg2 = Deserialize_NonNullableBoolean(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "isOnline")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0, arg1, arg2, entity.ImageUri, entity.LastSeen, entity.Messages)); + } + else + { + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0, arg1, arg2, default !, default !, default !)); + } } return entityId; @@ -4813,11 +4884,30 @@ namespace Foo.Bar.State { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.MessageEntity? entity)) { - session.SetEntity(entityId, new global::Foo.Bar.State.MessageEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")), Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "text")), Deserialize_NonNullableDirection(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "direction")), Update_NonNullableIGetMessages_PersonByEmail_Messages_Nodes_RecipientEntity(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "recipient"), entityIds), Update_NonNullableIGetMessages_PersonByEmail_Messages_Nodes_SenderEntity(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "sender"), entityIds), Deserialize_NonNullableDateTimeOffset(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "sent")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")); + var arg1 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "text")); + var arg2 = Deserialize_NonNullableDirection(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "direction")); + var arg3 = Update_NonNullableIGetMessages_PersonByEmail_Messages_Nodes_RecipientEntity(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "recipient"), entityIds); + var arg4 = Update_NonNullableIGetMessages_PersonByEmail_Messages_Nodes_SenderEntity(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "sender"), entityIds); + var arg5 = Deserialize_NonNullableDateTimeOffset(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "sent")); + session.SetEntity(entityId, new global::Foo.Bar.State.MessageEntity(arg0, arg1, arg2, arg3, arg4, arg5)); } else { - session.SetEntity(entityId, new global::Foo.Bar.State.MessageEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")), Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "text")), Deserialize_NonNullableDirection(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "direction")), Update_NonNullableIGetMessages_PersonByEmail_Messages_Nodes_RecipientEntity(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "recipient"), entityIds), Update_NonNullableIGetMessages_PersonByEmail_Messages_Nodes_SenderEntity(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "sender"), entityIds), Deserialize_NonNullableDateTimeOffset(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "sent")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")); + var arg1 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "text")); + var arg2 = Deserialize_NonNullableDirection(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "direction")); + var arg3 = Update_NonNullableIGetMessages_PersonByEmail_Messages_Nodes_RecipientEntity(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "recipient"), entityIds); + var arg4 = Update_NonNullableIGetMessages_PersonByEmail_Messages_Nodes_SenderEntity(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "sender"), entityIds); + var arg5 = Deserialize_NonNullableDateTimeOffset(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "sent")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::Foo.Bar.State.MessageEntity(arg0, arg1, arg2, arg3, arg4, arg5)); + } + else + { + session.SetEntity(entityId, new global::Foo.Bar.State.MessageEntity(arg0, arg1, arg2, arg3, arg4, arg5)); + } } return entityId; @@ -4874,11 +4964,24 @@ namespace Foo.Bar.State { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.PersonEntity? entity)) { - session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "email")), Deserialize_NonNullableBoolean(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "isOnline")), entity.ImageUri, entity.LastSeen, entity.Messages)); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + var arg1 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "email")); + var arg2 = Deserialize_NonNullableBoolean(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "isOnline")); + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0, arg1, arg2, entity.ImageUri, entity.LastSeen, entity.Messages)); } else { - session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "email")), Deserialize_NonNullableBoolean(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "isOnline")), default !, default !, default !)); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + var arg1 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "email")); + var arg2 = Deserialize_NonNullableBoolean(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "isOnline")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0, arg1, arg2, entity.ImageUri, entity.LastSeen, entity.Messages)); + } + else + { + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0, arg1, arg2, default !, default !, default !)); + } } return entityId; @@ -4920,11 +5023,24 @@ namespace Foo.Bar.State { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.PersonEntity? entity)) { - session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "email")), Deserialize_NonNullableBoolean(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "isOnline")), entity.ImageUri, entity.LastSeen, entity.Messages)); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + var arg1 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "email")); + var arg2 = Deserialize_NonNullableBoolean(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "isOnline")); + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0, arg1, arg2, entity.ImageUri, entity.LastSeen, entity.Messages)); } else { - session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "email")), Deserialize_NonNullableBoolean(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "isOnline")), default !, default !, default !)); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + var arg1 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "email")); + var arg2 = Deserialize_NonNullableBoolean(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "isOnline")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0, arg1, arg2, entity.ImageUri, entity.LastSeen, entity.Messages)); + } + else + { + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0, arg1, arg2, default !, default !, default !)); + } } return entityId; @@ -5026,11 +5142,30 @@ namespace Foo.Bar.State { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.MessageEntity? entity)) { - session.SetEntity(entityId, new global::Foo.Bar.State.MessageEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")), Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "text")), Deserialize_NonNullableDirection(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "direction")), Update_NonNullableIGetMessages_PersonByEmail_Messages_Nodes_RecipientEntity(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "recipient"), entityIds), Update_NonNullableIGetMessages_PersonByEmail_Messages_Nodes_SenderEntity(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "sender"), entityIds), Deserialize_NonNullableDateTimeOffset(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "sent")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")); + var arg1 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "text")); + var arg2 = Deserialize_NonNullableDirection(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "direction")); + var arg3 = Update_NonNullableIGetMessages_PersonByEmail_Messages_Nodes_RecipientEntity(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "recipient"), entityIds); + var arg4 = Update_NonNullableIGetMessages_PersonByEmail_Messages_Nodes_SenderEntity(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "sender"), entityIds); + var arg5 = Deserialize_NonNullableDateTimeOffset(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "sent")); + session.SetEntity(entityId, new global::Foo.Bar.State.MessageEntity(arg0, arg1, arg2, arg3, arg4, arg5)); } else { - session.SetEntity(entityId, new global::Foo.Bar.State.MessageEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")), Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "text")), Deserialize_NonNullableDirection(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "direction")), Update_NonNullableIGetMessages_PersonByEmail_Messages_Nodes_RecipientEntity(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "recipient"), entityIds), Update_NonNullableIGetMessages_PersonByEmail_Messages_Nodes_SenderEntity(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "sender"), entityIds), Deserialize_NonNullableDateTimeOffset(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "sent")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")); + var arg1 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "text")); + var arg2 = Deserialize_NonNullableDirection(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "direction")); + var arg3 = Update_NonNullableIGetMessages_PersonByEmail_Messages_Nodes_RecipientEntity(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "recipient"), entityIds); + var arg4 = Update_NonNullableIGetMessages_PersonByEmail_Messages_Nodes_SenderEntity(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "sender"), entityIds); + var arg5 = Deserialize_NonNullableDateTimeOffset(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "sent")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::Foo.Bar.State.MessageEntity(arg0, arg1, arg2, arg3, arg4, arg5)); + } + else + { + session.SetEntity(entityId, new global::Foo.Bar.State.MessageEntity(arg0, arg1, arg2, arg3, arg4, arg5)); + } } return entityId; @@ -5087,11 +5222,24 @@ namespace Foo.Bar.State { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.PersonEntity? entity)) { - session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "email")), Deserialize_NonNullableBoolean(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "isOnline")), entity.ImageUri, entity.LastSeen, entity.Messages)); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + var arg1 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "email")); + var arg2 = Deserialize_NonNullableBoolean(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "isOnline")); + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0, arg1, arg2, entity.ImageUri, entity.LastSeen, entity.Messages)); } else { - session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "email")), Deserialize_NonNullableBoolean(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "isOnline")), default !, default !, default !)); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + var arg1 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "email")); + var arg2 = Deserialize_NonNullableBoolean(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "isOnline")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0, arg1, arg2, entity.ImageUri, entity.LastSeen, entity.Messages)); + } + else + { + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0, arg1, arg2, default !, default !, default !)); + } } return entityId; @@ -5133,11 +5281,24 @@ namespace Foo.Bar.State { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.PersonEntity? entity)) { - session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "email")), Deserialize_NonNullableBoolean(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "isOnline")), entity.ImageUri, entity.LastSeen, entity.Messages)); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + var arg1 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "email")); + var arg2 = Deserialize_NonNullableBoolean(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "isOnline")); + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0, arg1, arg2, entity.ImageUri, entity.LastSeen, entity.Messages)); } else { - session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "email")), Deserialize_NonNullableBoolean(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "isOnline")), default !, default !, default !)); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + var arg1 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "email")); + var arg2 = Deserialize_NonNullableBoolean(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "isOnline")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0, arg1, arg2, entity.ImageUri, entity.LastSeen, entity.Messages)); + } + else + { + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0, arg1, arg2, default !, default !, default !)); + } } return entityId; @@ -5218,11 +5379,30 @@ namespace Foo.Bar.State { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.MessageEntity? entity)) { - session.SetEntity(entityId, new global::Foo.Bar.State.MessageEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")), Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "text")), Deserialize_NonNullableDirection(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "direction")), Update_NonNullableIGetMessages_PersonByEmail_Messages_Nodes_RecipientEntity(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "recipient"), entityIds), Update_NonNullableIGetMessages_PersonByEmail_Messages_Nodes_SenderEntity(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "sender"), entityIds), Deserialize_NonNullableDateTimeOffset(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "sent")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")); + var arg1 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "text")); + var arg2 = Deserialize_NonNullableDirection(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "direction")); + var arg3 = Update_NonNullableIGetMessages_PersonByEmail_Messages_Nodes_RecipientEntity(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "recipient"), entityIds); + var arg4 = Update_NonNullableIGetMessages_PersonByEmail_Messages_Nodes_SenderEntity(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "sender"), entityIds); + var arg5 = Deserialize_NonNullableDateTimeOffset(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "sent")); + session.SetEntity(entityId, new global::Foo.Bar.State.MessageEntity(arg0, arg1, arg2, arg3, arg4, arg5)); } else { - session.SetEntity(entityId, new global::Foo.Bar.State.MessageEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")), Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "text")), Deserialize_NonNullableDirection(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "direction")), Update_NonNullableIGetMessages_PersonByEmail_Messages_Nodes_RecipientEntity(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "recipient"), entityIds), Update_NonNullableIGetMessages_PersonByEmail_Messages_Nodes_SenderEntity(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "sender"), entityIds), Deserialize_NonNullableDateTimeOffset(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "sent")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")); + var arg1 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "text")); + var arg2 = Deserialize_NonNullableDirection(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "direction")); + var arg3 = Update_NonNullableIGetMessages_PersonByEmail_Messages_Nodes_RecipientEntity(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "recipient"), entityIds); + var arg4 = Update_NonNullableIGetMessages_PersonByEmail_Messages_Nodes_SenderEntity(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "sender"), entityIds); + var arg5 = Deserialize_NonNullableDateTimeOffset(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "sent")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::Foo.Bar.State.MessageEntity(arg0, arg1, arg2, arg3, arg4, arg5)); + } + else + { + session.SetEntity(entityId, new global::Foo.Bar.State.MessageEntity(arg0, arg1, arg2, arg3, arg4, arg5)); + } } return entityId; @@ -5279,11 +5459,24 @@ namespace Foo.Bar.State { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.PersonEntity? entity)) { - session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "email")), Deserialize_NonNullableBoolean(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "isOnline")), entity.ImageUri, entity.LastSeen, entity.Messages)); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + var arg1 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "email")); + var arg2 = Deserialize_NonNullableBoolean(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "isOnline")); + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0, arg1, arg2, entity.ImageUri, entity.LastSeen, entity.Messages)); } else { - session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "email")), Deserialize_NonNullableBoolean(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "isOnline")), default !, default !, default !)); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + var arg1 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "email")); + var arg2 = Deserialize_NonNullableBoolean(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "isOnline")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0, arg1, arg2, entity.ImageUri, entity.LastSeen, entity.Messages)); + } + else + { + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0, arg1, arg2, default !, default !, default !)); + } } return entityId; @@ -5325,11 +5518,24 @@ namespace Foo.Bar.State { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.PersonEntity? entity)) { - session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "email")), Deserialize_NonNullableBoolean(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "isOnline")), entity.ImageUri, entity.LastSeen, entity.Messages)); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + var arg1 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "email")); + var arg2 = Deserialize_NonNullableBoolean(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "isOnline")); + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0, arg1, arg2, entity.ImageUri, entity.LastSeen, entity.Messages)); } else { - session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "email")), Deserialize_NonNullableBoolean(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "isOnline")), default !, default !, default !)); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + var arg1 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "email")); + var arg2 = Deserialize_NonNullableBoolean(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "isOnline")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0, arg1, arg2, entity.ImageUri, entity.LastSeen, entity.Messages)); + } + else + { + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0, arg1, arg2, default !, default !, default !)); + } } return entityId; diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/ResultTypeGeneratorTests.Nested_Entity.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/ResultTypeGeneratorTests.Nested_Entity.snap index 09b0690f390..295d53debeb 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/ResultTypeGeneratorTests.Nested_Entity.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/ResultTypeGeneratorTests.Nested_Entity.snap @@ -898,11 +898,26 @@ namespace Foo.Bar.State { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.VehicleMakeEntity? entity)) { - session.SetEntity(entityId, new global::Foo.Bar.State.VehicleMakeEntity(Deserialize_NonNullableGuid(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")), Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "make")), Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "makeCode")), Deserialize_NonNullableBoolean(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "isDisabled")))); + var arg0 = Deserialize_NonNullableGuid(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")); + var arg1 = Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "make")); + var arg2 = Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "makeCode")); + var arg3 = Deserialize_NonNullableBoolean(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "isDisabled")); + session.SetEntity(entityId, new global::Foo.Bar.State.VehicleMakeEntity(arg0, arg1, arg2, arg3)); } else { - session.SetEntity(entityId, new global::Foo.Bar.State.VehicleMakeEntity(Deserialize_NonNullableGuid(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")), Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "make")), Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "makeCode")), Deserialize_NonNullableBoolean(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "isDisabled")))); + var arg0 = Deserialize_NonNullableGuid(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")); + var arg1 = Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "make")); + var arg2 = Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "makeCode")); + var arg3 = Deserialize_NonNullableBoolean(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "isDisabled")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::Foo.Bar.State.VehicleMakeEntity(arg0, arg1, arg2, arg3)); + } + else + { + session.SetEntity(entityId, new global::Foo.Bar.State.VehicleMakeEntity(arg0, arg1, arg2, arg3)); + } } return entityId; @@ -959,11 +974,30 @@ namespace Foo.Bar.State { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.VehicleModelEntity? entity)) { - session.SetEntity(entityId, new global::Foo.Bar.State.VehicleModelEntity(Deserialize_NonNullableGuid(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")), Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "model")), Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "modelCode")), Deserialize_NonNullableGuid(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "vehicleMakeId")), Deserialize_NonNullableBoolean(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "isDisabled")), Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "modelType")))); + var arg0 = Deserialize_NonNullableGuid(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")); + var arg1 = Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "model")); + var arg2 = Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "modelCode")); + var arg3 = Deserialize_NonNullableGuid(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "vehicleMakeId")); + var arg4 = Deserialize_NonNullableBoolean(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "isDisabled")); + var arg5 = Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "modelType")); + session.SetEntity(entityId, new global::Foo.Bar.State.VehicleModelEntity(arg0, arg1, arg2, arg3, arg4, arg5)); } else { - session.SetEntity(entityId, new global::Foo.Bar.State.VehicleModelEntity(Deserialize_NonNullableGuid(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")), Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "model")), Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "modelCode")), Deserialize_NonNullableGuid(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "vehicleMakeId")), Deserialize_NonNullableBoolean(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "isDisabled")), Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "modelType")))); + var arg0 = Deserialize_NonNullableGuid(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")); + var arg1 = Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "model")); + var arg2 = Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "modelCode")); + var arg3 = Deserialize_NonNullableGuid(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "vehicleMakeId")); + var arg4 = Deserialize_NonNullableBoolean(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "isDisabled")); + var arg5 = Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "modelType")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::Foo.Bar.State.VehicleModelEntity(arg0, arg1, arg2, arg3, arg4, arg5)); + } + else + { + session.SetEntity(entityId, new global::Foo.Bar.State.VehicleModelEntity(arg0, arg1, arg2, arg3, arg4, arg5)); + } } return entityId; diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/ScalarGeneratorTests.Complete_Schema_With_UUID_And_DateTime.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/ScalarGeneratorTests.Complete_Schema_With_UUID_And_DateTime.snap index 874e28f71dd..473a13bc10f 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/ScalarGeneratorTests.Complete_Schema_With_UUID_And_DateTime.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/ScalarGeneratorTests.Complete_Schema_With_UUID_And_DateTime.snap @@ -799,11 +799,32 @@ namespace Foo.Bar.State { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.ExpenseEntity? entity)) { - session.SetEntity(entityId, new global::Foo.Bar.State.ExpenseEntity(Deserialize_NonNullableGuid(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")), Deserialize_NonNullableDecimal(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "amount")), Deserialize_NonNullableDateTimeOffset(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "date")), Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "description")), Deserialize_NonNullableExpenseCategory(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "category")), Deserialize_NonNullablePaymentMethod(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "paymentMethod")), Deserialize_IAllExpenses_Expense_TagsArray(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "tags")))); + var arg0 = Deserialize_NonNullableGuid(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")); + var arg1 = Deserialize_NonNullableDecimal(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "amount")); + var arg2 = Deserialize_NonNullableDateTimeOffset(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "date")); + var arg3 = Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "description")); + var arg4 = Deserialize_NonNullableExpenseCategory(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "category")); + var arg5 = Deserialize_NonNullablePaymentMethod(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "paymentMethod")); + var arg6 = Deserialize_IAllExpenses_Expense_TagsArray(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "tags")); + session.SetEntity(entityId, new global::Foo.Bar.State.ExpenseEntity(arg0, arg1, arg2, arg3, arg4, arg5, arg6)); } else { - session.SetEntity(entityId, new global::Foo.Bar.State.ExpenseEntity(Deserialize_NonNullableGuid(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")), Deserialize_NonNullableDecimal(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "amount")), Deserialize_NonNullableDateTimeOffset(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "date")), Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "description")), Deserialize_NonNullableExpenseCategory(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "category")), Deserialize_NonNullablePaymentMethod(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "paymentMethod")), Deserialize_IAllExpenses_Expense_TagsArray(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "tags")))); + var arg0 = Deserialize_NonNullableGuid(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")); + var arg1 = Deserialize_NonNullableDecimal(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "amount")); + var arg2 = Deserialize_NonNullableDateTimeOffset(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "date")); + var arg3 = Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "description")); + var arg4 = Deserialize_NonNullableExpenseCategory(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "category")); + var arg5 = Deserialize_NonNullablePaymentMethod(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "paymentMethod")); + var arg6 = Deserialize_IAllExpenses_Expense_TagsArray(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "tags")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::Foo.Bar.State.ExpenseEntity(arg0, arg1, arg2, arg3, arg4, arg5, arg6)); + } + else + { + session.SetEntity(entityId, new global::Foo.Bar.State.ExpenseEntity(arg0, arg1, arg2, arg3, arg4, arg5, arg6)); + } } return entityId; diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/ScalarGeneratorTests.Duration_Not_Detected.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/ScalarGeneratorTests.Duration_Not_Detected.snap index 6592ecdd316..03916d34401 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/ScalarGeneratorTests.Duration_Not_Detected.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/ScalarGeneratorTests.Duration_Not_Detected.snap @@ -652,11 +652,20 @@ namespace Foo.Bar.State { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.SessionEntity? entity)) { - session.SetEntity(entityId, new global::Foo.Bar.State.SessionEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "title")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "title")); + session.SetEntity(entityId, new global::Foo.Bar.State.SessionEntity(arg0)); } else { - session.SetEntity(entityId, new global::Foo.Bar.State.SessionEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "title")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "title")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::Foo.Bar.State.SessionEntity(arg0)); + } + else + { + session.SetEntity(entityId, new global::Foo.Bar.State.SessionEntity(arg0)); + } } return entityId; diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/SchemaGeneratorTests.Create_GetFeatById.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/SchemaGeneratorTests.Create_GetFeatById.snap index a24b08f5810..d8f972108ac 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/SchemaGeneratorTests.Create_GetFeatById.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/SchemaGeneratorTests.Create_GetFeatById.snap @@ -823,11 +823,26 @@ namespace Foo.Bar.State { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.FeatEntity? entity)) { - session.SetEntity(entityId, new global::Foo.Bar.State.FeatEntity(Deserialize_NonNullableGuid(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")), Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_NonNullableInt32(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "level")), Update_NonNullableIGetFeatById_Feats_Items_DetailsEntityNonNullableArray(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "details"), entityIds))); + var arg0 = Deserialize_NonNullableGuid(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")); + var arg1 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + var arg2 = Deserialize_NonNullableInt32(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "level")); + var arg3 = Update_NonNullableIGetFeatById_Feats_Items_DetailsEntityNonNullableArray(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "details"), entityIds); + session.SetEntity(entityId, new global::Foo.Bar.State.FeatEntity(arg0, arg1, arg2, arg3)); } else { - session.SetEntity(entityId, new global::Foo.Bar.State.FeatEntity(Deserialize_NonNullableGuid(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")), Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_NonNullableInt32(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "level")), Update_NonNullableIGetFeatById_Feats_Items_DetailsEntityNonNullableArray(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "details"), entityIds))); + var arg0 = Deserialize_NonNullableGuid(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")); + var arg1 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + var arg2 = Deserialize_NonNullableInt32(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "level")); + var arg3 = Update_NonNullableIGetFeatById_Feats_Items_DetailsEntityNonNullableArray(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "details"), entityIds); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::Foo.Bar.State.FeatEntity(arg0, arg1, arg2, arg3)); + } + else + { + session.SetEntity(entityId, new global::Foo.Bar.State.FeatEntity(arg0, arg1, arg2, arg3)); + } } return entityId; @@ -920,11 +935,20 @@ namespace Foo.Bar.State { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.FeatDetailsBlockEntity? entity)) { - session.SetEntity(entityId, new global::Foo.Bar.State.FeatDetailsBlockEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "text")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "text")); + session.SetEntity(entityId, new global::Foo.Bar.State.FeatDetailsBlockEntity(arg0)); } else { - session.SetEntity(entityId, new global::Foo.Bar.State.FeatDetailsBlockEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "text")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "text")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::Foo.Bar.State.FeatDetailsBlockEntity(arg0)); + } + else + { + session.SetEntity(entityId, new global::Foo.Bar.State.FeatDetailsBlockEntity(arg0)); + } } return entityId; diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/SchemaGeneratorTests.Create_GetFeatsPage.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/SchemaGeneratorTests.Create_GetFeatsPage.snap index a3592ebaf41..32403722771 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/SchemaGeneratorTests.Create_GetFeatsPage.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/SchemaGeneratorTests.Create_GetFeatsPage.snap @@ -823,11 +823,26 @@ namespace Foo.Bar.State { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.FeatEntity? entity)) { - session.SetEntity(entityId, new global::Foo.Bar.State.FeatEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_NonNullableInt32(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "level")), Deserialize_NonNullableBoolean(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "canBeLearnedMoreThanOnce")), Update_NonNullableIGetFeatsPage_Feats_Items_ActionTypeEntity(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "actionType"), entityIds))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + var arg1 = Deserialize_NonNullableInt32(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "level")); + var arg2 = Deserialize_NonNullableBoolean(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "canBeLearnedMoreThanOnce")); + var arg3 = Update_NonNullableIGetFeatsPage_Feats_Items_ActionTypeEntity(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "actionType"), entityIds); + session.SetEntity(entityId, new global::Foo.Bar.State.FeatEntity(arg0, arg1, arg2, arg3)); } else { - session.SetEntity(entityId, new global::Foo.Bar.State.FeatEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_NonNullableInt32(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "level")), Deserialize_NonNullableBoolean(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "canBeLearnedMoreThanOnce")), Update_NonNullableIGetFeatsPage_Feats_Items_ActionTypeEntity(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "actionType"), entityIds))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + var arg1 = Deserialize_NonNullableInt32(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "level")); + var arg2 = Deserialize_NonNullableBoolean(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "canBeLearnedMoreThanOnce")); + var arg3 = Update_NonNullableIGetFeatsPage_Feats_Items_ActionTypeEntity(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "actionType"), entityIds); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::Foo.Bar.State.FeatEntity(arg0, arg1, arg2, arg3)); + } + else + { + session.SetEntity(entityId, new global::Foo.Bar.State.FeatEntity(arg0, arg1, arg2, arg3)); + } } return entityId; @@ -899,11 +914,20 @@ namespace Foo.Bar.State { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.ActionTypeEntity? entity)) { - session.SetEntity(entityId, new global::Foo.Bar.State.ActionTypeEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + session.SetEntity(entityId, new global::Foo.Bar.State.ActionTypeEntity(arg0)); } else { - session.SetEntity(entityId, new global::Foo.Bar.State.ActionTypeEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::Foo.Bar.State.ActionTypeEntity(arg0)); + } + else + { + session.SetEntity(entityId, new global::Foo.Bar.State.ActionTypeEntity(arg0)); + } } return entityId; diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/SchemaGeneratorTests.Create_PeopleSearch_From_ActiveDirectory_Schema.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/SchemaGeneratorTests.Create_PeopleSearch_From_ActiveDirectory_Schema.snap index c84dbdf79ca..024b94302b8 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/SchemaGeneratorTests.Create_PeopleSearch_From_ActiveDirectory_Schema.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/SchemaGeneratorTests.Create_PeopleSearch_From_ActiveDirectory_Schema.snap @@ -1353,11 +1353,34 @@ namespace Foo.Bar.State { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.PersonEntity? entity)) { - session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")), Deserialize_NonNullableInt64(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "key")), Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "displayName")), Deserialize_NonNullableBoolean(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "isActive")), Update_IPeopleSearch_People_Items_DepartmentEntity(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "department"), entityIds), Deserialize_Uri(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "image")), Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "title")), Update_IPeopleSearch_People_Items_ManagerEntity(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "manager"), entityIds))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")); + var arg1 = Deserialize_NonNullableInt64(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "key")); + var arg2 = Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "displayName")); + var arg3 = Deserialize_NonNullableBoolean(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "isActive")); + var arg4 = Update_IPeopleSearch_People_Items_DepartmentEntity(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "department"), entityIds); + var arg5 = Deserialize_Uri(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "image")); + var arg6 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "title")); + var arg7 = Update_IPeopleSearch_People_Items_ManagerEntity(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "manager"), entityIds); + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7)); } else { - session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")), Deserialize_NonNullableInt64(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "key")), Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "displayName")), Deserialize_NonNullableBoolean(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "isActive")), Update_IPeopleSearch_People_Items_DepartmentEntity(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "department"), entityIds), Deserialize_Uri(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "image")), Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "title")), Update_IPeopleSearch_People_Items_ManagerEntity(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "manager"), entityIds))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")); + var arg1 = Deserialize_NonNullableInt64(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "key")); + var arg2 = Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "displayName")); + var arg3 = Deserialize_NonNullableBoolean(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "isActive")); + var arg4 = Update_IPeopleSearch_People_Items_DepartmentEntity(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "department"), entityIds); + var arg5 = Deserialize_Uri(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "image")); + var arg6 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "title")); + var arg7 = Update_IPeopleSearch_People_Items_ManagerEntity(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "manager"), entityIds); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7)); + } + else + { + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7)); + } } return entityId; @@ -1429,11 +1452,22 @@ namespace Foo.Bar.State { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.DepartmentEntity? entity)) { - session.SetEntity(entityId, new global::Foo.Bar.State.DepartmentEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")), Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")); + var arg1 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + session.SetEntity(entityId, new global::Foo.Bar.State.DepartmentEntity(arg0, arg1)); } else { - session.SetEntity(entityId, new global::Foo.Bar.State.DepartmentEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")), Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")); + var arg1 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::Foo.Bar.State.DepartmentEntity(arg0, arg1)); + } + else + { + session.SetEntity(entityId, new global::Foo.Bar.State.DepartmentEntity(arg0, arg1)); + } } return entityId; @@ -1475,11 +1509,24 @@ namespace Foo.Bar.State { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.PersonEntity? entity)) { - session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")), Deserialize_NonNullableInt64(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "key")), Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "displayName")), entity.IsActive, entity.Department, entity.Image, entity.Title, entity.Manager)); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")); + var arg1 = Deserialize_NonNullableInt64(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "key")); + var arg2 = Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "displayName")); + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0, arg1, arg2, entity.IsActive, entity.Department, entity.Image, entity.Title, entity.Manager)); } else { - session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")), Deserialize_NonNullableInt64(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "key")), Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "displayName")), default !, default !, default !, default !, default !)); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")); + var arg1 = Deserialize_NonNullableInt64(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "key")); + var arg2 = Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "displayName")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0, arg1, arg2, entity.IsActive, entity.Department, entity.Image, entity.Title, entity.Manager)); + } + else + { + session.SetEntity(entityId, new global::Foo.Bar.State.PersonEntity(arg0, arg1, arg2, default !, default !, default !, default !, default !)); + } } return entityId; diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/SchemaGeneratorTests.Create_Query_With_Skip_Take.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/SchemaGeneratorTests.Create_Query_With_Skip_Take.snap index 5cf38da3c89..13871ebc71c 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/SchemaGeneratorTests.Create_Query_With_Skip_Take.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/SchemaGeneratorTests.Create_Query_With_Skip_Take.snap @@ -711,11 +711,24 @@ namespace Foo.Bar.State { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.NewsItemEntity? entity)) { - session.SetEntity(entityId, new global::Foo.Bar.State.NewsItemEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")), Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "title")), Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "summary")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")); + var arg1 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "title")); + var arg2 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "summary")); + session.SetEntity(entityId, new global::Foo.Bar.State.NewsItemEntity(arg0, arg1, arg2)); } else { - session.SetEntity(entityId, new global::Foo.Bar.State.NewsItemEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")), Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "title")), Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "summary")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")); + var arg1 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "title")); + var arg2 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "summary")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::Foo.Bar.State.NewsItemEntity(arg0, arg1, arg2)); + } + else + { + session.SetEntity(entityId, new global::Foo.Bar.State.NewsItemEntity(arg0, arg1, arg2)); + } } return entityId; diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/SchemaGeneratorTests.FieldsWithUnderlineInName.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/SchemaGeneratorTests.FieldsWithUnderlineInName.snap index 2daded24966..5486f4a6985 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/SchemaGeneratorTests.FieldsWithUnderlineInName.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/SchemaGeneratorTests.FieldsWithUnderlineInName.snap @@ -3797,11 +3797,44 @@ namespace Foo.Bar.State { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.bwr_TimeSeriesEntity? entity)) { - session.SetEntity(entityId, new global::Foo.Bar.State.bwr_TimeSeriesEntity(Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "inventoryId")), Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "area")), Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "source")), Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "type")), Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "category")), Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "specification")), Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "commodity")), Deserialize_IGetBwr_TimeSeries_Bwr_TimeSeries_Nodes_Resolution(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "resolution")), Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "unit")), Update_IGetBwr_TimeSeries_Bwr_TimeSeries_Nodes_ValidationCriteriaEntity(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "validationCriteria"), entityIds), Update_IGetBwr_TimeSeries_Bwr_TimeSeries_Nodes_ImportSpecificationEntity(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "importSpecification"), entityIds), Deserialize_IGetBwr_TimeSeries_Bwr_TimeSeries_Nodes__dataPointsNonNullableArray(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "_dataPoints")))); + var arg0 = Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "inventoryId")); + var arg1 = Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "area")); + var arg2 = Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "source")); + var arg3 = Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "type")); + var arg4 = Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + var arg5 = Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "category")); + var arg6 = Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "specification")); + var arg7 = Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "commodity")); + var arg8 = Deserialize_IGetBwr_TimeSeries_Bwr_TimeSeries_Nodes_Resolution(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "resolution")); + var arg9 = Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "unit")); + var arg10 = Update_IGetBwr_TimeSeries_Bwr_TimeSeries_Nodes_ValidationCriteriaEntity(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "validationCriteria"), entityIds); + var arg11 = Update_IGetBwr_TimeSeries_Bwr_TimeSeries_Nodes_ImportSpecificationEntity(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "importSpecification"), entityIds); + var arg12 = Deserialize_IGetBwr_TimeSeries_Bwr_TimeSeries_Nodes__dataPointsNonNullableArray(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "_dataPoints")); + session.SetEntity(entityId, new global::Foo.Bar.State.bwr_TimeSeriesEntity(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12)); } else { - session.SetEntity(entityId, new global::Foo.Bar.State.bwr_TimeSeriesEntity(Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "inventoryId")), Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "area")), Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "source")), Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "type")), Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "category")), Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "specification")), Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "commodity")), Deserialize_IGetBwr_TimeSeries_Bwr_TimeSeries_Nodes_Resolution(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "resolution")), Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "unit")), Update_IGetBwr_TimeSeries_Bwr_TimeSeries_Nodes_ValidationCriteriaEntity(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "validationCriteria"), entityIds), Update_IGetBwr_TimeSeries_Bwr_TimeSeries_Nodes_ImportSpecificationEntity(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "importSpecification"), entityIds), Deserialize_IGetBwr_TimeSeries_Bwr_TimeSeries_Nodes__dataPointsNonNullableArray(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "_dataPoints")))); + var arg0 = Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "inventoryId")); + var arg1 = Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "area")); + var arg2 = Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "source")); + var arg3 = Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "type")); + var arg4 = Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + var arg5 = Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "category")); + var arg6 = Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "specification")); + var arg7 = Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "commodity")); + var arg8 = Deserialize_IGetBwr_TimeSeries_Bwr_TimeSeries_Nodes_Resolution(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "resolution")); + var arg9 = Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "unit")); + var arg10 = Update_IGetBwr_TimeSeries_Bwr_TimeSeries_Nodes_ValidationCriteriaEntity(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "validationCriteria"), entityIds); + var arg11 = Update_IGetBwr_TimeSeries_Bwr_TimeSeries_Nodes_ImportSpecificationEntity(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "importSpecification"), entityIds); + var arg12 = Deserialize_IGetBwr_TimeSeries_Bwr_TimeSeries_Nodes__dataPointsNonNullableArray(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "_dataPoints")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::Foo.Bar.State.bwr_TimeSeriesEntity(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12)); + } + else + { + session.SetEntity(entityId, new global::Foo.Bar.State.bwr_TimeSeriesEntity(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12)); + } } return entityId; @@ -3894,11 +3927,28 @@ namespace Foo.Bar.State { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.bwr_ValidationCriteriaEntity? entity)) { - session.SetEntity(entityId, new global::Foo.Bar.State.bwr_ValidationCriteriaEntity(Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "_inventoryItemId")), Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "completeness")), Deserialize_Decimal(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "lowerBound")), Deserialize_Decimal(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "upperBound")))); + var arg0 = Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "_inventoryItemId")); + var arg1 = Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + var arg2 = Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "completeness")); + var arg3 = Deserialize_Decimal(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "lowerBound")); + var arg4 = Deserialize_Decimal(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "upperBound")); + session.SetEntity(entityId, new global::Foo.Bar.State.bwr_ValidationCriteriaEntity(arg0, arg1, arg2, arg3, arg4)); } else { - session.SetEntity(entityId, new global::Foo.Bar.State.bwr_ValidationCriteriaEntity(Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "_inventoryItemId")), Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "completeness")), Deserialize_Decimal(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "lowerBound")), Deserialize_Decimal(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "upperBound")))); + var arg0 = Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "_inventoryItemId")); + var arg1 = Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + var arg2 = Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "completeness")); + var arg3 = Deserialize_Decimal(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "lowerBound")); + var arg4 = Deserialize_Decimal(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "upperBound")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::Foo.Bar.State.bwr_ValidationCriteriaEntity(arg0, arg1, arg2, arg3, arg4)); + } + else + { + session.SetEntity(entityId, new global::Foo.Bar.State.bwr_ValidationCriteriaEntity(arg0, arg1, arg2, arg3, arg4)); + } } return entityId; @@ -3940,11 +3990,22 @@ namespace Foo.Bar.State { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.bwr_ImportSpecificationEntity? entity)) { - session.SetEntity(entityId, new global::Foo.Bar.State.bwr_ImportSpecificationEntity(Deserialize_Int32(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "fromPeriod")), Deserialize_Int32(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "toPeriod")))); + var arg0 = Deserialize_Int32(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "fromPeriod")); + var arg1 = Deserialize_Int32(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "toPeriod")); + session.SetEntity(entityId, new global::Foo.Bar.State.bwr_ImportSpecificationEntity(arg0, arg1)); } else { - session.SetEntity(entityId, new global::Foo.Bar.State.bwr_ImportSpecificationEntity(Deserialize_Int32(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "fromPeriod")), Deserialize_Int32(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "toPeriod")))); + var arg0 = Deserialize_Int32(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "fromPeriod")); + var arg1 = Deserialize_Int32(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "toPeriod")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::Foo.Bar.State.bwr_ImportSpecificationEntity(arg0, arg1)); + } + else + { + session.SetEntity(entityId, new global::Foo.Bar.State.bwr_ImportSpecificationEntity(arg0, arg1)); + } } return entityId; diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/SchemaGeneratorTests.LowerCaseScalarArgument.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/SchemaGeneratorTests.LowerCaseScalarArgument.snap index 2dfd99b1402..204a2e1a975 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/SchemaGeneratorTests.LowerCaseScalarArgument.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/SchemaGeneratorTests.LowerCaseScalarArgument.snap @@ -527,11 +527,24 @@ namespace Foo.Bar.State { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.peopleEntity? entity)) { - session.SetEntity(entityId, new global::Foo.Bar.State.peopleEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")), Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "firstName")), Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "lastName")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")); + var arg1 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "firstName")); + var arg2 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "lastName")); + session.SetEntity(entityId, new global::Foo.Bar.State.peopleEntity(arg0, arg1, arg2)); } else { - session.SetEntity(entityId, new global::Foo.Bar.State.peopleEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")), Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "firstName")), Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "lastName")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")); + var arg1 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "firstName")); + var arg2 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "lastName")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::Foo.Bar.State.peopleEntity(arg0, arg1, arg2)); + } + else + { + session.SetEntity(entityId, new global::Foo.Bar.State.peopleEntity(arg0, arg1, arg2)); + } } return entityId; diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/SchemaGeneratorTests.NodeTypenameCollision.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/SchemaGeneratorTests.NodeTypenameCollision.snap index 25ce713173d..886c2ead5a1 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/SchemaGeneratorTests.NodeTypenameCollision.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/SchemaGeneratorTests.NodeTypenameCollision.snap @@ -500,11 +500,22 @@ namespace Foo.Bar.State { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.WorkspaceEntity? entity)) { - session.SetEntity(entityId, new global::Foo.Bar.State.WorkspaceEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "__typename")), Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "__typename")); + var arg1 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")); + session.SetEntity(entityId, new global::Foo.Bar.State.WorkspaceEntity(arg0, arg1)); } else { - session.SetEntity(entityId, new global::Foo.Bar.State.WorkspaceEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "__typename")), Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "__typename")); + var arg1 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::Foo.Bar.State.WorkspaceEntity(arg0, arg1)); + } + else + { + session.SetEntity(entityId, new global::Foo.Bar.State.WorkspaceEntity(arg0, arg1)); + } } return entityId; diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/SchemaGeneratorTests.QueryInterference.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/SchemaGeneratorTests.QueryInterference.snap index 2e2185b1518..fd831b6bde7 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/SchemaGeneratorTests.QueryInterference.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/SchemaGeneratorTests.QueryInterference.snap @@ -3310,11 +3310,28 @@ namespace Foo.Bar.State { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.FeatEntity? entity)) { - session.SetEntity(entityId, new global::Foo.Bar.State.FeatEntity(Deserialize_NonNullableGuid(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")), Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_NonNullableInt32(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "level")), Deserialize_NonNullableBoolean(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "canBeLearnedMoreThanOnce")), Update_NonNullableIGetFeatsPage_Feats_Items_DetailsEntityNonNullableArray(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "details"), entityIds), entity.Special, entity.Trigger, entity.ActionType)); + var arg0 = Deserialize_NonNullableGuid(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")); + var arg1 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + var arg2 = Deserialize_NonNullableInt32(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "level")); + var arg3 = Deserialize_NonNullableBoolean(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "canBeLearnedMoreThanOnce")); + var arg4 = Update_NonNullableIGetFeatsPage_Feats_Items_DetailsEntityNonNullableArray(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "details"), entityIds); + session.SetEntity(entityId, new global::Foo.Bar.State.FeatEntity(arg0, arg1, arg2, arg3, arg4, entity.Special, entity.Trigger, entity.ActionType)); } else { - session.SetEntity(entityId, new global::Foo.Bar.State.FeatEntity(Deserialize_NonNullableGuid(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")), Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_NonNullableInt32(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "level")), Deserialize_NonNullableBoolean(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "canBeLearnedMoreThanOnce")), Update_NonNullableIGetFeatsPage_Feats_Items_DetailsEntityNonNullableArray(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "details"), entityIds), default !, default !, default !)); + var arg0 = Deserialize_NonNullableGuid(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")); + var arg1 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + var arg2 = Deserialize_NonNullableInt32(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "level")); + var arg3 = Deserialize_NonNullableBoolean(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "canBeLearnedMoreThanOnce")); + var arg4 = Update_NonNullableIGetFeatsPage_Feats_Items_DetailsEntityNonNullableArray(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "details"), entityIds); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::Foo.Bar.State.FeatEntity(arg0, arg1, arg2, arg3, arg4, entity.Special, entity.Trigger, entity.ActionType)); + } + else + { + session.SetEntity(entityId, new global::Foo.Bar.State.FeatEntity(arg0, arg1, arg2, arg3, arg4, default !, default !, default !)); + } } return entityId; @@ -3407,11 +3424,20 @@ namespace Foo.Bar.State { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.FeatDetailsBlockEntity? entity)) { - session.SetEntity(entityId, new global::Foo.Bar.State.FeatDetailsBlockEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "text")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "text")); + session.SetEntity(entityId, new global::Foo.Bar.State.FeatDetailsBlockEntity(arg0)); } else { - session.SetEntity(entityId, new global::Foo.Bar.State.FeatDetailsBlockEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "text")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "text")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::Foo.Bar.State.FeatDetailsBlockEntity(arg0)); + } + else + { + session.SetEntity(entityId, new global::Foo.Bar.State.FeatDetailsBlockEntity(arg0)); + } } return entityId; @@ -3515,11 +3541,32 @@ namespace Foo.Bar.State { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.FeatEntity? entity)) { - session.SetEntity(entityId, new global::Foo.Bar.State.FeatEntity(Deserialize_NonNullableGuid(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")), Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_NonNullableInt32(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "level")), entity.CanBeLearnedMoreThanOnce, Update_NonNullableIGetFeatById_Feats_Items_DetailsEntityNonNullableArray(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "details"), entityIds), Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "special")), Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "trigger")), Update_NonNullableIGetFeatById_Feats_Items_ActionTypeEntity(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "actionType"), entityIds))); + var arg0 = Deserialize_NonNullableGuid(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")); + var arg1 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + var arg2 = Deserialize_NonNullableInt32(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "level")); + var arg3 = Update_NonNullableIGetFeatById_Feats_Items_DetailsEntityNonNullableArray(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "details"), entityIds); + var arg4 = Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "special")); + var arg5 = Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "trigger")); + var arg6 = Update_NonNullableIGetFeatById_Feats_Items_ActionTypeEntity(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "actionType"), entityIds); + session.SetEntity(entityId, new global::Foo.Bar.State.FeatEntity(arg0, arg1, arg2, entity.CanBeLearnedMoreThanOnce, arg3, arg4, arg5, arg6)); } else { - session.SetEntity(entityId, new global::Foo.Bar.State.FeatEntity(Deserialize_NonNullableGuid(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")), Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_NonNullableInt32(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "level")), default !, Update_NonNullableIGetFeatById_Feats_Items_DetailsEntityNonNullableArray(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "details"), entityIds), Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "special")), Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "trigger")), Update_NonNullableIGetFeatById_Feats_Items_ActionTypeEntity(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "actionType"), entityIds))); + var arg0 = Deserialize_NonNullableGuid(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")); + var arg1 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + var arg2 = Deserialize_NonNullableInt32(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "level")); + var arg3 = Update_NonNullableIGetFeatById_Feats_Items_DetailsEntityNonNullableArray(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "details"), entityIds); + var arg4 = Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "special")); + var arg5 = Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "trigger")); + var arg6 = Update_NonNullableIGetFeatById_Feats_Items_ActionTypeEntity(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "actionType"), entityIds); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::Foo.Bar.State.FeatEntity(arg0, arg1, arg2, entity.CanBeLearnedMoreThanOnce, arg3, arg4, arg5, arg6)); + } + else + { + session.SetEntity(entityId, new global::Foo.Bar.State.FeatEntity(arg0, arg1, arg2, default !, arg3, arg4, arg5, arg6)); + } } return entityId; @@ -3627,11 +3674,20 @@ namespace Foo.Bar.State { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.FeatDetailsBlockEntity? entity)) { - session.SetEntity(entityId, new global::Foo.Bar.State.FeatDetailsBlockEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "text")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "text")); + session.SetEntity(entityId, new global::Foo.Bar.State.FeatDetailsBlockEntity(arg0)); } else { - session.SetEntity(entityId, new global::Foo.Bar.State.FeatDetailsBlockEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "text")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "text")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::Foo.Bar.State.FeatDetailsBlockEntity(arg0)); + } + else + { + session.SetEntity(entityId, new global::Foo.Bar.State.FeatDetailsBlockEntity(arg0)); + } } return entityId; @@ -3658,11 +3714,20 @@ namespace Foo.Bar.State { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.ActionTypeEntity? entity)) { - session.SetEntity(entityId, new global::Foo.Bar.State.ActionTypeEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + session.SetEntity(entityId, new global::Foo.Bar.State.ActionTypeEntity(arg0)); } else { - session.SetEntity(entityId, new global::Foo.Bar.State.ActionTypeEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::Foo.Bar.State.ActionTypeEntity(arg0)); + } + else + { + session.SetEntity(entityId, new global::Foo.Bar.State.ActionTypeEntity(arg0)); + } } return entityId; diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/StarWarsGeneratorTests.Generate_Client_With_Internal_Access_Modifier.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/StarWarsGeneratorTests.Generate_Client_With_Internal_Access_Modifier.snap index 2302f16f059..3c8e2ac578f 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/StarWarsGeneratorTests.Generate_Client_With_Internal_Access_Modifier.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/StarWarsGeneratorTests.Generate_Client_With_Internal_Access_Modifier.snap @@ -641,11 +641,22 @@ namespace Foo.Bar.State { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.DroidEntity? entity)) { - session.SetEntity(entityId, new global::Foo.Bar.State.DroidEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_EpisodeArray(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "appearsIn")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + var arg1 = Deserialize_EpisodeArray(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "appearsIn")); + session.SetEntity(entityId, new global::Foo.Bar.State.DroidEntity(arg0, arg1)); } else { - session.SetEntity(entityId, new global::Foo.Bar.State.DroidEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_EpisodeArray(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "appearsIn")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + var arg1 = Deserialize_EpisodeArray(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "appearsIn")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::Foo.Bar.State.DroidEntity(arg0, arg1)); + } + else + { + session.SetEntity(entityId, new global::Foo.Bar.State.DroidEntity(arg0, arg1)); + } } return entityId; @@ -655,11 +666,22 @@ namespace Foo.Bar.State { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.HumanEntity? entity)) { - session.SetEntity(entityId, new global::Foo.Bar.State.HumanEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_EpisodeArray(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "appearsIn")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + var arg1 = Deserialize_EpisodeArray(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "appearsIn")); + session.SetEntity(entityId, new global::Foo.Bar.State.HumanEntity(arg0, arg1)); } else { - session.SetEntity(entityId, new global::Foo.Bar.State.HumanEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_EpisodeArray(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "appearsIn")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + var arg1 = Deserialize_EpisodeArray(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "appearsIn")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::Foo.Bar.State.HumanEntity(arg0, arg1)); + } + else + { + session.SetEntity(entityId, new global::Foo.Bar.State.HumanEntity(arg0, arg1)); + } } return entityId; diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/StarWarsGeneratorTests.Interface_With_Default_Names.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/StarWarsGeneratorTests.Interface_With_Default_Names.snap index 7a7f81f32aa..83ef8c212c3 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/StarWarsGeneratorTests.Interface_With_Default_Names.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/StarWarsGeneratorTests.Interface_With_Default_Names.snap @@ -641,11 +641,22 @@ namespace Foo.Bar.State { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.DroidEntity? entity)) { - session.SetEntity(entityId, new global::Foo.Bar.State.DroidEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_EpisodeArray(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "appearsIn")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + var arg1 = Deserialize_EpisodeArray(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "appearsIn")); + session.SetEntity(entityId, new global::Foo.Bar.State.DroidEntity(arg0, arg1)); } else { - session.SetEntity(entityId, new global::Foo.Bar.State.DroidEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_EpisodeArray(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "appearsIn")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + var arg1 = Deserialize_EpisodeArray(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "appearsIn")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::Foo.Bar.State.DroidEntity(arg0, arg1)); + } + else + { + session.SetEntity(entityId, new global::Foo.Bar.State.DroidEntity(arg0, arg1)); + } } return entityId; @@ -655,11 +666,22 @@ namespace Foo.Bar.State { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.HumanEntity? entity)) { - session.SetEntity(entityId, new global::Foo.Bar.State.HumanEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_EpisodeArray(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "appearsIn")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + var arg1 = Deserialize_EpisodeArray(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "appearsIn")); + session.SetEntity(entityId, new global::Foo.Bar.State.HumanEntity(arg0, arg1)); } else { - session.SetEntity(entityId, new global::Foo.Bar.State.HumanEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_EpisodeArray(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "appearsIn")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + var arg1 = Deserialize_EpisodeArray(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "appearsIn")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::Foo.Bar.State.HumanEntity(arg0, arg1)); + } + else + { + session.SetEntity(entityId, new global::Foo.Bar.State.HumanEntity(arg0, arg1)); + } } return entityId; diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/StarWarsGeneratorTests.Interface_With_Fragment_Definition_Two_Models.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/StarWarsGeneratorTests.Interface_With_Fragment_Definition_Two_Models.snap index 4c93ea9c8df..142c4307c18 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/StarWarsGeneratorTests.Interface_With_Fragment_Definition_Two_Models.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/StarWarsGeneratorTests.Interface_With_Fragment_Definition_Two_Models.snap @@ -966,11 +966,24 @@ namespace Foo.Bar.State { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.DroidEntity? entity)) { - session.SetEntity(entityId, new global::Foo.Bar.State.DroidEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "primaryFunction")), Deserialize_IGetHero_Hero_Friends(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "friends"), entityIds))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + var arg1 = Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "primaryFunction")); + var arg2 = Deserialize_IGetHero_Hero_Friends(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "friends"), entityIds); + session.SetEntity(entityId, new global::Foo.Bar.State.DroidEntity(arg0, arg1, arg2)); } else { - session.SetEntity(entityId, new global::Foo.Bar.State.DroidEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "primaryFunction")), Deserialize_IGetHero_Hero_Friends(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "friends"), entityIds))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + var arg1 = Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "primaryFunction")); + var arg2 = Deserialize_IGetHero_Hero_Friends(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "friends"), entityIds); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::Foo.Bar.State.DroidEntity(arg0, arg1, arg2)); + } + else + { + session.SetEntity(entityId, new global::Foo.Bar.State.DroidEntity(arg0, arg1, arg2)); + } } return entityId; @@ -980,11 +993,24 @@ namespace Foo.Bar.State { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.HumanEntity? entity)) { - session.SetEntity(entityId, new global::Foo.Bar.State.HumanEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "homePlanet")), Deserialize_IGetHero_Hero_Friends(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "friends"), entityIds))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + var arg1 = Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "homePlanet")); + var arg2 = Deserialize_IGetHero_Hero_Friends(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "friends"), entityIds); + session.SetEntity(entityId, new global::Foo.Bar.State.HumanEntity(arg0, arg1, arg2)); } else { - session.SetEntity(entityId, new global::Foo.Bar.State.HumanEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "homePlanet")), Deserialize_IGetHero_Hero_Friends(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "friends"), entityIds))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + var arg1 = Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "homePlanet")); + var arg2 = Deserialize_IGetHero_Hero_Friends(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "friends"), entityIds); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::Foo.Bar.State.HumanEntity(arg0, arg1, arg2)); + } + else + { + session.SetEntity(entityId, new global::Foo.Bar.State.HumanEntity(arg0, arg1, arg2)); + } } return entityId; @@ -1083,11 +1109,20 @@ namespace Foo.Bar.State { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.DroidEntity? entity)) { - session.SetEntity(entityId, new global::Foo.Bar.State.DroidEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), entity.PrimaryFunction, entity.Friends)); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + session.SetEntity(entityId, new global::Foo.Bar.State.DroidEntity(arg0, entity.PrimaryFunction, entity.Friends)); } else { - session.SetEntity(entityId, new global::Foo.Bar.State.DroidEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), default !, default !)); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::Foo.Bar.State.DroidEntity(arg0, entity.PrimaryFunction, entity.Friends)); + } + else + { + session.SetEntity(entityId, new global::Foo.Bar.State.DroidEntity(arg0, default !, default !)); + } } return entityId; @@ -1097,11 +1132,20 @@ namespace Foo.Bar.State { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.HumanEntity? entity)) { - session.SetEntity(entityId, new global::Foo.Bar.State.HumanEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), entity.HomePlanet, entity.Friends)); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + session.SetEntity(entityId, new global::Foo.Bar.State.HumanEntity(arg0, entity.HomePlanet, entity.Friends)); } else { - session.SetEntity(entityId, new global::Foo.Bar.State.HumanEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), default !, default !)); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::Foo.Bar.State.HumanEntity(arg0, entity.HomePlanet, entity.Friends)); + } + else + { + session.SetEntity(entityId, new global::Foo.Bar.State.HumanEntity(arg0, default !, default !)); + } } return entityId; diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/StarWarsGeneratorTests.Operation_With_Leaf_Argument.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/StarWarsGeneratorTests.Operation_With_Leaf_Argument.snap index c374c18da15..4b44ce561d8 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/StarWarsGeneratorTests.Operation_With_Leaf_Argument.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/StarWarsGeneratorTests.Operation_With_Leaf_Argument.snap @@ -658,11 +658,22 @@ namespace Foo.Bar.State { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.DroidEntity? entity)) { - session.SetEntity(entityId, new global::Foo.Bar.State.DroidEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_EpisodeArray(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "appearsIn")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + var arg1 = Deserialize_EpisodeArray(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "appearsIn")); + session.SetEntity(entityId, new global::Foo.Bar.State.DroidEntity(arg0, arg1)); } else { - session.SetEntity(entityId, new global::Foo.Bar.State.DroidEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_EpisodeArray(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "appearsIn")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + var arg1 = Deserialize_EpisodeArray(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "appearsIn")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::Foo.Bar.State.DroidEntity(arg0, arg1)); + } + else + { + session.SetEntity(entityId, new global::Foo.Bar.State.DroidEntity(arg0, arg1)); + } } return entityId; @@ -672,11 +683,22 @@ namespace Foo.Bar.State { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.HumanEntity? entity)) { - session.SetEntity(entityId, new global::Foo.Bar.State.HumanEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_EpisodeArray(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "appearsIn")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + var arg1 = Deserialize_EpisodeArray(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "appearsIn")); + session.SetEntity(entityId, new global::Foo.Bar.State.HumanEntity(arg0, arg1)); } else { - session.SetEntity(entityId, new global::Foo.Bar.State.HumanEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), Deserialize_EpisodeArray(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "appearsIn")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + var arg1 = Deserialize_EpisodeArray(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "appearsIn")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::Foo.Bar.State.HumanEntity(arg0, arg1)); + } + else + { + session.SetEntity(entityId, new global::Foo.Bar.State.HumanEntity(arg0, arg1)); + } } return entityId; diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/StarWarsGeneratorTests.StarWarsTypeNameOnUnions.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/StarWarsGeneratorTests.StarWarsTypeNameOnUnions.snap index 3a369fc11d1..97eba360dae 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/StarWarsGeneratorTests.StarWarsTypeNameOnUnions.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/StarWarsGeneratorTests.StarWarsTypeNameOnUnions.snap @@ -717,11 +717,20 @@ namespace Foo.Bar.State { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.StarshipEntity? entity)) { - session.SetEntity(entityId, new global::Foo.Bar.State.StarshipEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "__typename")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "__typename")); + session.SetEntity(entityId, new global::Foo.Bar.State.StarshipEntity(arg0)); } else { - session.SetEntity(entityId, new global::Foo.Bar.State.StarshipEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "__typename")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "__typename")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::Foo.Bar.State.StarshipEntity(arg0)); + } + else + { + session.SetEntity(entityId, new global::Foo.Bar.State.StarshipEntity(arg0)); + } } return entityId; @@ -731,11 +740,20 @@ namespace Foo.Bar.State { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.HumanEntity? entity)) { - session.SetEntity(entityId, new global::Foo.Bar.State.HumanEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "__typename")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "__typename")); + session.SetEntity(entityId, new global::Foo.Bar.State.HumanEntity(arg0)); } else { - session.SetEntity(entityId, new global::Foo.Bar.State.HumanEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "__typename")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "__typename")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::Foo.Bar.State.HumanEntity(arg0)); + } + else + { + session.SetEntity(entityId, new global::Foo.Bar.State.HumanEntity(arg0)); + } } return entityId; @@ -745,11 +763,20 @@ namespace Foo.Bar.State { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.DroidEntity? entity)) { - session.SetEntity(entityId, new global::Foo.Bar.State.DroidEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "__typename")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "__typename")); + session.SetEntity(entityId, new global::Foo.Bar.State.DroidEntity(arg0)); } else { - session.SetEntity(entityId, new global::Foo.Bar.State.DroidEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "__typename")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "__typename")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::Foo.Bar.State.DroidEntity(arg0)); + } + else + { + session.SetEntity(entityId, new global::Foo.Bar.State.DroidEntity(arg0)); + } } return entityId; diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/StarWarsGeneratorTests.StarWarsUnionList.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/StarWarsGeneratorTests.StarWarsUnionList.snap index 76c41dc3cef..245ed8a1b4a 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/StarWarsGeneratorTests.StarWarsUnionList.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/StarWarsGeneratorTests.StarWarsUnionList.snap @@ -718,7 +718,14 @@ namespace Foo.Bar.State } else { - session.SetEntity(entityId, new global::Foo.Bar.State.StarshipEntity()); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::Foo.Bar.State.StarshipEntity()); + } + else + { + session.SetEntity(entityId, new global::Foo.Bar.State.StarshipEntity()); + } } return entityId; @@ -728,11 +735,20 @@ namespace Foo.Bar.State { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.HumanEntity? entity)) { - session.SetEntity(entityId, new global::Foo.Bar.State.HumanEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + session.SetEntity(entityId, new global::Foo.Bar.State.HumanEntity(arg0)); } else { - session.SetEntity(entityId, new global::Foo.Bar.State.HumanEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::Foo.Bar.State.HumanEntity(arg0)); + } + else + { + session.SetEntity(entityId, new global::Foo.Bar.State.HumanEntity(arg0)); + } } return entityId; @@ -742,11 +758,20 @@ namespace Foo.Bar.State { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.DroidEntity? entity)) { - session.SetEntity(entityId, new global::Foo.Bar.State.DroidEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + session.SetEntity(entityId, new global::Foo.Bar.State.DroidEntity(arg0)); } else { - session.SetEntity(entityId, new global::Foo.Bar.State.DroidEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::Foo.Bar.State.DroidEntity(arg0)); + } + else + { + session.SetEntity(entityId, new global::Foo.Bar.State.DroidEntity(arg0)); + } } return entityId; diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.Razor.Tests/__snapshots__/RazorGeneratorTests.Query_And_Mutation.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.Razor.Tests/__snapshots__/RazorGeneratorTests.Query_And_Mutation.snap index c3de0b37310..e8e725983b3 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.Razor.Tests/__snapshots__/RazorGeneratorTests.Query_And_Mutation.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.Razor.Tests/__snapshots__/RazorGeneratorTests.Query_And_Mutation.snap @@ -965,11 +965,22 @@ namespace Foo.Bar.State { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.BarEntity? entity)) { - session.SetEntity(entityId, new global::Foo.Bar.State.BarEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")), Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")); + var arg1 = Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + session.SetEntity(entityId, new global::Foo.Bar.State.BarEntity(arg0, arg1)); } else { - session.SetEntity(entityId, new global::Foo.Bar.State.BarEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")), Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")); + var arg1 = Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::Foo.Bar.State.BarEntity(arg0, arg1)); + } + else + { + session.SetEntity(entityId, new global::Foo.Bar.State.BarEntity(arg0, arg1)); + } } return entityId; @@ -1057,11 +1068,22 @@ namespace Foo.Bar.State { if (session.CurrentSnapshot.TryGetEntity(entityId, out global::Foo.Bar.State.BarEntity? entity)) { - session.SetEntity(entityId, new global::Foo.Bar.State.BarEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")), Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")); + var arg1 = Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + session.SetEntity(entityId, new global::Foo.Bar.State.BarEntity(arg0, arg1)); } else { - session.SetEntity(entityId, new global::Foo.Bar.State.BarEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")), Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")))); + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")); + var arg1 = Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::Foo.Bar.State.BarEntity(arg0, arg1)); + } + else + { + session.SetEntity(entityId, new global::Foo.Bar.State.BarEntity(arg0, arg1)); + } } return entityId;