﻿[  
// ------------------------------------------------------------------------------
// <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

public static class VogenSwashbuckleExtensions
{
    public static global::Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenOptions MapVogenTypesIngenerator(this global::Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenOptions o)
    {
        global::Microsoft.Extensions.DependencyInjection.SwaggerGenOptionsExtensions.MapType<MyNamespace.MyVoInt>(o, () => new global::Microsoft.OpenApi.Models.OpenApiSchema { Type = "integer", Format = "int32", Nullable = false });
global::Microsoft.Extensions.DependencyInjection.SwaggerGenOptionsExtensions.MapType<MyNamespace.MyVoFloat>(o, () => new global::Microsoft.OpenApi.Models.OpenApiSchema { Type = "number", Nullable = false });
global::Microsoft.Extensions.DependencyInjection.SwaggerGenOptionsExtensions.MapType<MyNamespace.MyVoDecimal>(o, () => new global::Microsoft.OpenApi.Models.OpenApiSchema { Type = "number", Format = "double", Nullable = false });
global::Microsoft.Extensions.DependencyInjection.SwaggerGenOptionsExtensions.MapType<MyNamespace.MyVoDouble>(o, () => new global::Microsoft.OpenApi.Models.OpenApiSchema { Type = "number", Format = "double", Nullable = false });
global::Microsoft.Extensions.DependencyInjection.SwaggerGenOptionsExtensions.MapType<MyNamespace.MyVoString>(o, () => new global::Microsoft.OpenApi.Models.OpenApiSchema { Type = "string", Nullable = false });
global::Microsoft.Extensions.DependencyInjection.SwaggerGenOptionsExtensions.MapType<MyNamespace.MyVoBool>(o, () => new global::Microsoft.OpenApi.Models.OpenApiSchema { Type = "boolean", Nullable = false });
global::Microsoft.Extensions.DependencyInjection.SwaggerGenOptionsExtensions.MapType<MyNamespace.@bool>(o, () => new global::Microsoft.OpenApi.Models.OpenApiSchema { Type = "boolean", Nullable = false });


        return o;
    }
}
  
// ------------------------------------------------------------------------------
// <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::MyNamespace.MyVoInt),
            new global::System.Lazy<global::System.Text.Json.Serialization.JsonConverter>(() => new global::MyNamespace.MyVoInt.MyVoIntSystemTextJsonConverter())
        },
        {
            typeof(global::MyNamespace.MyVoFloat),
            new global::System.Lazy<global::System.Text.Json.Serialization.JsonConverter>(() => new global::MyNamespace.MyVoFloat.MyVoFloatSystemTextJsonConverter())
        },
        {
            typeof(global::MyNamespace.MyVoDecimal),
            new global::System.Lazy<global::System.Text.Json.Serialization.JsonConverter>(() => new global::MyNamespace.MyVoDecimal.MyVoDecimalSystemTextJsonConverter())
        },
        {
            typeof(global::MyNamespace.MyVoDouble),
            new global::System.Lazy<global::System.Text.Json.Serialization.JsonConverter>(() => new global::MyNamespace.MyVoDouble.MyVoDoubleSystemTextJsonConverter())
        },
        {
            typeof(global::MyNamespace.MyVoString),
            new global::System.Lazy<global::System.Text.Json.Serialization.JsonConverter>(() => new global::MyNamespace.MyVoString.MyVoStringSystemTextJsonConverter())
        },
        {
            typeof(global::MyNamespace.MyVoBool),
            new global::System.Lazy<global::System.Text.Json.Serialization.JsonConverter>(() => new global::MyNamespace.MyVoBool.MyVoBoolSystemTextJsonConverter())
        },
        {
            typeof(global::MyNamespace.@bool),
            new global::System.Lazy<global::System.Text.Json.Serialization.JsonConverter>(() => new global::MyNamespace.@bool.@boolSystemTextJsonConverter())
        }
    };
    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 MyNamespace
{
    [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
        [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Vogen", "1.0.0.0")]
    [global::System.Text.Json.Serialization.JsonConverter(typeof(MyVoIntSystemTextJsonConverter))]
    [global::System.ComponentModel.TypeConverter(typeof(MyVoIntTypeConverter))]
    [global::System.Diagnostics.DebuggerTypeProxyAttribute(typeof(MyVoIntDebugView))]
    [global::System.Diagnostics.DebuggerDisplayAttribute("Underlying type: System.Int32, Value = { _value }")]
    public partial class MyVoInt : global::System.IEquatable<MyVoInt>, global::System.IEquatable<System.Int32>, global::System.IComparable<MyVoInt>, global::System.IComparable, global::System.IParsable<MyVoInt>, global::System.ISpanParsable<MyVoInt>, global::System.IUtf8SpanParsable<MyVoInt>, global::System.IFormattable, global::System.ISpanFormattable, global::System.IUtf8SpanFormattable
    {
#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 MyVoInt()
        {
#if DEBUG
            _stackTrace = new global::System.Diagnostics.StackTrace();
#endif
#if !VOGEN_NO_VALIDATION
            _isInitialized = false;
#endif
            _value = default;
        }

        [global::System.Diagnostics.DebuggerStepThroughAttribute]
        private MyVoInt(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 MyVoInt From(System.Int32 value)
        {
            return new MyVoInt(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 MyVoInt 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 MyVoInt(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<MyVoInt> TryFrom(System.Int32 value)
        {
            return new Vogen.ValueObjectOrError<MyVoInt>(new MyVoInt(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 MyVoInt __Deserialize(System.Int32 value)
        {
            return new MyVoInt(value);
        }

        public global::System.Boolean Equals(MyVoInt 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(MyVoInt other, global::System.Collections.Generic.IEqualityComparer<MyVoInt> 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 MyVoInt);
        }

        public static global::System.Boolean operator ==(MyVoInt left, MyVoInt right) => Equals(left, right);
        public static global::System.Boolean operator !=(MyVoInt left, MyVoInt right) => !Equals(left, right);
        public static global::System.Boolean operator ==(MyVoInt left, System.Int32 right) => left.Value.Equals(right);
        public static global::System.Boolean operator ==(System.Int32 left, MyVoInt right) => right.Value.Equals(left);
        public static global::System.Boolean operator !=(System.Int32 left, MyVoInt right) => !(left == right);
        public static global::System.Boolean operator !=(MyVoInt left, System.Int32 right) => !(left == right);
        public static explicit operator MyVoInt(System.Int32 value) => From(value);
        public static explicit operator System.Int32(MyVoInt value) => value.Value;
        public int CompareTo(MyVoInt 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 MyVoInt x)
                return CompareTo(x);
            ThrowHelper.ThrowArgumentException("Cannot compare to object as it is not of type MyVoInt", nameof(other));
            return 0;
        }

        /// <inheritdoc cref = "int.TryParse(System.ReadOnlySpan{byte}, 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(global::System.ReadOnlySpan<byte> utf8Text, global::System.Globalization.NumberStyles style, global::System.IFormatProvider provider, 
#if NETCOREAPP3_0_OR_GREATER
[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
#endif
        out MyVoInt result)
        {
            if (System.Int32.TryParse(utf8Text, style, provider, out var __v))
            {
                result = new MyVoInt(__v);
                return true;
            }

            result = default;
            return false;
        }

        /// <inheritdoc cref = "int.TryParse(System.ReadOnlySpan{byte}, 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(global::System.ReadOnlySpan<byte> utf8Text, global::System.IFormatProvider provider, 
#if NETCOREAPP3_0_OR_GREATER
[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
#endif
        out MyVoInt result)
        {
            if (System.Int32.TryParse(utf8Text, provider, out var __v))
            {
                result = new MyVoInt(__v);
                return true;
            }

            result = default;
            return false;
        }

        /// <inheritdoc cref = "int.TryParse(System.ReadOnlySpan{byte}, 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(global::System.ReadOnlySpan<byte> utf8Text, 
#if NETCOREAPP3_0_OR_GREATER
[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
#endif
        out MyVoInt result)
        {
            if (System.Int32.TryParse(utf8Text, out var __v))
            {
                result = new MyVoInt(__v);
                return true;
            }

            result = default;
            return false;
        }

        /// <inheritdoc cref = "int.TryParse(System.ReadOnlySpan{char}, 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(global::System.ReadOnlySpan<char> s, global::System.Globalization.NumberStyles style, global::System.IFormatProvider provider, 
#if NETCOREAPP3_0_OR_GREATER
[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
#endif
        out MyVoInt result)
        {
            if (System.Int32.TryParse(s, style, provider, out var __v))
            {
                result = new MyVoInt(__v);
                return true;
            }

            result = default;
            return false;
        }

        /// <inheritdoc cref = "int.TryParse(System.ReadOnlySpan{char}, 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(global::System.ReadOnlySpan<char> s, global::System.IFormatProvider provider, 
#if NETCOREAPP3_0_OR_GREATER
[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
#endif
        out MyVoInt result)
        {
            if (System.Int32.TryParse(s, provider, out var __v))
            {
                result = new MyVoInt(__v);
                return true;
            }

            result = default;
            return false;
        }

        /// <inheritdoc cref = "int.TryParse(System.ReadOnlySpan{char}, 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(global::System.ReadOnlySpan<char> s, 
#if NETCOREAPP3_0_OR_GREATER
[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
#endif
        out MyVoInt result)
        {
            if (System.Int32.TryParse(s, out var __v))
            {
                result = new MyVoInt(__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 MyVoInt result)
        {
            if (System.Int32.TryParse(s, style, provider, out var __v))
            {
                result = new MyVoInt(__v);
                return true;
            }

            result = default;
            return false;
        }

        /// <inheritdoc cref = "int.TryParse(string? , 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.IFormatProvider provider, 
#if NETCOREAPP3_0_OR_GREATER
[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
#endif
        out MyVoInt result)
        {
            if (System.Int32.TryParse(s, provider, out var __v))
            {
                result = new MyVoInt(__v);
                return true;
            }

            result = default;
            return false;
        }

        /// <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 MyVoInt result)
        {
            if (System.Int32.TryParse(s, out var __v))
            {
                result = new MyVoInt(__v);
                return true;
            }

            result = default;
            return false;
        }

        /// <inheritdoc cref = "int.Parse(System.ReadOnlySpan{byte}, 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 MyVoInt Parse(global::System.ReadOnlySpan<byte> utf8Text, global::System.Globalization.NumberStyles style, global::System.IFormatProvider provider)
        {
            var r = System.Int32.Parse(utf8Text, style, provider);
            return From(r);
        }

        /// <inheritdoc cref = "int.Parse(System.ReadOnlySpan{byte}, 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 MyVoInt Parse(global::System.ReadOnlySpan<byte> utf8Text, global::System.IFormatProvider provider)
        {
            var r = System.Int32.Parse(utf8Text, provider);
            return From(r);
        }

        /// <inheritdoc cref = "int.Parse(System.ReadOnlySpan{char}, 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 MyVoInt Parse(global::System.ReadOnlySpan<char> s, global::System.Globalization.NumberStyles style, global::System.IFormatProvider provider)
        {
            var r = System.Int32.Parse(s, style, provider);
            return From(r);
        }

        /// <inheritdoc cref = "int.Parse(System.ReadOnlySpan{char}, 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 MyVoInt Parse(global::System.ReadOnlySpan<char> s, global::System.IFormatProvider provider)
        {
            var r = System.Int32.Parse(s, provider);
            return From(r);
        }

        /// <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 MyVoInt 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 MyVoInt Parse(string s, global::System.Globalization.NumberStyles style)
        {
            var r = System.Int32.Parse(s, style);
            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 MyVoInt Parse(string s, global::System.Globalization.NumberStyles style, global::System.IFormatProvider provider)
        {
            var r = System.Int32.Parse(s, style, provider);
            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 MyVoInt Parse(string s, global::System.IFormatProvider provider)
        {
            var r = System.Int32.Parse(s, provider);
            return From(r);
        }

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

        /// <inheritdoc cref = "int.TryFormat(System.Span{char}, out int, System.ReadOnlySpan{char}, System.IFormatProvider? )"/>
        public bool TryFormat(global::System.Span<char> destination, out int charsWritten, [System.Diagnostics.CodeAnalysis.StringSyntaxAttribute("NumericFormat")] global::System.ReadOnlySpan<char> format, global::System.IFormatProvider provider)
        {
            charsWritten = default;
            return IsInitialized() ? Value.TryFormat(destination, out charsWritten, format, provider) : true;
        }

        /// <inheritdoc cref = "int.TryFormat(System.Span{byte}, out int, System.ReadOnlySpan{char}, System.IFormatProvider? )"/>
        public bool TryFormat(global::System.Span<byte> utf8Destination, out int bytesWritten, [System.Diagnostics.CodeAnalysis.StringSyntaxAttribute("NumericFormat")] global::System.ReadOnlySpan<char> format, global::System.IFormatProvider provider)
        {
            bytesWritten = default;
            return IsInitialized() ? Value.TryFormat(utf8Destination, out bytesWritten, format, provider) : true;
        }

#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(System.IFormatProvider? )"/>
        public global::System.String ToString(global::System.IFormatProvider provider) => IsInitialized() ? Value.ToString(provider) ?? "" : "[UNINITIALIZED]";
        /// <inheritdoc cref = "System.Int32.ToString(string? )"/>
        public global::System.String ToString([System.Diagnostics.CodeAnalysis.StringSyntaxAttribute("NumericFormat")] string format) => IsInitialized() ? Value.ToString(format) ?? "" : "[UNINITIALIZED]";
#nullable disable
        /// <summary>
        /// Converts a MyVoInt to or from JSON.
        /// </summary>
        public class MyVoIntSystemTextJsonConverter : global::System.Text.Json.Serialization.JsonConverter<MyVoInt>
        {
            public override MyVoInt 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, MyVoInt 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 MyVoInt 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, MyVoInt 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 MyVoInt DeserializeJson(System.Int32 value)
            {
                return new MyVoInt(value);
            }
        }

#nullable restore
#nullable disable
        class MyVoIntTypeConverter : 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 => MyVoInt.__Deserialize(intValue),
                    global::System.String stringValue when !global::System.String.IsNullOrEmpty(stringValue) && global::System.Int32.TryParse(stringValue, out var result) => MyVoInt.__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 MyVoInt 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 MyVoIntDebugView
        {
            private readonly MyVoInt _t;
            MyVoIntDebugView(MyVoInt 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(MyVoIntSystemTextJsonConverter))]
[global::System.ComponentModel.TypeConverter(typeof(MyVoIntTypeConverter))]
";
        }

        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 MyNamespace
{
    [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
        [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Vogen", "1.0.0.0")]
    [global::System.Text.Json.Serialization.JsonConverter(typeof(MyVoFloatSystemTextJsonConverter))]
    [global::System.ComponentModel.TypeConverter(typeof(MyVoFloatTypeConverter))]
    [global::System.Diagnostics.DebuggerTypeProxyAttribute(typeof(MyVoFloatDebugView))]
    [global::System.Diagnostics.DebuggerDisplayAttribute("Underlying type: System.Single, Value = { _value }")]
    public partial class MyVoFloat : global::System.IEquatable<MyVoFloat>, global::System.IEquatable<System.Single>, global::System.IComparable<MyVoFloat>, global::System.IComparable, global::System.IParsable<MyVoFloat>, global::System.ISpanParsable<MyVoFloat>, global::System.IUtf8SpanParsable<MyVoFloat>, global::System.IFormattable, global::System.ISpanFormattable, global::System.IUtf8SpanFormattable
    {
#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.Single _value;
        /// <summary>
        /// Gets the underlying <see cref = "System.Single"/> value if set, otherwise a <see cref = "Vogen.ValueObjectValidationException"/> is thrown.
        /// </summary>
        public System.Single 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 MyVoFloat()
        {
#if DEBUG
            _stackTrace = new global::System.Diagnostics.StackTrace();
#endif
#if !VOGEN_NO_VALIDATION
            _isInitialized = false;
#endif
            _value = default;
        }

        [global::System.Diagnostics.DebuggerStepThroughAttribute]
        private MyVoFloat(System.Single 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 MyVoFloat From(System.Single value)
        {
            return new MyVoFloat(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.Single value, 
#if NETCOREAPP3_0_OR_GREATER
[global::System.Diagnostics.CodeAnalysis.MaybeNullWhen(false)]
#endif
        out MyVoFloat 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 MyVoFloat(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<MyVoFloat> TryFrom(System.Single value)
        {
            return new Vogen.ValueObjectOrError<MyVoFloat>(new MyVoFloat(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 MyVoFloat __Deserialize(System.Single value)
        {
            return new MyVoFloat(value);
        }

        public global::System.Boolean Equals(MyVoFloat 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.Single>.Default.Equals(Value, other.Value);
        }

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

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

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

        public static global::System.Boolean operator ==(MyVoFloat left, MyVoFloat right) => Equals(left, right);
        public static global::System.Boolean operator !=(MyVoFloat left, MyVoFloat right) => !Equals(left, right);
        public static global::System.Boolean operator ==(MyVoFloat left, System.Single right) => left.Value.Equals(right);
        public static global::System.Boolean operator ==(System.Single left, MyVoFloat right) => right.Value.Equals(left);
        public static global::System.Boolean operator !=(System.Single left, MyVoFloat right) => !(left == right);
        public static global::System.Boolean operator !=(MyVoFloat left, System.Single right) => !(left == right);
        public static explicit operator MyVoFloat(System.Single value) => From(value);
        public static explicit operator System.Single(MyVoFloat value) => value.Value;
        public int CompareTo(MyVoFloat 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 MyVoFloat x)
                return CompareTo(x);
            ThrowHelper.ThrowArgumentException("Cannot compare to object as it is not of type MyVoFloat", nameof(other));
            return 0;
        }

        /// <inheritdoc cref = "float.TryParse(System.ReadOnlySpan{byte}, System.Globalization.NumberStyles, System.IFormatProvider? , out float)"/>
        /// <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(global::System.ReadOnlySpan<byte> utf8Text, global::System.Globalization.NumberStyles style, global::System.IFormatProvider provider, 
#if NETCOREAPP3_0_OR_GREATER
[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
#endif
        out MyVoFloat result)
        {
            if (System.Single.TryParse(utf8Text, style, provider, out var __v))
            {
                result = new MyVoFloat(__v);
                return true;
            }

            result = default;
            return false;
        }

        /// <inheritdoc cref = "float.TryParse(System.ReadOnlySpan{byte}, System.IFormatProvider? , out float)"/>
        /// <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(global::System.ReadOnlySpan<byte> utf8Text, global::System.IFormatProvider provider, 
#if NETCOREAPP3_0_OR_GREATER
[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
#endif
        out MyVoFloat result)
        {
            if (System.Single.TryParse(utf8Text, provider, out var __v))
            {
                result = new MyVoFloat(__v);
                return true;
            }

            result = default;
            return false;
        }

        /// <inheritdoc cref = "float.TryParse(System.ReadOnlySpan{byte}, out float)"/>
        /// <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(global::System.ReadOnlySpan<byte> utf8Text, 
#if NETCOREAPP3_0_OR_GREATER
[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
#endif
        out MyVoFloat result)
        {
            if (System.Single.TryParse(utf8Text, out var __v))
            {
                result = new MyVoFloat(__v);
                return true;
            }

            result = default;
            return false;
        }

        /// <inheritdoc cref = "float.TryParse(System.ReadOnlySpan{char}, System.Globalization.NumberStyles, System.IFormatProvider? , out float)"/>
        /// <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(global::System.ReadOnlySpan<char> s, global::System.Globalization.NumberStyles style, global::System.IFormatProvider provider, 
#if NETCOREAPP3_0_OR_GREATER
[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
#endif
        out MyVoFloat result)
        {
            if (System.Single.TryParse(s, style, provider, out var __v))
            {
                result = new MyVoFloat(__v);
                return true;
            }

            result = default;
            return false;
        }

        /// <inheritdoc cref = "float.TryParse(System.ReadOnlySpan{char}, System.IFormatProvider? , out float)"/>
        /// <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(global::System.ReadOnlySpan<char> s, global::System.IFormatProvider provider, 
#if NETCOREAPP3_0_OR_GREATER
[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
#endif
        out MyVoFloat result)
        {
            if (System.Single.TryParse(s, provider, out var __v))
            {
                result = new MyVoFloat(__v);
                return true;
            }

            result = default;
            return false;
        }

        /// <inheritdoc cref = "float.TryParse(System.ReadOnlySpan{char}, out float)"/>
        /// <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(global::System.ReadOnlySpan<char> s, 
#if NETCOREAPP3_0_OR_GREATER
[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
#endif
        out MyVoFloat result)
        {
            if (System.Single.TryParse(s, out var __v))
            {
                result = new MyVoFloat(__v);
                return true;
            }

            result = default;
            return false;
        }

        /// <inheritdoc cref = "float.TryParse(string? , System.Globalization.NumberStyles, System.IFormatProvider? , out float)"/>
        /// <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 MyVoFloat result)
        {
            if (System.Single.TryParse(s, style, provider, out var __v))
            {
                result = new MyVoFloat(__v);
                return true;
            }

            result = default;
            return false;
        }

        /// <inheritdoc cref = "float.TryParse(string? , System.IFormatProvider? , out float)"/>
        /// <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.IFormatProvider provider, 
#if NETCOREAPP3_0_OR_GREATER
[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
#endif
        out MyVoFloat result)
        {
            if (System.Single.TryParse(s, provider, out var __v))
            {
                result = new MyVoFloat(__v);
                return true;
            }

            result = default;
            return false;
        }

        /// <inheritdoc cref = "float.TryParse(string? , out float)"/>
        /// <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 MyVoFloat result)
        {
            if (System.Single.TryParse(s, out var __v))
            {
                result = new MyVoFloat(__v);
                return true;
            }

            result = default;
            return false;
        }

        /// <inheritdoc cref = "float.Parse(System.ReadOnlySpan{byte}, 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 MyVoFloat Parse(global::System.ReadOnlySpan<byte> utf8Text, global::System.Globalization.NumberStyles style, global::System.IFormatProvider provider)
        {
            var r = System.Single.Parse(utf8Text, style, provider);
            return From(r);
        }

        /// <inheritdoc cref = "float.Parse(System.ReadOnlySpan{byte}, 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 MyVoFloat Parse(global::System.ReadOnlySpan<byte> utf8Text, global::System.IFormatProvider provider)
        {
            var r = System.Single.Parse(utf8Text, provider);
            return From(r);
        }

        /// <inheritdoc cref = "float.Parse(System.ReadOnlySpan{char}, 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 MyVoFloat Parse(global::System.ReadOnlySpan<char> s, global::System.Globalization.NumberStyles style, global::System.IFormatProvider provider)
        {
            var r = System.Single.Parse(s, style, provider);
            return From(r);
        }

        /// <inheritdoc cref = "float.Parse(System.ReadOnlySpan{char}, 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 MyVoFloat Parse(global::System.ReadOnlySpan<char> s, global::System.IFormatProvider provider)
        {
            var r = System.Single.Parse(s, provider);
            return From(r);
        }

        /// <inheritdoc cref = "float.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 MyVoFloat Parse(string s)
        {
            var r = System.Single.Parse(s);
            return From(r);
        }

        /// <inheritdoc cref = "float.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 MyVoFloat Parse(string s, global::System.Globalization.NumberStyles style)
        {
            var r = System.Single.Parse(s, style);
            return From(r);
        }

        /// <inheritdoc cref = "float.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 MyVoFloat Parse(string s, global::System.Globalization.NumberStyles style, global::System.IFormatProvider provider)
        {
            var r = System.Single.Parse(s, style, provider);
            return From(r);
        }

        /// <inheritdoc cref = "float.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 MyVoFloat Parse(string s, global::System.IFormatProvider provider)
        {
            var r = System.Single.Parse(s, provider);
            return From(r);
        }

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

        /// <inheritdoc cref = "float.TryFormat(System.Span{char}, out int, System.ReadOnlySpan{char}, System.IFormatProvider? )"/>
        public bool TryFormat(global::System.Span<char> destination, out int charsWritten, [System.Diagnostics.CodeAnalysis.StringSyntaxAttribute("NumericFormat")] global::System.ReadOnlySpan<char> format, global::System.IFormatProvider provider)
        {
            charsWritten = default;
            return IsInitialized() ? Value.TryFormat(destination, out charsWritten, format, provider) : true;
        }

        /// <inheritdoc cref = "float.TryFormat(System.Span{byte}, out int, System.ReadOnlySpan{char}, System.IFormatProvider? )"/>
        public bool TryFormat(global::System.Span<byte> utf8Destination, out int bytesWritten, [System.Diagnostics.CodeAnalysis.StringSyntaxAttribute("NumericFormat")] global::System.ReadOnlySpan<char> format, global::System.IFormatProvider provider)
        {
            bytesWritten = default;
            return IsInitialized() ? Value.TryFormat(utf8Destination, out bytesWritten, format, provider) : true;
        }

#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.Single>.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.Single.ToString()"/>
        public override global::System.String ToString() => IsInitialized() ? Value.ToString() ?? "" : "[UNINITIALIZED]";
        /// <inheritdoc cref = "System.Single.ToString(System.IFormatProvider? )"/>
        public global::System.String ToString(global::System.IFormatProvider provider) => IsInitialized() ? Value.ToString(provider) ?? "" : "[UNINITIALIZED]";
        /// <inheritdoc cref = "System.Single.ToString(string? )"/>
        public global::System.String ToString([System.Diagnostics.CodeAnalysis.StringSyntaxAttribute("NumericFormat")] string format) => IsInitialized() ? Value.ToString(format) ?? "" : "[UNINITIALIZED]";
#nullable disable
        /// <summary>
        /// Converts a MyVoFloat to or from JSON.
        /// </summary>
        public class MyVoFloatSystemTextJsonConverter : global::System.Text.Json.Serialization.JsonConverter<MyVoFloat>
        {
            public override MyVoFloat 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.Single>)options.GetTypeInfo(typeof(global::System.Single))));
#else
                return DeserializeJson(reader.GetSingle());
#endif
            }

            public override void Write(System.Text.Json.Utf8JsonWriter writer, MyVoFloat 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 MyVoFloat ReadAsPropertyName(ref global::System.Text.Json.Utf8JsonReader reader, global::System.Type typeToConvert, global::System.Text.Json.JsonSerializerOptions options)
            {
                return DeserializeJson(global::System.Single.Parse(reader.GetString(), global::System.Globalization.NumberStyles.Any, global::System.Globalization.CultureInfo.InvariantCulture));
            }

            public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, MyVoFloat 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 MyVoFloat DeserializeJson(System.Single value)
            {
                return new MyVoFloat(value);
            }
        }

#nullable restore
#nullable disable
        class MyVoFloatTypeConverter : global::System.ComponentModel.TypeConverter
        {
            public override global::System.Boolean CanConvertFrom(global::System.ComponentModel.ITypeDescriptorContext context, global::System.Type sourceType)
            {
                return sourceType == typeof(global::System.Single) || 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.Single floatValue => MyVoFloat.__Deserialize(floatValue),
                    global::System.String stringValue when !global::System.String.IsNullOrEmpty(stringValue) && global::System.Single.TryParse(stringValue, global::System.Globalization.NumberStyles.Float | global::System.Globalization.NumberStyles.AllowThousands, culture.NumberFormat, out var result) => MyVoFloat.__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.Single) || 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 MyVoFloat idValue)
                {
                    if (destinationType == typeof(global::System.Single))
                    {
                        return idValue.Value;
                    }

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

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

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

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

        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 MyNamespace
{
    [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
        [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Vogen", "1.0.0.0")]
    [global::System.Text.Json.Serialization.JsonConverter(typeof(MyVoDecimalSystemTextJsonConverter))]
    [global::System.ComponentModel.TypeConverter(typeof(MyVoDecimalTypeConverter))]
    [global::System.Diagnostics.DebuggerTypeProxyAttribute(typeof(MyVoDecimalDebugView))]
    [global::System.Diagnostics.DebuggerDisplayAttribute("Underlying type: System.Decimal, Value = { _value }")]
    public partial class MyVoDecimal : global::System.IEquatable<MyVoDecimal>, global::System.IEquatable<System.Decimal>, global::System.IComparable<MyVoDecimal>, global::System.IComparable, global::System.IParsable<MyVoDecimal>, global::System.ISpanParsable<MyVoDecimal>, global::System.IUtf8SpanParsable<MyVoDecimal>, global::System.IFormattable, global::System.ISpanFormattable, global::System.IUtf8SpanFormattable
    {
#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.Decimal _value;
        /// <summary>
        /// Gets the underlying <see cref = "System.Decimal"/> value if set, otherwise a <see cref = "Vogen.ValueObjectValidationException"/> is thrown.
        /// </summary>
        public System.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 MyVoDecimal()
        {
#if DEBUG
            _stackTrace = new global::System.Diagnostics.StackTrace();
#endif
#if !VOGEN_NO_VALIDATION
            _isInitialized = false;
#endif
            _value = default;
        }

        [global::System.Diagnostics.DebuggerStepThroughAttribute]
        private MyVoDecimal(System.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 MyVoDecimal From(System.Decimal value)
        {
            return new MyVoDecimal(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.Decimal value, 
#if NETCOREAPP3_0_OR_GREATER
[global::System.Diagnostics.CodeAnalysis.MaybeNullWhen(false)]
#endif
        out MyVoDecimal 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 MyVoDecimal(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<MyVoDecimal> TryFrom(System.Decimal value)
        {
            return new Vogen.ValueObjectOrError<MyVoDecimal>(new MyVoDecimal(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 MyVoDecimal __Deserialize(System.Decimal value)
        {
            return new MyVoDecimal(value);
        }

        public global::System.Boolean Equals(MyVoDecimal 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.Decimal>.Default.Equals(Value, other.Value);
        }

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

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

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

        public static global::System.Boolean operator ==(MyVoDecimal left, MyVoDecimal right) => Equals(left, right);
        public static global::System.Boolean operator !=(MyVoDecimal left, MyVoDecimal right) => !Equals(left, right);
        public static global::System.Boolean operator ==(MyVoDecimal left, System.Decimal right) => left.Value.Equals(right);
        public static global::System.Boolean operator ==(System.Decimal left, MyVoDecimal right) => right.Value.Equals(left);
        public static global::System.Boolean operator !=(System.Decimal left, MyVoDecimal right) => !(left == right);
        public static global::System.Boolean operator !=(MyVoDecimal left, System.Decimal right) => !(left == right);
        public static explicit operator MyVoDecimal(System.Decimal value) => From(value);
        public static explicit operator System.Decimal(MyVoDecimal value) => value.Value;
        public int CompareTo(MyVoDecimal 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 MyVoDecimal x)
                return CompareTo(x);
            ThrowHelper.ThrowArgumentException("Cannot compare to object as it is not of type MyVoDecimal", nameof(other));
            return 0;
        }

        /// <inheritdoc cref = "decimal.TryParse(System.ReadOnlySpan{byte}, out decimal)"/>
        /// <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(global::System.ReadOnlySpan<byte> utf8Text, 
#if NETCOREAPP3_0_OR_GREATER
[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
#endif
        out MyVoDecimal result)
        {
            if (System.Decimal.TryParse(utf8Text, out var __v))
            {
                result = new MyVoDecimal(__v);
                return true;
            }

            result = default;
            return false;
        }

        /// <inheritdoc cref = "decimal.TryParse(System.ReadOnlySpan{byte}, System.Globalization.NumberStyles, System.IFormatProvider? , out decimal)"/>
        /// <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(global::System.ReadOnlySpan<byte> utf8Text, global::System.Globalization.NumberStyles style, global::System.IFormatProvider provider, 
#if NETCOREAPP3_0_OR_GREATER
[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
#endif
        out MyVoDecimal result)
        {
            if (System.Decimal.TryParse(utf8Text, style, provider, out var __v))
            {
                result = new MyVoDecimal(__v);
                return true;
            }

            result = default;
            return false;
        }

        /// <inheritdoc cref = "decimal.TryParse(System.ReadOnlySpan{byte}, System.IFormatProvider? , out decimal)"/>
        /// <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(global::System.ReadOnlySpan<byte> utf8Text, global::System.IFormatProvider provider, 
#if NETCOREAPP3_0_OR_GREATER
[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
#endif
        out MyVoDecimal result)
        {
            if (System.Decimal.TryParse(utf8Text, provider, out var __v))
            {
                result = new MyVoDecimal(__v);
                return true;
            }

            result = default;
            return false;
        }

        /// <inheritdoc cref = "decimal.TryParse(System.ReadOnlySpan{char}, out decimal)"/>
        /// <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(global::System.ReadOnlySpan<char> s, 
#if NETCOREAPP3_0_OR_GREATER
[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
#endif
        out MyVoDecimal result)
        {
            if (System.Decimal.TryParse(s, out var __v))
            {
                result = new MyVoDecimal(__v);
                return true;
            }

            result = default;
            return false;
        }

        /// <inheritdoc cref = "decimal.TryParse(System.ReadOnlySpan{char}, System.Globalization.NumberStyles, System.IFormatProvider? , out decimal)"/>
        /// <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(global::System.ReadOnlySpan<char> s, global::System.Globalization.NumberStyles style, global::System.IFormatProvider provider, 
#if NETCOREAPP3_0_OR_GREATER
[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
#endif
        out MyVoDecimal result)
        {
            if (System.Decimal.TryParse(s, style, provider, out var __v))
            {
                result = new MyVoDecimal(__v);
                return true;
            }

            result = default;
            return false;
        }

        /// <inheritdoc cref = "decimal.TryParse(System.ReadOnlySpan{char}, System.IFormatProvider? , out decimal)"/>
        /// <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(global::System.ReadOnlySpan<char> s, global::System.IFormatProvider provider, 
#if NETCOREAPP3_0_OR_GREATER
[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
#endif
        out MyVoDecimal result)
        {
            if (System.Decimal.TryParse(s, provider, out var __v))
            {
                result = new MyVoDecimal(__v);
                return true;
            }

            result = default;
            return false;
        }

        /// <inheritdoc cref = "decimal.TryParse(string? , out decimal)"/>
        /// <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 MyVoDecimal result)
        {
            if (System.Decimal.TryParse(s, out var __v))
            {
                result = new MyVoDecimal(__v);
                return true;
            }

            result = default;
            return false;
        }

        /// <inheritdoc cref = "decimal.TryParse(string? , System.Globalization.NumberStyles, System.IFormatProvider? , out decimal)"/>
        /// <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 MyVoDecimal result)
        {
            if (System.Decimal.TryParse(s, style, provider, out var __v))
            {
                result = new MyVoDecimal(__v);
                return true;
            }

            result = default;
            return false;
        }

        /// <inheritdoc cref = "decimal.TryParse(string? , System.IFormatProvider? , out decimal)"/>
        /// <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.IFormatProvider provider, 
#if NETCOREAPP3_0_OR_GREATER
[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
#endif
        out MyVoDecimal result)
        {
            if (System.Decimal.TryParse(s, provider, out var __v))
            {
                result = new MyVoDecimal(__v);
                return true;
            }

            result = default;
            return false;
        }

        /// <inheritdoc cref = "decimal.Parse(System.ReadOnlySpan{byte}, 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 MyVoDecimal Parse(global::System.ReadOnlySpan<byte> utf8Text, global::System.Globalization.NumberStyles style, global::System.IFormatProvider provider)
        {
            var r = System.Decimal.Parse(utf8Text, style, provider);
            return From(r);
        }

        /// <inheritdoc cref = "decimal.Parse(System.ReadOnlySpan{byte}, 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 MyVoDecimal Parse(global::System.ReadOnlySpan<byte> utf8Text, global::System.IFormatProvider provider)
        {
            var r = System.Decimal.Parse(utf8Text, provider);
            return From(r);
        }

        /// <inheritdoc cref = "decimal.Parse(System.ReadOnlySpan{char}, 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 MyVoDecimal Parse(global::System.ReadOnlySpan<char> s, global::System.Globalization.NumberStyles style, global::System.IFormatProvider provider)
        {
            var r = System.Decimal.Parse(s, style, provider);
            return From(r);
        }

        /// <inheritdoc cref = "decimal.Parse(System.ReadOnlySpan{char}, 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 MyVoDecimal Parse(global::System.ReadOnlySpan<char> s, global::System.IFormatProvider provider)
        {
            var r = System.Decimal.Parse(s, provider);
            return From(r);
        }

        /// <inheritdoc cref = "decimal.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 MyVoDecimal Parse(string s)
        {
            var r = System.Decimal.Parse(s);
            return From(r);
        }

        /// <inheritdoc cref = "decimal.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 MyVoDecimal Parse(string s, global::System.Globalization.NumberStyles style)
        {
            var r = System.Decimal.Parse(s, style);
            return From(r);
        }

        /// <inheritdoc cref = "decimal.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 MyVoDecimal Parse(string s, global::System.Globalization.NumberStyles style, global::System.IFormatProvider provider)
        {
            var r = System.Decimal.Parse(s, style, provider);
            return From(r);
        }

        /// <inheritdoc cref = "decimal.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 MyVoDecimal Parse(string s, global::System.IFormatProvider provider)
        {
            var r = System.Decimal.Parse(s, provider);
            return From(r);
        }

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

        /// <inheritdoc cref = "decimal.TryFormat(System.Span{char}, out int, System.ReadOnlySpan{char}, System.IFormatProvider? )"/>
        public bool TryFormat(global::System.Span<char> destination, out int charsWritten, [System.Diagnostics.CodeAnalysis.StringSyntaxAttribute("NumericFormat")] global::System.ReadOnlySpan<char> format, global::System.IFormatProvider provider)
        {
            charsWritten = default;
            return IsInitialized() ? Value.TryFormat(destination, out charsWritten, format, provider) : true;
        }

        /// <inheritdoc cref = "decimal.TryFormat(System.Span{byte}, out int, System.ReadOnlySpan{char}, System.IFormatProvider? )"/>
        public bool TryFormat(global::System.Span<byte> utf8Destination, out int bytesWritten, [System.Diagnostics.CodeAnalysis.StringSyntaxAttribute("NumericFormat")] global::System.ReadOnlySpan<char> format, global::System.IFormatProvider provider)
        {
            bytesWritten = default;
            return IsInitialized() ? Value.TryFormat(utf8Destination, out bytesWritten, format, provider) : true;
        }

#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.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 = "System.Decimal.ToString()"/>
        public override global::System.String ToString() => IsInitialized() ? Value.ToString() ?? "" : "[UNINITIALIZED]";
        /// <inheritdoc cref = "System.Decimal.ToString(System.IFormatProvider? )"/>
        public global::System.String ToString(global::System.IFormatProvider provider) => IsInitialized() ? Value.ToString(provider) ?? "" : "[UNINITIALIZED]";
        /// <inheritdoc cref = "System.Decimal.ToString(string? )"/>
        public global::System.String ToString([System.Diagnostics.CodeAnalysis.StringSyntaxAttribute("NumericFormat")] string format) => IsInitialized() ? Value.ToString(format) ?? "" : "[UNINITIALIZED]";
#nullable disable
        /// <summary>
        /// Converts a MyVoDecimal to or from JSON.
        /// </summary>
        public class MyVoDecimalSystemTextJsonConverter : global::System.Text.Json.Serialization.JsonConverter<MyVoDecimal>
        {
            public override MyVoDecimal Read(ref global::System.Text.Json.Utf8JsonReader reader, global::System.Type typeToConvert, global::System.Text.Json.JsonSerializerOptions options)
            {
#if NET5_0_OR_GREATER
                return __DeserializeSystemTextJson(global::System.Text.Json.JsonSerializer.Deserialize(ref reader, (global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Decimal>)options.GetTypeInfo(typeof(global::System.Decimal))));
#else
                return __DeserializeSystemTextJson(reader.GetDecimal());
#endif
            }

            public override void Write(System.Text.Json.Utf8JsonWriter writer, MyVoDecimal 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 MyVoDecimal ReadAsPropertyName(ref global::System.Text.Json.Utf8JsonReader reader, global::System.Type typeToConvert, global::System.Text.Json.JsonSerializerOptions options)
            {
                return __DeserializeSystemTextJson(global::System.Decimal.Parse(reader.GetString(), global::System.Globalization.NumberStyles.Any, global::System.Globalization.CultureInfo.InvariantCulture));
            }

            public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, MyVoDecimal value, global::System.Text.Json.JsonSerializerOptions options)
            {
                writer.WritePropertyName(value.Value.ToString(global::System.Globalization.CultureInfo.InvariantCulture));
            }
#endif
            private static MyVoDecimal __DeserializeSystemTextJson(System.Decimal value)
            {
                try
                {
                    return MyVoDecimal.__Deserialize(value);
                }
                catch (System.Exception e)
                {
                    throw new global::System.Text.Json.JsonException(null, e);
                }
            }
        }

#nullable restore
#nullable disable
        class MyVoDecimalTypeConverter : global::System.ComponentModel.TypeConverter
        {
            public override global::System.Boolean CanConvertFrom(global::System.ComponentModel.ITypeDescriptorContext context, global::System.Type sourceType)
            {
                return sourceType == typeof(global::System.Decimal) || 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.Decimal decimalValue => MyVoDecimal.__Deserialize(decimalValue),
                    global::System.String stringValue when !global::System.String.IsNullOrEmpty(stringValue) && global::System.Decimal.TryParse(stringValue, global::System.Globalization.NumberStyles.Number, culture.NumberFormat, out var result) => MyVoDecimal.__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.Decimal) || 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, System.Type destinationType)
            {
                if (value is MyVoDecimal idValue)
                {
                    if (destinationType == typeof(global::System.Decimal))
                    {
                        return idValue.Value;
                    }

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

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

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

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

        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 MyNamespace
{
    [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
        [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Vogen", "1.0.0.0")]
    [global::System.Text.Json.Serialization.JsonConverter(typeof(MyVoDoubleSystemTextJsonConverter))]
    [global::System.ComponentModel.TypeConverter(typeof(MyVoDoubleTypeConverter))]
    [global::System.Diagnostics.DebuggerTypeProxyAttribute(typeof(MyVoDoubleDebugView))]
    [global::System.Diagnostics.DebuggerDisplayAttribute("Underlying type: System.Double, Value = { _value }")]
    public partial class MyVoDouble : global::System.IEquatable<MyVoDouble>, global::System.IEquatable<System.Double>, global::System.IComparable<MyVoDouble>, global::System.IComparable, global::System.IParsable<MyVoDouble>, global::System.ISpanParsable<MyVoDouble>, global::System.IUtf8SpanParsable<MyVoDouble>, global::System.IFormattable, global::System.ISpanFormattable, global::System.IUtf8SpanFormattable
    {
#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.Double _value;
        /// <summary>
        /// Gets the underlying <see cref = "System.Double"/> value if set, otherwise a <see cref = "Vogen.ValueObjectValidationException"/> is thrown.
        /// </summary>
        public System.Double 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 MyVoDouble()
        {
#if DEBUG
            _stackTrace = new global::System.Diagnostics.StackTrace();
#endif
#if !VOGEN_NO_VALIDATION
            _isInitialized = false;
#endif
            _value = default;
        }

        [global::System.Diagnostics.DebuggerStepThroughAttribute]
        private MyVoDouble(System.Double 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 MyVoDouble From(System.Double value)
        {
            return new MyVoDouble(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.Double value, 
#if NETCOREAPP3_0_OR_GREATER
[global::System.Diagnostics.CodeAnalysis.MaybeNullWhen(false)]
#endif
        out MyVoDouble 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 MyVoDouble(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<MyVoDouble> TryFrom(System.Double value)
        {
            return new Vogen.ValueObjectOrError<MyVoDouble>(new MyVoDouble(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 MyVoDouble __Deserialize(System.Double value)
        {
            return new MyVoDouble(value);
        }

        public global::System.Boolean Equals(MyVoDouble 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.Double>.Default.Equals(Value, other.Value);
        }

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

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

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

        public static global::System.Boolean operator ==(MyVoDouble left, MyVoDouble right) => Equals(left, right);
        public static global::System.Boolean operator !=(MyVoDouble left, MyVoDouble right) => !Equals(left, right);
        public static global::System.Boolean operator ==(MyVoDouble left, System.Double right) => left.Value.Equals(right);
        public static global::System.Boolean operator ==(System.Double left, MyVoDouble right) => right.Value.Equals(left);
        public static global::System.Boolean operator !=(System.Double left, MyVoDouble right) => !(left == right);
        public static global::System.Boolean operator !=(MyVoDouble left, System.Double right) => !(left == right);
        public static explicit operator MyVoDouble(System.Double value) => From(value);
        public static explicit operator System.Double(MyVoDouble value) => value.Value;
        public int CompareTo(MyVoDouble 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 MyVoDouble x)
                return CompareTo(x);
            ThrowHelper.ThrowArgumentException("Cannot compare to object as it is not of type MyVoDouble", nameof(other));
            return 0;
        }

        /// <inheritdoc cref = "double.TryParse(System.ReadOnlySpan{byte}, out double)"/>
        /// <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(global::System.ReadOnlySpan<byte> utf8Text, 
#if NETCOREAPP3_0_OR_GREATER
[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
#endif
        out MyVoDouble result)
        {
            if (System.Double.TryParse(utf8Text, out var __v))
            {
                result = new MyVoDouble(__v);
                return true;
            }

            result = default;
            return false;
        }

        /// <inheritdoc cref = "double.TryParse(System.ReadOnlySpan{byte}, System.Globalization.NumberStyles, System.IFormatProvider? , out double)"/>
        /// <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(global::System.ReadOnlySpan<byte> utf8Text, global::System.Globalization.NumberStyles style, global::System.IFormatProvider provider, 
#if NETCOREAPP3_0_OR_GREATER
[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
#endif
        out MyVoDouble result)
        {
            if (System.Double.TryParse(utf8Text, style, provider, out var __v))
            {
                result = new MyVoDouble(__v);
                return true;
            }

            result = default;
            return false;
        }

        /// <inheritdoc cref = "double.TryParse(System.ReadOnlySpan{byte}, System.IFormatProvider? , out double)"/>
        /// <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(global::System.ReadOnlySpan<byte> utf8Text, global::System.IFormatProvider provider, 
#if NETCOREAPP3_0_OR_GREATER
[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
#endif
        out MyVoDouble result)
        {
            if (System.Double.TryParse(utf8Text, provider, out var __v))
            {
                result = new MyVoDouble(__v);
                return true;
            }

            result = default;
            return false;
        }

        /// <inheritdoc cref = "double.TryParse(System.ReadOnlySpan{char}, out double)"/>
        /// <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(global::System.ReadOnlySpan<char> s, 
#if NETCOREAPP3_0_OR_GREATER
[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
#endif
        out MyVoDouble result)
        {
            if (System.Double.TryParse(s, out var __v))
            {
                result = new MyVoDouble(__v);
                return true;
            }

            result = default;
            return false;
        }

        /// <inheritdoc cref = "double.TryParse(System.ReadOnlySpan{char}, System.Globalization.NumberStyles, System.IFormatProvider? , out double)"/>
        /// <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(global::System.ReadOnlySpan<char> s, global::System.Globalization.NumberStyles style, global::System.IFormatProvider provider, 
#if NETCOREAPP3_0_OR_GREATER
[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
#endif
        out MyVoDouble result)
        {
            if (System.Double.TryParse(s, style, provider, out var __v))
            {
                result = new MyVoDouble(__v);
                return true;
            }

            result = default;
            return false;
        }

        /// <inheritdoc cref = "double.TryParse(System.ReadOnlySpan{char}, System.IFormatProvider? , out double)"/>
        /// <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(global::System.ReadOnlySpan<char> s, global::System.IFormatProvider provider, 
#if NETCOREAPP3_0_OR_GREATER
[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
#endif
        out MyVoDouble result)
        {
            if (System.Double.TryParse(s, provider, out var __v))
            {
                result = new MyVoDouble(__v);
                return true;
            }

            result = default;
            return false;
        }

        /// <inheritdoc cref = "double.TryParse(string? , out double)"/>
        /// <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 MyVoDouble result)
        {
            if (System.Double.TryParse(s, out var __v))
            {
                result = new MyVoDouble(__v);
                return true;
            }

            result = default;
            return false;
        }

        /// <inheritdoc cref = "double.TryParse(string? , System.Globalization.NumberStyles, System.IFormatProvider? , out double)"/>
        /// <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 MyVoDouble result)
        {
            if (System.Double.TryParse(s, style, provider, out var __v))
            {
                result = new MyVoDouble(__v);
                return true;
            }

            result = default;
            return false;
        }

        /// <inheritdoc cref = "double.TryParse(string? , System.IFormatProvider? , out double)"/>
        /// <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.IFormatProvider provider, 
#if NETCOREAPP3_0_OR_GREATER
[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
#endif
        out MyVoDouble result)
        {
            if (System.Double.TryParse(s, provider, out var __v))
            {
                result = new MyVoDouble(__v);
                return true;
            }

            result = default;
            return false;
        }

        /// <inheritdoc cref = "double.Parse(System.ReadOnlySpan{byte}, 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 MyVoDouble Parse(global::System.ReadOnlySpan<byte> utf8Text, global::System.Globalization.NumberStyles style, global::System.IFormatProvider provider)
        {
            var r = System.Double.Parse(utf8Text, style, provider);
            return From(r);
        }

        /// <inheritdoc cref = "double.Parse(System.ReadOnlySpan{byte}, 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 MyVoDouble Parse(global::System.ReadOnlySpan<byte> utf8Text, global::System.IFormatProvider provider)
        {
            var r = System.Double.Parse(utf8Text, provider);
            return From(r);
        }

        /// <inheritdoc cref = "double.Parse(System.ReadOnlySpan{char}, 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 MyVoDouble Parse(global::System.ReadOnlySpan<char> s, global::System.Globalization.NumberStyles style, global::System.IFormatProvider provider)
        {
            var r = System.Double.Parse(s, style, provider);
            return From(r);
        }

        /// <inheritdoc cref = "double.Parse(System.ReadOnlySpan{char}, 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 MyVoDouble Parse(global::System.ReadOnlySpan<char> s, global::System.IFormatProvider provider)
        {
            var r = System.Double.Parse(s, provider);
            return From(r);
        }

        /// <inheritdoc cref = "double.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 MyVoDouble Parse(string s)
        {
            var r = System.Double.Parse(s);
            return From(r);
        }

        /// <inheritdoc cref = "double.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 MyVoDouble Parse(string s, global::System.Globalization.NumberStyles style)
        {
            var r = System.Double.Parse(s, style);
            return From(r);
        }

        /// <inheritdoc cref = "double.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 MyVoDouble Parse(string s, global::System.Globalization.NumberStyles style, global::System.IFormatProvider provider)
        {
            var r = System.Double.Parse(s, style, provider);
            return From(r);
        }

        /// <inheritdoc cref = "double.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 MyVoDouble Parse(string s, global::System.IFormatProvider provider)
        {
            var r = System.Double.Parse(s, provider);
            return From(r);
        }

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

        /// <inheritdoc cref = "double.TryFormat(System.Span{char}, out int, System.ReadOnlySpan{char}, System.IFormatProvider? )"/>
        public bool TryFormat(global::System.Span<char> destination, out int charsWritten, [System.Diagnostics.CodeAnalysis.StringSyntaxAttribute("NumericFormat")] global::System.ReadOnlySpan<char> format, global::System.IFormatProvider provider)
        {
            charsWritten = default;
            return IsInitialized() ? Value.TryFormat(destination, out charsWritten, format, provider) : true;
        }

        /// <inheritdoc cref = "double.TryFormat(System.Span{byte}, out int, System.ReadOnlySpan{char}, System.IFormatProvider? )"/>
        public bool TryFormat(global::System.Span<byte> utf8Destination, out int bytesWritten, [System.Diagnostics.CodeAnalysis.StringSyntaxAttribute("NumericFormat")] global::System.ReadOnlySpan<char> format, global::System.IFormatProvider provider)
        {
            bytesWritten = default;
            return IsInitialized() ? Value.TryFormat(utf8Destination, out bytesWritten, format, provider) : true;
        }

#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.Double>.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.Double.ToString()"/>
        public override global::System.String ToString() => IsInitialized() ? Value.ToString() ?? "" : "[UNINITIALIZED]";
        /// <inheritdoc cref = "System.Double.ToString(System.IFormatProvider? )"/>
        public global::System.String ToString(global::System.IFormatProvider provider) => IsInitialized() ? Value.ToString(provider) ?? "" : "[UNINITIALIZED]";
        /// <inheritdoc cref = "System.Double.ToString(string? )"/>
        public global::System.String ToString([System.Diagnostics.CodeAnalysis.StringSyntaxAttribute("NumericFormat")] string format) => IsInitialized() ? Value.ToString(format) ?? "" : "[UNINITIALIZED]";
#nullable disable
        /// <summary>
        /// Converts a MyVoDouble to or from JSON.
        /// </summary>
        public class MyVoDoubleSystemTextJsonConverter : global::System.Text.Json.Serialization.JsonConverter<MyVoDouble>
        {
            public override MyVoDouble Read(ref global::System.Text.Json.Utf8JsonReader reader, global::System.Type typeToConvert, global::System.Text.Json.JsonSerializerOptions options)
            {
#if NET5_0_OR_GREATER
                return __DeserializeSystemTextJson(global::System.Text.Json.JsonSerializer.Deserialize(ref reader, (global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Double>)options.GetTypeInfo(typeof(global::System.Double))));
#else
                return __DeserializeSystemTextJson(reader.GetDouble());
#endif
            }

            public override void Write(System.Text.Json.Utf8JsonWriter writer, MyVoDouble 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 MyVoDouble ReadAsPropertyName(ref global::System.Text.Json.Utf8JsonReader reader, global::System.Type typeToConvert, global::System.Text.Json.JsonSerializerOptions options)
            {
                return __DeserializeSystemTextJson(global::System.Double.Parse(reader.GetString(), global::System.Globalization.NumberStyles.Any, global::System.Globalization.CultureInfo.InvariantCulture));
            }

            public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, MyVoDouble value, global::System.Text.Json.JsonSerializerOptions options)
            {
                writer.WritePropertyName(value.Value.ToString(global::System.Globalization.CultureInfo.InvariantCulture));
            }
#endif
            private static MyVoDouble __DeserializeSystemTextJson(System.Double value)
            {
                try
                {
                    return MyVoDouble.__Deserialize(value);
                }
                catch (System.Exception e)
                {
                    throw new global::System.Text.Json.JsonException(null, e);
                }
            }
        }

#nullable restore
#nullable disable
        class MyVoDoubleTypeConverter : global::System.ComponentModel.TypeConverter
        {
            public override global::System.Boolean CanConvertFrom(global::System.ComponentModel.ITypeDescriptorContext context, global::System.Type sourceType)
            {
                return sourceType == typeof(global::System.Double) || 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.Double doubleValue => MyVoDouble.__Deserialize(doubleValue),
                    global::System.Int64 longValue => MyVoDouble.__Deserialize((global::System.Double)longValue),
                    global::System.String stringValue when !global::System.String.IsNullOrEmpty(stringValue) && global::System.Double.TryParse(stringValue, global::System.Globalization.NumberStyles.Float | global::System.Globalization.NumberStyles.AllowThousands, culture.NumberFormat, out var result) => MyVoDouble.__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.Double) || 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 MyVoDouble idValue)
                {
                    if (destinationType == typeof(global::System.Double))
                    {
                        return idValue.Value;
                    }

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

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

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

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

        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 MyNamespace
{
    [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
        [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Vogen", "1.0.0.0")]
    [global::System.Text.Json.Serialization.JsonConverter(typeof(MyVoStringSystemTextJsonConverter))]
    [global::System.ComponentModel.TypeConverter(typeof(MyVoStringTypeConverter))]
    [global::System.Diagnostics.DebuggerTypeProxyAttribute(typeof(MyVoStringDebugView))]
    [global::System.Diagnostics.DebuggerDisplayAttribute("Underlying type: System.String, Value = { _value }")]
    public partial class MyVoString : global::System.IEquatable<MyVoString>, global::System.IEquatable<System.String>, global::System.IComparable<MyVoString>, global::System.IComparable, global::System.IParsable<MyVoString>
    {
#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.String _value;
        /// <summary>
        /// Gets the underlying <see cref = "System.String"/> value if set, otherwise a <see cref = "Vogen.ValueObjectValidationException"/> is thrown.
        /// </summary>
        public System.String 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 MyVoString()
        {
#if DEBUG
            _stackTrace = new global::System.Diagnostics.StackTrace();
#endif
#if !VOGEN_NO_VALIDATION
            _isInitialized = false;
#endif
            _value = default;
        }

        [global::System.Diagnostics.DebuggerStepThroughAttribute]
        private MyVoString(System.String 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 MyVoString From(System.String value)
        {
            if (value is null)
            {
                ThrowHelper.ThrowWhenCreatedWithNull();
                return default !;
            }

            return new MyVoString(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.String value, 
#if NETCOREAPP3_0_OR_GREATER
[global::System.Diagnostics.CodeAnalysis.MaybeNullWhen(false)]
#endif
        out MyVoString vo)
#pragma warning restore CS8767 // Nullability of reference types in type of parameter doesn't match implicitly implemented member because of nullability attributes.

        {
            if (value is null)
            {
                vo = default;
                return false;
            }

            vo = new MyVoString(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<MyVoString> TryFrom(System.String value)
        {
            if (value is null)
            {
                return new Vogen.ValueObjectOrError<MyVoString>(Vogen.Validation.Invalid("The value provided was null"));
            }

            return new Vogen.ValueObjectOrError<MyVoString>(new MyVoString(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 MyVoString __Deserialize(System.String value)
        {
            if (value is null)
            {
                ThrowHelper.ThrowWhenCreatedWithNull();
                return default !;
            }

            return new MyVoString(value);
        }

        public global::System.Boolean Equals(MyVoString 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.String>.Default.Equals(Value, other.Value);
        }

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

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

        public global::System.Boolean Equals(System.String primitive, global::System.StringComparer comparer)
        {
            return comparer.Equals(Value, primitive);
        }

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

        public static global::System.Boolean operator ==(MyVoString left, MyVoString right) => Equals(left, right);
        public static global::System.Boolean operator !=(MyVoString left, MyVoString right) => !Equals(left, right);
        public static global::System.Boolean operator ==(MyVoString left, System.String right) => left.Value.Equals(right);
        public static global::System.Boolean operator ==(System.String left, MyVoString right) => right.Value.Equals(left);
        public static global::System.Boolean operator !=(System.String left, MyVoString right) => !(left == right);
        public static global::System.Boolean operator !=(MyVoString left, System.String right) => !(left == right);
        public static explicit operator MyVoString(System.String value) => From(value);
        public static explicit operator System.String(MyVoString value) => value.Value;
        public int CompareTo(MyVoString 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 MyVoString x)
                return CompareTo(x);
            ThrowHelper.ThrowArgumentException("Cannot compare to object as it is not of type MyVoString", nameof(other));
            return 0;
        }

        /// <summary>
        /// </summary>
        /// <returns>
        /// True if the value passes any validation (after running any optional normalization).
        /// </returns>
        public static global::System.Boolean TryParse(
#if NETCOREAPP3_0_OR_GREATER
[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
#endif
        global::System.String s, global::System.IFormatProvider provider, 
#if NETCOREAPP3_0_OR_GREATER
[global::System.Diagnostics.CodeAnalysis.MaybeNullWhen(false)]
#endif
        out MyVoString result)
        {
            if (s is null)
            {
                result = default;
                return false;
            }

            result = new MyVoString(s);
            return true;
        }

        /// <summary>
        /// </summary>
        /// <returns>
        /// The value created via the <see cref = "From(global::System.String)"/> method.
        /// </returns>
        /// <exception cref = "global::Vogen.ValueObjectValidationException">Thrown when the value can be parsed, but is not valid.</exception>
        public static MyVoString Parse(global::System.String s, global::System.IFormatProvider provider)
        {
            return From(s);
        }

#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<System.String>.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.String.ToString()"/>
        public override global::System.String ToString() => IsInitialized() ? Value.ToString() ?? "" : "[UNINITIALIZED]";
        /// <inheritdoc cref = "System.String.ToString(System.IFormatProvider? )"/>
        public global::System.String ToString(global::System.IFormatProvider provider) => IsInitialized() ? Value.ToString(provider) ?? "" : "[UNINITIALIZED]";
#nullable disable
        /// <summary>
        /// Converts a MyVoString to or from JSON.
        /// </summary>
        public class MyVoStringSystemTextJsonConverter : global::System.Text.Json.Serialization.JsonConverter<MyVoString>
        {
            public override MyVoString Read(ref global::System.Text.Json.Utf8JsonReader reader, global::System.Type typeToConvert, global::System.Text.Json.JsonSerializerOptions options)
            {
                return DeserializeJson(reader.GetString());
            }

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

#if NET6_0_OR_GREATER
            public override MyVoString ReadAsPropertyName(ref global::System.Text.Json.Utf8JsonReader reader, global::System.Type typeToConvert, global::System.Text.Json.JsonSerializerOptions options)
            {
                return DeserializeJson(reader.GetString());
            }

            public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, MyVoString value, global::System.Text.Json.JsonSerializerOptions options)
            {
                writer.WritePropertyName(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);
            }

            private static void ThrowJsonExceptionWhenNull(System.String value)
            {
                if (value == null)
                {
                    var e = ThrowHelper.CreateCannotBeNullException();
                    throw new global::System.Text.Json.JsonException(null, e);
                }
            }

            public static MyVoString DeserializeJson(System.String value)
            {
                ThrowJsonExceptionWhenNull(value);
                return new MyVoString(value);
            }
        }

#nullable restore
#nullable disable
        class MyVoStringTypeConverter : global::System.ComponentModel.TypeConverter
        {
            public override global::System.Boolean CanConvertFrom(global::System.ComponentModel.ITypeDescriptorContext context, global::System.Type sourceType)
            {
                return 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)
            {
                var stringValue = value as global::System.String;
                if (stringValue is not null)
                {
                    return MyVoString.__Deserialize(stringValue);
                }

                return base.ConvertFrom(context, culture, value);
            }

            public override bool CanConvertTo(global::System.ComponentModel.ITypeDescriptorContext context, global::System.Type sourceType)
            {
                return 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 MyVoString idValue)
                {
                    if (destinationType == typeof(global::System.String))
                    {
                        return idValue.Value;
                    }
                }

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

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

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

        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 MyNamespace
{
    [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
        [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Vogen", "1.0.0.0")]
    [global::System.Text.Json.Serialization.JsonConverter(typeof(MyVoBoolSystemTextJsonConverter))]
    [global::System.ComponentModel.TypeConverter(typeof(MyVoBoolTypeConverter))]
    [global::System.Diagnostics.DebuggerTypeProxyAttribute(typeof(MyVoBoolDebugView))]
    [global::System.Diagnostics.DebuggerDisplayAttribute("Underlying type: System.Boolean, Value = { _value }")]
    public partial class MyVoBool : global::System.IEquatable<MyVoBool>, global::System.IEquatable<System.Boolean>, global::System.IComparable<MyVoBool>, global::System.IComparable
    {
#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.Boolean _value;
        /// <summary>
        /// Gets the underlying <see cref = "System.Boolean"/> value if set, otherwise a <see cref = "Vogen.ValueObjectValidationException"/> is thrown.
        /// </summary>
        public System.Boolean 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 MyVoBool()
        {
#if DEBUG
            _stackTrace = new global::System.Diagnostics.StackTrace();
#endif
#if !VOGEN_NO_VALIDATION
            _isInitialized = false;
#endif
            _value = default;
        }

        [global::System.Diagnostics.DebuggerStepThroughAttribute]
        private MyVoBool(System.Boolean 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 MyVoBool From(System.Boolean value)
        {
            return new MyVoBool(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.Boolean value, 
#if NETCOREAPP3_0_OR_GREATER
[global::System.Diagnostics.CodeAnalysis.MaybeNullWhen(false)]
#endif
        out MyVoBool 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 MyVoBool(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<MyVoBool> TryFrom(System.Boolean value)
        {
            return new Vogen.ValueObjectOrError<MyVoBool>(new MyVoBool(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 MyVoBool __Deserialize(System.Boolean value)
        {
            return new MyVoBool(value);
        }

        public global::System.Boolean Equals(MyVoBool 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.Boolean>.Default.Equals(Value, other.Value);
        }

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

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

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

        public static global::System.Boolean operator ==(MyVoBool left, MyVoBool right) => Equals(left, right);
        public static global::System.Boolean operator !=(MyVoBool left, MyVoBool right) => !Equals(left, right);
        public static global::System.Boolean operator ==(MyVoBool left, System.Boolean right) => left.Value.Equals(right);
        public static global::System.Boolean operator ==(System.Boolean left, MyVoBool right) => right.Value.Equals(left);
        public static global::System.Boolean operator !=(System.Boolean left, MyVoBool right) => !(left == right);
        public static global::System.Boolean operator !=(MyVoBool left, System.Boolean right) => !(left == right);
        public static explicit operator MyVoBool(System.Boolean value) => From(value);
        public static explicit operator System.Boolean(MyVoBool value) => value.Value;
        public int CompareTo(MyVoBool 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 MyVoBool x)
                return CompareTo(x);
            ThrowHelper.ThrowArgumentException("Cannot compare to object as it is not of type MyVoBool", nameof(other));
            return 0;
        }

        /// <inheritdoc cref = "bool.TryParse(System.ReadOnlySpan{char}, out bool)"/>
        /// <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(global::System.ReadOnlySpan<char> value, 
#if NETCOREAPP3_0_OR_GREATER
[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
#endif
        out MyVoBool result)
        {
            if (System.Boolean.TryParse(value, out var __v))
            {
                result = new MyVoBool(__v);
                return true;
            }

            result = default;
            return false;
        }

        /// <inheritdoc cref = "bool.TryParse(string? , out bool)"/>
        /// <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 value, 
#if NETCOREAPP3_0_OR_GREATER
[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
#endif
        out MyVoBool result)
        {
            if (System.Boolean.TryParse(value, out var __v))
            {
                result = new MyVoBool(__v);
                return true;
            }

            result = default;
            return false;
        }

        /// <inheritdoc cref = "bool.Parse(System.ReadOnlySpan{char})"/>
        /// <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 MyVoBool Parse(global::System.ReadOnlySpan<char> value)
        {
            var r = System.Boolean.Parse(value);
            return From(r);
        }

        /// <inheritdoc cref = "bool.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 MyVoBool Parse(string value)
        {
            var r = System.Boolean.Parse(value);
            return From(r);
        }

#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<System.Boolean>.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.Boolean.ToString()"/>
        public override global::System.String ToString() => IsInitialized() ? Value.ToString() ?? "" : "[UNINITIALIZED]";
        /// <inheritdoc cref = "System.Boolean.ToString(System.IFormatProvider? )"/>
        public global::System.String ToString(global::System.IFormatProvider provider) => IsInitialized() ? Value.ToString(provider) ?? "" : "[UNINITIALIZED]";
#nullable disable
        /// <summary>
        /// Converts a MyVoBool to or from JSON.
        /// </summary>
        public class MyVoBoolSystemTextJsonConverter : global::System.Text.Json.Serialization.JsonConverter<MyVoBool>
        {
            public override MyVoBool Read(ref global::System.Text.Json.Utf8JsonReader reader, global::System.Type typeToConvert, global::System.Text.Json.JsonSerializerOptions options)
            {
                return DeserializeJson(reader.GetBoolean());
            }

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

#if NET6_0_OR_GREATER
            public override MyVoBool ReadAsPropertyName(ref global::System.Text.Json.Utf8JsonReader reader, global::System.Type typeToConvert, global::System.Text.Json.JsonSerializerOptions options)
            {
                return DeserializeJson(bool.Parse(reader.GetString()));
            }

            public override void WriteAsPropertyName(global::System.Text.Json.Utf8JsonWriter writer, MyVoBool value, global::System.Text.Json.JsonSerializerOptions options)
            {
                writer.WritePropertyName(value.Value.ToString());
            }
#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 MyVoBool DeserializeJson(System.Boolean value)
            {
                return new MyVoBool(value);
            }
        }

#nullable restore
#nullable disable
        class MyVoBoolTypeConverter : global::System.ComponentModel.TypeConverter
        {
            public override global::System.Boolean CanConvertFrom(global::System.ComponentModel.ITypeDescriptorContext context, global::System.Type sourceType)
            {
                return sourceType == typeof(global::System.Boolean) || 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.Boolean boolValue => MyVoBool.__Deserialize(boolValue),
                    global::System.String stringValue when !global::System.String.IsNullOrEmpty(stringValue) && global::System.Boolean.TryParse(stringValue, out var result) => MyVoBool.__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.Boolean) || 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 MyVoBool idValue)
                {
                    if (destinationType == typeof(global::System.Boolean))
                    {
                        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 MyVoBoolDebugView
        {
            private readonly MyVoBool _t;
            MyVoBoolDebugView(MyVoBool t)
            {
                _t = t;
            }

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

        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 MyNamespace
{
    [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
        [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Vogen", "1.0.0.0")]
    [global::System.Text.Json.Serialization.JsonConverter(typeof(@boolSystemTextJsonConverter))]
    [global::System.ComponentModel.TypeConverter(typeof(@boolTypeConverter))]
    [global::System.Diagnostics.DebuggerTypeProxyAttribute(typeof(@boolDebugView))]
    [global::System.Diagnostics.DebuggerDisplayAttribute("Underlying type: System.Boolean, Value = { _value }")]
    public partial class @bool : global::System.IEquatable<@bool>, global::System.IEquatable<System.Boolean>, global::System.IComparable<@bool>, global::System.IComparable
    {
#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.Boolean _value;
        /// <summary>
        /// Gets the underlying <see cref = "System.Boolean"/> value if set, otherwise a <see cref = "Vogen.ValueObjectValidationException"/> is thrown.
        /// </summary>
        public System.Boolean 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 @bool()
        {
#if DEBUG
            _stackTrace = new global::System.Diagnostics.StackTrace();
#endif
#if !VOGEN_NO_VALIDATION
            _isInitialized = false;
#endif
            _value = default;
        }

        [global::System.Diagnostics.DebuggerStepThroughAttribute]
        private @bool(System.Boolean 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 @bool From(System.Boolean value)
        {
            return new @bool(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.Boolean value, 
#if NETCOREAPP3_0_OR_GREATER
[global::System.Diagnostics.CodeAnalysis.MaybeNullWhen(false)]
#endif
        out @bool 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 @bool(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<@bool> TryFrom(System.Boolean value)
        {
            return new Vogen.ValueObjectOrError<@bool>(new @bool(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 @bool __Deserialize(System.Boolean value)
        {
            return new @bool(value);
        }

        public global::System.Boolean Equals(@bool 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.Boolean>.Default.Equals(Value, other.Value);
        }

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

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

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

        public static global::System.Boolean operator ==(@bool left, @bool right) => Equals(left, right);
        public static global::System.Boolean operator !=(@bool left, @bool right) => !Equals(left, right);
        public static global::System.Boolean operator ==(@bool left, System.Boolean right) => left.Value.Equals(right);
        public static global::System.Boolean operator ==(System.Boolean left, @bool right) => right.Value.Equals(left);
        public static global::System.Boolean operator !=(System.Boolean left, @bool right) => !(left == right);
        public static global::System.Boolean operator !=(@bool left, System.Boolean right) => !(left == right);
        public static explicit operator @bool(System.Boolean value) => From(value);
        public static explicit operator System.Boolean(@bool value) => value.Value;
        public int CompareTo(@bool 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 @bool x)
                return CompareTo(x);
            ThrowHelper.ThrowArgumentException("Cannot compare to object as it is not of type @bool", nameof(other));
            return 0;
        }

        /// <inheritdoc cref = "bool.TryParse(System.ReadOnlySpan{char}, out bool)"/>
        /// <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(global::System.ReadOnlySpan<char> value, 
#if NETCOREAPP3_0_OR_GREATER
[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
#endif
        out @bool result)
        {
            if (System.Boolean.TryParse(value, out var __v))
            {
                result = new @bool(__v);
                return true;
            }

            result = default;
            return false;
        }

        /// <inheritdoc cref = "bool.TryParse(string? , out bool)"/>
        /// <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 value, 
#if NETCOREAPP3_0_OR_GREATER
[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
#endif
        out @bool result)
        {
            if (System.Boolean.TryParse(value, out var __v))
            {
                result = new @bool(__v);
                return true;
            }

            result = default;
            return false;
        }

        /// <inheritdoc cref = "bool.Parse(System.ReadOnlySpan{char})"/>
        /// <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 @bool Parse(global::System.ReadOnlySpan<char> value)
        {
            var r = System.Boolean.Parse(value);
            return From(r);
        }

        /// <inheritdoc cref = "bool.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 @bool Parse(string value)
        {
            var r = System.Boolean.Parse(value);
            return From(r);
        }

#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<System.Boolean>.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.Boolean.ToString()"/>
        public override global::System.String ToString() => IsInitialized() ? Value.ToString() ?? "" : "[UNINITIALIZED]";
        /// <inheritdoc cref = "System.Boolean.ToString(System.IFormatProvider? )"/>
        public global::System.String ToString(global::System.IFormatProvider provider) => IsInitialized() ? Value.ToString(provider) ?? "" : "[UNINITIALIZED]";
#nullable disable
        /// <summary>
        /// Converts a @bool to or from JSON.
        /// </summary>
        public class @boolSystemTextJsonConverter : global::System.Text.Json.Serialization.JsonConverter<@bool>
        {
            public override @bool Read(ref global::System.Text.Json.Utf8JsonReader reader, global::System.Type typeToConvert, global::System.Text.Json.JsonSerializerOptions options)
            {
                return DeserializeJson(reader.GetBoolean());
            }

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

#if NET6_0_OR_GREATER
            public override @bool ReadAsPropertyName(ref global::System.Text.Json.Utf8JsonReader reader, global::System.Type typeToConvert, global::System.Text.Json.JsonSerializerOptions options)
            {
                return DeserializeJson(bool.Parse(reader.GetString()));
            }

            public override void WriteAsPropertyName(global::System.Text.Json.Utf8JsonWriter writer, @bool value, global::System.Text.Json.JsonSerializerOptions options)
            {
                writer.WritePropertyName(value.Value.ToString());
            }
#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 @bool DeserializeJson(System.Boolean value)
            {
                return new @bool(value);
            }
        }

#nullable restore
#nullable disable
        class @boolTypeConverter : global::System.ComponentModel.TypeConverter
        {
            public override global::System.Boolean CanConvertFrom(global::System.ComponentModel.ITypeDescriptorContext context, global::System.Type sourceType)
            {
                return sourceType == typeof(global::System.Boolean) || 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.Boolean boolValue => @bool.__Deserialize(boolValue),
                    global::System.String stringValue when !global::System.String.IsNullOrEmpty(stringValue) && global::System.Boolean.TryParse(stringValue, out var result) => @bool.__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.Boolean) || 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 @bool idValue)
                {
                    if (destinationType == typeof(global::System.Boolean))
                    {
                        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 @boolDebugView
        {
            private readonly @bool _t;
            @boolDebugView(@bool t)
            {
                _t = t;
            }

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

        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;
            }
        }
    }
}
]