﻿[  
// ------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a source generator named Vogen (https://github.com/SteveDunn/Vogen)
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
// ------------------------------------------------------------------------------
// Suppress warnings about [Obsolete] member usage in generated code.
#pragma warning disable CS0618
// Suppress warnings for 'Override methods on comparable types'.
#pragma warning disable CA1036
// Suppress Error MA0097 : A class that implements IComparable<T> or IComparable should override comparison operators
#pragma warning disable MA0097
// Suppress warning for 'The annotation for nullable reference types should only be used in code within a '#nullable' annotations context. Auto-generated code requires an explicit '#nullable' directive in source.'
// The generator copies signatures from the BCL, e.g. for `TryParse`, and some of those have nullable annotations.
#pragma warning disable CS8669, CS8632
// Suppress warnings about CS1591: Missing XML comment for publicly visible type or member 'Type_or_Member'
#pragma warning disable CS1591
namespace generator;
public class VogenTypesFactory : global::System.Text.Json.Serialization.JsonConverterFactory
{
    public VogenTypesFactory()
    {
    }

    private static readonly global::System.Collections.Generic.Dictionary<global::System.Type, global::System.Lazy<global::System.Text.Json.Serialization.JsonConverter>> _lookup = new global::System.Collections.Generic.Dictionary<global::System.Type, global::System.Lazy<global::System.Text.Json.Serialization.JsonConverter>>
    {
        {
            typeof(global::@double.classFromEscapedNamespaceWithReservedUnderlyingType),
            new global::System.Lazy<global::System.Text.Json.Serialization.JsonConverter>(() => new global::@double.classFromEscapedNamespaceWithReservedUnderlyingType.classFromEscapedNamespaceWithReservedUnderlyingTypeSystemTextJsonConverter())
        },
        {
            typeof(global::@double.classFromEscapedNamespace),
            new global::System.Lazy<global::System.Text.Json.Serialization.JsonConverter>(() => new global::@double.classFromEscapedNamespace.classFromEscapedNamespaceSystemTextJsonConverter())
        },
        {
            typeof(global::@bool.@byte.@short.@float.@object.@class),
            new global::System.Lazy<global::System.Text.Json.Serialization.JsonConverter>(() => new global::@bool.@byte.@short.@float.@object.@class.@classSystemTextJsonConverter())
        },
        {
            typeof(global::@bool.@byte.@short.@float.@object.@event),
            new global::System.Lazy<global::System.Text.Json.Serialization.JsonConverter>(() => new global::@bool.@byte.@short.@float.@object.@event.@eventSystemTextJsonConverter())
        },
        {
            typeof(global::@bool.@byte.@short.@float.@object.@event2),
            new global::System.Lazy<global::System.Text.Json.Serialization.JsonConverter>(() => new global::@bool.@byte.@short.@float.@object.@event2.@event2SystemTextJsonConverter())
        }
    };
    public override bool CanConvert(global::System.Type typeToConvert) => _lookup.ContainsKey(typeToConvert);
    public override global::System.Text.Json.Serialization.JsonConverter CreateConverter(global::System.Type typeToConvert, global::System.Text.Json.JsonSerializerOptions options) => _lookup[typeToConvert].Value;
}
  
// ------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a source generator named Vogen (https://github.com/SteveDunn/Vogen)
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
// ------------------------------------------------------------------------------
// Suppress warnings about [Obsolete] member usage in generated code.
#pragma warning disable CS0618
// Suppress warnings for 'Override methods on comparable types'.
#pragma warning disable CA1036
// Suppress Error MA0097 : A class that implements IComparable<T> or IComparable should override comparison operators
#pragma warning disable MA0097
// Suppress warning for 'The annotation for nullable reference types should only be used in code within a '#nullable' annotations context. Auto-generated code requires an explicit '#nullable' directive in source.'
// The generator copies signatures from the BCL, e.g. for `TryParse`, and some of those have nullable annotations.
#pragma warning disable CS8669, CS8632
// Suppress warnings about CS1591: Missing XML comment for publicly visible type or member 'Type_or_Member'
#pragma warning disable CS1591
namespace @double
{
    [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
        [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Vogen", "1.0.0.0")]
    [global::System.Text.Json.Serialization.JsonConverter(typeof(classFromEscapedNamespaceWithReservedUnderlyingTypeSystemTextJsonConverter))]
    [global::System.ComponentModel.TypeConverter(typeof(classFromEscapedNamespaceWithReservedUnderlyingTypeTypeConverter))]
    [global::System.Diagnostics.DebuggerTypeProxyAttribute(typeof(classFromEscapedNamespaceWithReservedUnderlyingTypeDebugView))]
    [global::System.Diagnostics.DebuggerDisplayAttribute("Underlying type: @double.@decimal, Value = { _value }")]
    public partial class classFromEscapedNamespaceWithReservedUnderlyingType : global::System.IEquatable<classFromEscapedNamespaceWithReservedUnderlyingType>, global::System.IEquatable<@double.@decimal>
    {
#if DEBUG
private readonly global::System.Diagnostics.StackTrace _stackTrace = null!;
#endif
#if !VOGEN_NO_VALIDATION
        private readonly global::System.Boolean _isInitialized;
#endif
        private readonly @double.@decimal _value;
        /// <summary>
        /// Gets the underlying <see cref = "@double.@decimal"/> value if set, otherwise a <see cref = "Vogen.ValueObjectValidationException"/> is thrown.
        /// </summary>
        public @double.@decimal Value
        {
            [global::System.Runtime.CompilerServices.MethodImpl(global::System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
            [global::System.Diagnostics.DebuggerStepThroughAttribute]
            get
            {
                EnsureInitialized();
                return _value;
            }
        }

        [global::System.Diagnostics.DebuggerStepThroughAttribute]
        [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]
        public classFromEscapedNamespaceWithReservedUnderlyingType()
        {
#if DEBUG
            _stackTrace = new global::System.Diagnostics.StackTrace();
#endif
#if !VOGEN_NO_VALIDATION
            _isInitialized = false;
#endif
            _value = default;
        }

        [global::System.Diagnostics.DebuggerStepThroughAttribute]
        private classFromEscapedNamespaceWithReservedUnderlyingType(@double.@decimal value)
        {
            _value = value;
#if !VOGEN_NO_VALIDATION
            _isInitialized = true;
#endif
        }

        /// <summary>
        /// Builds an instance from the provided underlying type.
        /// </summary>
        /// <param name = "value">The underlying type.</param>
        /// <returns>An instance of this type.</returns>
        [global::System.Runtime.CompilerServices.MethodImpl(global::System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
        public static classFromEscapedNamespaceWithReservedUnderlyingType From(@double.@decimal value)
        {
            return new classFromEscapedNamespaceWithReservedUnderlyingType(value);
        }

        /// <summary>
        /// Tries to build an instance from the provided underlying type.
        /// If a normalization method is provided, it will be called.
        /// If validation is provided, and it fails, false will be returned.
        /// </summary>
        /// <param name = "value">The underlying type.</param>
        /// <param name = "vo">An instance of the value object.</param>
        /// <returns>True if the value object can be built, otherwise false.</returns>
        
#pragma warning disable CS8767 // Nullability of reference types in type of parameter doesn't match implicitly implemented member because of nullability attributes.

        public static bool TryFrom(
#if NETCOREAPP3_0_OR_GREATER
[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
#endif
        @double.@decimal value, 
#if NETCOREAPP3_0_OR_GREATER
[global::System.Diagnostics.CodeAnalysis.MaybeNullWhen(false)]
#endif
        out classFromEscapedNamespaceWithReservedUnderlyingType vo)
#pragma warning restore CS8767 // Nullability of reference types in type of parameter doesn't match implicitly implemented member because of nullability attributes.

        {
            vo = new classFromEscapedNamespaceWithReservedUnderlyingType(value);
            return true;
        }

        /// <summary>
        /// Tries to build an instance from the provided underlying value.
        /// If a normalization method is provided, it will be called.
        /// If validation is provided, and it fails, an error will be returned.
        /// </summary>
        /// <param name = "value">The primitive value.</param>
        /// <returns>A <see cref = "Vogen.ValueObjectOrError{T}"/> containing either the value object, or an error.</returns>
        public static Vogen.ValueObjectOrError<classFromEscapedNamespaceWithReservedUnderlyingType> TryFrom(@double.@decimal value)
        {
            return new Vogen.ValueObjectOrError<classFromEscapedNamespaceWithReservedUnderlyingType>(new classFromEscapedNamespaceWithReservedUnderlyingType(value));
        }

        [global::System.Runtime.CompilerServices.MethodImpl(global::System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
#if VOGEN_NO_VALIDATION
#pragma warning disable CS8775
  public bool IsInitialized() => true;
#pragma warning restore CS8775
#else
        public bool IsInitialized() => _isInitialized;
#endif
        // only called internally when something has been deserialized into
        // its primitive type.
        private static classFromEscapedNamespaceWithReservedUnderlyingType __Deserialize(@double.@decimal value)
        {
            return new classFromEscapedNamespaceWithReservedUnderlyingType(value);
        }

        public global::System.Boolean Equals(classFromEscapedNamespaceWithReservedUnderlyingType other)
        {
            if (ReferenceEquals(null, other))
            {
                return false;
            }

            // It's possible to create uninitialized instances via converters such as EfCore (HasDefaultValue), which call Equals.
            // We treat anything uninitialized as not equal to anything, even other uninitialized instances of this type.
            if (!IsInitialized() || !other.IsInitialized())
                return false;
            if (ReferenceEquals(this, other))
            {
                return true;
            }

            return GetType() == other.GetType() && global::System.Collections.Generic.EqualityComparer<@double.@decimal>.Default.Equals(Value, other.Value);
        }

        public global::System.Boolean Equals(classFromEscapedNamespaceWithReservedUnderlyingType other, global::System.Collections.Generic.IEqualityComparer<classFromEscapedNamespaceWithReservedUnderlyingType> comparer)
        {
            return comparer.Equals(this, other);
        }

        public global::System.Boolean Equals(@double.@decimal primitive)
        {
            return Value.Equals(primitive);
        }

        public override global::System.Boolean Equals(global::System.Object obj)
        {
            return Equals(obj as classFromEscapedNamespaceWithReservedUnderlyingType);
        }

        public static global::System.Boolean operator ==(classFromEscapedNamespaceWithReservedUnderlyingType left, classFromEscapedNamespaceWithReservedUnderlyingType right) => Equals(left, right);
        public static global::System.Boolean operator !=(classFromEscapedNamespaceWithReservedUnderlyingType left, classFromEscapedNamespaceWithReservedUnderlyingType right) => !Equals(left, right);
        public static global::System.Boolean operator ==(classFromEscapedNamespaceWithReservedUnderlyingType left, @double.@decimal right) => left.Value.Equals(right);
        public static global::System.Boolean operator ==(@double.@decimal left, classFromEscapedNamespaceWithReservedUnderlyingType right) => right.Value.Equals(left);
        public static global::System.Boolean operator !=(@double.@decimal left, classFromEscapedNamespaceWithReservedUnderlyingType right) => !(left == right);
        public static global::System.Boolean operator !=(classFromEscapedNamespaceWithReservedUnderlyingType left, @double.@decimal right) => !(left == right);
        public static explicit operator classFromEscapedNamespaceWithReservedUnderlyingType(@double.@decimal value) => From(value);
        public static explicit operator @double.@decimal(classFromEscapedNamespaceWithReservedUnderlyingType value) => value.Value;
#nullable disable
#nullable restore
        public override global::System.Int32 GetHashCode()
        {
            unchecked // Overflow is fine, just wrap
            {
                global::System.Int32 hash = (global::System.Int32)2166136261;
                hash = (hash * 16777619) ^ GetType().GetHashCode();
                hash = (hash * 16777619) ^ global::System.Collections.Generic.EqualityComparer<@double.@decimal>.Default.GetHashCode(Value);
                return hash;
            }
        }

        [global::System.Runtime.CompilerServices.MethodImpl(global::System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
        private void EnsureInitialized()
        {
            if (!IsInitialized())
            {
#if DEBUG
               ThrowHelper.ThrowWhenNotInitialized(_stackTrace);
#else
                ThrowHelper.ThrowWhenNotInitialized();
#endif
            }
        }

        /// <inheritdoc cref = "@double.@decimal.ToString()"/>
        public override global::System.String ToString() => IsInitialized() ? Value.ToString() ?? "" : "[UNINITIALIZED]";
#nullable disable
        /// <summary>
        /// Converts a classFromEscapedNamespaceWithReservedUnderlyingType to or from JSON.
        /// </summary>
        public class classFromEscapedNamespaceWithReservedUnderlyingTypeSystemTextJsonConverter : global::System.Text.Json.Serialization.JsonConverter<classFromEscapedNamespaceWithReservedUnderlyingType>
        {
            public override classFromEscapedNamespaceWithReservedUnderlyingType Read(ref global::System.Text.Json.Utf8JsonReader reader, global::System.Type typeToConvert, global::System.Text.Json.JsonSerializerOptions options)
            {
                var primitive = global::System.Text.Json.JsonSerializer.Deserialize<@double.@decimal>(ref reader, options);
                return DeserializeJson(primitive);
            }

            public override void Write(System.Text.Json.Utf8JsonWriter writer, classFromEscapedNamespaceWithReservedUnderlyingType value, global::System.Text.Json.JsonSerializerOptions options)
            {
                global::System.Text.Json.JsonSerializer.Serialize(writer, value.Value, options);
            }

#if NET6_0_OR_GREATER
            public override classFromEscapedNamespaceWithReservedUnderlyingType ReadAsPropertyName(ref global::System.Text.Json.Utf8JsonReader reader, global::System.Type typeToConvert, global::System.Text.Json.JsonSerializerOptions options)
            {
                var primitive = global::System.Text.Json.JsonSerializer.Deserialize<@double.@decimal>(ref reader, options);
                return DeserializeJson(primitive);
            }

            public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, classFromEscapedNamespaceWithReservedUnderlyingType value, global::System.Text.Json.JsonSerializerOptions options)
            {
                writer.WritePropertyName(global::System.Text.Json.JsonSerializer.Serialize(value.Value));
            }
#endif
#if NETCOREAPP3_0_OR_GREATER
            [global::System.Diagnostics.CodeAnalysis.DoesNotReturnAttribute]
#endif
            private static void ThrowJsonExceptionWhenValidationFails(Vogen.Validation validation)
            {
                var e = ThrowHelper.CreateValidationException(validation);
                throw new global::System.Text.Json.JsonException(null, e);
            }

            public static classFromEscapedNamespaceWithReservedUnderlyingType DeserializeJson(@double.@decimal value)
            {
                return new classFromEscapedNamespaceWithReservedUnderlyingType(value);
            }
        }

#nullable restore
#nullable disable
        class classFromEscapedNamespaceWithReservedUnderlyingTypeTypeConverter : global::System.ComponentModel.TypeConverter
        {
            public override global::System.Boolean CanConvertFrom(global::System.ComponentModel.ITypeDescriptorContext context, global::System.Type sourceType)
            {
                return sourceType == typeof(@double.@decimal);
            }

            public override global::System.Object ConvertFrom(global::System.ComponentModel.ITypeDescriptorContext context, global::System.Globalization.CultureInfo culture, global::System.Object value)
            {
                @double.@decimal ut = (@double.@decimal)value;
                return classFromEscapedNamespaceWithReservedUnderlyingType.__Deserialize(ut);
            }

            public override bool CanConvertTo(global::System.ComponentModel.ITypeDescriptorContext context, global::System.Type sourceType)
            {
                return sourceType == typeof(@double.@decimal);
            }

            public override object ConvertTo(global::System.ComponentModel.ITypeDescriptorContext context, global::System.Globalization.CultureInfo culture, global::System.Object value, global::System.Type destinationType)
            {
                if (value is classFromEscapedNamespaceWithReservedUnderlyingType idValue)
                {
                    return idValue.Value;
                }

                return base.ConvertTo(context, culture, value, destinationType);
            }
        }

#nullable restore
        internal sealed class classFromEscapedNamespaceWithReservedUnderlyingTypeDebugView
        {
            private readonly classFromEscapedNamespaceWithReservedUnderlyingType _t;
            classFromEscapedNamespaceWithReservedUnderlyingTypeDebugView(classFromEscapedNamespaceWithReservedUnderlyingType t)
            {
                _t = t;
            }

            public global::System.String UnderlyingType => "@double.@decimal";
            public @double.@decimal Value => _t.Value;
            public global::System.String Conversions => @"[global::System.Text.Json.Serialization.JsonConverter(typeof(classFromEscapedNamespaceWithReservedUnderlyingTypeSystemTextJsonConverter))]
[global::System.ComponentModel.TypeConverter(typeof(classFromEscapedNamespaceWithReservedUnderlyingTypeTypeConverter))]
";
        }

        static class ThrowHelper
        {
#if NETCOREAPP3_0_OR_GREATER
    [global::System.Diagnostics.CodeAnalysis.DoesNotReturnAttribute]
#endif
            internal static void ThrowInvalidOperationException(string message) => throw new global::System.InvalidOperationException(message);
#if NETCOREAPP3_0_OR_GREATER
    [global::System.Diagnostics.CodeAnalysis.DoesNotReturnAttribute]
#endif
            internal static void ThrowArgumentException(string message, string arg) => throw new global::System.ArgumentException(message, arg);
#if NETCOREAPP3_0_OR_GREATER
    [global::System.Diagnostics.CodeAnalysis.DoesNotReturnAttribute]
#endif
            internal static void ThrowWhenCreatedWithNull() => throw CreateCannotBeNullException();
#if NETCOREAPP3_0_OR_GREATER
    [global::System.Diagnostics.CodeAnalysis.DoesNotReturnAttribute]
#endif
            internal static void ThrowWhenNotInitialized() => throw CreateValidationException("Use of uninitialized Value Object.");
#if NETCOREAPP3_0_OR_GREATER
    [global::System.Diagnostics.CodeAnalysis.DoesNotReturnAttribute]
#endif
            internal static void ThrowWhenNotInitialized(global::System.Diagnostics.StackTrace stackTrace) => throw CreateValidationException("Use of uninitialized Value Object at: " + stackTrace ?? "");
#if NETCOREAPP3_0_OR_GREATER
    [global::System.Diagnostics.CodeAnalysis.DoesNotReturnAttribute]
#endif
            internal static void ThrowWhenValidationFails(Vogen.Validation validation)
            {
                throw CreateValidationException(validation);
            }

            internal static System.Exception CreateValidationException(string message) => new global::Vogen.ValueObjectValidationException(message);
            internal static System.Exception CreateCannotBeNullException() => new global::Vogen.ValueObjectValidationException("Cannot create a value object with null.");
            internal static System.Exception CreateValidationException(Vogen.Validation validation)
            {
                var ex = CreateValidationException(validation.ErrorMessage);
                if (validation.Data is not null)
                {
                    foreach (var kvp in validation.Data)
                    {
                        ex.Data[kvp.Key] = kvp.Value;
                    }
                }

                return ex;
            }
        }
    }
}
  
// ------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a source generator named Vogen (https://github.com/SteveDunn/Vogen)
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
// ------------------------------------------------------------------------------
// Suppress warnings about [Obsolete] member usage in generated code.
#pragma warning disable CS0618
// Suppress warnings for 'Override methods on comparable types'.
#pragma warning disable CA1036
// Suppress Error MA0097 : A class that implements IComparable<T> or IComparable should override comparison operators
#pragma warning disable MA0097
// Suppress warning for 'The annotation for nullable reference types should only be used in code within a '#nullable' annotations context. Auto-generated code requires an explicit '#nullable' directive in source.'
// The generator copies signatures from the BCL, e.g. for `TryParse`, and some of those have nullable annotations.
#pragma warning disable CS8669, CS8632
// Suppress warnings about CS1591: Missing XML comment for publicly visible type or member 'Type_or_Member'
#pragma warning disable CS1591
namespace @double
{
    [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
        [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Vogen", "1.0.0.0")]
    [global::System.Text.Json.Serialization.JsonConverter(typeof(classFromEscapedNamespaceSystemTextJsonConverter))]
    [global::System.ComponentModel.TypeConverter(typeof(classFromEscapedNamespaceTypeConverter))]
    [global::System.Diagnostics.DebuggerTypeProxyAttribute(typeof(classFromEscapedNamespaceDebugView))]
    [global::System.Diagnostics.DebuggerDisplayAttribute("Underlying type: System.Int32, Value = { _value }")]
    public partial class classFromEscapedNamespace : global::System.IEquatable<classFromEscapedNamespace>, global::System.IEquatable<System.Int32>, global::System.IComparable<classFromEscapedNamespace>, global::System.IComparable, global::System.IFormattable
    {
#if DEBUG
private readonly global::System.Diagnostics.StackTrace _stackTrace = null!;
#endif
#if !VOGEN_NO_VALIDATION
        private readonly global::System.Boolean _isInitialized;
#endif
        private readonly System.Int32 _value;
        /// <summary>
        /// Gets the underlying <see cref = "System.Int32"/> value if set, otherwise a <see cref = "Vogen.ValueObjectValidationException"/> is thrown.
        /// </summary>
        public System.Int32 Value
        {
            [global::System.Runtime.CompilerServices.MethodImpl(global::System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
            [global::System.Diagnostics.DebuggerStepThroughAttribute]
            get
            {
                EnsureInitialized();
                return _value;
            }
        }

        [global::System.Diagnostics.DebuggerStepThroughAttribute]
        [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]
        public classFromEscapedNamespace()
        {
#if DEBUG
            _stackTrace = new global::System.Diagnostics.StackTrace();
#endif
#if !VOGEN_NO_VALIDATION
            _isInitialized = false;
#endif
            _value = default;
        }

        [global::System.Diagnostics.DebuggerStepThroughAttribute]
        private classFromEscapedNamespace(System.Int32 value)
        {
            _value = value;
#if !VOGEN_NO_VALIDATION
            _isInitialized = true;
#endif
        }

        /// <summary>
        /// Builds an instance from the provided underlying type.
        /// </summary>
        /// <param name = "value">The underlying type.</param>
        /// <returns>An instance of this type.</returns>
        [global::System.Runtime.CompilerServices.MethodImpl(global::System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
        public static classFromEscapedNamespace From(System.Int32 value)
        {
            return new classFromEscapedNamespace(value);
        }

        /// <summary>
        /// Tries to build an instance from the provided underlying type.
        /// If a normalization method is provided, it will be called.
        /// If validation is provided, and it fails, false will be returned.
        /// </summary>
        /// <param name = "value">The underlying type.</param>
        /// <param name = "vo">An instance of the value object.</param>
        /// <returns>True if the value object can be built, otherwise false.</returns>
        
#pragma warning disable CS8767 // Nullability of reference types in type of parameter doesn't match implicitly implemented member because of nullability attributes.

        public static bool TryFrom(
#if NETCOREAPP3_0_OR_GREATER
[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
#endif
        System.Int32 value, 
#if NETCOREAPP3_0_OR_GREATER
[global::System.Diagnostics.CodeAnalysis.MaybeNullWhen(false)]
#endif
        out classFromEscapedNamespace vo)
#pragma warning restore CS8767 // Nullability of reference types in type of parameter doesn't match implicitly implemented member because of nullability attributes.

        {
            vo = new classFromEscapedNamespace(value);
            return true;
        }

        /// <summary>
        /// Tries to build an instance from the provided underlying value.
        /// If a normalization method is provided, it will be called.
        /// If validation is provided, and it fails, an error will be returned.
        /// </summary>
        /// <param name = "value">The primitive value.</param>
        /// <returns>A <see cref = "Vogen.ValueObjectOrError{T}"/> containing either the value object, or an error.</returns>
        public static Vogen.ValueObjectOrError<classFromEscapedNamespace> TryFrom(System.Int32 value)
        {
            return new Vogen.ValueObjectOrError<classFromEscapedNamespace>(new classFromEscapedNamespace(value));
        }

        [global::System.Runtime.CompilerServices.MethodImpl(global::System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
#if VOGEN_NO_VALIDATION
#pragma warning disable CS8775
  public bool IsInitialized() => true;
#pragma warning restore CS8775
#else
        public bool IsInitialized() => _isInitialized;
#endif
        // only called internally when something has been deserialized into
        // its primitive type.
        private static classFromEscapedNamespace __Deserialize(System.Int32 value)
        {
            return new classFromEscapedNamespace(value);
        }

        public global::System.Boolean Equals(classFromEscapedNamespace other)
        {
            if (ReferenceEquals(null, other))
            {
                return false;
            }

            // It's possible to create uninitialized instances via converters such as EfCore (HasDefaultValue), which call Equals.
            // We treat anything uninitialized as not equal to anything, even other uninitialized instances of this type.
            if (!IsInitialized() || !other.IsInitialized())
                return false;
            if (ReferenceEquals(this, other))
            {
                return true;
            }

            return GetType() == other.GetType() && global::System.Collections.Generic.EqualityComparer<System.Int32>.Default.Equals(Value, other.Value);
        }

        public global::System.Boolean Equals(classFromEscapedNamespace other, global::System.Collections.Generic.IEqualityComparer<classFromEscapedNamespace> comparer)
        {
            return comparer.Equals(this, other);
        }

        public global::System.Boolean Equals(System.Int32 primitive)
        {
            return Value.Equals(primitive);
        }

        public override global::System.Boolean Equals(global::System.Object obj)
        {
            return Equals(obj as classFromEscapedNamespace);
        }

        public static global::System.Boolean operator ==(classFromEscapedNamespace left, classFromEscapedNamespace right) => Equals(left, right);
        public static global::System.Boolean operator !=(classFromEscapedNamespace left, classFromEscapedNamespace right) => !Equals(left, right);
        public static global::System.Boolean operator ==(classFromEscapedNamespace left, System.Int32 right) => left.Value.Equals(right);
        public static global::System.Boolean operator ==(System.Int32 left, classFromEscapedNamespace right) => right.Value.Equals(left);
        public static global::System.Boolean operator !=(System.Int32 left, classFromEscapedNamespace right) => !(left == right);
        public static global::System.Boolean operator !=(classFromEscapedNamespace left, System.Int32 right) => !(left == right);
        public static explicit operator classFromEscapedNamespace(System.Int32 value) => From(value);
        public static explicit operator System.Int32(classFromEscapedNamespace value) => value.Value;
        public int CompareTo(classFromEscapedNamespace other)
        {
            if (other is null)
                return 1;
            return Value.CompareTo(other.Value);
        }

        public int CompareTo(object other)
        {
            if (other is null)
                return 1;
            if (other is classFromEscapedNamespace x)
                return CompareTo(x);
            ThrowHelper.ThrowArgumentException("Cannot compare to object as it is not of type classFromEscapedNamespace", nameof(other));
            return 0;
        }

        /// <inheritdoc cref = "int.TryParse(string, out int)"/>
        /// <summary>
        /// </summary>
        /// <returns>
        /// True if the value could a) be parsed by the underlying type, and b) passes any validation (after running any optional normalization).
        /// </returns>
        public static global::System.Boolean TryParse(string s, 
#if NETCOREAPP3_0_OR_GREATER
[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
#endif
        out classFromEscapedNamespace result)
        {
            if (System.Int32.TryParse(s, out var __v))
            {
                result = new classFromEscapedNamespace(__v);
                return true;
            }

            result = default;
            return false;
        }

        /// <inheritdoc cref = "int.TryParse(string, System.Globalization.NumberStyles, System.IFormatProvider, out int)"/>
        /// <summary>
        /// </summary>
        /// <returns>
        /// True if the value could a) be parsed by the underlying type, and b) passes any validation (after running any optional normalization).
        /// </returns>
        public static global::System.Boolean TryParse(string s, global::System.Globalization.NumberStyles style, global::System.IFormatProvider provider, 
#if NETCOREAPP3_0_OR_GREATER
[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
#endif
        out classFromEscapedNamespace result)
        {
            if (System.Int32.TryParse(s, style, provider, out var __v))
            {
                result = new classFromEscapedNamespace(__v);
                return true;
            }

            result = default;
            return false;
        }

        /// <inheritdoc cref = "int.Parse(string)"/>
        /// <summary>
        /// </summary>
        /// <returns>
        /// The value created by calling the Parse method on the primitive.
        /// </returns>
        /// <exception cref = "global::Vogen.ValueObjectValidationException">Thrown when the value can be parsed, but is not valid.</exception>
        public static classFromEscapedNamespace Parse(string s)
        {
            var r = System.Int32.Parse(s);
            return From(r);
        }

        /// <inheritdoc cref = "int.Parse(string, System.Globalization.NumberStyles)"/>
        /// <summary>
        /// </summary>
        /// <returns>
        /// The value created by calling the Parse method on the primitive.
        /// </returns>
        /// <exception cref = "global::Vogen.ValueObjectValidationException">Thrown when the value can be parsed, but is not valid.</exception>
        public static classFromEscapedNamespace Parse(string s, global::System.Globalization.NumberStyles style)
        {
            var r = System.Int32.Parse(s, style);
            return From(r);
        }

        /// <inheritdoc cref = "int.Parse(string, System.IFormatProvider)"/>
        /// <summary>
        /// </summary>
        /// <returns>
        /// The value created by calling the Parse method on the primitive.
        /// </returns>
        /// <exception cref = "global::Vogen.ValueObjectValidationException">Thrown when the value can be parsed, but is not valid.</exception>
        public static classFromEscapedNamespace Parse(string s, global::System.IFormatProvider provider)
        {
            var r = System.Int32.Parse(s, provider);
            return From(r);
        }

        /// <inheritdoc cref = "int.Parse(string, System.Globalization.NumberStyles, System.IFormatProvider)"/>
        /// <summary>
        /// </summary>
        /// <returns>
        /// The value created by calling the Parse method on the primitive.
        /// </returns>
        /// <exception cref = "global::Vogen.ValueObjectValidationException">Thrown when the value can be parsed, but is not valid.</exception>
        public static classFromEscapedNamespace Parse(string s, global::System.Globalization.NumberStyles style, global::System.IFormatProvider provider)
        {
            var r = System.Int32.Parse(s, style, provider);
            return From(r);
        }

#nullable disable
        /// <inheritdoc cref = "int.ToString(string, System.IFormatProvider)"/>
        [System.Security.SecuritySafeCriticalAttribute]
        public string ToString(string format, global::System.IFormatProvider provider)
        {
            return IsInitialized() ? Value.ToString(format, provider) : "[UNINITIALIZED]";
        }

#nullable restore
        public override global::System.Int32 GetHashCode()
        {
            unchecked // Overflow is fine, just wrap
            {
                global::System.Int32 hash = (global::System.Int32)2166136261;
                hash = (hash * 16777619) ^ GetType().GetHashCode();
                hash = (hash * 16777619) ^ global::System.Collections.Generic.EqualityComparer<System.Int32>.Default.GetHashCode(Value);
                return hash;
            }
        }

        [global::System.Runtime.CompilerServices.MethodImpl(global::System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
        private void EnsureInitialized()
        {
            if (!IsInitialized())
            {
#if DEBUG
               ThrowHelper.ThrowWhenNotInitialized(_stackTrace);
#else
                ThrowHelper.ThrowWhenNotInitialized();
#endif
            }
        }

        /// <inheritdoc cref = "System.Int32.ToString()"/>
        public override global::System.String ToString() => IsInitialized() ? Value.ToString() ?? "" : "[UNINITIALIZED]";
        /// <inheritdoc cref = "System.Int32.ToString(string)"/>
        public global::System.String ToString(string format) => IsInitialized() ? Value.ToString(format) ?? "" : "[UNINITIALIZED]";
        /// <inheritdoc cref = "System.Int32.ToString(System.IFormatProvider)"/>
        public global::System.String ToString(global::System.IFormatProvider provider) => IsInitialized() ? Value.ToString(provider) ?? "" : "[UNINITIALIZED]";
#nullable disable
        /// <summary>
        /// Converts a classFromEscapedNamespace to or from JSON.
        /// </summary>
        public class classFromEscapedNamespaceSystemTextJsonConverter : global::System.Text.Json.Serialization.JsonConverter<classFromEscapedNamespace>
        {
            public override classFromEscapedNamespace Read(ref global::System.Text.Json.Utf8JsonReader reader, global::System.Type typeToConvert, global::System.Text.Json.JsonSerializerOptions options)
            {
#if NET5_0_OR_GREATER
                return DeserializeJson(global::System.Text.Json.JsonSerializer.Deserialize(ref reader, (global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Int32>)options.GetTypeInfo(typeof(global::System.Int32))));
#else
                return DeserializeJson(reader.GetInt32());
#endif
            }

            public override void Write(System.Text.Json.Utf8JsonWriter writer, classFromEscapedNamespace value, global::System.Text.Json.JsonSerializerOptions options)
            {
#if NET5_0_OR_GREATER
                global::System.Text.Json.JsonSerializer.Serialize(writer, value.Value, options);
#else
                writer.WriteNumberValue(value.Value);
#endif
            }

#if NET6_0_OR_GREATER
            public override classFromEscapedNamespace ReadAsPropertyName(ref global::System.Text.Json.Utf8JsonReader reader, global::System.Type typeToConvert, global::System.Text.Json.JsonSerializerOptions options)
            {
                return DeserializeJson(global::System.Int32.Parse(reader.GetString(), global::System.Globalization.NumberStyles.Any, global::System.Globalization.CultureInfo.InvariantCulture));
            }

            public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, classFromEscapedNamespace value, global::System.Text.Json.JsonSerializerOptions options)
            {
                writer.WritePropertyName(value.Value.ToString(global::System.Globalization.CultureInfo.InvariantCulture));
            }
#endif
#if NETCOREAPP3_0_OR_GREATER
            [global::System.Diagnostics.CodeAnalysis.DoesNotReturnAttribute]
#endif
            private static void ThrowJsonExceptionWhenValidationFails(Vogen.Validation validation)
            {
                var e = ThrowHelper.CreateValidationException(validation);
                throw new global::System.Text.Json.JsonException(null, e);
            }

            public static classFromEscapedNamespace DeserializeJson(System.Int32 value)
            {
                return new classFromEscapedNamespace(value);
            }
        }

#nullable restore
#nullable disable
        class classFromEscapedNamespaceTypeConverter : global::System.ComponentModel.TypeConverter
        {
            public override global::System.Boolean CanConvertFrom(global::System.ComponentModel.ITypeDescriptorContext context, global::System.Type sourceType)
            {
                return sourceType == typeof(global::System.Int32) || sourceType == typeof(global::System.String) || base.CanConvertFrom(context, sourceType);
            }

            public override global::System.Object ConvertFrom(global::System.ComponentModel.ITypeDescriptorContext context, global::System.Globalization.CultureInfo culture, global::System.Object value)
            {
                return value switch
                {
                    global::System.Int32 intValue => classFromEscapedNamespace.__Deserialize(intValue),
                    global::System.String stringValue when !global::System.String.IsNullOrEmpty(stringValue) && global::System.Int32.TryParse(stringValue, out var result) => classFromEscapedNamespace.__Deserialize(result),
                    _ => base.ConvertFrom(context, culture, value),
                };
            }

            public override bool CanConvertTo(global::System.ComponentModel.ITypeDescriptorContext context, global::System.Type sourceType)
            {
                return sourceType == typeof(global::System.Int32) || sourceType == typeof(global::System.String) || base.CanConvertTo(context, sourceType);
            }

            public override object ConvertTo(global::System.ComponentModel.ITypeDescriptorContext context, global::System.Globalization.CultureInfo culture, global::System.Object value, global::System.Type destinationType)
            {
                if (value is classFromEscapedNamespace idValue)
                {
                    if (destinationType == typeof(global::System.Int32))
                    {
                        return idValue.Value;
                    }

                    if (destinationType == typeof(global::System.String))
                    {
                        return idValue.Value.ToString();
                    }
                }

                return base.ConvertTo(context, culture, value, destinationType);
            }
        }

#nullable restore
        internal sealed class classFromEscapedNamespaceDebugView
        {
            private readonly classFromEscapedNamespace _t;
            classFromEscapedNamespaceDebugView(classFromEscapedNamespace t)
            {
                _t = t;
            }

            public global::System.String UnderlyingType => "System.Int32";
            public System.Int32 Value => _t.Value;
            public global::System.String Conversions => @"[global::System.Text.Json.Serialization.JsonConverter(typeof(classFromEscapedNamespaceSystemTextJsonConverter))]
[global::System.ComponentModel.TypeConverter(typeof(classFromEscapedNamespaceTypeConverter))]
";
        }

        static class ThrowHelper
        {
#if NETCOREAPP3_0_OR_GREATER
    [global::System.Diagnostics.CodeAnalysis.DoesNotReturnAttribute]
#endif
            internal static void ThrowInvalidOperationException(string message) => throw new global::System.InvalidOperationException(message);
#if NETCOREAPP3_0_OR_GREATER
    [global::System.Diagnostics.CodeAnalysis.DoesNotReturnAttribute]
#endif
            internal static void ThrowArgumentException(string message, string arg) => throw new global::System.ArgumentException(message, arg);
#if NETCOREAPP3_0_OR_GREATER
    [global::System.Diagnostics.CodeAnalysis.DoesNotReturnAttribute]
#endif
            internal static void ThrowWhenCreatedWithNull() => throw CreateCannotBeNullException();
#if NETCOREAPP3_0_OR_GREATER
    [global::System.Diagnostics.CodeAnalysis.DoesNotReturnAttribute]
#endif
            internal static void ThrowWhenNotInitialized() => throw CreateValidationException("Use of uninitialized Value Object.");
#if NETCOREAPP3_0_OR_GREATER
    [global::System.Diagnostics.CodeAnalysis.DoesNotReturnAttribute]
#endif
            internal static void ThrowWhenNotInitialized(global::System.Diagnostics.StackTrace stackTrace) => throw CreateValidationException("Use of uninitialized Value Object at: " + stackTrace ?? "");
#if NETCOREAPP3_0_OR_GREATER
    [global::System.Diagnostics.CodeAnalysis.DoesNotReturnAttribute]
#endif
            internal static void ThrowWhenValidationFails(Vogen.Validation validation)
            {
                throw CreateValidationException(validation);
            }

            internal static System.Exception CreateValidationException(string message) => new global::Vogen.ValueObjectValidationException(message);
            internal static System.Exception CreateCannotBeNullException() => new global::Vogen.ValueObjectValidationException("Cannot create a value object with null.");
            internal static System.Exception CreateValidationException(Vogen.Validation validation)
            {
                var ex = CreateValidationException(validation.ErrorMessage);
                if (validation.Data is not null)
                {
                    foreach (var kvp in validation.Data)
                    {
                        ex.Data[kvp.Key] = kvp.Value;
                    }
                }

                return ex;
            }
        }
    }
}
  
// ------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a source generator named Vogen (https://github.com/SteveDunn/Vogen)
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
// ------------------------------------------------------------------------------
// Suppress warnings about [Obsolete] member usage in generated code.
#pragma warning disable CS0618
// Suppress warnings for 'Override methods on comparable types'.
#pragma warning disable CA1036
// Suppress Error MA0097 : A class that implements IComparable<T> or IComparable should override comparison operators
#pragma warning disable MA0097
// Suppress warning for 'The annotation for nullable reference types should only be used in code within a '#nullable' annotations context. Auto-generated code requires an explicit '#nullable' directive in source.'
// The generator copies signatures from the BCL, e.g. for `TryParse`, and some of those have nullable annotations.
#pragma warning disable CS8669, CS8632
// Suppress warnings about CS1591: Missing XML comment for publicly visible type or member 'Type_or_Member'
#pragma warning disable CS1591
namespace @bool.@byte.@short.@float.@object
{
    [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
        [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Vogen", "1.0.0.0")]
    [global::System.Text.Json.Serialization.JsonConverter(typeof(@classSystemTextJsonConverter))]
    [global::System.ComponentModel.TypeConverter(typeof(@classTypeConverter))]
    [global::System.Diagnostics.DebuggerTypeProxyAttribute(typeof(@classDebugView))]
    [global::System.Diagnostics.DebuggerDisplayAttribute("Underlying type: System.Int32, Value = { _value }")]
    public partial class @class : global::System.IEquatable<@class>, global::System.IEquatable<System.Int32>, global::System.IComparable<@class>, global::System.IComparable, global::System.IFormattable
    {
#if DEBUG
private readonly global::System.Diagnostics.StackTrace _stackTrace = null!;
#endif
#if !VOGEN_NO_VALIDATION
        private readonly global::System.Boolean _isInitialized;
#endif
        private readonly System.Int32 _value;
        /// <summary>
        /// Gets the underlying <see cref = "System.Int32"/> value if set, otherwise a <see cref = "Vogen.ValueObjectValidationException"/> is thrown.
        /// </summary>
        public System.Int32 Value
        {
            [global::System.Runtime.CompilerServices.MethodImpl(global::System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
            [global::System.Diagnostics.DebuggerStepThroughAttribute]
            get
            {
                EnsureInitialized();
                return _value;
            }
        }

        [global::System.Diagnostics.DebuggerStepThroughAttribute]
        [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]
        public @class()
        {
#if DEBUG
            _stackTrace = new global::System.Diagnostics.StackTrace();
#endif
#if !VOGEN_NO_VALIDATION
            _isInitialized = false;
#endif
            _value = default;
        }

        [global::System.Diagnostics.DebuggerStepThroughAttribute]
        private @class(System.Int32 value)
        {
            _value = value;
#if !VOGEN_NO_VALIDATION
            _isInitialized = true;
#endif
        }

        /// <summary>
        /// Builds an instance from the provided underlying type.
        /// </summary>
        /// <param name = "value">The underlying type.</param>
        /// <returns>An instance of this type.</returns>
        [global::System.Runtime.CompilerServices.MethodImpl(global::System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
        public static @class From(System.Int32 value)
        {
            return new @class(value);
        }

        /// <summary>
        /// Tries to build an instance from the provided underlying type.
        /// If a normalization method is provided, it will be called.
        /// If validation is provided, and it fails, false will be returned.
        /// </summary>
        /// <param name = "value">The underlying type.</param>
        /// <param name = "vo">An instance of the value object.</param>
        /// <returns>True if the value object can be built, otherwise false.</returns>
        
#pragma warning disable CS8767 // Nullability of reference types in type of parameter doesn't match implicitly implemented member because of nullability attributes.

        public static bool TryFrom(
#if NETCOREAPP3_0_OR_GREATER
[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
#endif
        System.Int32 value, 
#if NETCOREAPP3_0_OR_GREATER
[global::System.Diagnostics.CodeAnalysis.MaybeNullWhen(false)]
#endif
        out @class vo)
#pragma warning restore CS8767 // Nullability of reference types in type of parameter doesn't match implicitly implemented member because of nullability attributes.

        {
            vo = new @class(value);
            return true;
        }

        /// <summary>
        /// Tries to build an instance from the provided underlying value.
        /// If a normalization method is provided, it will be called.
        /// If validation is provided, and it fails, an error will be returned.
        /// </summary>
        /// <param name = "value">The primitive value.</param>
        /// <returns>A <see cref = "Vogen.ValueObjectOrError{T}"/> containing either the value object, or an error.</returns>
        public static Vogen.ValueObjectOrError<@class> TryFrom(System.Int32 value)
        {
            return new Vogen.ValueObjectOrError<@class>(new @class(value));
        }

        [global::System.Runtime.CompilerServices.MethodImpl(global::System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
#if VOGEN_NO_VALIDATION
#pragma warning disable CS8775
  public bool IsInitialized() => true;
#pragma warning restore CS8775
#else
        public bool IsInitialized() => _isInitialized;
#endif
        // only called internally when something has been deserialized into
        // its primitive type.
        private static @class __Deserialize(System.Int32 value)
        {
            return new @class(value);
        }

        public global::System.Boolean Equals(@class other)
        {
            if (ReferenceEquals(null, other))
            {
                return false;
            }

            // It's possible to create uninitialized instances via converters such as EfCore (HasDefaultValue), which call Equals.
            // We treat anything uninitialized as not equal to anything, even other uninitialized instances of this type.
            if (!IsInitialized() || !other.IsInitialized())
                return false;
            if (ReferenceEquals(this, other))
            {
                return true;
            }

            return GetType() == other.GetType() && global::System.Collections.Generic.EqualityComparer<System.Int32>.Default.Equals(Value, other.Value);
        }

        public global::System.Boolean Equals(@class other, global::System.Collections.Generic.IEqualityComparer<@class> comparer)
        {
            return comparer.Equals(this, other);
        }

        public global::System.Boolean Equals(System.Int32 primitive)
        {
            return Value.Equals(primitive);
        }

        public override global::System.Boolean Equals(global::System.Object obj)
        {
            return Equals(obj as @class);
        }

        public static global::System.Boolean operator ==(@class left, @class right) => Equals(left, right);
        public static global::System.Boolean operator !=(@class left, @class right) => !Equals(left, right);
        public static global::System.Boolean operator ==(@class left, System.Int32 right) => left.Value.Equals(right);
        public static global::System.Boolean operator ==(System.Int32 left, @class right) => right.Value.Equals(left);
        public static global::System.Boolean operator !=(System.Int32 left, @class right) => !(left == right);
        public static global::System.Boolean operator !=(@class left, System.Int32 right) => !(left == right);
        public static explicit operator @class(System.Int32 value) => From(value);
        public static explicit operator System.Int32(@class value) => value.Value;
        public int CompareTo(@class other)
        {
            if (other is null)
                return 1;
            return Value.CompareTo(other.Value);
        }

        public int CompareTo(object other)
        {
            if (other is null)
                return 1;
            if (other is @class x)
                return CompareTo(x);
            ThrowHelper.ThrowArgumentException("Cannot compare to object as it is not of type @class", nameof(other));
            return 0;
        }

        /// <inheritdoc cref = "int.TryParse(string, out int)"/>
        /// <summary>
        /// </summary>
        /// <returns>
        /// True if the value could a) be parsed by the underlying type, and b) passes any validation (after running any optional normalization).
        /// </returns>
        public static global::System.Boolean TryParse(string s, 
#if NETCOREAPP3_0_OR_GREATER
[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
#endif
        out @class result)
        {
            if (System.Int32.TryParse(s, out var __v))
            {
                result = new @class(__v);
                return true;
            }

            result = default;
            return false;
        }

        /// <inheritdoc cref = "int.TryParse(string, System.Globalization.NumberStyles, System.IFormatProvider, out int)"/>
        /// <summary>
        /// </summary>
        /// <returns>
        /// True if the value could a) be parsed by the underlying type, and b) passes any validation (after running any optional normalization).
        /// </returns>
        public static global::System.Boolean TryParse(string s, global::System.Globalization.NumberStyles style, global::System.IFormatProvider provider, 
#if NETCOREAPP3_0_OR_GREATER
[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
#endif
        out @class result)
        {
            if (System.Int32.TryParse(s, style, provider, out var __v))
            {
                result = new @class(__v);
                return true;
            }

            result = default;
            return false;
        }

        /// <inheritdoc cref = "int.Parse(string)"/>
        /// <summary>
        /// </summary>
        /// <returns>
        /// The value created by calling the Parse method on the primitive.
        /// </returns>
        /// <exception cref = "global::Vogen.ValueObjectValidationException">Thrown when the value can be parsed, but is not valid.</exception>
        public static @class Parse(string s)
        {
            var r = System.Int32.Parse(s);
            return From(r);
        }

        /// <inheritdoc cref = "int.Parse(string, System.Globalization.NumberStyles)"/>
        /// <summary>
        /// </summary>
        /// <returns>
        /// The value created by calling the Parse method on the primitive.
        /// </returns>
        /// <exception cref = "global::Vogen.ValueObjectValidationException">Thrown when the value can be parsed, but is not valid.</exception>
        public static @class Parse(string s, global::System.Globalization.NumberStyles style)
        {
            var r = System.Int32.Parse(s, style);
            return From(r);
        }

        /// <inheritdoc cref = "int.Parse(string, System.IFormatProvider)"/>
        /// <summary>
        /// </summary>
        /// <returns>
        /// The value created by calling the Parse method on the primitive.
        /// </returns>
        /// <exception cref = "global::Vogen.ValueObjectValidationException">Thrown when the value can be parsed, but is not valid.</exception>
        public static @class Parse(string s, global::System.IFormatProvider provider)
        {
            var r = System.Int32.Parse(s, provider);
            return From(r);
        }

        /// <inheritdoc cref = "int.Parse(string, System.Globalization.NumberStyles, System.IFormatProvider)"/>
        /// <summary>
        /// </summary>
        /// <returns>
        /// The value created by calling the Parse method on the primitive.
        /// </returns>
        /// <exception cref = "global::Vogen.ValueObjectValidationException">Thrown when the value can be parsed, but is not valid.</exception>
        public static @class Parse(string s, global::System.Globalization.NumberStyles style, global::System.IFormatProvider provider)
        {
            var r = System.Int32.Parse(s, style, provider);
            return From(r);
        }

#nullable disable
        /// <inheritdoc cref = "int.ToString(string, System.IFormatProvider)"/>
        [System.Security.SecuritySafeCriticalAttribute]
        public string ToString(string format, global::System.IFormatProvider provider)
        {
            return IsInitialized() ? Value.ToString(format, provider) : "[UNINITIALIZED]";
        }

#nullable restore
        public override global::System.Int32 GetHashCode()
        {
            unchecked // Overflow is fine, just wrap
            {
                global::System.Int32 hash = (global::System.Int32)2166136261;
                hash = (hash * 16777619) ^ GetType().GetHashCode();
                hash = (hash * 16777619) ^ global::System.Collections.Generic.EqualityComparer<System.Int32>.Default.GetHashCode(Value);
                return hash;
            }
        }

        [global::System.Runtime.CompilerServices.MethodImpl(global::System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
        private void EnsureInitialized()
        {
            if (!IsInitialized())
            {
#if DEBUG
               ThrowHelper.ThrowWhenNotInitialized(_stackTrace);
#else
                ThrowHelper.ThrowWhenNotInitialized();
#endif
            }
        }

        /// <inheritdoc cref = "System.Int32.ToString()"/>
        public override global::System.String ToString() => IsInitialized() ? Value.ToString() ?? "" : "[UNINITIALIZED]";
        /// <inheritdoc cref = "System.Int32.ToString(string)"/>
        public global::System.String ToString(string format) => IsInitialized() ? Value.ToString(format) ?? "" : "[UNINITIALIZED]";
        /// <inheritdoc cref = "System.Int32.ToString(System.IFormatProvider)"/>
        public global::System.String ToString(global::System.IFormatProvider provider) => IsInitialized() ? Value.ToString(provider) ?? "" : "[UNINITIALIZED]";
#nullable disable
        /// <summary>
        /// Converts a @class to or from JSON.
        /// </summary>
        public class @classSystemTextJsonConverter : global::System.Text.Json.Serialization.JsonConverter<@class>
        {
            public override @class Read(ref global::System.Text.Json.Utf8JsonReader reader, global::System.Type typeToConvert, global::System.Text.Json.JsonSerializerOptions options)
            {
#if NET5_0_OR_GREATER
                return DeserializeJson(global::System.Text.Json.JsonSerializer.Deserialize(ref reader, (global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Int32>)options.GetTypeInfo(typeof(global::System.Int32))));
#else
                return DeserializeJson(reader.GetInt32());
#endif
            }

            public override void Write(System.Text.Json.Utf8JsonWriter writer, @class value, global::System.Text.Json.JsonSerializerOptions options)
            {
#if NET5_0_OR_GREATER
                global::System.Text.Json.JsonSerializer.Serialize(writer, value.Value, options);
#else
                writer.WriteNumberValue(value.Value);
#endif
            }

#if NET6_0_OR_GREATER
            public override @class ReadAsPropertyName(ref global::System.Text.Json.Utf8JsonReader reader, global::System.Type typeToConvert, global::System.Text.Json.JsonSerializerOptions options)
            {
                return DeserializeJson(global::System.Int32.Parse(reader.GetString(), global::System.Globalization.NumberStyles.Any, global::System.Globalization.CultureInfo.InvariantCulture));
            }

            public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, @class value, global::System.Text.Json.JsonSerializerOptions options)
            {
                writer.WritePropertyName(value.Value.ToString(global::System.Globalization.CultureInfo.InvariantCulture));
            }
#endif
#if NETCOREAPP3_0_OR_GREATER
            [global::System.Diagnostics.CodeAnalysis.DoesNotReturnAttribute]
#endif
            private static void ThrowJsonExceptionWhenValidationFails(Vogen.Validation validation)
            {
                var e = ThrowHelper.CreateValidationException(validation);
                throw new global::System.Text.Json.JsonException(null, e);
            }

            public static @class DeserializeJson(System.Int32 value)
            {
                return new @class(value);
            }
        }

#nullable restore
#nullable disable
        class @classTypeConverter : global::System.ComponentModel.TypeConverter
        {
            public override global::System.Boolean CanConvertFrom(global::System.ComponentModel.ITypeDescriptorContext context, global::System.Type sourceType)
            {
                return sourceType == typeof(global::System.Int32) || sourceType == typeof(global::System.String) || base.CanConvertFrom(context, sourceType);
            }

            public override global::System.Object ConvertFrom(global::System.ComponentModel.ITypeDescriptorContext context, global::System.Globalization.CultureInfo culture, global::System.Object value)
            {
                return value switch
                {
                    global::System.Int32 intValue => @class.__Deserialize(intValue),
                    global::System.String stringValue when !global::System.String.IsNullOrEmpty(stringValue) && global::System.Int32.TryParse(stringValue, out var result) => @class.__Deserialize(result),
                    _ => base.ConvertFrom(context, culture, value),
                };
            }

            public override bool CanConvertTo(global::System.ComponentModel.ITypeDescriptorContext context, global::System.Type sourceType)
            {
                return sourceType == typeof(global::System.Int32) || sourceType == typeof(global::System.String) || base.CanConvertTo(context, sourceType);
            }

            public override object ConvertTo(global::System.ComponentModel.ITypeDescriptorContext context, global::System.Globalization.CultureInfo culture, global::System.Object value, global::System.Type destinationType)
            {
                if (value is @class idValue)
                {
                    if (destinationType == typeof(global::System.Int32))
                    {
                        return idValue.Value;
                    }

                    if (destinationType == typeof(global::System.String))
                    {
                        return idValue.Value.ToString();
                    }
                }

                return base.ConvertTo(context, culture, value, destinationType);
            }
        }

#nullable restore
        internal sealed class @classDebugView
        {
            private readonly @class _t;
            @classDebugView(@class t)
            {
                _t = t;
            }

            public global::System.String UnderlyingType => "System.Int32";
            public System.Int32 Value => _t.Value;
            public global::System.String Conversions => @"[global::System.Text.Json.Serialization.JsonConverter(typeof(@classSystemTextJsonConverter))]
[global::System.ComponentModel.TypeConverter(typeof(@classTypeConverter))]
";
        }

        static class ThrowHelper
        {
#if NETCOREAPP3_0_OR_GREATER
    [global::System.Diagnostics.CodeAnalysis.DoesNotReturnAttribute]
#endif
            internal static void ThrowInvalidOperationException(string message) => throw new global::System.InvalidOperationException(message);
#if NETCOREAPP3_0_OR_GREATER
    [global::System.Diagnostics.CodeAnalysis.DoesNotReturnAttribute]
#endif
            internal static void ThrowArgumentException(string message, string arg) => throw new global::System.ArgumentException(message, arg);
#if NETCOREAPP3_0_OR_GREATER
    [global::System.Diagnostics.CodeAnalysis.DoesNotReturnAttribute]
#endif
            internal static void ThrowWhenCreatedWithNull() => throw CreateCannotBeNullException();
#if NETCOREAPP3_0_OR_GREATER
    [global::System.Diagnostics.CodeAnalysis.DoesNotReturnAttribute]
#endif
            internal static void ThrowWhenNotInitialized() => throw CreateValidationException("Use of uninitialized Value Object.");
#if NETCOREAPP3_0_OR_GREATER
    [global::System.Diagnostics.CodeAnalysis.DoesNotReturnAttribute]
#endif
            internal static void ThrowWhenNotInitialized(global::System.Diagnostics.StackTrace stackTrace) => throw CreateValidationException("Use of uninitialized Value Object at: " + stackTrace ?? "");
#if NETCOREAPP3_0_OR_GREATER
    [global::System.Diagnostics.CodeAnalysis.DoesNotReturnAttribute]
#endif
            internal static void ThrowWhenValidationFails(Vogen.Validation validation)
            {
                throw CreateValidationException(validation);
            }

            internal static System.Exception CreateValidationException(string message) => new global::Vogen.ValueObjectValidationException(message);
            internal static System.Exception CreateCannotBeNullException() => new global::Vogen.ValueObjectValidationException("Cannot create a value object with null.");
            internal static System.Exception CreateValidationException(Vogen.Validation validation)
            {
                var ex = CreateValidationException(validation.ErrorMessage);
                if (validation.Data is not null)
                {
                    foreach (var kvp in validation.Data)
                    {
                        ex.Data[kvp.Key] = kvp.Value;
                    }
                }

                return ex;
            }
        }
    }
}
  
// ------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a source generator named Vogen (https://github.com/SteveDunn/Vogen)
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
// ------------------------------------------------------------------------------
// Suppress warnings about [Obsolete] member usage in generated code.
#pragma warning disable CS0618
// Suppress warnings for 'Override methods on comparable types'.
#pragma warning disable CA1036
// Suppress Error MA0097 : A class that implements IComparable<T> or IComparable should override comparison operators
#pragma warning disable MA0097
// Suppress warning for 'The annotation for nullable reference types should only be used in code within a '#nullable' annotations context. Auto-generated code requires an explicit '#nullable' directive in source.'
// The generator copies signatures from the BCL, e.g. for `TryParse`, and some of those have nullable annotations.
#pragma warning disable CS8669, CS8632
// Suppress warnings about CS1591: Missing XML comment for publicly visible type or member 'Type_or_Member'
#pragma warning disable CS1591
namespace @bool.@byte.@short.@float.@object
{
    [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
        [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Vogen", "1.0.0.0")]
    [global::System.Text.Json.Serialization.JsonConverter(typeof(@eventSystemTextJsonConverter))]
    [global::System.ComponentModel.TypeConverter(typeof(@eventTypeConverter))]
    [global::System.Diagnostics.DebuggerTypeProxyAttribute(typeof(@eventDebugView))]
    [global::System.Diagnostics.DebuggerDisplayAttribute("Underlying type: System.Int32, Value = { _value }")]
    public partial class @event : global::System.IEquatable<@event>, global::System.IEquatable<System.Int32>, global::System.IComparable<@event>, global::System.IComparable, global::System.IFormattable
    {
#if DEBUG
private readonly global::System.Diagnostics.StackTrace _stackTrace = null!;
#endif
#if !VOGEN_NO_VALIDATION
        private readonly global::System.Boolean _isInitialized;
#endif
        private readonly System.Int32 _value;
        /// <summary>
        /// Gets the underlying <see cref = "System.Int32"/> value if set, otherwise a <see cref = "Vogen.ValueObjectValidationException"/> is thrown.
        /// </summary>
        public System.Int32 Value
        {
            [global::System.Runtime.CompilerServices.MethodImpl(global::System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
            [global::System.Diagnostics.DebuggerStepThroughAttribute]
            get
            {
                EnsureInitialized();
                return _value;
            }
        }

        [global::System.Diagnostics.DebuggerStepThroughAttribute]
        [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]
        public @event()
        {
#if DEBUG
            _stackTrace = new global::System.Diagnostics.StackTrace();
#endif
#if !VOGEN_NO_VALIDATION
            _isInitialized = false;
#endif
            _value = default;
        }

        [global::System.Diagnostics.DebuggerStepThroughAttribute]
        private @event(System.Int32 value)
        {
            _value = value;
#if !VOGEN_NO_VALIDATION
            _isInitialized = true;
#endif
        }

        /// <summary>
        /// Builds an instance from the provided underlying type.
        /// </summary>
        /// <param name = "value">The underlying type.</param>
        /// <returns>An instance of this type.</returns>
        [global::System.Runtime.CompilerServices.MethodImpl(global::System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
        public static @event From(System.Int32 value)
        {
            return new @event(value);
        }

        /// <summary>
        /// Tries to build an instance from the provided underlying type.
        /// If a normalization method is provided, it will be called.
        /// If validation is provided, and it fails, false will be returned.
        /// </summary>
        /// <param name = "value">The underlying type.</param>
        /// <param name = "vo">An instance of the value object.</param>
        /// <returns>True if the value object can be built, otherwise false.</returns>
        
#pragma warning disable CS8767 // Nullability of reference types in type of parameter doesn't match implicitly implemented member because of nullability attributes.

        public static bool TryFrom(
#if NETCOREAPP3_0_OR_GREATER
[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
#endif
        System.Int32 value, 
#if NETCOREAPP3_0_OR_GREATER
[global::System.Diagnostics.CodeAnalysis.MaybeNullWhen(false)]
#endif
        out @event vo)
#pragma warning restore CS8767 // Nullability of reference types in type of parameter doesn't match implicitly implemented member because of nullability attributes.

        {
            vo = new @event(value);
            return true;
        }

        /// <summary>
        /// Tries to build an instance from the provided underlying value.
        /// If a normalization method is provided, it will be called.
        /// If validation is provided, and it fails, an error will be returned.
        /// </summary>
        /// <param name = "value">The primitive value.</param>
        /// <returns>A <see cref = "Vogen.ValueObjectOrError{T}"/> containing either the value object, or an error.</returns>
        public static Vogen.ValueObjectOrError<@event> TryFrom(System.Int32 value)
        {
            return new Vogen.ValueObjectOrError<@event>(new @event(value));
        }

        [global::System.Runtime.CompilerServices.MethodImpl(global::System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
#if VOGEN_NO_VALIDATION
#pragma warning disable CS8775
  public bool IsInitialized() => true;
#pragma warning restore CS8775
#else
        public bool IsInitialized() => _isInitialized;
#endif
        // only called internally when something has been deserialized into
        // its primitive type.
        private static @event __Deserialize(System.Int32 value)
        {
            return new @event(value);
        }

        public global::System.Boolean Equals(@event other)
        {
            if (ReferenceEquals(null, other))
            {
                return false;
            }

            // It's possible to create uninitialized instances via converters such as EfCore (HasDefaultValue), which call Equals.
            // We treat anything uninitialized as not equal to anything, even other uninitialized instances of this type.
            if (!IsInitialized() || !other.IsInitialized())
                return false;
            if (ReferenceEquals(this, other))
            {
                return true;
            }

            return GetType() == other.GetType() && global::System.Collections.Generic.EqualityComparer<System.Int32>.Default.Equals(Value, other.Value);
        }

        public global::System.Boolean Equals(@event other, global::System.Collections.Generic.IEqualityComparer<@event> comparer)
        {
            return comparer.Equals(this, other);
        }

        public global::System.Boolean Equals(System.Int32 primitive)
        {
            return Value.Equals(primitive);
        }

        public override global::System.Boolean Equals(global::System.Object obj)
        {
            return Equals(obj as @event);
        }

        public static global::System.Boolean operator ==(@event left, @event right) => Equals(left, right);
        public static global::System.Boolean operator !=(@event left, @event right) => !Equals(left, right);
        public static global::System.Boolean operator ==(@event left, System.Int32 right) => left.Value.Equals(right);
        public static global::System.Boolean operator ==(System.Int32 left, @event right) => right.Value.Equals(left);
        public static global::System.Boolean operator !=(System.Int32 left, @event right) => !(left == right);
        public static global::System.Boolean operator !=(@event left, System.Int32 right) => !(left == right);
        public static explicit operator @event(System.Int32 value) => From(value);
        public static explicit operator System.Int32(@event value) => value.Value;
        public int CompareTo(@event other)
        {
            if (other is null)
                return 1;
            return Value.CompareTo(other.Value);
        }

        public int CompareTo(object other)
        {
            if (other is null)
                return 1;
            if (other is @event x)
                return CompareTo(x);
            ThrowHelper.ThrowArgumentException("Cannot compare to object as it is not of type @event", nameof(other));
            return 0;
        }

        /// <inheritdoc cref = "int.TryParse(string, out int)"/>
        /// <summary>
        /// </summary>
        /// <returns>
        /// True if the value could a) be parsed by the underlying type, and b) passes any validation (after running any optional normalization).
        /// </returns>
        public static global::System.Boolean TryParse(string s, 
#if NETCOREAPP3_0_OR_GREATER
[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
#endif
        out @event result)
        {
            if (System.Int32.TryParse(s, out var __v))
            {
                result = new @event(__v);
                return true;
            }

            result = default;
            return false;
        }

        /// <inheritdoc cref = "int.TryParse(string, System.Globalization.NumberStyles, System.IFormatProvider, out int)"/>
        /// <summary>
        /// </summary>
        /// <returns>
        /// True if the value could a) be parsed by the underlying type, and b) passes any validation (after running any optional normalization).
        /// </returns>
        public static global::System.Boolean TryParse(string s, global::System.Globalization.NumberStyles style, global::System.IFormatProvider provider, 
#if NETCOREAPP3_0_OR_GREATER
[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
#endif
        out @event result)
        {
            if (System.Int32.TryParse(s, style, provider, out var __v))
            {
                result = new @event(__v);
                return true;
            }

            result = default;
            return false;
        }

        /// <inheritdoc cref = "int.Parse(string)"/>
        /// <summary>
        /// </summary>
        /// <returns>
        /// The value created by calling the Parse method on the primitive.
        /// </returns>
        /// <exception cref = "global::Vogen.ValueObjectValidationException">Thrown when the value can be parsed, but is not valid.</exception>
        public static @event Parse(string s)
        {
            var r = System.Int32.Parse(s);
            return From(r);
        }

        /// <inheritdoc cref = "int.Parse(string, System.Globalization.NumberStyles)"/>
        /// <summary>
        /// </summary>
        /// <returns>
        /// The value created by calling the Parse method on the primitive.
        /// </returns>
        /// <exception cref = "global::Vogen.ValueObjectValidationException">Thrown when the value can be parsed, but is not valid.</exception>
        public static @event Parse(string s, global::System.Globalization.NumberStyles style)
        {
            var r = System.Int32.Parse(s, style);
            return From(r);
        }

        /// <inheritdoc cref = "int.Parse(string, System.IFormatProvider)"/>
        /// <summary>
        /// </summary>
        /// <returns>
        /// The value created by calling the Parse method on the primitive.
        /// </returns>
        /// <exception cref = "global::Vogen.ValueObjectValidationException">Thrown when the value can be parsed, but is not valid.</exception>
        public static @event Parse(string s, global::System.IFormatProvider provider)
        {
            var r = System.Int32.Parse(s, provider);
            return From(r);
        }

        /// <inheritdoc cref = "int.Parse(string, System.Globalization.NumberStyles, System.IFormatProvider)"/>
        /// <summary>
        /// </summary>
        /// <returns>
        /// The value created by calling the Parse method on the primitive.
        /// </returns>
        /// <exception cref = "global::Vogen.ValueObjectValidationException">Thrown when the value can be parsed, but is not valid.</exception>
        public static @event Parse(string s, global::System.Globalization.NumberStyles style, global::System.IFormatProvider provider)
        {
            var r = System.Int32.Parse(s, style, provider);
            return From(r);
        }

#nullable disable
        /// <inheritdoc cref = "int.ToString(string, System.IFormatProvider)"/>
        [System.Security.SecuritySafeCriticalAttribute]
        public string ToString(string format, global::System.IFormatProvider provider)
        {
            return IsInitialized() ? Value.ToString(format, provider) : "[UNINITIALIZED]";
        }

#nullable restore
        public override global::System.Int32 GetHashCode()
        {
            unchecked // Overflow is fine, just wrap
            {
                global::System.Int32 hash = (global::System.Int32)2166136261;
                hash = (hash * 16777619) ^ GetType().GetHashCode();
                hash = (hash * 16777619) ^ global::System.Collections.Generic.EqualityComparer<System.Int32>.Default.GetHashCode(Value);
                return hash;
            }
        }

        [global::System.Runtime.CompilerServices.MethodImpl(global::System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
        private void EnsureInitialized()
        {
            if (!IsInitialized())
            {
#if DEBUG
               ThrowHelper.ThrowWhenNotInitialized(_stackTrace);
#else
                ThrowHelper.ThrowWhenNotInitialized();
#endif
            }
        }

        /// <inheritdoc cref = "System.Int32.ToString()"/>
        public override global::System.String ToString() => IsInitialized() ? Value.ToString() ?? "" : "[UNINITIALIZED]";
        /// <inheritdoc cref = "System.Int32.ToString(string)"/>
        public global::System.String ToString(string format) => IsInitialized() ? Value.ToString(format) ?? "" : "[UNINITIALIZED]";
        /// <inheritdoc cref = "System.Int32.ToString(System.IFormatProvider)"/>
        public global::System.String ToString(global::System.IFormatProvider provider) => IsInitialized() ? Value.ToString(provider) ?? "" : "[UNINITIALIZED]";
#nullable disable
        /// <summary>
        /// Converts a @event to or from JSON.
        /// </summary>
        public class @eventSystemTextJsonConverter : global::System.Text.Json.Serialization.JsonConverter<@event>
        {
            public override @event Read(ref global::System.Text.Json.Utf8JsonReader reader, global::System.Type typeToConvert, global::System.Text.Json.JsonSerializerOptions options)
            {
#if NET5_0_OR_GREATER
                return DeserializeJson(global::System.Text.Json.JsonSerializer.Deserialize(ref reader, (global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Int32>)options.GetTypeInfo(typeof(global::System.Int32))));
#else
                return DeserializeJson(reader.GetInt32());
#endif
            }

            public override void Write(System.Text.Json.Utf8JsonWriter writer, @event value, global::System.Text.Json.JsonSerializerOptions options)
            {
#if NET5_0_OR_GREATER
                global::System.Text.Json.JsonSerializer.Serialize(writer, value.Value, options);
#else
                writer.WriteNumberValue(value.Value);
#endif
            }

#if NET6_0_OR_GREATER
            public override @event ReadAsPropertyName(ref global::System.Text.Json.Utf8JsonReader reader, global::System.Type typeToConvert, global::System.Text.Json.JsonSerializerOptions options)
            {
                return DeserializeJson(global::System.Int32.Parse(reader.GetString(), global::System.Globalization.NumberStyles.Any, global::System.Globalization.CultureInfo.InvariantCulture));
            }

            public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, @event value, global::System.Text.Json.JsonSerializerOptions options)
            {
                writer.WritePropertyName(value.Value.ToString(global::System.Globalization.CultureInfo.InvariantCulture));
            }
#endif
#if NETCOREAPP3_0_OR_GREATER
            [global::System.Diagnostics.CodeAnalysis.DoesNotReturnAttribute]
#endif
            private static void ThrowJsonExceptionWhenValidationFails(Vogen.Validation validation)
            {
                var e = ThrowHelper.CreateValidationException(validation);
                throw new global::System.Text.Json.JsonException(null, e);
            }

            public static @event DeserializeJson(System.Int32 value)
            {
                return new @event(value);
            }
        }

#nullable restore
#nullable disable
        class @eventTypeConverter : global::System.ComponentModel.TypeConverter
        {
            public override global::System.Boolean CanConvertFrom(global::System.ComponentModel.ITypeDescriptorContext context, global::System.Type sourceType)
            {
                return sourceType == typeof(global::System.Int32) || sourceType == typeof(global::System.String) || base.CanConvertFrom(context, sourceType);
            }

            public override global::System.Object ConvertFrom(global::System.ComponentModel.ITypeDescriptorContext context, global::System.Globalization.CultureInfo culture, global::System.Object value)
            {
                return value switch
                {
                    global::System.Int32 intValue => @event.__Deserialize(intValue),
                    global::System.String stringValue when !global::System.String.IsNullOrEmpty(stringValue) && global::System.Int32.TryParse(stringValue, out var result) => @event.__Deserialize(result),
                    _ => base.ConvertFrom(context, culture, value),
                };
            }

            public override bool CanConvertTo(global::System.ComponentModel.ITypeDescriptorContext context, global::System.Type sourceType)
            {
                return sourceType == typeof(global::System.Int32) || sourceType == typeof(global::System.String) || base.CanConvertTo(context, sourceType);
            }

            public override object ConvertTo(global::System.ComponentModel.ITypeDescriptorContext context, global::System.Globalization.CultureInfo culture, global::System.Object value, global::System.Type destinationType)
            {
                if (value is @event idValue)
                {
                    if (destinationType == typeof(global::System.Int32))
                    {
                        return idValue.Value;
                    }

                    if (destinationType == typeof(global::System.String))
                    {
                        return idValue.Value.ToString();
                    }
                }

                return base.ConvertTo(context, culture, value, destinationType);
            }
        }

#nullable restore
        internal sealed class @eventDebugView
        {
            private readonly @event _t;
            @eventDebugView(@event t)
            {
                _t = t;
            }

            public global::System.String UnderlyingType => "System.Int32";
            public System.Int32 Value => _t.Value;
            public global::System.String Conversions => @"[global::System.Text.Json.Serialization.JsonConverter(typeof(@eventSystemTextJsonConverter))]
[global::System.ComponentModel.TypeConverter(typeof(@eventTypeConverter))]
";
        }

        static class ThrowHelper
        {
#if NETCOREAPP3_0_OR_GREATER
    [global::System.Diagnostics.CodeAnalysis.DoesNotReturnAttribute]
#endif
            internal static void ThrowInvalidOperationException(string message) => throw new global::System.InvalidOperationException(message);
#if NETCOREAPP3_0_OR_GREATER
    [global::System.Diagnostics.CodeAnalysis.DoesNotReturnAttribute]
#endif
            internal static void ThrowArgumentException(string message, string arg) => throw new global::System.ArgumentException(message, arg);
#if NETCOREAPP3_0_OR_GREATER
    [global::System.Diagnostics.CodeAnalysis.DoesNotReturnAttribute]
#endif
            internal static void ThrowWhenCreatedWithNull() => throw CreateCannotBeNullException();
#if NETCOREAPP3_0_OR_GREATER
    [global::System.Diagnostics.CodeAnalysis.DoesNotReturnAttribute]
#endif
            internal static void ThrowWhenNotInitialized() => throw CreateValidationException("Use of uninitialized Value Object.");
#if NETCOREAPP3_0_OR_GREATER
    [global::System.Diagnostics.CodeAnalysis.DoesNotReturnAttribute]
#endif
            internal static void ThrowWhenNotInitialized(global::System.Diagnostics.StackTrace stackTrace) => throw CreateValidationException("Use of uninitialized Value Object at: " + stackTrace ?? "");
#if NETCOREAPP3_0_OR_GREATER
    [global::System.Diagnostics.CodeAnalysis.DoesNotReturnAttribute]
#endif
            internal static void ThrowWhenValidationFails(Vogen.Validation validation)
            {
                throw CreateValidationException(validation);
            }

            internal static System.Exception CreateValidationException(string message) => new global::Vogen.ValueObjectValidationException(message);
            internal static System.Exception CreateCannotBeNullException() => new global::Vogen.ValueObjectValidationException("Cannot create a value object with null.");
            internal static System.Exception CreateValidationException(Vogen.Validation validation)
            {
                var ex = CreateValidationException(validation.ErrorMessage);
                if (validation.Data is not null)
                {
                    foreach (var kvp in validation.Data)
                    {
                        ex.Data[kvp.Key] = kvp.Value;
                    }
                }

                return ex;
            }
        }
    }
}
  
// ------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a source generator named Vogen (https://github.com/SteveDunn/Vogen)
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
// ------------------------------------------------------------------------------
// Suppress warnings about [Obsolete] member usage in generated code.
#pragma warning disable CS0618
// Suppress warnings for 'Override methods on comparable types'.
#pragma warning disable CA1036
// Suppress Error MA0097 : A class that implements IComparable<T> or IComparable should override comparison operators
#pragma warning disable MA0097
// Suppress warning for 'The annotation for nullable reference types should only be used in code within a '#nullable' annotations context. Auto-generated code requires an explicit '#nullable' directive in source.'
// The generator copies signatures from the BCL, e.g. for `TryParse`, and some of those have nullable annotations.
#pragma warning disable CS8669, CS8632
// Suppress warnings about CS1591: Missing XML comment for publicly visible type or member 'Type_or_Member'
#pragma warning disable CS1591
namespace @bool.@byte.@short.@float.@object
{
    [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
        [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Vogen", "1.0.0.0")]
    [global::System.Text.Json.Serialization.JsonConverter(typeof(@event2SystemTextJsonConverter))]
    [global::System.ComponentModel.TypeConverter(typeof(@event2TypeConverter))]
    [global::System.Diagnostics.DebuggerTypeProxyAttribute(typeof(@event2DebugView))]
    [global::System.Diagnostics.DebuggerDisplayAttribute("Underlying type: @record.@struct.@float.@decimal, Value = { _value }")]
    public partial class @event2 : global::System.IEquatable<@event2>, global::System.IEquatable<@record.@struct.@float.@decimal>
    {
#if DEBUG
private readonly global::System.Diagnostics.StackTrace _stackTrace = null!;
#endif
#if !VOGEN_NO_VALIDATION
        private readonly global::System.Boolean _isInitialized;
#endif
        private readonly @record.@struct.@float.@decimal _value;
        /// <summary>
        /// Gets the underlying <see cref = "@record.@struct.@float.@decimal"/> value if set, otherwise a <see cref = "Vogen.ValueObjectValidationException"/> is thrown.
        /// </summary>
        public @record.@struct.@float.@decimal Value
        {
            [global::System.Runtime.CompilerServices.MethodImpl(global::System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
            [global::System.Diagnostics.DebuggerStepThroughAttribute]
            get
            {
                EnsureInitialized();
                return _value;
            }
        }

        [global::System.Diagnostics.DebuggerStepThroughAttribute]
        [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]
        public @event2()
        {
#if DEBUG
            _stackTrace = new global::System.Diagnostics.StackTrace();
#endif
#if !VOGEN_NO_VALIDATION
            _isInitialized = false;
#endif
            _value = default;
        }

        [global::System.Diagnostics.DebuggerStepThroughAttribute]
        private @event2(@record.@struct.@float.@decimal value)
        {
            _value = value;
#if !VOGEN_NO_VALIDATION
            _isInitialized = true;
#endif
        }

        /// <summary>
        /// Builds an instance from the provided underlying type.
        /// </summary>
        /// <param name = "value">The underlying type.</param>
        /// <returns>An instance of this type.</returns>
        [global::System.Runtime.CompilerServices.MethodImpl(global::System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
        public static @event2 From(@record.@struct.@float.@decimal value)
        {
            return new @event2(value);
        }

        /// <summary>
        /// Tries to build an instance from the provided underlying type.
        /// If a normalization method is provided, it will be called.
        /// If validation is provided, and it fails, false will be returned.
        /// </summary>
        /// <param name = "value">The underlying type.</param>
        /// <param name = "vo">An instance of the value object.</param>
        /// <returns>True if the value object can be built, otherwise false.</returns>
        
#pragma warning disable CS8767 // Nullability of reference types in type of parameter doesn't match implicitly implemented member because of nullability attributes.

        public static bool TryFrom(
#if NETCOREAPP3_0_OR_GREATER
[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
#endif
        @record.@struct.@float.@decimal value, 
#if NETCOREAPP3_0_OR_GREATER
[global::System.Diagnostics.CodeAnalysis.MaybeNullWhen(false)]
#endif
        out @event2 vo)
#pragma warning restore CS8767 // Nullability of reference types in type of parameter doesn't match implicitly implemented member because of nullability attributes.

        {
            vo = new @event2(value);
            return true;
        }

        /// <summary>
        /// Tries to build an instance from the provided underlying value.
        /// If a normalization method is provided, it will be called.
        /// If validation is provided, and it fails, an error will be returned.
        /// </summary>
        /// <param name = "value">The primitive value.</param>
        /// <returns>A <see cref = "Vogen.ValueObjectOrError{T}"/> containing either the value object, or an error.</returns>
        public static Vogen.ValueObjectOrError<@event2> TryFrom(@record.@struct.@float.@decimal value)
        {
            return new Vogen.ValueObjectOrError<@event2>(new @event2(value));
        }

        [global::System.Runtime.CompilerServices.MethodImpl(global::System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
#if VOGEN_NO_VALIDATION
#pragma warning disable CS8775
  public bool IsInitialized() => true;
#pragma warning restore CS8775
#else
        public bool IsInitialized() => _isInitialized;
#endif
        // only called internally when something has been deserialized into
        // its primitive type.
        private static @event2 __Deserialize(@record.@struct.@float.@decimal value)
        {
            return new @event2(value);
        }

        public global::System.Boolean Equals(@event2 other)
        {
            if (ReferenceEquals(null, other))
            {
                return false;
            }

            // It's possible to create uninitialized instances via converters such as EfCore (HasDefaultValue), which call Equals.
            // We treat anything uninitialized as not equal to anything, even other uninitialized instances of this type.
            if (!IsInitialized() || !other.IsInitialized())
                return false;
            if (ReferenceEquals(this, other))
            {
                return true;
            }

            return GetType() == other.GetType() && global::System.Collections.Generic.EqualityComparer<@record.@struct.@float.@decimal>.Default.Equals(Value, other.Value);
        }

        public global::System.Boolean Equals(@event2 other, global::System.Collections.Generic.IEqualityComparer<@event2> comparer)
        {
            return comparer.Equals(this, other);
        }

        public global::System.Boolean Equals(@record.@struct.@float.@decimal primitive)
        {
            return Value.Equals(primitive);
        }

        public override global::System.Boolean Equals(global::System.Object obj)
        {
            return Equals(obj as @event2);
        }

        public static global::System.Boolean operator ==(@event2 left, @event2 right) => Equals(left, right);
        public static global::System.Boolean operator !=(@event2 left, @event2 right) => !Equals(left, right);
        public static global::System.Boolean operator ==(@event2 left, @record.@struct.@float.@decimal right) => left.Value.Equals(right);
        public static global::System.Boolean operator ==(@record.@struct.@float.@decimal left, @event2 right) => right.Value.Equals(left);
        public static global::System.Boolean operator !=(@record.@struct.@float.@decimal left, @event2 right) => !(left == right);
        public static global::System.Boolean operator !=(@event2 left, @record.@struct.@float.@decimal right) => !(left == right);
        public static explicit operator @event2(@record.@struct.@float.@decimal value) => From(value);
        public static explicit operator @record.@struct.@float.@decimal(@event2 value) => value.Value;
#nullable disable
#nullable restore
        public override global::System.Int32 GetHashCode()
        {
            unchecked // Overflow is fine, just wrap
            {
                global::System.Int32 hash = (global::System.Int32)2166136261;
                hash = (hash * 16777619) ^ GetType().GetHashCode();
                hash = (hash * 16777619) ^ global::System.Collections.Generic.EqualityComparer<@record.@struct.@float.@decimal>.Default.GetHashCode(Value);
                return hash;
            }
        }

        [global::System.Runtime.CompilerServices.MethodImpl(global::System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
        private void EnsureInitialized()
        {
            if (!IsInitialized())
            {
#if DEBUG
               ThrowHelper.ThrowWhenNotInitialized(_stackTrace);
#else
                ThrowHelper.ThrowWhenNotInitialized();
#endif
            }
        }

        /// <inheritdoc cref = "@record.@struct.@float.@decimal.ToString()"/>
        public override global::System.String ToString() => IsInitialized() ? Value.ToString() ?? "" : "[UNINITIALIZED]";
#nullable disable
        /// <summary>
        /// Converts a @event2 to or from JSON.
        /// </summary>
        public class @event2SystemTextJsonConverter : global::System.Text.Json.Serialization.JsonConverter<@event2>
        {
            public override @event2 Read(ref global::System.Text.Json.Utf8JsonReader reader, global::System.Type typeToConvert, global::System.Text.Json.JsonSerializerOptions options)
            {
                var primitive = global::System.Text.Json.JsonSerializer.Deserialize<@record.@struct.@float.@decimal>(ref reader, options);
                return DeserializeJson(primitive);
            }

            public override void Write(System.Text.Json.Utf8JsonWriter writer, @event2 value, global::System.Text.Json.JsonSerializerOptions options)
            {
                global::System.Text.Json.JsonSerializer.Serialize(writer, value.Value, options);
            }

#if NET6_0_OR_GREATER
            public override @event2 ReadAsPropertyName(ref global::System.Text.Json.Utf8JsonReader reader, global::System.Type typeToConvert, global::System.Text.Json.JsonSerializerOptions options)
            {
                var primitive = global::System.Text.Json.JsonSerializer.Deserialize<@record.@struct.@float.@decimal>(ref reader, options);
                return DeserializeJson(primitive);
            }

            public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, @event2 value, global::System.Text.Json.JsonSerializerOptions options)
            {
                writer.WritePropertyName(global::System.Text.Json.JsonSerializer.Serialize(value.Value));
            }
#endif
#if NETCOREAPP3_0_OR_GREATER
            [global::System.Diagnostics.CodeAnalysis.DoesNotReturnAttribute]
#endif
            private static void ThrowJsonExceptionWhenValidationFails(Vogen.Validation validation)
            {
                var e = ThrowHelper.CreateValidationException(validation);
                throw new global::System.Text.Json.JsonException(null, e);
            }

            public static @event2 DeserializeJson(@record.@struct.@float.@decimal value)
            {
                return new @event2(value);
            }
        }

#nullable restore
#nullable disable
        class @event2TypeConverter : global::System.ComponentModel.TypeConverter
        {
            public override global::System.Boolean CanConvertFrom(global::System.ComponentModel.ITypeDescriptorContext context, global::System.Type sourceType)
            {
                return sourceType == typeof(@record.@struct.@float.@decimal);
            }

            public override global::System.Object ConvertFrom(global::System.ComponentModel.ITypeDescriptorContext context, global::System.Globalization.CultureInfo culture, global::System.Object value)
            {
                @record.@struct.@float.@decimal ut = (@record.@struct.@float.@decimal)value;
                return @event2.__Deserialize(ut);
            }

            public override bool CanConvertTo(global::System.ComponentModel.ITypeDescriptorContext context, global::System.Type sourceType)
            {
                return sourceType == typeof(@record.@struct.@float.@decimal);
            }

            public override object ConvertTo(global::System.ComponentModel.ITypeDescriptorContext context, global::System.Globalization.CultureInfo culture, global::System.Object value, global::System.Type destinationType)
            {
                if (value is @event2 idValue)
                {
                    return idValue.Value;
                }

                return base.ConvertTo(context, culture, value, destinationType);
            }
        }

#nullable restore
        internal sealed class @event2DebugView
        {
            private readonly @event2 _t;
            @event2DebugView(@event2 t)
            {
                _t = t;
            }

            public global::System.String UnderlyingType => "@record.@struct.@float.@decimal";
            public @record.@struct.@float.@decimal Value => _t.Value;
            public global::System.String Conversions => @"[global::System.Text.Json.Serialization.JsonConverter(typeof(@event2SystemTextJsonConverter))]
[global::System.ComponentModel.TypeConverter(typeof(@event2TypeConverter))]
";
        }

        static class ThrowHelper
        {
#if NETCOREAPP3_0_OR_GREATER
    [global::System.Diagnostics.CodeAnalysis.DoesNotReturnAttribute]
#endif
            internal static void ThrowInvalidOperationException(string message) => throw new global::System.InvalidOperationException(message);
#if NETCOREAPP3_0_OR_GREATER
    [global::System.Diagnostics.CodeAnalysis.DoesNotReturnAttribute]
#endif
            internal static void ThrowArgumentException(string message, string arg) => throw new global::System.ArgumentException(message, arg);
#if NETCOREAPP3_0_OR_GREATER
    [global::System.Diagnostics.CodeAnalysis.DoesNotReturnAttribute]
#endif
            internal static void ThrowWhenCreatedWithNull() => throw CreateCannotBeNullException();
#if NETCOREAPP3_0_OR_GREATER
    [global::System.Diagnostics.CodeAnalysis.DoesNotReturnAttribute]
#endif
            internal static void ThrowWhenNotInitialized() => throw CreateValidationException("Use of uninitialized Value Object.");
#if NETCOREAPP3_0_OR_GREATER
    [global::System.Diagnostics.CodeAnalysis.DoesNotReturnAttribute]
#endif
            internal static void ThrowWhenNotInitialized(global::System.Diagnostics.StackTrace stackTrace) => throw CreateValidationException("Use of uninitialized Value Object at: " + stackTrace ?? "");
#if NETCOREAPP3_0_OR_GREATER
    [global::System.Diagnostics.CodeAnalysis.DoesNotReturnAttribute]
#endif
            internal static void ThrowWhenValidationFails(Vogen.Validation validation)
            {
                throw CreateValidationException(validation);
            }

            internal static System.Exception CreateValidationException(string message) => new global::Vogen.ValueObjectValidationException(message);
            internal static System.Exception CreateCannotBeNullException() => new global::Vogen.ValueObjectValidationException("Cannot create a value object with null.");
            internal static System.Exception CreateValidationException(Vogen.Validation validation)
            {
                var ex = CreateValidationException(validation.ErrorMessage);
                if (validation.Data is not null)
                {
                    foreach (var kvp in validation.Data)
                    {
                        ex.Data[kvp.Key] = kvp.Value;
                    }
                }

                return ex;
            }
        }
    }
}
]