From 26240b12377bf7c867e642bc32053c2ea472fcf3 Mon Sep 17 00:00:00 2001 From: NOlbert <45466413+N-Olbert@users.noreply.github.com> Date: Mon, 25 Aug 2025 23:11:37 +0200 Subject: [PATCH 1/2] Handle self-referencing entities with different selection sets. Adjusted first tests. --- .../Builders/MethodCallBuilder.cs | 7 +- ...JsonResultBuilderGenerator_UpdateEntity.cs | 81 +- .../Integration/EntityIdOrDataTest.Client.cs | 26 +- .../Integration/MultiProfileTest.Client.cs | 56 +- ...RecursiveEntitySelfReferenceTest.Client.cs | 1410 +++++++++++++++++ .../RecursiveEntitySelfReferenceTest.cs | 91 ++ ...tarWarsGetFriendsDeferInListTest.Client.cs | 56 +- .../StarWarsGetFriendsDeferredTest.Client.cs | 60 +- .../StarWarsGetFriendsTest.Client.cs | 56 +- .../Integration/StarWarsGetHeroTest.Client.cs | 26 +- .../StarWarsGetHeroTraitsTest.Client.cs | 30 +- ...gmentIncludeAndSkipDirectiveTest.Client.cs | 30 +- ...StarWarsTypeNameOnInterfacesTest.Client.cs | 26 +- .../StarWarsTypeNameOnUnionsTest.Client.cs | 39 +- .../StarWarsUnionListTest.Client.cs | 63 +- .../Integration/TestGeneration.cs | 41 + ...DifferentSelectionSets_ReturnsAllData.snap | 25 + ...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 +- ...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 +- ...omplete_Schema_With_UUID_And_DateTime.snap | 25 +- ...rGeneratorTests.TimeSpan_Not_Detected.snap | 13 +- ...hemaGeneratorTests.Create_GetFeatById.snap | 32 +- ...emaGeneratorTests.Create_GetFeatsPage.snap | 32 +- ...atorTests.Create_Query_With_Skip_Take.snap | 17 +- ...eneratorTests.LowerCaseScalarArgument.snap | 17 +- ...aGeneratorTests.NodeTypenameCollision.snap | 15 +- ..._Client_With_Internal_Access_Modifier.snap | 30 +- ...torTests.Interface_With_Default_Names.snap | 30 +- ...torTests.Operation_With_Leaf_Argument.snap | 30 +- ...neratorTests.StarWarsTypeNameOnUnions.snap | 39 +- ...rWarsGeneratorTests.StarWarsUnionList.snap | 35 +- ...azorGeneratorTests.Query_And_Mutation.snap | 30 +- 56 files changed, 2856 insertions(+), 213 deletions(-) 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 create mode 100644 src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/__snapshots__/RecursiveEntitySelfReferenceTest.SelfReferencingEntity_WithDifferentSelectionSets_ReturnsAllData.snap 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..22981682cc0 100644 --- a/src/StrawberryShake/CodeGeneration/src/CodeGeneration.CSharp/Generators/JsonResultBuilderGenerator_UpdateEntity.cs +++ b/src/StrawberryShake/CodeGeneration/src/CodeGeneration.CSharp/Generators/JsonResultBuilderGenerator_UpdateEntity.cs @@ -51,12 +51,13 @@ private void AddUpdateEntityMethod( } else if (namedTypeDescriptor is ObjectTypeDescriptor objectTypeDescriptor) { - BuildTryGetEntityIf( + methodBuilder.AddCode( + BuildTryGetEntityIf( CreateEntityType( - objectTypeDescriptor.Name, - objectTypeDescriptor.RuntimeType.NamespaceWithoutGlobal)) - .AddCode(CreateEntityConstructorCall(objectTypeDescriptor, false)) - .AddElse(CreateEntityConstructorCall(objectTypeDescriptor, true)); + objectTypeDescriptor.Name, + objectTypeDescriptor.RuntimeType.NamespaceWithoutGlobal)) + .AddCode(CreateEntityConstructorCall(objectTypeDescriptor, false)) + .AddElse(CreateEntityConstructorCall(objectTypeDescriptor, true))); methodBuilder.AddEmptyLine(); methodBuilder.AddCode($"return {EntityId};"); @@ -109,21 +110,75 @@ private static ICode CreateEntityConstructorCall( } } - var newEntity = MethodCallBuilder - .Inline() - .SetNew() - .SetMethodName(objectType.EntityTypeDescriptor.RuntimeType.ToString()); + var codeBlock = GenerateArgumentsFromResponse(objectType, propertyLookup, fragments); + if (assignDefault) + { + // Merge: Check whether the same entity was already stored while evaluating an argument + // An entity may reference itself but with a different selection set. + 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 +197,7 @@ private static ICode CreateEntityConstructorCall( .AddArgument(newEntity); } - private static IfBuilder BuildTryGetEntityIf(RuntimeTypeInfo entityType) + private static IfBuilder BuildTryGetEntityIf(RuntimeTypeInfo? entityType) { return IfBuilder .New() @@ -150,7 +205,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 0371db9c882..cc3993e2c72 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 @@ -1088,11 +1088,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); @@ -1111,11 +1120,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/MultiProfileTest.Client.cs b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/MultiProfileTest.Client.cs index 548c3039f56..91a6ac9c5ab 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 @@ -2432,11 +2432,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; @@ -2446,11 +2457,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; @@ -2534,11 +2556,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; @@ -2548,11 +2579,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..644eab3f2d1 --- /dev/null +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/RecursiveEntitySelfReferenceTest.Client.cs @@ -0,0 +1,1410 @@ +// 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 + +// 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))); + 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.Http.HttpConnection(() => clientFactory.CreateClient("RecursiveEntitySelfReferenceClient")); + }); + 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, global::StrawberryShake.CodeGeneration.CSharp.Integration.RecursiveEntitySelfReference.State.GetSelfishGuy_SelfishGuy_Friends_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, 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, global::System.Collections.Generic.IReadOnlyList? friends) + { + Id = id; + FirstName = firstName; + LastName = lastName; + BestFriend = bestFriend; + Friends = friends; + } + + 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 global::System.Collections.Generic.IReadOnlyList? Friends { 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.Equals(other.BestFriend) && global::StrawberryShake.Internal.ComparisonHelper.SequenceEqual(Friends, other.Friends); + } + + 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(); + hash ^= 397 * BestFriend.GetHashCode(); + if (Friends != null) + { + foreach (var Friends_elm in Friends) + { + hash ^= 397 * Friends_elm.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.String lastName, global::System.Int32 age, global::System.String phone) + { + FirstName = firstName; + LastName = lastName; + Age = age; + Phone = phone; + } + + public global::System.String FirstName { get; } + public global::System.String LastName { 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)) && LastName.Equals(other.LastName) && 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 * LastName.GetHashCode(); + hash ^= 397 * Age.GetHashCode(); + hash ^= 397 * Phone.GetHashCode(); + return hash; + } + } + } + + // StrawberryShake.CodeGeneration.CSharp.Generators.ResultTypeGenerator + [global::System.CodeDom.Compiler.GeneratedCode("StrawberryShake", "11.0.0")] + public partial class GetSelfishGuy_SelfishGuy_Friends_Person : global::System.IEquatable, IGetSelfishGuy_SelfishGuy_Friends_Person + { + public GetSelfishGuy_SelfishGuy_Friends_Person(global::System.String id, global::System.String firstName, global::System.String lastName, global::System.String zipCode) + { + Id = id; + FirstName = firstName; + LastName = lastName; + ZipCode = zipCode; + } + + public global::System.String Id { get; } + public global::System.String FirstName { get; } + public global::System.String LastName { get; } + public global::System.String ZipCode { get; } + + public virtual global::System.Boolean Equals(GetSelfishGuy_SelfishGuy_Friends_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) && ZipCode.Equals(other.ZipCode); + } + + 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_Friends_Person)obj); + } + + public override global::System.Int32 GetHashCode() + { + unchecked + { + int hash = 5; + hash ^= 397 * Id.GetHashCode(); + hash ^= 397 * FirstName.GetHashCode(); + hash ^= 397 * LastName.GetHashCode(); + hash ^= 397 * ZipCode.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; } + public global::System.Collections.Generic.IReadOnlyList? Friends { 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.String LastName { 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.ResultInterfaceGenerator + [global::System.CodeDom.Compiler.GeneratedCode("StrawberryShake", "11.0.0")] + public partial interface IGetSelfishGuy_SelfishGuy_Friends + { + public global::System.String Id { get; } + public global::System.String FirstName { get; } + public global::System.String LastName { get; } + public global::System.String ZipCode { get; } + } + + // StrawberryShake.CodeGeneration.CSharp.Generators.ResultInterfaceGenerator + [global::System.CodeDom.Compiler.GeneratedCode("StrawberryShake", "11.0.0")] + public partial interface IGetSelfishGuy_SelfishGuy_Friends_Person : IGetSelfishGuy_SelfishGuy_Friends + { + } + + // StrawberryShake.CodeGeneration.CSharp.Generators.OperationDocumentGenerator + /// + /// Represents the operation service of the GetSelfishGuy GraphQL operation + /// + /// query GetSelfishGuy { + /// selfishGuy { + /// __typename + /// id + /// firstName + /// lastName + /// bestFriend { + /// __typename + /// firstName + /// lastName + /// age + /// phone + /// ... on Person { + /// id + /// } + /// } + /// friends { + /// __typename + /// id + /// firstName + /// lastName + /// zipCode + /// ... 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 => new global::System.Byte[] + { + 0x71, + 0x75, + 0x65, + 0x72, + 0x79, + 0x20, + 0x47, + 0x65, + 0x74, + 0x53, + 0x65, + 0x6c, + 0x66, + 0x69, + 0x73, + 0x68, + 0x47, + 0x75, + 0x79, + 0x20, + 0x7b, + 0x20, + 0x73, + 0x65, + 0x6c, + 0x66, + 0x69, + 0x73, + 0x68, + 0x47, + 0x75, + 0x79, + 0x20, + 0x7b, + 0x20, + 0x5f, + 0x5f, + 0x74, + 0x79, + 0x70, + 0x65, + 0x6e, + 0x61, + 0x6d, + 0x65, + 0x20, + 0x69, + 0x64, + 0x20, + 0x66, + 0x69, + 0x72, + 0x73, + 0x74, + 0x4e, + 0x61, + 0x6d, + 0x65, + 0x20, + 0x6c, + 0x61, + 0x73, + 0x74, + 0x4e, + 0x61, + 0x6d, + 0x65, + 0x20, + 0x62, + 0x65, + 0x73, + 0x74, + 0x46, + 0x72, + 0x69, + 0x65, + 0x6e, + 0x64, + 0x20, + 0x7b, + 0x20, + 0x5f, + 0x5f, + 0x74, + 0x79, + 0x70, + 0x65, + 0x6e, + 0x61, + 0x6d, + 0x65, + 0x20, + 0x66, + 0x69, + 0x72, + 0x73, + 0x74, + 0x4e, + 0x61, + 0x6d, + 0x65, + 0x20, + 0x6c, + 0x61, + 0x73, + 0x74, + 0x4e, + 0x61, + 0x6d, + 0x65, + 0x20, + 0x61, + 0x67, + 0x65, + 0x20, + 0x70, + 0x68, + 0x6f, + 0x6e, + 0x65, + 0x20, + 0x2e, + 0x2e, + 0x2e, + 0x20, + 0x6f, + 0x6e, + 0x20, + 0x50, + 0x65, + 0x72, + 0x73, + 0x6f, + 0x6e, + 0x20, + 0x7b, + 0x20, + 0x69, + 0x64, + 0x20, + 0x7d, + 0x20, + 0x7d, + 0x20, + 0x66, + 0x72, + 0x69, + 0x65, + 0x6e, + 0x64, + 0x73, + 0x20, + 0x7b, + 0x20, + 0x5f, + 0x5f, + 0x74, + 0x79, + 0x70, + 0x65, + 0x6e, + 0x61, + 0x6d, + 0x65, + 0x20, + 0x69, + 0x64, + 0x20, + 0x66, + 0x69, + 0x72, + 0x73, + 0x74, + 0x4e, + 0x61, + 0x6d, + 0x65, + 0x20, + 0x6c, + 0x61, + 0x73, + 0x74, + 0x4e, + 0x61, + 0x6d, + 0x65, + 0x20, + 0x7a, + 0x69, + 0x70, + 0x43, + 0x6f, + 0x64, + 0x65, + 0x20, + 0x2e, + 0x2e, + 0x2e, + 0x20, + 0x6f, + 0x6e, + 0x20, + 0x50, + 0x65, + 0x72, + 0x73, + 0x6f, + 0x6e, + 0x20, + 0x7b, + 0x20, + 0x69, + 0x64, + 0x20, + 0x7d, + 0x20, + 0x7d, + 0x20, + 0x2e, + 0x2e, + 0x2e, + 0x20, + 0x6f, + 0x6e, + 0x20, + 0x50, + 0x65, + 0x72, + 0x73, + 0x6f, + 0x6e, + 0x20, + 0x7b, + 0x20, + 0x69, + 0x64, + 0x20, + 0x7d, + 0x20, + 0x7d, + 0x20, + 0x7d + }; + public global::StrawberryShake.DocumentHash Hash { get; } = new global::StrawberryShake.DocumentHash("sha1Hash", "c7dd849ba27f5c120d9980675ecef0add7d5e838"); + + 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 + /// lastName + /// age + /// phone + /// ... on Person { + /// id + /// } + /// } + /// friends { + /// __typename + /// id + /// firstName + /// lastName + /// zipCode + /// ... 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 + /// lastName + /// age + /// phone + /// ... on Person { + /// id + /// } + /// } + /// friends { + /// __typename + /// id + /// firstName + /// lastName + /// zipCode + /// ... 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.Collections.Generic.IReadOnlyList? friends = default !, global::System.Int32 age = default !, global::System.String phone = default !, global::System.String zipCode = default !) + { + Id = id; + FirstName = firstName; + LastName = lastName; + BestFriend = bestFriend; + Friends = friends; + Age = age; + Phone = phone; + ZipCode = zipCode; + } + + 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.Collections.Generic.IReadOnlyList? Friends { get; } + public global::System.Int32 Age { get; } + public global::System.String Phone { get; } + public global::System.String ZipCode { 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_NonNullableIGetSelfishGuy_SelfishGuy_BestFriendEntity(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "bestFriend"), entityIds); + var arg4 = Update_IGetSelfishGuy_SelfishGuy_FriendsEntityNonNullableArray(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "friends"), entityIds); + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.RecursiveEntitySelfReference.State.PersonEntity(arg0, arg1, arg2, arg3, arg4, entity.Age, entity.Phone, entity.ZipCode)); + } + 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_NonNullableIGetSelfishGuy_SelfishGuy_BestFriendEntity(session, global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "bestFriend"), entityIds); + var arg4 = Update_IGetSelfishGuy_SelfishGuy_FriendsEntityNonNullableArray(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.RecursiveEntitySelfReference.State.PersonEntity(arg0, arg1, arg2, arg3, arg4, entity.Age, entity.Phone, entity.ZipCode)); + } + else + { + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.RecursiveEntitySelfReference.State.PersonEntity(arg0, arg1, arg2, arg3, arg4, default !, 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_NonNullableIGetSelfishGuy_SelfishGuy_BestFriendEntity(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, "firstName")); + var arg1 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "lastName")); + var arg2 = Deserialize_NonNullableInt32(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "age")); + var arg3 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "phone")); + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.RecursiveEntitySelfReference.State.PersonEntity(entity.Id, arg0, arg1, entity.BestFriend, entity.Friends, arg2, arg3, entity.ZipCode)); + } + else + { + var arg0 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "firstName")); + var arg1 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "lastName")); + var arg2 = Deserialize_NonNullableInt32(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "age")); + var arg3 = 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, arg1, entity.BestFriend, entity.Friends, arg2, arg3, entity.ZipCode)); + } + else + { + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.RecursiveEntitySelfReference.State.PersonEntity(default !, arg0, arg1, default !, default !, arg2, arg3, default !)); + } + } + + 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.Collections.Generic.IReadOnlyList? Update_IGetSelfishGuy_SelfishGuy_FriendsEntityNonNullableArray(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; + } + + var persons = new global::System.Collections.Generic.List(); + foreach (global::System.Text.Json.JsonElement child in obj.Value.EnumerateArray()) + { + persons.Add(Update_NonNullableIGetSelfishGuy_SelfishGuy_FriendsEntity(session, child, entityIds)); + } + + return persons; + } + + private global::StrawberryShake.EntityId Update_NonNullableIGetSelfishGuy_SelfishGuy_FriendsEntity(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 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "zipCode")); + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.RecursiveEntitySelfReference.State.PersonEntity(arg0, arg1, arg2, entity.BestFriend, entity.Friends, entity.Age, entity.Phone, arg3)); + } + 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 = Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "zipCode")); + if (session.CurrentSnapshot.TryGetEntity(entityId, out entity)) + { + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.RecursiveEntitySelfReference.State.PersonEntity(arg0, arg1, arg2, entity.BestFriend, entity.Friends, entity.Age, entity.Phone, arg3)); + } + else + { + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.RecursiveEntitySelfReference.State.PersonEntity(arg0, arg1, arg2, default !, default !, default !, default !, arg3)); + } + } + + return entityId; + } + + throw new global::System.NotSupportedException(); + } + } + + // 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; + private readonly global::StrawberryShake.IEntityMapper _getSelfishGuy_SelfishGuy_Friends_PersonFromPersonEntityMapper; + public GetSelfishGuy_SelfishGuy_PersonFromPersonEntityMapper(global::StrawberryShake.IEntityStore entityStore, global::StrawberryShake.IEntityMapper getSelfishGuy_SelfishGuy_BestFriend_PersonFromPersonEntityMapper, global::StrawberryShake.IEntityMapper getSelfishGuy_SelfishGuy_Friends_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)); + _getSelfishGuy_SelfishGuy_Friends_PersonFromPersonEntityMapper = getSelfishGuy_SelfishGuy_Friends_PersonFromPersonEntityMapper ?? throw new global::System.ArgumentNullException(nameof(getSelfishGuy_SelfishGuy_Friends_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, MapNonNullableIGetSelfishGuy_SelfishGuy_BestFriend(entity.BestFriend, snapshot), MapIGetSelfishGuy_SelfishGuy_FriendsNonNullableArray(entity.Friends, snapshot)); + } + + private global::StrawberryShake.CodeGeneration.CSharp.Integration.RecursiveEntitySelfReference.IGetSelfishGuy_SelfishGuy_BestFriend MapNonNullableIGetSelfishGuy_SelfishGuy_BestFriend(global::StrawberryShake.EntityId entityId, global::StrawberryShake.IEntityStoreSnapshot snapshot) + { + if (entityId.Name.Equals("Person", global::System.StringComparison.Ordinal)) + { + return _getSelfishGuy_SelfishGuy_BestFriend_PersonFromPersonEntityMapper.Map(snapshot.GetEntity(entityId) ?? throw new global::StrawberryShake.GraphQLClientException()); + } + + throw new global::System.NotSupportedException(); + } + + private global::System.Collections.Generic.IReadOnlyList? MapIGetSelfishGuy_SelfishGuy_FriendsNonNullableArray(global::System.Collections.Generic.IReadOnlyList? list, global::StrawberryShake.IEntityStoreSnapshot snapshot) + { + if (list is null) + { + return null; + } + + var persons = new global::System.Collections.Generic.List(); + foreach (global::StrawberryShake.EntityId child in list) + { + persons.Add(MapNonNullableIGetSelfishGuy_SelfishGuy_Friends(child, snapshot)); + } + + return persons; + } + + private global::StrawberryShake.CodeGeneration.CSharp.Integration.RecursiveEntitySelfReference.IGetSelfishGuy_SelfishGuy_Friends MapNonNullableIGetSelfishGuy_SelfishGuy_Friends(global::StrawberryShake.EntityId entityId, global::StrawberryShake.IEntityStoreSnapshot snapshot) + { + if (entityId.Name.Equals("Person", global::System.StringComparison.Ordinal)) + { + return _getSelfishGuy_SelfishGuy_Friends_PersonFromPersonEntityMapper.Map(snapshot.GetEntity(entityId) ?? 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.LastName, entity.Age, entity.Phone); + } + } + + // StrawberryShake.CodeGeneration.CSharp.Generators.ResultFromEntityTypeMapperGenerator + [global::System.CodeDom.Compiler.GeneratedCode("StrawberryShake", "11.0.0")] + public partial class GetSelfishGuy_SelfishGuy_Friends_PersonFromPersonEntityMapper : global::StrawberryShake.IEntityMapper + { + private readonly global::StrawberryShake.IEntityStore _entityStore; + public GetSelfishGuy_SelfishGuy_Friends_PersonFromPersonEntityMapper(global::StrawberryShake.IEntityStore entityStore) + { + _entityStore = entityStore ?? throw new global::System.ArgumentNullException(nameof(entityStore)); + } + + public GetSelfishGuy_SelfishGuy_Friends_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_Friends_Person(entity.Id, entity.FirstName, entity.LastName, entity.ZipCode); + } + } + + // 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..8adb9b9a549 --- /dev/null +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/RecursiveEntitySelfReferenceTest.cs @@ -0,0 +1,91 @@ +using HotChocolate.AspNetCore.Tests.Utilities; +using HotChocolate.Types; +using Microsoft.Extensions.DependencyInjection; +using Snapshooter.Xunit; +using StrawberryShake.Transport.WebSockets; + +namespace StrawberryShake.CodeGeneration.CSharp.Integration.RecursiveEntitySelfReference; + +public class RecursiveEntitySelfReferenceTest : ServerTestBase +{ + public RecursiveEntitySelfReferenceTest(TestServerFactory serverFactory) : base(serverFactory) + { + } + + [Fact] + public async Task SelfReferencingEntity_WithDifferentSelectionSets_ReturnsAllData() + { + // arrange + var ct = new CancellationTokenSource(1200_000).Token; + using var host = TestServerHelper.CreateServer( + builder => builder.AddTypeExtension(typeof(QueryType)), + out var port); + + var entityStore = new EntityStore(); + var serviceCollection = new ServiceCollection(); + serviceCollection.AddSingleton(entityStore); + serviceCollection.AddHttpClient( + RecursiveEntitySelfReferenceClient.ClientName, + c => c.BaseAddress = new Uri("http://localhost:" + port + "/graphql")); + serviceCollection.AddRecursiveEntitySelfReferenceClient(); + IServiceProvider services = serviceCollection.BuildServiceProvider(); + RecursiveEntitySelfReferenceClient client = services.GetRequiredService(); + + // act + var response = await client.GetSelfishGuy.ExecuteAsync(ct); + + // assert + response.Data!.SelfishGuy.MatchSnapshot(); + } + + [QueryType] + public static class QueryType + { + public static Person GetSelfishGuy() => Person.GetSelfishGuy(); + } + + public record Person + { + internal static Person GetSelfishGuy() + { + var selfishGuy = new Person + { + Id = "1", + FirstName = "John", + LastName = "Doe", + Age = 42, + Phone = "123-456-7890", + ZipCode = "12345" + }; + var otherFriend = new Person + { + Id = "2", + FirstName = "Jane", + LastName = "Smith", + Age = 41, + Phone = "555-111-2222", + ZipCode = "67890" + }; + + selfishGuy.BestFriend = selfishGuy; + selfishGuy.Friends = new List { selfishGuy, otherFriend }; + + return selfishGuy; + } + + 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; } + public List? Friends { get; set; } + } + + [ExtendObjectType(OperationTypeNames.Query)] + public class QueryResolvers + { + public Person GetSelfishGuy() => Person.GetSelfishGuy(); + } +} 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 85aa57364d0..0513cd03e98 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 @@ -1379,11 +1379,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.IsCharacterNameFulfilled, 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.IsCharacterNameFulfilled, 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 !, 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.IsCharacterNameFulfilled, entity.Name)); + } + else + { + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriendsDeferInList.State.DroidEntity(arg0, default !, default !)); + } } return entityId; @@ -1393,11 +1402,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.IsCharacterNameFulfilled, 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.IsCharacterNameFulfilled, 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 !, 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.IsCharacterNameFulfilled, entity.Name)); + } + else + { + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriendsDeferInList.State.HumanEntity(arg0, default !, default !)); + } } return entityId; @@ -1466,11 +1484,22 @@ 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, global::StrawberryShake.Json.JsonElementExtensions.ContainsFragment(obj, "_isCharacterNameFulfilled"), Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name"))!)); + var arg0 = global::StrawberryShake.Json.JsonElementExtensions.ContainsFragment(obj, "_isCharacterNameFulfilled"); + var arg1 = Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name"))!; + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriendsDeferInList.State.DroidEntity(entity.Friends, arg0, arg1)); } else { - session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriendsDeferInList.State.DroidEntity(default !, global::StrawberryShake.Json.JsonElementExtensions.ContainsFragment(obj, "_isCharacterNameFulfilled"), Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name"))!)); + var arg0 = global::StrawberryShake.Json.JsonElementExtensions.ContainsFragment(obj, "_isCharacterNameFulfilled"); + var arg1 = Deserialize_String(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, arg1)); + } + else + { + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriendsDeferInList.State.DroidEntity(default !, arg0, arg1)); + } } return entityId; @@ -1480,11 +1509,22 @@ 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, global::StrawberryShake.Json.JsonElementExtensions.ContainsFragment(obj, "_isCharacterNameFulfilled"), Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name"))!)); + var arg0 = global::StrawberryShake.Json.JsonElementExtensions.ContainsFragment(obj, "_isCharacterNameFulfilled"); + var arg1 = Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name"))!; + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriendsDeferInList.State.HumanEntity(entity.Friends, arg0, arg1)); } else { - session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriendsDeferInList.State.HumanEntity(default !, global::StrawberryShake.Json.JsonElementExtensions.ContainsFragment(obj, "_isCharacterNameFulfilled"), Deserialize_String(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name"))!)); + var arg0 = global::StrawberryShake.Json.JsonElementExtensions.ContainsFragment(obj, "_isCharacterNameFulfilled"); + var arg1 = Deserialize_String(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, arg1)); + } + else + { + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriendsDeferInList.State.HumanEntity(default !, arg0, arg1)); + } } 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 fec49eb0c5f..421afd15b98 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 @@ -1387,11 +1387,24 @@ 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")), global::StrawberryShake.Json.JsonElementExtensions.ContainsFragment(obj, "_isFriendsListFulfilled"), 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 = global::StrawberryShake.Json.JsonElementExtensions.ContainsFragment(obj, "_isFriendsListFulfilled"); + var arg2 = 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, arg2)); } else { - session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriendsDeferred.State.DroidEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), global::StrawberryShake.Json.JsonElementExtensions.ContainsFragment(obj, "_isFriendsListFulfilled"), 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 = global::StrawberryShake.Json.JsonElementExtensions.ContainsFragment(obj, "_isFriendsListFulfilled"); + 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::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriendsDeferred.State.DroidEntity(arg0, arg1, arg2)); + } + else + { + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriendsDeferred.State.DroidEntity(arg0, arg1, arg2)); + } } return entityId; @@ -1401,11 +1414,24 @@ 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")), global::StrawberryShake.Json.JsonElementExtensions.ContainsFragment(obj, "_isFriendsListFulfilled"), 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 = global::StrawberryShake.Json.JsonElementExtensions.ContainsFragment(obj, "_isFriendsListFulfilled"); + var arg2 = 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, arg2)); } else { - session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriendsDeferred.State.HumanEntity(Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "name")), global::StrawberryShake.Json.JsonElementExtensions.ContainsFragment(obj, "_isFriendsListFulfilled"), 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 = global::StrawberryShake.Json.JsonElementExtensions.ContainsFragment(obj, "_isFriendsListFulfilled"); + 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::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriendsDeferred.State.HumanEntity(arg0, arg1, arg2)); + } + else + { + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriendsDeferred.State.HumanEntity(arg0, arg1, arg2)); + } } return entityId; @@ -1489,11 +1515,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.IsFriendsListFulfilled, 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.IsFriendsListFulfilled, 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 !, 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.IsFriendsListFulfilled, entity.Friends)); + } + else + { + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriendsDeferred.State.DroidEntity(arg0, default !, default !)); + } } return entityId; @@ -1503,11 +1538,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.IsFriendsListFulfilled, 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.IsFriendsListFulfilled, 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 !, 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.IsFriendsListFulfilled, entity.Friends)); + } + else + { + session.SetEntity(entityId, new global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetFriendsDeferred.State.HumanEntity(arg0, default !, 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 6bb13f2e169..7766a834ae2 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 @@ -1153,11 +1153,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; @@ -1167,11 +1178,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; @@ -1255,11 +1277,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; @@ -1269,11 +1300,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 28973e4b65d..4fb6c40d774 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 @@ -761,11 +761,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; @@ -775,11 +784,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 daca9fcba25..6e770a9acc4 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 @@ -793,11 +793,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; @@ -807,11 +818,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 58b05b4cedb..502e6f7e1f5 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 @@ -1681,11 +1681,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; @@ -1695,11 +1706,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 61fcb81be3f..e5ca8cc0bb5 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 @@ -761,11 +761,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; @@ -775,11 +784,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 df669d6a368..64075bc83e6 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 @@ -925,11 +925,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; @@ -939,11 +948,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; @@ -953,11 +971,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 cbbb13e75dd..2f730ff5c99 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 @@ -1353,7 +1353,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; @@ -1363,11 +1370,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; @@ -1377,11 +1395,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; @@ -1465,11 +1492,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; @@ -1479,11 +1515,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 07983f605b3..f9bb3fae76c 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/TestGeneration.cs +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/TestGeneration.cs @@ -421,4 +421,45 @@ scalar LocalDate scalar LocalDateTime scalar LocalTime """); + + [Fact] + public void RecursiveEntitySelfReference() => + AssertResult( + CreateIntegrationTest(), + skipWarnings: true, + """ + query GetSelfishGuy { + selfishGuy { + id + firstName + lastName + bestFriend { + firstName + lastName + age + phone + } + friends { + id + firstName + lastName + zipCode + } + } + } + """, + "type Query { selfishGuy: Person! }", + """ + type Person { + id: String! + firstName: String! + lastName: String! + age: Int! + phone: String! + zipCode: String! + bestFriend: Person! + friends: [Person!] + } + """, + "extend schema @key(fields: \"id\")"); } diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/__snapshots__/RecursiveEntitySelfReferenceTest.SelfReferencingEntity_WithDifferentSelectionSets_ReturnsAllData.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/__snapshots__/RecursiveEntitySelfReferenceTest.SelfReferencingEntity_WithDifferentSelectionSets_ReturnsAllData.snap new file mode 100644 index 00000000000..bb392b4d89d --- /dev/null +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/__snapshots__/RecursiveEntitySelfReferenceTest.SelfReferencingEntity_WithDifferentSelectionSets_ReturnsAllData.snap @@ -0,0 +1,25 @@ +{ + "Id": "1", + "FirstName": "John", + "LastName": "Doe", + "BestFriend": { + "FirstName": "John", + "LastName": "Doe", + "Age": 42, + "Phone": "123-456-7890" + }, + "Friends": [ + { + "Id": "1", + "FirstName": "John", + "LastName": "Doe", + "ZipCode": "12345" + }, + { + "Id": "2", + "FirstName": "Jane", + "LastName": "Smith", + "ZipCode": "67890" + } + ] +} 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 fff78165182..d60419c66b3 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 @@ -1407,11 +1407,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; @@ -1484,11 +1493,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; @@ -1561,11 +1579,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 a3094a35ccb..52957794b36 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 @@ -1407,11 +1407,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; @@ -1484,11 +1493,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; @@ -1561,11 +1579,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 e2af712140b..a40aef22df5 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 @@ -1407,11 +1407,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; @@ -1484,11 +1493,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; @@ -1561,11 +1579,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 4ce6c51b157..0682ad96cf7 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 @@ -1415,11 +1415,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; @@ -1492,11 +1501,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; @@ -1569,11 +1587,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 81a8888138f..1b5e1a31adf 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 @@ -560,11 +560,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 7cd4d539b29..c77ba5ea719 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 @@ -541,11 +541,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 da6d1c459f6..2b7563dc249 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 @@ -512,11 +512,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 7af52ea5b8b..14ba53ca49b 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 @@ -913,11 +913,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 ffb085c8a69..d3cc5c62c31 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 @@ -913,11 +913,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 1a5675e8937..a62799a0b9d 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 @@ -855,11 +855,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 8c3b00f525b..add65a7d94d 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 @@ -855,11 +855,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__/EntityIdFactoryGeneratorTests.Simple_ComplexEntity.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityIdFactoryGeneratorTests.Simple_ComplexEntity.snap index c05e7857263..1822d2b8db8 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 @@ -567,11 +567,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 0e016cdd2bd..19ab7223d8a 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 @@ -560,11 +560,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 37abdbbbc30..80c6eedf911 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 @@ -558,11 +558,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 5bfb58a4d5a..39f8ec06943 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 @@ -560,11 +560,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 1b15d829866..10d541e196a 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 @@ -995,11 +995,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); @@ -1013,11 +1024,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 ab6f0bc514f..3bb9c8a152a 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 @@ -1038,11 +1038,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); @@ -1056,11 +1067,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 29d34d49d5b..3a26b3f8b9b 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 @@ -992,11 +992,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); @@ -1015,11 +1024,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 65b08a4d296..791cbbc44e8 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 @@ -955,11 +955,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); @@ -978,11 +987,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 eeebdf25ed2..93e5d7f8930 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 @@ -998,11 +998,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); @@ -1021,11 +1030,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 5be55e8500e..c6fb7c4c2aa 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 @@ -1055,11 +1055,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; @@ -1109,11 +1118,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); @@ -1132,11 +1150,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 06f7e69df4d..8efb9cb19ac 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 @@ -1289,11 +1289,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 4d62513e284..b2f20ba91b7 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 @@ -898,11 +898,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; @@ -971,11 +980,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 ff708645364..a3d66c54c7c 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 @@ -753,11 +753,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; @@ -767,11 +778,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 b6681cfe104..86c402f673d 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 @@ -940,11 +940,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 85297d5c969..0c329eaa698 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 @@ -958,11 +958,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__/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 911aff42118..ede31565d9f 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 @@ -941,11 +941,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.TimeSpan_Not_Detected.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/ScalarGeneratorTests.TimeSpan_Not_Detected.snap index daa24a0e23e..c7832ed0cb8 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/ScalarGeneratorTests.TimeSpan_Not_Detected.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/ScalarGeneratorTests.TimeSpan_Not_Detected.snap @@ -770,11 +770,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 70e281c1ebb..02e8504e1e5 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 @@ -1025,11 +1025,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; @@ -1122,11 +1137,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 2e6d2f4163e..eb0756e1ed6 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 @@ -1058,11 +1058,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; @@ -1134,11 +1149,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_Query_With_Skip_Take.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/SchemaGeneratorTests.Create_Query_With_Skip_Take.snap index c6263f5b60f..70fd20fd809 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 @@ -917,11 +917,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.LowerCaseScalarArgument.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/SchemaGeneratorTests.LowerCaseScalarArgument.snap index 4f4abb97de4..5d9be4efbdd 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 @@ -649,11 +649,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 e6f68cb9934..670a83830b9 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 @@ -588,11 +588,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__/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 e6a61011a66..a1556723d67 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 @@ -753,11 +753,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; @@ -767,11 +778,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 ff708645364..a3d66c54c7c 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 @@ -753,11 +753,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; @@ -767,11 +778,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.Operation_With_Leaf_Argument.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/StarWarsGeneratorTests.Operation_With_Leaf_Argument.snap index 3dab2dddaca..0ad652d90bb 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 @@ -795,11 +795,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; @@ -809,11 +820,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 7db3eb0782e..88c27b73200 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 @@ -834,11 +834,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; @@ -848,11 +857,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; @@ -862,11 +880,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 218e1f972d1..4c92dc8d07f 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 @@ -879,7 +879,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; @@ -889,11 +896,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; @@ -903,11 +919,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 6854fb18ed7..99eb2f94560 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 @@ -1197,11 +1197,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; @@ -1289,11 +1300,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; From 03b746973814882fa254e5db26e5d3bb4d541927 Mon Sep 17 00:00:00 2001 From: NOlbert <45466413+N-Olbert@users.noreply.github.com> Date: Mon, 25 Aug 2025 23:15:14 +0200 Subject: [PATCH 2/2] Updated snapshots --- ...lient_MapperMapsEntityOnRootCorrectly.snap | 73 ++++- ...apsEntityOnRootCorrectly_With_Records.snap | 73 ++++- ...sts.Generate_ChatClient_AllOperations.snap | 264 ++++++++++++++++-- ...esultTypeGeneratorTests.Nested_Entity.snap | 44 ++- ...pleSearch_From_ActiveDirectory_Schema.snap | 61 +++- ...eratorTests.FieldsWithUnderlineInName.snap | 75 ++++- ...chemaGeneratorTests.QueryInterference.snap | 87 +++++- ...e_With_Fragment_Definition_Two_Models.snap | 62 +++- 8 files changed, 649 insertions(+), 90 deletions(-) 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 46b3ffd3369..79d1af3f73f 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 @@ -1,4 +1,4 @@ -// ReSharper disable ArrangeObjectCreationWhenTypeEvident +// ReSharper disable ArrangeObjectCreationWhenTypeEvident // ReSharper disable BuiltInTypeReferenceStyle // ReSharper disable ConvertToAutoProperty // ReSharper disable InconsistentNaming @@ -2501,11 +2501,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; @@ -2589,11 +2600,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; @@ -2620,11 +2642,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; @@ -2703,11 +2734,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; @@ -2734,11 +2776,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 8c249809576..bab325cc498 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 @@ -1,4 +1,4 @@ -// ReSharper disable ArrangeObjectCreationWhenTypeEvident +// ReSharper disable ArrangeObjectCreationWhenTypeEvident // ReSharper disable BuiltInTypeReferenceStyle // ReSharper disable ConvertToAutoProperty // ReSharper disable InconsistentNaming @@ -2501,11 +2501,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; @@ -2589,11 +2600,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; @@ -2620,11 +2642,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; @@ -2703,11 +2734,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; @@ -2734,11 +2776,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__/OperationGeneratorTests.Generate_ChatClient_AllOperations.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/OperationGeneratorTests.Generate_ChatClient_AllOperations.snap index f24dc9e3407..09449c4ba89 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 @@ -1,4 +1,4 @@ -// ReSharper disable ArrangeObjectCreationWhenTypeEvident +// ReSharper disable ArrangeObjectCreationWhenTypeEvident // ReSharper disable BuiltInTypeReferenceStyle // ReSharper disable ConvertToAutoProperty // ReSharper disable InconsistentNaming @@ -6248,11 +6248,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; @@ -6378,11 +6395,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; @@ -6451,11 +6477,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; @@ -6512,11 +6557,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; @@ -6558,11 +6616,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; @@ -6664,11 +6735,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; @@ -6725,11 +6815,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; @@ -6771,11 +6874,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; @@ -6877,11 +6993,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; @@ -6938,11 +7073,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; @@ -6984,11 +7132,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; @@ -7069,11 +7230,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; @@ -7130,11 +7310,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; @@ -7176,11 +7369,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 4029b4f2b80..bdeff7133bf 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 @@ -1,4 +1,4 @@ -// ReSharper disable ArrangeObjectCreationWhenTypeEvident +// ReSharper disable ArrangeObjectCreationWhenTypeEvident // ReSharper disable BuiltInTypeReferenceStyle // ReSharper disable ConvertToAutoProperty // ReSharper disable InconsistentNaming @@ -1336,11 +1336,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; @@ -1397,11 +1412,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__/SchemaGeneratorTests.Create_PeopleSearch_From_ActiveDirectory_Schema.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/SchemaGeneratorTests.Create_PeopleSearch_From_ActiveDirectory_Schema.snap index a4a5e496297..de23edc7b21 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 @@ -1,4 +1,4 @@ -// ReSharper disable ArrangeObjectCreationWhenTypeEvident +// ReSharper disable ArrangeObjectCreationWhenTypeEvident // ReSharper disable BuiltInTypeReferenceStyle // ReSharper disable ConvertToAutoProperty // ReSharper disable InconsistentNaming @@ -1871,11 +1871,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; @@ -1947,11 +1970,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; @@ -1993,11 +2027,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.FieldsWithUnderlineInName.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/SchemaGeneratorTests.FieldsWithUnderlineInName.snap index e22e7be558b..597f4b26157 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 @@ -1,4 +1,4 @@ -// ReSharper disable ArrangeObjectCreationWhenTypeEvident +// ReSharper disable ArrangeObjectCreationWhenTypeEvident // ReSharper disable BuiltInTypeReferenceStyle // ReSharper disable ConvertToAutoProperty // ReSharper disable InconsistentNaming @@ -4565,11 +4565,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; @@ -4662,11 +4695,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; @@ -4708,11 +4758,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.QueryInterference.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/SchemaGeneratorTests.QueryInterference.snap index 977a6fed95d..1fc8e73a8d4 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 @@ -1,4 +1,4 @@ -// ReSharper disable ArrangeObjectCreationWhenTypeEvident +// ReSharper disable ArrangeObjectCreationWhenTypeEvident // ReSharper disable BuiltInTypeReferenceStyle // ReSharper disable ConvertToAutoProperty // ReSharper disable InconsistentNaming @@ -4091,11 +4091,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; @@ -4188,11 +4205,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; @@ -4296,11 +4322,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; @@ -4408,11 +4455,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; @@ -4439,11 +4495,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.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 333db5d5bf9..1b772256742 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 @@ -1,4 +1,4 @@ -// ReSharper disable ArrangeObjectCreationWhenTypeEvident +// ReSharper disable ArrangeObjectCreationWhenTypeEvident // ReSharper disable BuiltInTypeReferenceStyle // ReSharper disable ConvertToAutoProperty // ReSharper disable InconsistentNaming @@ -1300,11 +1300,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; @@ -1314,11 +1327,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; @@ -1417,11 +1443,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; @@ -1431,11 +1466,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;