// <auto-generated/>

#nullable enable annotations
#nullable disable warnings

// Suppress warnings about [Obsolete] member usage in generated code.
#pragma warning disable CS0612, CS0618

namespace TestApp
{
    internal partial class MyContext
    {
        private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::TestApp.GenericProps<int>>? _GenericPropsInt32;
        
        /// <summary>
        /// Defines the source generated JSON serialization contract metadata for a given type.
        /// </summary>
        #nullable disable annotations // Marking the property type as nullable-oblivious.
        public global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::TestApp.GenericProps<int>> GenericPropsInt32
        #nullable enable annotations
        {
            get => _GenericPropsInt32 ??= (global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::TestApp.GenericProps<int>>)Options.GetTypeInfo(typeof(global::TestApp.GenericProps<int>));
        }
        
        private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::TestApp.GenericProps<int>> Create_GenericPropsInt32(global::System.Text.Json.JsonSerializerOptions options)
        {
            if (!TryGetTypeInfoForRuntimeCustomConverter<global::TestApp.GenericProps<int>>(options, out global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::TestApp.GenericProps<int>> jsonTypeInfo))
            {
                var objectInfo = new global::System.Text.Json.Serialization.Metadata.JsonObjectInfoValues<global::TestApp.GenericProps<int>>
                {
                    ObjectCreator = () => new global::TestApp.GenericProps<int>(),
                    ObjectWithParameterizedConstructorCreator = null,
                    PropertyMetadataInitializer = _ => GenericPropsInt32PropInit(options),
                    ConstructorParameterMetadataInitializer = null,
                    ConstructorAttributeProviderFactory = static () => typeof(global::TestApp.GenericProps<int>).GetConstructor(InstanceMemberBindingFlags, binder: null, global::System.Array.Empty<global::System.Type>(), modifiers: null),
                    SerializeHandler = GenericPropsInt32SerializeHandler,
                    PolymorphismOptions = new global::System.Text.Json.Serialization.Metadata.JsonPolymorphismOptions(),
                    TypeClassifierFactory = null,
                };
                
                jsonTypeInfo = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreateObjectInfo<global::TestApp.GenericProps<int>>(options, objectInfo);
                jsonTypeInfo.NumberHandling = null;
            }
        
            jsonTypeInfo.OriginatingResolver = this;
            return jsonTypeInfo;
        }

        private static global::System.Text.Json.Serialization.Metadata.JsonPropertyInfo[] GenericPropsInt32PropInit(global::System.Text.Json.JsonSerializerOptions options)
        {
            var properties = new global::System.Text.Json.Serialization.Metadata.JsonPropertyInfo[2];

            var info0 = new global::System.Text.Json.Serialization.Metadata.JsonPropertyInfoValues<int>
            {
                IsProperty = true,
                IsPublic = true,
                IsVirtual = false,
                DeclaringType = typeof(global::TestApp.GenericProps<int>),
                Converter = null,
                Getter = static obj => ((global::TestApp.GenericProps<int>)obj).Value,
                Setter = static (obj, value) => __set_GenericPropsInt32_Value((global::TestApp.GenericProps<int>)obj, value!),
                IgnoreCondition = null,
                HasJsonInclude = false,
                IsExtensionData = false,
                NumberHandling = null,
                PropertyName = "Value",
                JsonPropertyName = null,
                AttributeProviderFactory = static () => typeof(global::TestApp.GenericProps<int>).GetProperty("Value", InstanceMemberBindingFlags, null, typeof(int), global::System.Array.Empty<global::System.Type>(), null),
            };
            
            properties[0] = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreatePropertyInfo<int>(options, info0);

            var info1 = new global::System.Text.Json.Serialization.Metadata.JsonPropertyInfoValues<string>
            {
                IsProperty = true,
                IsPublic = true,
                IsVirtual = false,
                DeclaringType = typeof(global::TestApp.GenericProps<int>),
                Converter = null,
                Getter = static obj => ((global::TestApp.GenericProps<int>)obj).Label,
                Setter = static (obj, value) => __set_GenericPropsInt32_Label((global::TestApp.GenericProps<int>)obj, value!),
                IgnoreCondition = null,
                HasJsonInclude = false,
                IsExtensionData = false,
                NumberHandling = null,
                PropertyName = "Label",
                JsonPropertyName = null,
                AttributeProviderFactory = static () => typeof(global::TestApp.GenericProps<int>).GetProperty("Label", InstanceMemberBindingFlags, null, typeof(string), global::System.Array.Empty<global::System.Type>(), null),
            };
            
            properties[1] = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreatePropertyInfo<string>(options, info1);

            return properties;
        }

        // Intentionally not a static method because we create a delegate to it. Invoking delegates to instance
        // methods is almost as fast as virtual calls. Static methods need to go through a shuffle thunk.
        private void GenericPropsInt32SerializeHandler(global::System.Text.Json.Utf8JsonWriter writer, global::TestApp.GenericProps<int>? value)
        {
            if (value is null)
            {
                writer.WriteNullValue();
                return;
            }
            
            writer.WriteStartObject();

            writer.WriteNumber(PropName_Value, ((global::TestApp.GenericProps<int>)value).Value);
            writer.WriteString(PropName_Label, ((global::TestApp.GenericProps<int>)value).Label);

            writer.WriteEndObject();
        }

        private static global::System.Action<global::TestApp.GenericProps<int>, int>? s_set_GenericPropsInt32_Value;
        private static void __set_GenericPropsInt32_Value(global::TestApp.GenericProps<int> obj, int value) => (s_set_GenericPropsInt32_Value ??= (global::System.Action<global::TestApp.GenericProps<int>, int>)global::System.Delegate.CreateDelegate(typeof(global::System.Action<global::TestApp.GenericProps<int>, int>), typeof(global::TestApp.GenericProps<int>).GetProperty("Value", InstanceMemberBindingFlags, null, typeof(int), global::System.Array.Empty<global::System.Type>(), null)!.GetSetMethod(true)!))(obj, value);
        private static global::System.Action<global::TestApp.GenericProps<int>, string>? s_set_GenericPropsInt32_Label;
        private static void __set_GenericPropsInt32_Label(global::TestApp.GenericProps<int> obj, string value) => (s_set_GenericPropsInt32_Label ??= (global::System.Action<global::TestApp.GenericProps<int>, string>)global::System.Delegate.CreateDelegate(typeof(global::System.Action<global::TestApp.GenericProps<int>, string>), typeof(global::TestApp.GenericProps<int>).GetProperty("Label", InstanceMemberBindingFlags, null, typeof(string), global::System.Array.Empty<global::System.Type>(), null)!.GetSetMethod(true)!))(obj, value);
    }
}
