|
| 1 | +# GenerateSource_BindField_And_BindMember_MatchesSnapshot |
| 2 | + |
| 3 | +## HotChocolateTypeModule.735550c.g.cs |
| 4 | + |
| 5 | +```csharp |
| 6 | +// <auto-generated/> |
| 7 | +
|
| 8 | +#nullable enable |
| 9 | +#pragma warning disable |
| 10 | + |
| 11 | +using System; |
| 12 | +using System.Runtime.CompilerServices; |
| 13 | +using HotChocolate; |
| 14 | +using HotChocolate.Types; |
| 15 | +using HotChocolate.Execution.Configuration; |
| 16 | + |
| 17 | +namespace Microsoft.Extensions.DependencyInjection |
| 18 | +{ |
| 19 | + public static partial class TestsTypesRequestExecutorBuilderExtensions |
| 20 | + { |
| 21 | + public static IRequestExecutorBuilder AddTestsTypes(this IRequestExecutorBuilder builder) |
| 22 | + { |
| 23 | + builder.ConfigureDescriptorContext(ctx => ctx.TypeConfiguration.TryAdd<global::TestNamespace.User>( |
| 24 | + "Tests::TestNamespace.UserType", |
| 25 | + () => global::TestNamespace.UserType.Initialize)); |
| 26 | + builder.AddType<ObjectType<global::TestNamespace.User>>(); |
| 27 | + return builder; |
| 28 | + } |
| 29 | + } |
| 30 | +} |
| 31 | + |
| 32 | +``` |
| 33 | + |
| 34 | +## UserType.WaAdMHmlGJHjtEI4nqY7WA.hc.g.cs |
| 35 | + |
| 36 | +```csharp |
| 37 | +// <auto-generated/> |
| 38 | +
|
| 39 | +#nullable enable |
| 40 | +#pragma warning disable |
| 41 | + |
| 42 | +using System; |
| 43 | +using System.Runtime.CompilerServices; |
| 44 | +using HotChocolate; |
| 45 | +using HotChocolate.Types; |
| 46 | +using HotChocolate.Execution.Configuration; |
| 47 | +using Microsoft.Extensions.DependencyInjection; |
| 48 | +using HotChocolate.Internal; |
| 49 | + |
| 50 | +namespace TestNamespace |
| 51 | +{ |
| 52 | + public static partial class UserType |
| 53 | + { |
| 54 | + internal static void Initialize(global::HotChocolate.Types.IObjectTypeDescriptor<global::TestNamespace.User> descriptor) |
| 55 | + { |
| 56 | + var extension = descriptor.Extend(); |
| 57 | + var configuration = extension.Configuration; |
| 58 | + var thisType = typeof(global::TestNamespace.UserType); |
| 59 | + var bindingResolver = extension.Context.ParameterBindingResolver; |
| 60 | + var resolvers = new __Resolvers(); |
| 61 | + |
| 62 | + var naming = descriptor.Extend().Context.Naming; |
| 63 | + var boundFields = new global::System.Collections.Generic.HashSet<string>(); |
| 64 | + boundFields.Add("profile"); |
| 65 | + |
| 66 | + foreach(string fieldName in boundFields) |
| 67 | + { |
| 68 | + descriptor.Field(fieldName); |
| 69 | + } |
| 70 | + |
| 71 | + var ignoredFields = new global::System.Collections.Generic.HashSet<string>(); |
| 72 | + ignoredFields.Add(naming.GetMemberName("Email", global::HotChocolate.Types.MemberKind.ObjectField)); |
| 73 | + |
| 74 | + foreach(string fieldName in ignoredFields) |
| 75 | + { |
| 76 | + descriptor.Field(fieldName).Ignore(); |
| 77 | + } |
| 78 | + |
| 79 | + descriptor |
| 80 | + .Field("profile") |
| 81 | + .ExtendWith(static (field, context) => |
| 82 | + { |
| 83 | + var configuration = field.Configuration; |
| 84 | + var typeInspector = field.Context.TypeInspector; |
| 85 | + var bindingResolver = field.Context.ParameterBindingResolver; |
| 86 | + var naming = field.Context.Naming; |
| 87 | + |
| 88 | + configuration.Type = global::HotChocolate.Types.Descriptors.TypeReference.Create( |
| 89 | + typeInspector.GetTypeRef(typeof(global::TestNamespace.Profile), HotChocolate.Types.TypeContext.Output), |
| 90 | + new global::HotChocolate.Language.NonNullTypeNode(new global::HotChocolate.Language.NamedTypeNode("global__TestNamespace_Profile"))); |
| 91 | + configuration.ResultType = typeof(global::TestNamespace.Profile); |
| 92 | + configuration.DeclaringType = context.ThisType; |
| 93 | + |
| 94 | + configuration.SetSourceGeneratorFlags(); |
| 95 | + |
| 96 | + configuration.Member = context.ThisType.GetMethod( |
| 97 | + "GetProfile", |
| 98 | + global::HotChocolate.Utilities.ReflectionUtils.StaticMemberFlags, |
| 99 | + new global::System.Type[] |
| 100 | + { |
| 101 | + typeof(global::TestNamespace.User) |
| 102 | + })!; |
| 103 | + |
| 104 | + var fieldDescriptor = global::HotChocolate.Types.Descriptors.ObjectFieldDescriptor.From(field.Context, configuration); |
| 105 | + HotChocolate.Internal.ConfigurationHelper.ApplyConfiguration( |
| 106 | + field.Context, |
| 107 | + fieldDescriptor, |
| 108 | + configuration.Member, |
| 109 | + new global::HotChocolate.Types.BindFieldAttribute("profile")); |
| 110 | + configuration.ConfigurationsAreApplied = true; |
| 111 | + fieldDescriptor.CreateConfiguration(); |
| 112 | + |
| 113 | + configuration.Resolvers = context.Resolvers.GetProfile(); |
| 114 | + }, |
| 115 | + (Resolvers: resolvers, ThisType: thisType)); |
| 116 | + |
| 117 | + descriptor |
| 118 | + .Field(naming.GetMemberName("EmailFormatted", global::HotChocolate.Types.MemberKind.ObjectField)) |
| 119 | + .ExtendWith(static (field, context) => |
| 120 | + { |
| 121 | + var configuration = field.Configuration; |
| 122 | + var typeInspector = field.Context.TypeInspector; |
| 123 | + var bindingResolver = field.Context.ParameterBindingResolver; |
| 124 | + var naming = field.Context.Naming; |
| 125 | + |
| 126 | + configuration.Type = global::HotChocolate.Types.Descriptors.TypeReference.Create( |
| 127 | + typeInspector.GetTypeRef(typeof(string), HotChocolate.Types.TypeContext.Output), |
| 128 | + new global::HotChocolate.Language.NonNullTypeNode(new global::HotChocolate.Language.NamedTypeNode("string"))); |
| 129 | + configuration.ResultType = typeof(string); |
| 130 | + configuration.DeclaringType = context.ThisType; |
| 131 | + |
| 132 | + configuration.SetSourceGeneratorFlags(); |
| 133 | + |
| 134 | + configuration.Member = context.ThisType.GetMethod( |
| 135 | + "GetEmailFormatted", |
| 136 | + global::HotChocolate.Utilities.ReflectionUtils.StaticMemberFlags, |
| 137 | + new global::System.Type[] |
| 138 | + { |
| 139 | + typeof(global::TestNamespace.User) |
| 140 | + })!; |
| 141 | + |
| 142 | + var fieldDescriptor = global::HotChocolate.Types.Descriptors.ObjectFieldDescriptor.From(field.Context, configuration); |
| 143 | + HotChocolate.Internal.ConfigurationHelper.ApplyConfiguration( |
| 144 | + field.Context, |
| 145 | + fieldDescriptor, |
| 146 | + configuration.Member, |
| 147 | + new global::HotChocolate.Types.BindMemberAttribute("Email")); |
| 148 | + configuration.ConfigurationsAreApplied = true; |
| 149 | + fieldDescriptor.CreateConfiguration(); |
| 150 | + |
| 151 | + configuration.Resolvers = context.Resolvers.GetEmailFormatted(); |
| 152 | + }, |
| 153 | + (Resolvers: resolvers, ThisType: thisType)); |
| 154 | + |
| 155 | + Configure(descriptor); |
| 156 | + } |
| 157 | + |
| 158 | + static partial void Configure(global::HotChocolate.Types.IObjectTypeDescriptor<global::TestNamespace.User> descriptor); |
| 159 | + |
| 160 | + private sealed class __Resolvers |
| 161 | + { |
| 162 | + public HotChocolate.Resolvers.FieldResolverDelegates GetProfile() |
| 163 | + { |
| 164 | + return new global::HotChocolate.Resolvers.FieldResolverDelegates(pureResolver: GetProfile); |
| 165 | + } |
| 166 | + |
| 167 | + private global::System.Object? GetProfile(global::HotChocolate.Resolvers.IResolverContext context) |
| 168 | + { |
| 169 | + var args0 = context.Parent<global::TestNamespace.User>(); |
| 170 | + var result = global::TestNamespace.UserType.GetProfile(args0); |
| 171 | + return result; |
| 172 | + } |
| 173 | + |
| 174 | + public HotChocolate.Resolvers.FieldResolverDelegates GetEmailFormatted() |
| 175 | + { |
| 176 | + return new global::HotChocolate.Resolvers.FieldResolverDelegates(pureResolver: GetEmailFormatted); |
| 177 | + } |
| 178 | + |
| 179 | + private global::System.Object? GetEmailFormatted(global::HotChocolate.Resolvers.IResolverContext context) |
| 180 | + { |
| 181 | + var args0 = context.Parent<global::TestNamespace.User>(); |
| 182 | + var result = global::TestNamespace.UserType.GetEmailFormatted(args0); |
| 183 | + return result; |
| 184 | + } |
| 185 | + } |
| 186 | + } |
| 187 | +} |
| 188 | + |
| 189 | + |
| 190 | +``` |
0 commit comments