﻿[  
#if NET8_0_OR_GREATER

// ------------------------------------------------------------------------------
// <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 Whatever;
    
  public static class EfCoreConverters__Ext
  {
      public static global::Microsoft.EntityFrameworkCore.ModelConfigurationBuilder RegisterAllInEfCoreConverters(this global::Microsoft.EntityFrameworkCore.ModelConfigurationBuilder configurationBuilder)
      {
        configurationBuilder.Properties<Whatever.MyVo1>().HaveConversion<Whatever.EfCoreConverters.MyVo1EfCoreValueConverter, Whatever.EfCoreConverters.MyVo1EfCoreValueComparer>();
configurationBuilder.Properties<Whatever.MyVo2>().HaveConversion<Whatever.EfCoreConverters.MyVo2EfCoreValueConverter, Whatever.EfCoreConverters.MyVo2EfCoreValueComparer>();
configurationBuilder.Properties<Whatever.MyVo3>().HaveConversion<Whatever.EfCoreConverters.MyVo3EfCoreValueConverter, Whatever.EfCoreConverters.MyVo3EfCoreValueComparer>();
configurationBuilder.Properties<Whatever.MyVo4>().HaveConversion<Whatever.EfCoreConverters.MyVo4EfCoreValueConverter, Whatever.EfCoreConverters.MyVo4EfCoreValueComparer>();
configurationBuilder.Properties<Whatever.MyVo5>().HaveConversion<Whatever.EfCoreConverters.MyVo5EfCoreValueConverter, Whatever.EfCoreConverters.MyVo5EfCoreValueComparer>();
configurationBuilder.Properties<Whatever.MyVo6>().HaveConversion<Whatever.EfCoreConverters.MyVo6EfCoreValueConverter, Whatever.EfCoreConverters.MyVo6EfCoreValueComparer>();
configurationBuilder.Properties<Whatever.@int>().HaveConversion<Whatever.EfCoreConverters.intEfCoreValueConverter, Whatever.EfCoreConverters.intEfCoreValueComparer>();
configurationBuilder.Properties<Whatever.@byte>().HaveConversion<Whatever.EfCoreConverters.byteEfCoreValueConverter, Whatever.EfCoreConverters.byteEfCoreValueComparer>();
configurationBuilder.Properties<Whatever.MyInt>().HaveConversion<Whatever.EfCoreConverters.MyIntEfCoreValueConverter, Whatever.EfCoreConverters.MyIntEfCoreValueComparer>();


        return configurationBuilder; 
      }
  }

#endif
  
#if NET8_0_OR_GREATER

// ------------------------------------------------------------------------------
// <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 Whatever;
    
public partial class EfCoreConverters
{
            public class MyVo1EfCoreValueConverter : global::Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter<Whatever.MyVo1, System.Int32>
        {
          public MyVo1EfCoreValueConverter() : this(null) { }
          public MyVo1EfCoreValueConverter(global::Microsoft.EntityFrameworkCore.Storage.ValueConversion.ConverterMappingHints mappingHints = null)
              : base(
                  vo => vo.Value,
                                                                      value => Deserialize(value),
                mappingHints
              ) { }

      static Whatever.MyVo1 Deserialize(System.Int32 value) => UnsafeDeserialize(default, value);
 
      [global::System.Runtime.CompilerServices.UnsafeAccessor(global::System.Runtime.CompilerServices.UnsafeAccessorKind.StaticMethod, Name = "__Deserialize")]
      static extern Whatever.MyVo1 UnsafeDeserialize(Whatever.MyVo1 @this, System.Int32 value);      
        }
        public class MyVo1EfCoreValueComparer : global::Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer<Whatever.MyVo1>
        {
            public MyVo1EfCoreValueComparer() : base(
                (left, right) => DoCompare(left, right), 
                instance => instance.IsInitialized() ? instance.GetHashCode() : 0) 
            { 
            }
            
            static bool DoCompare(Whatever.MyVo1 left, Whatever.MyVo1 right)
            {
                // if neither are initialized, then they're equal
                if(!left.IsInitialized() && !right.IsInitialized()) return true;
                
                return left.IsInitialized() && right.IsInitialized() && UnderlyingValue(left).Equals(UnderlyingValue(right));
            }
 private static System.Int32 UnderlyingValue(Whatever.MyVo1 i) => UnsafeValueField(ref i);

  [global::System.Runtime.CompilerServices.UnsafeAccessor(global::System.Runtime.CompilerServices.UnsafeAccessorKind.Field, Name = "_value")]
  static extern ref System.Int32 UnsafeValueField(ref Whatever.MyVo1 @this);                
        }
}

public static class MyVo1__Ext 
{
        public static global::Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder<Whatever.MyVo1> HasVogenConversion(this global::Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder<Whatever.MyVo1> propertyBuilder) =>
            propertyBuilder.HasConversion<Whatever.EfCoreConverters.MyVo1EfCoreValueConverter, Whatever.EfCoreConverters.MyVo1EfCoreValueComparer>();
}


#endif
  
#if NET8_0_OR_GREATER

// ------------------------------------------------------------------------------
// <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 Whatever;
    
public partial class EfCoreConverters
{
            public class MyVo2EfCoreValueConverter : global::Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter<Whatever.MyVo2, System.String>
        {
          public MyVo2EfCoreValueConverter() : this(null) { }
          public MyVo2EfCoreValueConverter(global::Microsoft.EntityFrameworkCore.Storage.ValueConversion.ConverterMappingHints mappingHints = null)
              : base(
                  vo => vo.Value,
                                                                      value => Deserialize(value),
                mappingHints
              ) { }

      static Whatever.MyVo2 Deserialize(System.String value) => UnsafeDeserialize(default, value);
 
      [global::System.Runtime.CompilerServices.UnsafeAccessor(global::System.Runtime.CompilerServices.UnsafeAccessorKind.StaticMethod, Name = "__Deserialize")]
      static extern Whatever.MyVo2 UnsafeDeserialize(Whatever.MyVo2 @this, System.String value);      
        }
       public class MyVo2EfCoreValueComparer : global::Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer<Whatever.MyVo2>
       {
           public MyVo2EfCoreValueComparer() : base(
               (left, right) => DoCompare(left, right), 
                instance => instance.IsInitialized() ? UnderlyingValue(instance).GetHashCode() : 0) 
           { 
           }
               
           static bool DoCompare(Whatever.MyVo2 left, Whatever.MyVo2 right)
           {
               // if both null, then they're equal
               if (left is null) return right is null;
               
               // if only right is null, then they're not equal
               if (right is null) return false;
               
               // if they're both the same reference, then they're equal
               if (ReferenceEquals(left, right)) return true;
               
               // if neither are initialized, then they're equal
                if(!left.IsInitialized() && !right.IsInitialized()) return true;
               
                return left.IsInitialized() && right.IsInitialized() && UnderlyingValue(left).Equals(UnderlyingValue(right));            
           }                
 private static System.String UnderlyingValue(Whatever.MyVo2 i) => UnsafeValueField( i);

  [global::System.Runtime.CompilerServices.UnsafeAccessor(global::System.Runtime.CompilerServices.UnsafeAccessorKind.Field, Name = "_value")]
  static extern ref System.String UnsafeValueField( Whatever.MyVo2 @this);                
}
}

public static class MyVo2__Ext 
{
        public static global::Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder<Whatever.MyVo2> HasVogenConversion(this global::Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder<Whatever.MyVo2> propertyBuilder) =>
            propertyBuilder.HasConversion<Whatever.EfCoreConverters.MyVo2EfCoreValueConverter, Whatever.EfCoreConverters.MyVo2EfCoreValueComparer>();
}


#endif
  
#if NET8_0_OR_GREATER

// ------------------------------------------------------------------------------
// <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 Whatever;
    
public partial class EfCoreConverters
{
            public class MyVo3EfCoreValueConverter : global::Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter<Whatever.MyVo3, System.String>
        {
          public MyVo3EfCoreValueConverter() : this(null) { }
          public MyVo3EfCoreValueConverter(global::Microsoft.EntityFrameworkCore.Storage.ValueConversion.ConverterMappingHints mappingHints = null)
              : base(
                  vo => vo.Value,
                                                                      value => Deserialize(value),
                mappingHints
              ) { }

      static Whatever.MyVo3 Deserialize(System.String value) => UnsafeDeserialize(default, value);
 
      [global::System.Runtime.CompilerServices.UnsafeAccessor(global::System.Runtime.CompilerServices.UnsafeAccessorKind.StaticMethod, Name = "__Deserialize")]
      static extern Whatever.MyVo3 UnsafeDeserialize(Whatever.MyVo3 @this, System.String value);      
        }
        public class MyVo3EfCoreValueComparer : global::Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer<Whatever.MyVo3>
        {
            public MyVo3EfCoreValueComparer() : base(
                (left, right) => DoCompare(left, right), 
                instance => instance.IsInitialized() ? instance.GetHashCode() : 0) 
            { 
            }
            
            static bool DoCompare(Whatever.MyVo3 left, Whatever.MyVo3 right)
            {
                // if neither are initialized, then they're equal
                if(!left.IsInitialized() && !right.IsInitialized()) return true;
                
                return left.IsInitialized() && right.IsInitialized() && UnderlyingValue(left).Equals(UnderlyingValue(right));
            }
 private static System.String UnderlyingValue(Whatever.MyVo3 i) => UnsafeValueField(ref i);

  [global::System.Runtime.CompilerServices.UnsafeAccessor(global::System.Runtime.CompilerServices.UnsafeAccessorKind.Field, Name = "_value")]
  static extern ref System.String UnsafeValueField(ref Whatever.MyVo3 @this);                
        }
}

public static class MyVo3__Ext 
{
        public static global::Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder<Whatever.MyVo3> HasVogenConversion(this global::Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder<Whatever.MyVo3> propertyBuilder) =>
            propertyBuilder.HasConversion<Whatever.EfCoreConverters.MyVo3EfCoreValueConverter, Whatever.EfCoreConverters.MyVo3EfCoreValueComparer>();
}


#endif
  
#if NET8_0_OR_GREATER

// ------------------------------------------------------------------------------
// <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 Whatever;
    
public partial class EfCoreConverters
{
            public class MyVo4EfCoreValueConverter : global::Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter<Whatever.MyVo4, System.Int32>
        {
          public MyVo4EfCoreValueConverter() : this(null) { }
          public MyVo4EfCoreValueConverter(global::Microsoft.EntityFrameworkCore.Storage.ValueConversion.ConverterMappingHints mappingHints = null)
              : base(
                  vo => vo.Value,
                                                                      value => Deserialize(value),
                mappingHints
              ) { }

      static Whatever.MyVo4 Deserialize(System.Int32 value) => UnsafeDeserialize(default, value);
 
      [global::System.Runtime.CompilerServices.UnsafeAccessor(global::System.Runtime.CompilerServices.UnsafeAccessorKind.StaticMethod, Name = "__Deserialize")]
      static extern Whatever.MyVo4 UnsafeDeserialize(Whatever.MyVo4 @this, System.Int32 value);      
        }
        public class MyVo4EfCoreValueComparer : global::Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer<Whatever.MyVo4>
        {
            public MyVo4EfCoreValueComparer() : base(
                (left, right) => DoCompare(left, right), 
                instance => instance.IsInitialized() ? instance.GetHashCode() : 0) 
            { 
            }
            
            static bool DoCompare(Whatever.MyVo4 left, Whatever.MyVo4 right)
            {
                // if neither are initialized, then they're equal
                if(!left.IsInitialized() && !right.IsInitialized()) return true;
                
                return left.IsInitialized() && right.IsInitialized() && UnderlyingValue(left).Equals(UnderlyingValue(right));
            }
 private static System.Int32 UnderlyingValue(Whatever.MyVo4 i) => UnsafeValueField(ref i);

  [global::System.Runtime.CompilerServices.UnsafeAccessor(global::System.Runtime.CompilerServices.UnsafeAccessorKind.Field, Name = "_value")]
  static extern ref System.Int32 UnsafeValueField(ref Whatever.MyVo4 @this);                
        }
}

public static class MyVo4__Ext 
{
        public static global::Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder<Whatever.MyVo4> HasVogenConversion(this global::Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder<Whatever.MyVo4> propertyBuilder) =>
            propertyBuilder.HasConversion<Whatever.EfCoreConverters.MyVo4EfCoreValueConverter, Whatever.EfCoreConverters.MyVo4EfCoreValueComparer>();
}


#endif
  
#if NET8_0_OR_GREATER

// ------------------------------------------------------------------------------
// <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 Whatever;
    
public partial class EfCoreConverters
{
            public class MyVo5EfCoreValueConverter : global::Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter<Whatever.MyVo5, System.Int32>
        {
          public MyVo5EfCoreValueConverter() : this(null) { }
          public MyVo5EfCoreValueConverter(global::Microsoft.EntityFrameworkCore.Storage.ValueConversion.ConverterMappingHints mappingHints = null)
              : base(
                  vo => vo.Value,
                                                                      value => Deserialize(value),
                mappingHints
              ) { }

      static Whatever.MyVo5 Deserialize(System.Int32 value) => UnsafeDeserialize(default, value);
 
      [global::System.Runtime.CompilerServices.UnsafeAccessor(global::System.Runtime.CompilerServices.UnsafeAccessorKind.StaticMethod, Name = "__Deserialize")]
      static extern Whatever.MyVo5 UnsafeDeserialize(Whatever.MyVo5 @this, System.Int32 value);      
        }
        public class MyVo5EfCoreValueComparer : global::Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer<Whatever.MyVo5>
        {
            public MyVo5EfCoreValueComparer() : base(
                (left, right) => DoCompare(left, right), 
                instance => instance.IsInitialized() ? instance.GetHashCode() : 0) 
            { 
            }
            
            static bool DoCompare(Whatever.MyVo5 left, Whatever.MyVo5 right)
            {
                // if neither are initialized, then they're equal
                if(!left.IsInitialized() && !right.IsInitialized()) return true;
                
                return left.IsInitialized() && right.IsInitialized() && UnderlyingValue(left).Equals(UnderlyingValue(right));
            }
 private static System.Int32 UnderlyingValue(Whatever.MyVo5 i) => UnsafeValueField(ref i);

  [global::System.Runtime.CompilerServices.UnsafeAccessor(global::System.Runtime.CompilerServices.UnsafeAccessorKind.Field, Name = "_value")]
  static extern ref System.Int32 UnsafeValueField(ref Whatever.MyVo5 @this);                
        }
}

public static class MyVo5__Ext 
{
        public static global::Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder<Whatever.MyVo5> HasVogenConversion(this global::Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder<Whatever.MyVo5> propertyBuilder) =>
            propertyBuilder.HasConversion<Whatever.EfCoreConverters.MyVo5EfCoreValueConverter, Whatever.EfCoreConverters.MyVo5EfCoreValueComparer>();
}


#endif
  
#if NET8_0_OR_GREATER

// ------------------------------------------------------------------------------
// <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 Whatever;
    
public partial class EfCoreConverters
{
            public class MyVo6EfCoreValueConverter : global::Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter<Whatever.MyVo6, System.Int32>
        {
          public MyVo6EfCoreValueConverter() : this(null) { }
          public MyVo6EfCoreValueConverter(global::Microsoft.EntityFrameworkCore.Storage.ValueConversion.ConverterMappingHints mappingHints = null)
              : base(
                  vo => vo.Value,
                                                                      value => Deserialize(value),
                mappingHints
              ) { }

      static Whatever.MyVo6 Deserialize(System.Int32 value) => UnsafeDeserialize(default, value);
 
      [global::System.Runtime.CompilerServices.UnsafeAccessor(global::System.Runtime.CompilerServices.UnsafeAccessorKind.StaticMethod, Name = "__Deserialize")]
      static extern Whatever.MyVo6 UnsafeDeserialize(Whatever.MyVo6 @this, System.Int32 value);      
        }
       public class MyVo6EfCoreValueComparer : global::Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer<Whatever.MyVo6>
       {
           public MyVo6EfCoreValueComparer() : base(
               (left, right) => DoCompare(left, right), 
                instance => instance.IsInitialized() ? UnderlyingValue(instance).GetHashCode() : 0) 
           { 
           }
               
           static bool DoCompare(Whatever.MyVo6 left, Whatever.MyVo6 right)
           {
               // if both null, then they're equal
               if (left is null) return right is null;
               
               // if only right is null, then they're not equal
               if (right is null) return false;
               
               // if they're both the same reference, then they're equal
               if (ReferenceEquals(left, right)) return true;
               
               // if neither are initialized, then they're equal
                if(!left.IsInitialized() && !right.IsInitialized()) return true;
               
                return left.IsInitialized() && right.IsInitialized() && UnderlyingValue(left).Equals(UnderlyingValue(right));            
           }                
 private static System.Int32 UnderlyingValue(Whatever.MyVo6 i) => UnsafeValueField( i);

  [global::System.Runtime.CompilerServices.UnsafeAccessor(global::System.Runtime.CompilerServices.UnsafeAccessorKind.Field, Name = "_value")]
  static extern ref System.Int32 UnsafeValueField( Whatever.MyVo6 @this);                
}
}

public static class MyVo6__Ext 
{
        public static global::Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder<Whatever.MyVo6> HasVogenConversion(this global::Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder<Whatever.MyVo6> propertyBuilder) =>
            propertyBuilder.HasConversion<Whatever.EfCoreConverters.MyVo6EfCoreValueConverter, Whatever.EfCoreConverters.MyVo6EfCoreValueComparer>();
}


#endif
  
#if NET8_0_OR_GREATER

// ------------------------------------------------------------------------------
// <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 Whatever;
    
public partial class EfCoreConverters
{
            public class intEfCoreValueConverter : global::Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter<Whatever.@int, System.Int32>
        {
          public intEfCoreValueConverter() : this(null) { }
          public intEfCoreValueConverter(global::Microsoft.EntityFrameworkCore.Storage.ValueConversion.ConverterMappingHints mappingHints = null)
              : base(
                  vo => vo.Value,
                                                                      value => Deserialize(value),
                mappingHints
              ) { }

      static Whatever.@int Deserialize(System.Int32 value) => UnsafeDeserialize(default, value);
 
      [global::System.Runtime.CompilerServices.UnsafeAccessor(global::System.Runtime.CompilerServices.UnsafeAccessorKind.StaticMethod, Name = "__Deserialize")]
      static extern Whatever.@int UnsafeDeserialize(Whatever.@int @this, System.Int32 value);      
        }
        public class intEfCoreValueComparer : global::Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer<Whatever.@int>
        {
            public intEfCoreValueComparer() : base(
                (left, right) => DoCompare(left, right), 
                instance => instance.IsInitialized() ? instance.GetHashCode() : 0) 
            { 
            }
            
            static bool DoCompare(Whatever.@int left, Whatever.@int right)
            {
                // if neither are initialized, then they're equal
                if(!left.IsInitialized() && !right.IsInitialized()) return true;
                
                return left.IsInitialized() && right.IsInitialized() && UnderlyingValue(left).Equals(UnderlyingValue(right));
            }
 private static System.Int32 UnderlyingValue(Whatever.@int i) => UnsafeValueField(ref i);

  [global::System.Runtime.CompilerServices.UnsafeAccessor(global::System.Runtime.CompilerServices.UnsafeAccessorKind.Field, Name = "_value")]
  static extern ref System.Int32 UnsafeValueField(ref Whatever.@int @this);                
        }
}

public static class int__Ext 
{
        public static global::Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder<Whatever.@int> HasVogenConversion(this global::Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder<Whatever.@int> propertyBuilder) =>
            propertyBuilder.HasConversion<Whatever.EfCoreConverters.intEfCoreValueConverter, Whatever.EfCoreConverters.intEfCoreValueComparer>();
}


#endif
  
#if NET8_0_OR_GREATER

// ------------------------------------------------------------------------------
// <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 Whatever;
    
public partial class EfCoreConverters
{
            public class byteEfCoreValueConverter : global::Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter<Whatever.@byte, System.Int32>
        {
          public byteEfCoreValueConverter() : this(null) { }
          public byteEfCoreValueConverter(global::Microsoft.EntityFrameworkCore.Storage.ValueConversion.ConverterMappingHints mappingHints = null)
              : base(
                  vo => vo.Value,
                                                                      value => Deserialize(value),
                mappingHints
              ) { }

      static Whatever.@byte Deserialize(System.Int32 value) => UnsafeDeserialize(default, value);
 
      [global::System.Runtime.CompilerServices.UnsafeAccessor(global::System.Runtime.CompilerServices.UnsafeAccessorKind.StaticMethod, Name = "__Deserialize")]
      static extern Whatever.@byte UnsafeDeserialize(Whatever.@byte @this, System.Int32 value);      
        }
        public class byteEfCoreValueComparer : global::Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer<Whatever.@byte>
        {
            public byteEfCoreValueComparer() : base(
                (left, right) => DoCompare(left, right), 
                instance => instance.IsInitialized() ? instance.GetHashCode() : 0) 
            { 
            }
            
            static bool DoCompare(Whatever.@byte left, Whatever.@byte right)
            {
                // if neither are initialized, then they're equal
                if(!left.IsInitialized() && !right.IsInitialized()) return true;
                
                return left.IsInitialized() && right.IsInitialized() && UnderlyingValue(left).Equals(UnderlyingValue(right));
            }
 private static System.Int32 UnderlyingValue(Whatever.@byte i) => UnsafeValueField(ref i);

  [global::System.Runtime.CompilerServices.UnsafeAccessor(global::System.Runtime.CompilerServices.UnsafeAccessorKind.Field, Name = "_value")]
  static extern ref System.Int32 UnsafeValueField(ref Whatever.@byte @this);                
        }
}

public static class byte__Ext 
{
        public static global::Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder<Whatever.@byte> HasVogenConversion(this global::Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder<Whatever.@byte> propertyBuilder) =>
            propertyBuilder.HasConversion<Whatever.EfCoreConverters.byteEfCoreValueConverter, Whatever.EfCoreConverters.byteEfCoreValueComparer>();
}


#endif
  
#if NET8_0_OR_GREATER

// ------------------------------------------------------------------------------
// <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 Whatever;
    
public partial class EfCoreConverters
{
            public class MyIntEfCoreValueConverter : global::Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter<Whatever.MyInt, System.Int32>
        {
          public MyIntEfCoreValueConverter() : this(null) { }
          public MyIntEfCoreValueConverter(global::Microsoft.EntityFrameworkCore.Storage.ValueConversion.ConverterMappingHints mappingHints = null)
              : base(
                  vo => vo.Value,
                                                                      value => Deserialize(value),
                mappingHints
              ) { }

      static Whatever.MyInt Deserialize(System.Int32 value) => UnsafeDeserialize(default, value);
 
      [global::System.Runtime.CompilerServices.UnsafeAccessor(global::System.Runtime.CompilerServices.UnsafeAccessorKind.StaticMethod, Name = "__Deserialize")]
      static extern Whatever.MyInt UnsafeDeserialize(Whatever.MyInt @this, System.Int32 value);      
        }
       public class MyIntEfCoreValueComparer : global::Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer<Whatever.MyInt>
       {
           public MyIntEfCoreValueComparer() : base(
               (left, right) => DoCompare(left, right), 
                instance => instance.IsInitialized() ? UnderlyingValue(instance).GetHashCode() : 0) 
           { 
           }
               
           static bool DoCompare(Whatever.MyInt left, Whatever.MyInt right)
           {
               // if both null, then they're equal
               if (left is null) return right is null;
               
               // if only right is null, then they're not equal
               if (right is null) return false;
               
               // if they're both the same reference, then they're equal
               if (ReferenceEquals(left, right)) return true;
               
               // if neither are initialized, then they're equal
                if(!left.IsInitialized() && !right.IsInitialized()) return true;
               
                return left.IsInitialized() && right.IsInitialized() && UnderlyingValue(left).Equals(UnderlyingValue(right));            
           }                
 private static System.Int32 UnderlyingValue(Whatever.MyInt i) => UnsafeValueField( i);

  [global::System.Runtime.CompilerServices.UnsafeAccessor(global::System.Runtime.CompilerServices.UnsafeAccessorKind.Field, Name = "_value")]
  static extern ref System.Int32 UnsafeValueField( Whatever.MyInt @this);                
}
}

public static class MyInt__Ext 
{
        public static global::Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder<Whatever.MyInt> HasVogenConversion(this global::Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder<Whatever.MyInt> propertyBuilder) =>
            propertyBuilder.HasConversion<Whatever.EfCoreConverters.MyIntEfCoreValueConverter, Whatever.EfCoreConverters.MyIntEfCoreValueComparer>();
}


#endif
  
#if NET8_0_OR_GREATER

// ------------------------------------------------------------------------------
// <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 @byte;
    
  public static class EfCoreConverters__Ext
  {
      public static global::Microsoft.EntityFrameworkCore.ModelConfigurationBuilder RegisterAllInEfCoreConverters(this global::Microsoft.EntityFrameworkCore.ModelConfigurationBuilder configurationBuilder)
      {
        configurationBuilder.Properties<@int.@byte>().HaveConversion<@byte.EfCoreConverters.byteEfCoreValueConverter, @byte.EfCoreConverters.byteEfCoreValueComparer>();
configurationBuilder.Properties<@int.@string>().HaveConversion<@byte.EfCoreConverters.stringEfCoreValueConverter, @byte.EfCoreConverters.stringEfCoreValueComparer>();


        return configurationBuilder; 
      }
  }

#endif
  
#if NET8_0_OR_GREATER

// ------------------------------------------------------------------------------
// <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 @byte;
    
public partial class EfCoreConverters
{
            public class byteEfCoreValueConverter : global::Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter<@int.@byte, System.Byte>
        {
          public byteEfCoreValueConverter() : this(null) { }
          public byteEfCoreValueConverter(global::Microsoft.EntityFrameworkCore.Storage.ValueConversion.ConverterMappingHints mappingHints = null)
              : base(
                  vo => vo.Value,
                                                                      value => Deserialize(value),
                mappingHints
              ) { }

      static @int.@byte Deserialize(System.Byte value) => UnsafeDeserialize(default, value);
 
      [global::System.Runtime.CompilerServices.UnsafeAccessor(global::System.Runtime.CompilerServices.UnsafeAccessorKind.StaticMethod, Name = "__Deserialize")]
      static extern @int.@byte UnsafeDeserialize(@int.@byte @this, System.Byte value);      
        }
        public class byteEfCoreValueComparer : global::Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer<@int.@byte>
        {
            public byteEfCoreValueComparer() : base(
                (left, right) => DoCompare(left, right), 
                instance => instance.IsInitialized() ? instance.GetHashCode() : 0) 
            { 
            }
            
            static bool DoCompare(@int.@byte left, @int.@byte right)
            {
                // if neither are initialized, then they're equal
                if(!left.IsInitialized() && !right.IsInitialized()) return true;
                
                return left.IsInitialized() && right.IsInitialized() && UnderlyingValue(left).Equals(UnderlyingValue(right));
            }
 private static System.Byte UnderlyingValue(@int.@byte i) => UnsafeValueField(ref i);

  [global::System.Runtime.CompilerServices.UnsafeAccessor(global::System.Runtime.CompilerServices.UnsafeAccessorKind.Field, Name = "_value")]
  static extern ref System.Byte UnsafeValueField(ref @int.@byte @this);                
        }
}

public static class byte__Ext 
{
        public static global::Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder<@int.@byte> HasVogenConversion(this global::Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder<@int.@byte> propertyBuilder) =>
            propertyBuilder.HasConversion<@byte.EfCoreConverters.byteEfCoreValueConverter, @byte.EfCoreConverters.byteEfCoreValueComparer>();
}


#endif
  
#if NET8_0_OR_GREATER

// ------------------------------------------------------------------------------
// <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 @byte;
    
public partial class EfCoreConverters
{
            public class stringEfCoreValueConverter : global::Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter<@int.@string, System.String>
        {
          public stringEfCoreValueConverter() : this(null) { }
          public stringEfCoreValueConverter(global::Microsoft.EntityFrameworkCore.Storage.ValueConversion.ConverterMappingHints mappingHints = null)
              : base(
                  vo => vo.Value,
                                                                      value => Deserialize(value),
                mappingHints
              ) { }

      static @int.@string Deserialize(System.String value) => UnsafeDeserialize(default, value);
 
      [global::System.Runtime.CompilerServices.UnsafeAccessor(global::System.Runtime.CompilerServices.UnsafeAccessorKind.StaticMethod, Name = "__Deserialize")]
      static extern @int.@string UnsafeDeserialize(@int.@string @this, System.String value);      
        }
        public class stringEfCoreValueComparer : global::Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer<@int.@string>
        {
            public stringEfCoreValueComparer() : base(
                (left, right) => DoCompare(left, right), 
                instance => instance.IsInitialized() ? instance.GetHashCode() : 0) 
            { 
            }
            
            static bool DoCompare(@int.@string left, @int.@string right)
            {
                // if neither are initialized, then they're equal
                if(!left.IsInitialized() && !right.IsInitialized()) return true;
                
                return left.IsInitialized() && right.IsInitialized() && UnderlyingValue(left).Equals(UnderlyingValue(right));
            }
 private static System.String UnderlyingValue(@int.@string i) => UnsafeValueField(ref i);

  [global::System.Runtime.CompilerServices.UnsafeAccessor(global::System.Runtime.CompilerServices.UnsafeAccessorKind.Field, Name = "_value")]
  static extern ref System.String UnsafeValueField(ref @int.@string @this);                
        }
}

public static class string__Ext 
{
        public static global::Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder<@int.@string> HasVogenConversion(this global::Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder<@int.@string> propertyBuilder) =>
            propertyBuilder.HasConversion<@byte.EfCoreConverters.stringEfCoreValueConverter, @byte.EfCoreConverters.stringEfCoreValueComparer>();
}


#endif
  
// ------------------------------------------------------------------------------
// <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::@int.@byte),
            new global::System.Lazy<global::System.Text.Json.Serialization.JsonConverter>(() => new global::@int.@byte.@byteSystemTextJsonConverter())
        },
        {
            typeof(global::@int.@string),
            new global::System.Lazy<global::System.Text.Json.Serialization.JsonConverter>(() => new global::@int.@string.@stringSystemTextJsonConverter())
        },
        {
            typeof(global::Whatever.MyVo1),
            new global::System.Lazy<global::System.Text.Json.Serialization.JsonConverter>(() => new global::Whatever.MyVo1.MyVo1SystemTextJsonConverter())
        },
        {
            typeof(global::Whatever.MyVo2),
            new global::System.Lazy<global::System.Text.Json.Serialization.JsonConverter>(() => new global::Whatever.MyVo2.MyVo2SystemTextJsonConverter())
        },
        {
            typeof(global::Whatever.MyVo3),
            new global::System.Lazy<global::System.Text.Json.Serialization.JsonConverter>(() => new global::Whatever.MyVo3.MyVo3SystemTextJsonConverter())
        },
        {
            typeof(global::Whatever.MyVo4),
            new global::System.Lazy<global::System.Text.Json.Serialization.JsonConverter>(() => new global::Whatever.MyVo4.MyVo4SystemTextJsonConverter())
        },
        {
            typeof(global::Whatever.MyVo5),
            new global::System.Lazy<global::System.Text.Json.Serialization.JsonConverter>(() => new global::Whatever.MyVo5.MyVo5SystemTextJsonConverter())
        },
        {
            typeof(global::Whatever.MyVo6),
            new global::System.Lazy<global::System.Text.Json.Serialization.JsonConverter>(() => new global::Whatever.MyVo6.MyVo6SystemTextJsonConverter())
        },
        {
            typeof(global::Whatever.@int),
            new global::System.Lazy<global::System.Text.Json.Serialization.JsonConverter>(() => new global::Whatever.@int.@intSystemTextJsonConverter())
        },
        {
            typeof(global::Whatever.@byte),
            new global::System.Lazy<global::System.Text.Json.Serialization.JsonConverter>(() => new global::Whatever.@byte.@byteSystemTextJsonConverter())
        },
        {
            typeof(global::Whatever.MyInt),
            new global::System.Lazy<global::System.Text.Json.Serialization.JsonConverter>(() => new global::Whatever.MyInt.MyIntSystemTextJsonConverter())
        }
    };
    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 @int
{
    [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
        [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Vogen", "1.0.0.0")]
    [global::System.Text.Json.Serialization.JsonConverter(typeof(@byteSystemTextJsonConverter))]
    [global::System.ComponentModel.TypeConverter(typeof(@byteTypeConverter))]
    [global::System.Diagnostics.DebuggerTypeProxyAttribute(typeof(@byteDebugView))]
    [global::System.Diagnostics.DebuggerDisplayAttribute("Underlying type: System.Byte, Value = { _value }")]
    // ReSharper disable once UnusedType.Global
    public partial struct @byte : global::System.IEquatable<@byte>, global::System.IEquatable<System.Byte>, global::System.IComparable<@byte>, global::System.IComparable, global::System.IParsable<@byte>, global::System.ISpanParsable<@byte>, global::System.IUtf8SpanParsable<@byte>, 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.Byte _value;
        /// <summary>
        /// Gets the underlying <see cref = "System.Byte"/> value if set, otherwise a <see cref = "Vogen.ValueObjectValidationException"/> is thrown.
        /// </summary>
        public readonly System.Byte Value
        {
            [global::System.Diagnostics.DebuggerStepThroughAttribute]
            [global::System.Runtime.CompilerServices.MethodImpl(global::System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
            get
            {
                EnsureInitialized();
                return _value;
            }
        }

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

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

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

        public readonly global::System.Boolean Equals(@byte other)
        {
            // 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;
            return global::System.Collections.Generic.EqualityComparer<System.Byte>.Default.Equals(Value, other.Value);
        }

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

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

        public readonly override global::System.Boolean Equals(global::System.Object obj)
        {
            return obj is @byte && Equals((@byte)obj);
        }

        public static global::System.Boolean operator ==(@byte left, @byte right) => left.Equals(right);
        public static global::System.Boolean operator !=(@byte left, @byte right) => !(left == right);
        public static global::System.Boolean operator ==(@byte left, System.Byte right) => left.Value.Equals(right);
        public static global::System.Boolean operator ==(System.Byte left, @byte right) => right.Value.Equals(left);
        public static global::System.Boolean operator !=(System.Byte left, @byte right) => !(left == right);
        public static global::System.Boolean operator !=(@byte left, System.Byte right) => !(left == right);
        public int CompareTo(@byte other) => Value.CompareTo(other.Value);
        public int CompareTo(object other)
        {
            if (other is null)
                return 1;
            if (other is @byte x)
                return CompareTo(x);
            ThrowHelper.ThrowArgumentException("Cannot compare to object as it is not of type @byte", nameof(other));
            return 0;
        }

        /// <inheritdoc cref = "byte.TryParse(System.ReadOnlySpan{byte}, out byte)"/>
        /// <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 @byte result)
        {
            if (System.Byte.TryParse(utf8Text, out var __v))
            {
                result = new @byte(__v);
                return true;
            }

            result = default;
            return false;
        }

        /// <inheritdoc cref = "byte.TryParse(System.ReadOnlySpan{byte}, System.Globalization.NumberStyles, System.IFormatProvider? , out byte)"/>
        /// <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 @byte result)
        {
            if (System.Byte.TryParse(utf8Text, style, provider, out var __v))
            {
                result = new @byte(__v);
                return true;
            }

            result = default;
            return false;
        }

        /// <inheritdoc cref = "byte.TryParse(System.ReadOnlySpan{byte}, System.IFormatProvider? , out byte)"/>
        /// <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 @byte result)
        {
            if (System.Byte.TryParse(utf8Text, provider, out var __v))
            {
                result = new @byte(__v);
                return true;
            }

            result = default;
            return false;
        }

        /// <inheritdoc cref = "byte.TryParse(System.ReadOnlySpan{char}, out byte)"/>
        /// <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 @byte result)
        {
            if (System.Byte.TryParse(s, out var __v))
            {
                result = new @byte(__v);
                return true;
            }

            result = default;
            return false;
        }

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

            result = default;
            return false;
        }

        /// <inheritdoc cref = "byte.TryParse(System.ReadOnlySpan{char}, System.IFormatProvider? , out byte)"/>
        /// <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 @byte result)
        {
            if (System.Byte.TryParse(s, provider, out var __v))
            {
                result = new @byte(__v);
                return true;
            }

            result = default;
            return false;
        }

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

            result = default;
            return false;
        }

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

            result = default;
            return false;
        }

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

            result = default;
            return false;
        }

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

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

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

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

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

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

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

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

#nullable disable
        /// <inheritdoc cref = "byte.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 = "byte.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 = "byte.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 readonly override global::System.Int32 GetHashCode()
        {
            return global::System.Collections.Generic.EqualityComparer<System.Byte>.Default.GetHashCode(Value);
        }

        /// <inheritdoc cref = "System.Byte.ToString()"/>
        public override global::System.String ToString() => IsInitialized() ? Value.ToString() ?? "" : "[UNINITIALIZED]";
        /// <inheritdoc cref = "System.Byte.ToString(System.IFormatProvider? )"/>
        public global::System.String ToString(global::System.IFormatProvider provider) => IsInitialized() ? Value.ToString(provider) ?? "" : "[UNINITIALIZED]";
        /// <inheritdoc cref = "System.Byte.ToString(string? )"/>
        public global::System.String ToString([System.Diagnostics.CodeAnalysis.StringSyntaxAttribute("NumericFormat")] string format) => IsInitialized() ? Value.ToString(format) ?? "" : "[UNINITIALIZED]";
        [global::System.Runtime.CompilerServices.MethodImpl(global::System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
        private readonly void EnsureInitialized()
        {
            if (!IsInitialized())
            {
#if DEBUG
               ThrowHelper.ThrowWhenNotInitialized(_stackTrace);
#else
                ThrowHelper.ThrowWhenNotInitialized();
#endif
            }
        }

#nullable disable
        /// <summary>
        /// Converts a @byte to or from JSON.
        /// </summary>
        public class @byteSystemTextJsonConverter : global::System.Text.Json.Serialization.JsonConverter<@byte>
        {
            public override @byte 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.Byte>)options.GetTypeInfo(typeof(global::System.Byte))));
#else
                return DeserializeJson(reader.GetByte());
#endif
            }

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

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

#nullable restore
#nullable disable
        class @byteTypeConverter : global::System.ComponentModel.TypeConverter
        {
            public override global::System.Boolean CanConvertFrom(global::System.ComponentModel.ITypeDescriptorContext context, global::System.Type sourceType)
            {
                return sourceType == typeof(global::System.Byte) || 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.Byte byteValue => @byte.__Deserialize(byteValue),
                    global::System.Int16 shortValue => @byte.__Deserialize((global::System.Byte)shortValue),
                    global::System.Int32 intValue => @byte.__Deserialize((global::System.Byte)intValue),
                    global::System.Int64 longValue => @byte.__Deserialize((global::System.Byte)longValue),
                    global::System.String stringValue when !global::System.String.IsNullOrEmpty(stringValue) && global::System.Byte.TryParse(stringValue, out var result) => @byte.__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.Byte) || 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 @byte idValue)
                {
                    if (destinationType == typeof(global::System.Byte))
                    {
                        return idValue.Value;
                    }

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

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

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

            public global::System.Boolean IsInitialized => _t.IsInitialized();
            public global::System.String UnderlyingType => "System.Byte";
            public global::System.String Value => _t.IsInitialized() ? _t._value.ToString() : "[not initialized]";
#if DEBUG
        public global::System.String CreatedWith => _t._stackTrace.ToString() ?? "the From method";
#endif
            public global::System.String Conversions => @"Default";
        }

#nullable restore
        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 @int
{
    [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
        [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Vogen", "1.0.0.0")]
    [global::System.Text.Json.Serialization.JsonConverter(typeof(@stringSystemTextJsonConverter))]
    [global::System.ComponentModel.TypeConverter(typeof(@stringTypeConverter))]
    [global::System.Diagnostics.DebuggerTypeProxyAttribute(typeof(@stringDebugView))]
    [global::System.Diagnostics.DebuggerDisplayAttribute("Underlying type: System.String, Value = { _value }")]
    public partial record struct @string : global::System.IEquatable<@string>, global::System.IEquatable<System.String>, global::System.IComparable<@string>, global::System.IComparable, global::System.IParsable<@string>
    {
#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 readonly 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]
            init
            {
                if (value is null)
                {
                    ThrowHelper.ThrowWhenCreatedWithNull();
                    return;
                }

                _value = value;
            }
        }

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

        [global::System.Diagnostics.DebuggerStepThroughAttribute]
        private @string(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 @string From(System.String value)
        {
            return new @string(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 @string 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 @string(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<@string> TryFrom(System.String value)
        {
            if (value is null)
            {
                return new Vogen.ValueObjectOrError<@string>(Vogen.Validation.Invalid("The value provided was null"));
            }

            return new Vogen.ValueObjectOrError<@string>(new @string(value));
        }

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

        public readonly global::System.Boolean Equals(@string other)
        {
            // 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;
            return global::System.Collections.Generic.EqualityComparer<System.String>.Default.Equals(Value, other.Value);
        }

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

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

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

        public static global::System.Boolean operator ==(@string left, System.String right) => left.Value.Equals(right);
        public static global::System.Boolean operator ==(System.String left, @string right) => right.Value.Equals(left);
        public static global::System.Boolean operator !=(System.String left, @string right) => !(left == right);
        public static global::System.Boolean operator !=(@string left, System.String right) => !(left == right);
        public int CompareTo(@string other) => Value.CompareTo(other.Value);
        public int CompareTo(object other)
        {
            if (other is null)
                return 1;
            if (other is @string x)
                return CompareTo(x);
            ThrowHelper.ThrowArgumentException("Cannot compare to object as it is not of type @string", 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 @string result)
        {
            if (s is null)
            {
                result = default;
                return false;
            }

            result = new @string(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 @string Parse(global::System.String s, global::System.IFormatProvider provider)
        {
            return From(s);
        }

#nullable disable
#nullable restore
        public readonly override global::System.Int32 GetHashCode()
        {
            return global::System.Collections.Generic.EqualityComparer<System.String>.Default.GetHashCode(Value);
        }

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

        // record enumerates fields - we just want our Value and to throw if it's not initialized.
        /// <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 @string to or from JSON.
        /// </summary>
        public class @stringSystemTextJsonConverter : global::System.Text.Json.Serialization.JsonConverter<@string>
        {
            public override @string 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, @string value, global::System.Text.Json.JsonSerializerOptions options)
            {
                writer.WriteStringValue(value.Value);
            }

#if NET6_0_OR_GREATER
            public override @string 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, @string 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 @string DeserializeJson(System.String value)
            {
                ThrowJsonExceptionWhenNull(value);
                return new @string(value);
            }
        }

#nullable restore
#nullable disable
        class @stringTypeConverter : 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 @string.__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 @string idValue)
                {
                    if (destinationType == typeof(global::System.String))
                    {
                        return idValue.Value;
                    }
                }

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

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

            public global::System.Boolean IsInitialized => _t.IsInitialized();
            public global::System.String UnderlyingType => "System.String";
            public global::System.String Value => _t.IsInitialized() ? _t._value.ToString() : "[not initialized]";
#if DEBUG
        public global::System.String CreatedWith => _t._stackTrace.ToString() ?? "the From method";
#endif
            public global::System.String Conversions => @"Default";
        }

#nullable restore
        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 Whatever
{
    [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
        [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Vogen", "1.0.0.0")]
    [global::System.Text.Json.Serialization.JsonConverter(typeof(MyVo1SystemTextJsonConverter))]
    [global::System.ComponentModel.TypeConverter(typeof(MyVo1TypeConverter))]
    [global::System.Diagnostics.DebuggerTypeProxyAttribute(typeof(MyVo1DebugView))]
    [global::System.Diagnostics.DebuggerDisplayAttribute("Underlying type: System.Int32, Value = { _value }")]
    // ReSharper disable once UnusedType.Global
    public partial struct MyVo1 : global::System.IEquatable<MyVo1>, global::System.IEquatable<System.Int32>, global::System.IComparable<MyVo1>, global::System.IComparable, global::System.IParsable<MyVo1>, global::System.ISpanParsable<MyVo1>, global::System.IUtf8SpanParsable<MyVo1>, 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 readonly System.Int32 Value
        {
            [global::System.Diagnostics.DebuggerStepThroughAttribute]
            [global::System.Runtime.CompilerServices.MethodImpl(global::System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
            get
            {
                EnsureInitialized();
                return _value;
            }
        }

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

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

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

        public readonly global::System.Boolean Equals(MyVo1 other)
        {
            // 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;
            return global::System.Collections.Generic.EqualityComparer<System.Int32>.Default.Equals(Value, other.Value);
        }

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

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

        public readonly override global::System.Boolean Equals(global::System.Object obj)
        {
            return obj is MyVo1 && Equals((MyVo1)obj);
        }

        public static global::System.Boolean operator ==(MyVo1 left, MyVo1 right) => left.Equals(right);
        public static global::System.Boolean operator !=(MyVo1 left, MyVo1 right) => !(left == right);
        public static global::System.Boolean operator ==(MyVo1 left, System.Int32 right) => left.Value.Equals(right);
        public static global::System.Boolean operator ==(System.Int32 left, MyVo1 right) => right.Value.Equals(left);
        public static global::System.Boolean operator !=(System.Int32 left, MyVo1 right) => !(left == right);
        public static global::System.Boolean operator !=(MyVo1 left, System.Int32 right) => !(left == right);
        public int CompareTo(MyVo1 other) => Value.CompareTo(other.Value);
        public int CompareTo(object other)
        {
            if (other is null)
                return 1;
            if (other is MyVo1 x)
                return CompareTo(x);
            ThrowHelper.ThrowArgumentException("Cannot compare to object as it is not of type MyVo1", 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 MyVo1 result)
        {
            if (System.Int32.TryParse(utf8Text, style, provider, out var __v))
            {
                result = new MyVo1(__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 MyVo1 result)
        {
            if (System.Int32.TryParse(utf8Text, provider, out var __v))
            {
                result = new MyVo1(__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 MyVo1 result)
        {
            if (System.Int32.TryParse(utf8Text, out var __v))
            {
                result = new MyVo1(__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 MyVo1 result)
        {
            if (System.Int32.TryParse(s, style, provider, out var __v))
            {
                result = new MyVo1(__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 MyVo1 result)
        {
            if (System.Int32.TryParse(s, provider, out var __v))
            {
                result = new MyVo1(__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 MyVo1 result)
        {
            if (System.Int32.TryParse(s, out var __v))
            {
                result = new MyVo1(__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 MyVo1 result)
        {
            if (System.Int32.TryParse(s, style, provider, out var __v))
            {
                result = new MyVo1(__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 MyVo1 result)
        {
            if (System.Int32.TryParse(s, provider, out var __v))
            {
                result = new MyVo1(__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 MyVo1 result)
        {
            if (System.Int32.TryParse(s, out var __v))
            {
                result = new MyVo1(__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 MyVo1 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 MyVo1 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 MyVo1 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 MyVo1 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 MyVo1 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 MyVo1 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 MyVo1 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 MyVo1 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 readonly override global::System.Int32 GetHashCode()
        {
            return global::System.Collections.Generic.EqualityComparer<System.Int32>.Default.GetHashCode(Value);
        }

        /// <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]";
        [global::System.Runtime.CompilerServices.MethodImpl(global::System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
        private readonly void EnsureInitialized()
        {
            if (!IsInitialized())
            {
#if DEBUG
               ThrowHelper.ThrowWhenNotInitialized(_stackTrace);
#else
                ThrowHelper.ThrowWhenNotInitialized();
#endif
            }
        }

#nullable disable
        /// <summary>
        /// Converts a MyVo1 to or from JSON.
        /// </summary>
        public class MyVo1SystemTextJsonConverter : global::System.Text.Json.Serialization.JsonConverter<MyVo1>
        {
            public override MyVo1 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, MyVo1 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 MyVo1 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, MyVo1 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 MyVo1 DeserializeJson(System.Int32 value)
            {
                return new MyVo1(value);
            }
        }

#nullable restore
#nullable disable
        class MyVo1TypeConverter : 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 => MyVo1.__Deserialize(intValue),
                    global::System.String stringValue when !global::System.String.IsNullOrEmpty(stringValue) && global::System.Int32.TryParse(stringValue, out var result) => MyVo1.__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 MyVo1 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
#nullable disable
        internal sealed class MyVo1DebugView
        {
            private readonly MyVo1 _t;
            MyVo1DebugView(MyVo1 t)
            {
                _t = t;
            }

            public global::System.Boolean IsInitialized => _t.IsInitialized();
            public global::System.String UnderlyingType => "System.Int32";
            public global::System.String Value => _t.IsInitialized() ? _t._value.ToString() : "[not initialized]";
#if DEBUG
        public global::System.String CreatedWith => _t._stackTrace.ToString() ?? "the From method";
#endif
            public global::System.String Conversions => @"Default";
        }

#nullable restore
        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 Whatever
{
    [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
        [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Vogen", "1.0.0.0")]
    [global::System.Text.Json.Serialization.JsonConverter(typeof(MyVo2SystemTextJsonConverter))]
    [global::System.ComponentModel.TypeConverter(typeof(MyVo2TypeConverter))]
    [global::System.Diagnostics.DebuggerTypeProxyAttribute(typeof(MyVo2DebugView))]
    [global::System.Diagnostics.DebuggerDisplayAttribute("Underlying type: System.String, Value = { _value }")]
    public partial class MyVo2 : global::System.IEquatable<MyVo2>, global::System.IEquatable<System.String>, global::System.IComparable<MyVo2>, global::System.IComparable, global::System.IParsable<MyVo2>
    {
#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 MyVo2()
        {
#if DEBUG
            _stackTrace = new global::System.Diagnostics.StackTrace();
#endif
#if !VOGEN_NO_VALIDATION
            _isInitialized = false;
#endif
            _value = default;
        }

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

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

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

            return new MyVo2(value);
        }

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

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

            result = new MyVo2(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 MyVo2 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 MyVo2 to or from JSON.
        /// </summary>
        public class MyVo2SystemTextJsonConverter : global::System.Text.Json.Serialization.JsonConverter<MyVo2>
        {
            public override MyVo2 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, MyVo2 value, global::System.Text.Json.JsonSerializerOptions options)
            {
                writer.WriteStringValue(value.Value);
            }

#if NET6_0_OR_GREATER
            public override MyVo2 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, MyVo2 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 MyVo2 DeserializeJson(System.String value)
            {
                ThrowJsonExceptionWhenNull(value);
                return new MyVo2(value);
            }
        }

#nullable restore
#nullable disable
        class MyVo2TypeConverter : 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 MyVo2.__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 MyVo2 idValue)
                {
                    if (destinationType == typeof(global::System.String))
                    {
                        return idValue.Value;
                    }
                }

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

#nullable restore
        internal sealed class MyVo2DebugView
        {
            private readonly MyVo2 _t;
            MyVo2DebugView(MyVo2 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(MyVo2SystemTextJsonConverter))]
[global::System.ComponentModel.TypeConverter(typeof(MyVo2TypeConverter))]
";
        }

        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 Whatever
{
    [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
        [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Vogen", "1.0.0.0")]
    [global::System.Text.Json.Serialization.JsonConverter(typeof(MyVo3SystemTextJsonConverter))]
    [global::System.ComponentModel.TypeConverter(typeof(MyVo3TypeConverter))]
    [global::System.Diagnostics.DebuggerTypeProxyAttribute(typeof(MyVo3DebugView))]
    [global::System.Diagnostics.DebuggerDisplayAttribute("Underlying type: System.String, Value = { _value }")]
    // ReSharper disable once UnusedType.Global
    public readonly partial struct MyVo3 : global::System.IEquatable<MyVo3>, global::System.IEquatable<System.String>, global::System.IComparable<MyVo3>, global::System.IComparable, global::System.IParsable<MyVo3>
    {
#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 readonly System.String Value
        {
            [global::System.Diagnostics.DebuggerStepThroughAttribute]
            [global::System.Runtime.CompilerServices.MethodImpl(global::System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
            get
            {
                EnsureInitialized();
                return _value;
            }
        }

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

        [global::System.Diagnostics.DebuggerStepThroughAttribute]
        private MyVo3(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 MyVo3 From(System.String value)
        {
            return new MyVo3(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 MyVo3 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 MyVo3(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<MyVo3> TryFrom(System.String value)
        {
            if (value is null)
            {
                return new Vogen.ValueObjectOrError<MyVo3>(Vogen.Validation.Invalid("The value provided was null"));
            }

            return new Vogen.ValueObjectOrError<MyVo3>(new MyVo3(value));
        }

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

        public readonly global::System.Boolean Equals(MyVo3 other)
        {
            // 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;
            return global::System.Collections.Generic.EqualityComparer<System.String>.Default.Equals(Value, other.Value);
        }

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

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

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

        public readonly override global::System.Boolean Equals(global::System.Object obj)
        {
            return obj is MyVo3 && Equals((MyVo3)obj);
        }

        public static global::System.Boolean operator ==(MyVo3 left, MyVo3 right) => left.Equals(right);
        public static global::System.Boolean operator !=(MyVo3 left, MyVo3 right) => !(left == right);
        public static global::System.Boolean operator ==(MyVo3 left, System.String right) => left.Value.Equals(right);
        public static global::System.Boolean operator ==(System.String left, MyVo3 right) => right.Value.Equals(left);
        public static global::System.Boolean operator !=(System.String left, MyVo3 right) => !(left == right);
        public static global::System.Boolean operator !=(MyVo3 left, System.String right) => !(left == right);
        public int CompareTo(MyVo3 other) => Value.CompareTo(other.Value);
        public int CompareTo(object other)
        {
            if (other is null)
                return 1;
            if (other is MyVo3 x)
                return CompareTo(x);
            ThrowHelper.ThrowArgumentException("Cannot compare to object as it is not of type MyVo3", 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 MyVo3 result)
        {
            if (s is null)
            {
                result = default;
                return false;
            }

            result = new MyVo3(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 MyVo3 Parse(global::System.String s, global::System.IFormatProvider provider)
        {
            return From(s);
        }

#nullable disable
#nullable restore
        public readonly override global::System.Int32 GetHashCode()
        {
            return global::System.Collections.Generic.EqualityComparer<System.String>.Default.GetHashCode(Value);
        }

        /// <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]";
        [global::System.Runtime.CompilerServices.MethodImpl(global::System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
        private readonly void EnsureInitialized()
        {
            if (!IsInitialized())
            {
#if DEBUG
               ThrowHelper.ThrowWhenNotInitialized(_stackTrace);
#else
                ThrowHelper.ThrowWhenNotInitialized();
#endif
            }
        }

#nullable disable
        /// <summary>
        /// Converts a MyVo3 to or from JSON.
        /// </summary>
        public class MyVo3SystemTextJsonConverter : global::System.Text.Json.Serialization.JsonConverter<MyVo3>
        {
            public override MyVo3 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, MyVo3 value, global::System.Text.Json.JsonSerializerOptions options)
            {
                writer.WriteStringValue(value.Value);
            }

#if NET6_0_OR_GREATER
            public override MyVo3 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, MyVo3 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 MyVo3 DeserializeJson(System.String value)
            {
                ThrowJsonExceptionWhenNull(value);
                return new MyVo3(value);
            }
        }

#nullable restore
#nullable disable
        class MyVo3TypeConverter : 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 MyVo3.__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 MyVo3 idValue)
                {
                    if (destinationType == typeof(global::System.String))
                    {
                        return idValue.Value;
                    }
                }

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

#nullable restore
#nullable disable
        internal sealed class MyVo3DebugView
        {
            private readonly MyVo3 _t;
            MyVo3DebugView(MyVo3 t)
            {
                _t = t;
            }

            public global::System.Boolean IsInitialized => _t.IsInitialized();
            public global::System.String UnderlyingType => "System.String";
            public global::System.String Value => _t.IsInitialized() ? _t._value.ToString() : "[not initialized]";
#if DEBUG
        public global::System.String CreatedWith => _t._stackTrace.ToString() ?? "the From method";
#endif
            public global::System.String Conversions => @"Default";
        }

#nullable restore
        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 Whatever
{
    [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
        [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Vogen", "1.0.0.0")]
    [global::System.Text.Json.Serialization.JsonConverter(typeof(MyVo4SystemTextJsonConverter))]
    [global::System.ComponentModel.TypeConverter(typeof(MyVo4TypeConverter))]
    [global::System.Diagnostics.DebuggerTypeProxyAttribute(typeof(MyVo4DebugView))]
    [global::System.Diagnostics.DebuggerDisplayAttribute("Underlying type: System.Int32, Value = { _value }")]
    // ReSharper disable once UnusedType.Global
    public readonly partial struct MyVo4 : global::System.IEquatable<MyVo4>, global::System.IEquatable<System.Int32>, global::System.IComparable<MyVo4>, global::System.IComparable, global::System.IParsable<MyVo4>, global::System.ISpanParsable<MyVo4>, global::System.IUtf8SpanParsable<MyVo4>, 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 readonly System.Int32 Value
        {
            [global::System.Diagnostics.DebuggerStepThroughAttribute]
            [global::System.Runtime.CompilerServices.MethodImpl(global::System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
            get
            {
                EnsureInitialized();
                return _value;
            }
        }

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

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

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

        public readonly global::System.Boolean Equals(MyVo4 other)
        {
            // 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;
            return global::System.Collections.Generic.EqualityComparer<System.Int32>.Default.Equals(Value, other.Value);
        }

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

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

        public readonly override global::System.Boolean Equals(global::System.Object obj)
        {
            return obj is MyVo4 && Equals((MyVo4)obj);
        }

        public static global::System.Boolean operator ==(MyVo4 left, MyVo4 right) => left.Equals(right);
        public static global::System.Boolean operator !=(MyVo4 left, MyVo4 right) => !(left == right);
        public static global::System.Boolean operator ==(MyVo4 left, System.Int32 right) => left.Value.Equals(right);
        public static global::System.Boolean operator ==(System.Int32 left, MyVo4 right) => right.Value.Equals(left);
        public static global::System.Boolean operator !=(System.Int32 left, MyVo4 right) => !(left == right);
        public static global::System.Boolean operator !=(MyVo4 left, System.Int32 right) => !(left == right);
        public int CompareTo(MyVo4 other) => Value.CompareTo(other.Value);
        public int CompareTo(object other)
        {
            if (other is null)
                return 1;
            if (other is MyVo4 x)
                return CompareTo(x);
            ThrowHelper.ThrowArgumentException("Cannot compare to object as it is not of type MyVo4", 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 MyVo4 result)
        {
            if (System.Int32.TryParse(utf8Text, style, provider, out var __v))
            {
                result = new MyVo4(__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 MyVo4 result)
        {
            if (System.Int32.TryParse(utf8Text, provider, out var __v))
            {
                result = new MyVo4(__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 MyVo4 result)
        {
            if (System.Int32.TryParse(utf8Text, out var __v))
            {
                result = new MyVo4(__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 MyVo4 result)
        {
            if (System.Int32.TryParse(s, style, provider, out var __v))
            {
                result = new MyVo4(__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 MyVo4 result)
        {
            if (System.Int32.TryParse(s, provider, out var __v))
            {
                result = new MyVo4(__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 MyVo4 result)
        {
            if (System.Int32.TryParse(s, out var __v))
            {
                result = new MyVo4(__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 MyVo4 result)
        {
            if (System.Int32.TryParse(s, style, provider, out var __v))
            {
                result = new MyVo4(__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 MyVo4 result)
        {
            if (System.Int32.TryParse(s, provider, out var __v))
            {
                result = new MyVo4(__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 MyVo4 result)
        {
            if (System.Int32.TryParse(s, out var __v))
            {
                result = new MyVo4(__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 MyVo4 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 MyVo4 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 MyVo4 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 MyVo4 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 MyVo4 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 MyVo4 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 MyVo4 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 MyVo4 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 readonly override global::System.Int32 GetHashCode()
        {
            return global::System.Collections.Generic.EqualityComparer<System.Int32>.Default.GetHashCode(Value);
        }

        /// <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]";
        [global::System.Runtime.CompilerServices.MethodImpl(global::System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
        private readonly void EnsureInitialized()
        {
            if (!IsInitialized())
            {
#if DEBUG
               ThrowHelper.ThrowWhenNotInitialized(_stackTrace);
#else
                ThrowHelper.ThrowWhenNotInitialized();
#endif
            }
        }

#nullable disable
        /// <summary>
        /// Converts a MyVo4 to or from JSON.
        /// </summary>
        public class MyVo4SystemTextJsonConverter : global::System.Text.Json.Serialization.JsonConverter<MyVo4>
        {
            public override MyVo4 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, MyVo4 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 MyVo4 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, MyVo4 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 MyVo4 DeserializeJson(System.Int32 value)
            {
                return new MyVo4(value);
            }
        }

#nullable restore
#nullable disable
        class MyVo4TypeConverter : 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 => MyVo4.__Deserialize(intValue),
                    global::System.String stringValue when !global::System.String.IsNullOrEmpty(stringValue) && global::System.Int32.TryParse(stringValue, out var result) => MyVo4.__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 MyVo4 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
#nullable disable
        internal sealed class MyVo4DebugView
        {
            private readonly MyVo4 _t;
            MyVo4DebugView(MyVo4 t)
            {
                _t = t;
            }

            public global::System.Boolean IsInitialized => _t.IsInitialized();
            public global::System.String UnderlyingType => "System.Int32";
            public global::System.String Value => _t.IsInitialized() ? _t._value.ToString() : "[not initialized]";
#if DEBUG
        public global::System.String CreatedWith => _t._stackTrace.ToString() ?? "the From method";
#endif
            public global::System.String Conversions => @"Default";
        }

#nullable restore
        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 Whatever
{
    [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
        [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Vogen", "1.0.0.0")]
    [global::System.Text.Json.Serialization.JsonConverter(typeof(MyVo5SystemTextJsonConverter))]
    [global::System.ComponentModel.TypeConverter(typeof(MyVo5TypeConverter))]
    [global::System.Diagnostics.DebuggerTypeProxyAttribute(typeof(MyVo5DebugView))]
    [global::System.Diagnostics.DebuggerDisplayAttribute("Underlying type: System.Int32, Value = { _value }")]
    public readonly partial record struct MyVo5 : global::System.IEquatable<MyVo5>, global::System.IEquatable<System.Int32>, global::System.IComparable<MyVo5>, global::System.IComparable, global::System.IParsable<MyVo5>, global::System.ISpanParsable<MyVo5>, global::System.IUtf8SpanParsable<MyVo5>, 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 readonly 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]
            init
            {
                _value = value;
            }
        }

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

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

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

        public readonly global::System.Boolean Equals(MyVo5 other)
        {
            // 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;
            return global::System.Collections.Generic.EqualityComparer<System.Int32>.Default.Equals(Value, other.Value);
        }

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

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

        public static global::System.Boolean operator ==(MyVo5 left, System.Int32 right) => left.Value.Equals(right);
        public static global::System.Boolean operator ==(System.Int32 left, MyVo5 right) => right.Value.Equals(left);
        public static global::System.Boolean operator !=(System.Int32 left, MyVo5 right) => !(left == right);
        public static global::System.Boolean operator !=(MyVo5 left, System.Int32 right) => !(left == right);
        public int CompareTo(MyVo5 other) => Value.CompareTo(other.Value);
        public int CompareTo(object other)
        {
            if (other is null)
                return 1;
            if (other is MyVo5 x)
                return CompareTo(x);
            ThrowHelper.ThrowArgumentException("Cannot compare to object as it is not of type MyVo5", 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 MyVo5 result)
        {
            if (System.Int32.TryParse(utf8Text, style, provider, out var __v))
            {
                result = new MyVo5(__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 MyVo5 result)
        {
            if (System.Int32.TryParse(utf8Text, provider, out var __v))
            {
                result = new MyVo5(__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 MyVo5 result)
        {
            if (System.Int32.TryParse(utf8Text, out var __v))
            {
                result = new MyVo5(__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 MyVo5 result)
        {
            if (System.Int32.TryParse(s, style, provider, out var __v))
            {
                result = new MyVo5(__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 MyVo5 result)
        {
            if (System.Int32.TryParse(s, provider, out var __v))
            {
                result = new MyVo5(__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 MyVo5 result)
        {
            if (System.Int32.TryParse(s, out var __v))
            {
                result = new MyVo5(__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 MyVo5 result)
        {
            if (System.Int32.TryParse(s, style, provider, out var __v))
            {
                result = new MyVo5(__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 MyVo5 result)
        {
            if (System.Int32.TryParse(s, provider, out var __v))
            {
                result = new MyVo5(__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 MyVo5 result)
        {
            if (System.Int32.TryParse(s, out var __v))
            {
                result = new MyVo5(__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 MyVo5 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 MyVo5 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 MyVo5 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 MyVo5 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 MyVo5 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 MyVo5 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 MyVo5 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 MyVo5 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 readonly override global::System.Int32 GetHashCode()
        {
            return global::System.Collections.Generic.EqualityComparer<System.Int32>.Default.GetHashCode(Value);
        }

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

        // record enumerates fields - we just want our Value and to throw if it's not initialized.
        /// <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 MyVo5 to or from JSON.
        /// </summary>
        public class MyVo5SystemTextJsonConverter : global::System.Text.Json.Serialization.JsonConverter<MyVo5>
        {
            public override MyVo5 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, MyVo5 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 MyVo5 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, MyVo5 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 MyVo5 DeserializeJson(System.Int32 value)
            {
                return new MyVo5(value);
            }
        }

#nullable restore
#nullable disable
        class MyVo5TypeConverter : 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 => MyVo5.__Deserialize(intValue),
                    global::System.String stringValue when !global::System.String.IsNullOrEmpty(stringValue) && global::System.Int32.TryParse(stringValue, out var result) => MyVo5.__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 MyVo5 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
#nullable disable
        internal sealed class MyVo5DebugView
        {
            private readonly MyVo5 _t;
            MyVo5DebugView(MyVo5 t)
            {
                _t = t;
            }

            public global::System.Boolean IsInitialized => _t.IsInitialized();
            public global::System.String UnderlyingType => "System.Int32";
            public global::System.String Value => _t.IsInitialized() ? _t._value.ToString() : "[not initialized]";
#if DEBUG
        public global::System.String CreatedWith => _t._stackTrace.ToString() ?? "the From method";
#endif
            public global::System.String Conversions => @"Default";
        }

#nullable restore
        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 Whatever
{
    [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
        [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Vogen", "1.0.0.0")]
    [global::System.Text.Json.Serialization.JsonConverter(typeof(MyVo6SystemTextJsonConverter))]
    [global::System.ComponentModel.TypeConverter(typeof(MyVo6TypeConverter))]
    [global::System.Diagnostics.DebuggerTypeProxyAttribute(typeof(MyVo6DebugView))]
    [global::System.Diagnostics.DebuggerDisplayAttribute("Underlying type: System.Int32, Value = { _value }")]
    public partial record class MyVo6 : global::System.IEquatable<MyVo6>, global::System.IEquatable<System.Int32>, global::System.IComparable<MyVo6>, global::System.IComparable, global::System.IParsable<MyVo6>, global::System.ISpanParsable<MyVo6>, global::System.IUtf8SpanParsable<MyVo6>, 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]
            init
            {
                _value = value;
            }
        }

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

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

        public virtual global::System.Boolean Equals(MyVo6 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(MyVo6 other, global::System.Collections.Generic.IEqualityComparer<MyVo6> comparer)
        {
            return comparer.Equals(this, other);
        }

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

        public static global::System.Boolean operator ==(MyVo6 left, System.Int32 right) => left.Value.Equals(right);
        public static global::System.Boolean operator ==(System.Int32 left, MyVo6 right) => right.Value.Equals(left);
        public static global::System.Boolean operator !=(System.Int32 left, MyVo6 right) => !(left == right);
        public static global::System.Boolean operator !=(MyVo6 left, System.Int32 right) => !(left == right);
        public static explicit operator MyVo6(System.Int32 value) => From(value);
        public static explicit operator System.Int32(MyVo6 value) => value.Value;
        public int CompareTo(MyVo6 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 MyVo6 x)
                return CompareTo(x);
            ThrowHelper.ThrowArgumentException("Cannot compare to object as it is not of type MyVo6", 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 MyVo6 result)
        {
            if (System.Int32.TryParse(utf8Text, style, provider, out var __v))
            {
                result = new MyVo6(__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 MyVo6 result)
        {
            if (System.Int32.TryParse(utf8Text, provider, out var __v))
            {
                result = new MyVo6(__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 MyVo6 result)
        {
            if (System.Int32.TryParse(utf8Text, out var __v))
            {
                result = new MyVo6(__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 MyVo6 result)
        {
            if (System.Int32.TryParse(s, style, provider, out var __v))
            {
                result = new MyVo6(__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 MyVo6 result)
        {
            if (System.Int32.TryParse(s, provider, out var __v))
            {
                result = new MyVo6(__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 MyVo6 result)
        {
            if (System.Int32.TryParse(s, out var __v))
            {
                result = new MyVo6(__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 MyVo6 result)
        {
            if (System.Int32.TryParse(s, style, provider, out var __v))
            {
                result = new MyVo6(__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 MyVo6 result)
        {
            if (System.Int32.TryParse(s, provider, out var __v))
            {
                result = new MyVo6(__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 MyVo6 result)
        {
            if (System.Int32.TryParse(s, out var __v))
            {
                result = new MyVo6(__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 MyVo6 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 MyVo6 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 MyVo6 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 MyVo6 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 MyVo6 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 MyVo6 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 MyVo6 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 MyVo6 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
            }
        }

        // record enumerates fields - we just want our Value and to throw if it's not initialized.
        /// <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 MyVo6 to or from JSON.
        /// </summary>
        public class MyVo6SystemTextJsonConverter : global::System.Text.Json.Serialization.JsonConverter<MyVo6>
        {
            public override MyVo6 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, MyVo6 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 MyVo6 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, MyVo6 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 MyVo6 DeserializeJson(System.Int32 value)
            {
                return new MyVo6(value);
            }
        }

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

        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 Whatever
{
    [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
        [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Vogen", "1.0.0.0")]
    [global::System.Text.Json.Serialization.JsonConverter(typeof(@intSystemTextJsonConverter))]
    [global::System.ComponentModel.TypeConverter(typeof(@intTypeConverter))]
    [global::System.Diagnostics.DebuggerTypeProxyAttribute(typeof(@intDebugView))]
    [global::System.Diagnostics.DebuggerDisplayAttribute("Underlying type: System.Int32, Value = { _value }")]
    public partial record struct @int : global::System.IEquatable<@int>, global::System.IEquatable<System.Int32>, global::System.IComparable<@int>, global::System.IComparable, global::System.IParsable<@int>, global::System.ISpanParsable<@int>, global::System.IUtf8SpanParsable<@int>, 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 readonly 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]
            init
            {
                _value = value;
            }
        }

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

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

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

        public readonly global::System.Boolean Equals(@int other)
        {
            // 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;
            return global::System.Collections.Generic.EqualityComparer<System.Int32>.Default.Equals(Value, other.Value);
        }

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

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

        public static global::System.Boolean operator ==(@int left, System.Int32 right) => left.Value.Equals(right);
        public static global::System.Boolean operator ==(System.Int32 left, @int right) => right.Value.Equals(left);
        public static global::System.Boolean operator !=(System.Int32 left, @int right) => !(left == right);
        public static global::System.Boolean operator !=(@int left, System.Int32 right) => !(left == right);
        public int CompareTo(@int other) => Value.CompareTo(other.Value);
        public int CompareTo(object other)
        {
            if (other is null)
                return 1;
            if (other is @int x)
                return CompareTo(x);
            ThrowHelper.ThrowArgumentException("Cannot compare to object as it is not of type @int", 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 @int result)
        {
            if (System.Int32.TryParse(utf8Text, style, provider, out var __v))
            {
                result = new @int(__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 @int result)
        {
            if (System.Int32.TryParse(utf8Text, provider, out var __v))
            {
                result = new @int(__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 @int result)
        {
            if (System.Int32.TryParse(utf8Text, out var __v))
            {
                result = new @int(__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 @int result)
        {
            if (System.Int32.TryParse(s, style, provider, out var __v))
            {
                result = new @int(__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 @int result)
        {
            if (System.Int32.TryParse(s, provider, out var __v))
            {
                result = new @int(__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 @int result)
        {
            if (System.Int32.TryParse(s, out var __v))
            {
                result = new @int(__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 @int result)
        {
            if (System.Int32.TryParse(s, style, provider, out var __v))
            {
                result = new @int(__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 @int result)
        {
            if (System.Int32.TryParse(s, provider, out var __v))
            {
                result = new @int(__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 @int result)
        {
            if (System.Int32.TryParse(s, out var __v))
            {
                result = new @int(__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 @int 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 @int 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 @int 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 @int 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 @int 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 @int 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 @int 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 @int 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 readonly override global::System.Int32 GetHashCode()
        {
            return global::System.Collections.Generic.EqualityComparer<System.Int32>.Default.GetHashCode(Value);
        }

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

        // record enumerates fields - we just want our Value and to throw if it's not initialized.
        /// <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 @int to or from JSON.
        /// </summary>
        public class @intSystemTextJsonConverter : global::System.Text.Json.Serialization.JsonConverter<@int>
        {
            public override @int 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, @int 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 @int 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, @int 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 @int DeserializeJson(System.Int32 value)
            {
                return new @int(value);
            }
        }

#nullable restore
#nullable disable
        class @intTypeConverter : 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 => @int.__Deserialize(intValue),
                    global::System.String stringValue when !global::System.String.IsNullOrEmpty(stringValue) && global::System.Int32.TryParse(stringValue, out var result) => @int.__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 @int 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
#nullable disable
        internal sealed class @intDebugView
        {
            private readonly @int _t;
            @intDebugView(@int t)
            {
                _t = t;
            }

            public global::System.Boolean IsInitialized => _t.IsInitialized();
            public global::System.String UnderlyingType => "System.Int32";
            public global::System.String Value => _t.IsInitialized() ? _t._value.ToString() : "[not initialized]";
#if DEBUG
        public global::System.String CreatedWith => _t._stackTrace.ToString() ?? "the From method";
#endif
            public global::System.String Conversions => @"Default";
        }

#nullable restore
        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 Whatever
{
    [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
        [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Vogen", "1.0.0.0")]
    [global::System.Text.Json.Serialization.JsonConverter(typeof(@byteSystemTextJsonConverter))]
    [global::System.ComponentModel.TypeConverter(typeof(@byteTypeConverter))]
    [global::System.Diagnostics.DebuggerTypeProxyAttribute(typeof(@byteDebugView))]
    [global::System.Diagnostics.DebuggerDisplayAttribute("Underlying type: System.Int32, Value = { _value }")]
    public partial record struct @byte : global::System.IEquatable<@byte>, global::System.IEquatable<System.Int32>, global::System.IComparable<@byte>, global::System.IComparable, global::System.IParsable<@byte>, global::System.ISpanParsable<@byte>, global::System.IUtf8SpanParsable<@byte>, 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 readonly 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]
            init
            {
                _value = value;
            }
        }

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

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

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

        public readonly global::System.Boolean Equals(@byte other)
        {
            // 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;
            return global::System.Collections.Generic.EqualityComparer<System.Int32>.Default.Equals(Value, other.Value);
        }

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

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

        public static global::System.Boolean operator ==(@byte left, System.Int32 right) => left.Value.Equals(right);
        public static global::System.Boolean operator ==(System.Int32 left, @byte right) => right.Value.Equals(left);
        public static global::System.Boolean operator !=(System.Int32 left, @byte right) => !(left == right);
        public static global::System.Boolean operator !=(@byte left, System.Int32 right) => !(left == right);
        public int CompareTo(@byte other) => Value.CompareTo(other.Value);
        public int CompareTo(object other)
        {
            if (other is null)
                return 1;
            if (other is @byte x)
                return CompareTo(x);
            ThrowHelper.ThrowArgumentException("Cannot compare to object as it is not of type @byte", 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 @byte result)
        {
            if (System.Int32.TryParse(utf8Text, style, provider, out var __v))
            {
                result = new @byte(__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 @byte result)
        {
            if (System.Int32.TryParse(utf8Text, provider, out var __v))
            {
                result = new @byte(__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 @byte result)
        {
            if (System.Int32.TryParse(utf8Text, out var __v))
            {
                result = new @byte(__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 @byte result)
        {
            if (System.Int32.TryParse(s, style, provider, out var __v))
            {
                result = new @byte(__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 @byte result)
        {
            if (System.Int32.TryParse(s, provider, out var __v))
            {
                result = new @byte(__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 @byte result)
        {
            if (System.Int32.TryParse(s, out var __v))
            {
                result = new @byte(__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 @byte result)
        {
            if (System.Int32.TryParse(s, style, provider, out var __v))
            {
                result = new @byte(__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 @byte result)
        {
            if (System.Int32.TryParse(s, provider, out var __v))
            {
                result = new @byte(__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 @byte result)
        {
            if (System.Int32.TryParse(s, out var __v))
            {
                result = new @byte(__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 @byte 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 @byte 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 @byte 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 @byte 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 @byte 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 @byte 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 @byte 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 @byte 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 readonly override global::System.Int32 GetHashCode()
        {
            return global::System.Collections.Generic.EqualityComparer<System.Int32>.Default.GetHashCode(Value);
        }

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

        // record enumerates fields - we just want our Value and to throw if it's not initialized.
        /// <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 @byte to or from JSON.
        /// </summary>
        public class @byteSystemTextJsonConverter : global::System.Text.Json.Serialization.JsonConverter<@byte>
        {
            public override @byte 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, @byte 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 @byte 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, @byte 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 @byte DeserializeJson(System.Int32 value)
            {
                return new @byte(value);
            }
        }

#nullable restore
#nullable disable
        class @byteTypeConverter : 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 => @byte.__Deserialize(intValue),
                    global::System.String stringValue when !global::System.String.IsNullOrEmpty(stringValue) && global::System.Int32.TryParse(stringValue, out var result) => @byte.__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 @byte 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
#nullable disable
        internal sealed class @byteDebugView
        {
            private readonly @byte _t;
            @byteDebugView(@byte t)
            {
                _t = t;
            }

            public global::System.Boolean IsInitialized => _t.IsInitialized();
            public global::System.String UnderlyingType => "System.Int32";
            public global::System.String Value => _t.IsInitialized() ? _t._value.ToString() : "[not initialized]";
#if DEBUG
        public global::System.String CreatedWith => _t._stackTrace.ToString() ?? "the From method";
#endif
            public global::System.String Conversions => @"Default";
        }

#nullable restore
        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 Whatever
{
    [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
        [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Vogen", "1.0.0.0")]
    [global::System.Text.Json.Serialization.JsonConverter(typeof(MyIntSystemTextJsonConverter))]
    [global::System.ComponentModel.TypeConverter(typeof(MyIntTypeConverter))]
    [global::System.Diagnostics.DebuggerTypeProxyAttribute(typeof(MyIntDebugView))]
    [global::System.Diagnostics.DebuggerDisplayAttribute("Underlying type: System.Int32, Value = { _value }")]
    public partial record class MyInt : global::System.IEquatable<MyInt>, global::System.IEquatable<System.Int32>, global::System.IComparable<MyInt>, global::System.IComparable, global::System.IParsable<MyInt>, global::System.ISpanParsable<MyInt>, global::System.IUtf8SpanParsable<MyInt>, 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]
            init
            {
                _value = value;
            }
        }

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

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

        public virtual global::System.Boolean Equals(MyInt 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(MyInt other, global::System.Collections.Generic.IEqualityComparer<MyInt> comparer)
        {
            return comparer.Equals(this, other);
        }

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

        public static global::System.Boolean operator ==(MyInt left, System.Int32 right) => left.Value.Equals(right);
        public static global::System.Boolean operator ==(System.Int32 left, MyInt right) => right.Value.Equals(left);
        public static global::System.Boolean operator !=(System.Int32 left, MyInt right) => !(left == right);
        public static global::System.Boolean operator !=(MyInt left, System.Int32 right) => !(left == right);
        public static explicit operator MyInt(System.Int32 value) => From(value);
        public static explicit operator System.Int32(MyInt value) => value.Value;
        public int CompareTo(MyInt 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 MyInt x)
                return CompareTo(x);
            ThrowHelper.ThrowArgumentException("Cannot compare to object as it is not of type MyInt", 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 MyInt result)
        {
            if (System.Int32.TryParse(utf8Text, style, provider, out var __v))
            {
                result = new MyInt(__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 MyInt result)
        {
            if (System.Int32.TryParse(utf8Text, provider, out var __v))
            {
                result = new MyInt(__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 MyInt result)
        {
            if (System.Int32.TryParse(utf8Text, out var __v))
            {
                result = new MyInt(__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 MyInt result)
        {
            if (System.Int32.TryParse(s, style, provider, out var __v))
            {
                result = new MyInt(__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 MyInt result)
        {
            if (System.Int32.TryParse(s, provider, out var __v))
            {
                result = new MyInt(__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 MyInt result)
        {
            if (System.Int32.TryParse(s, out var __v))
            {
                result = new MyInt(__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 MyInt result)
        {
            if (System.Int32.TryParse(s, style, provider, out var __v))
            {
                result = new MyInt(__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 MyInt result)
        {
            if (System.Int32.TryParse(s, provider, out var __v))
            {
                result = new MyInt(__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 MyInt result)
        {
            if (System.Int32.TryParse(s, out var __v))
            {
                result = new MyInt(__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 MyInt 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 MyInt 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 MyInt 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 MyInt 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 MyInt 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 MyInt 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 MyInt 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 MyInt 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
            }
        }

        // record enumerates fields - we just want our Value and to throw if it's not initialized.
        /// <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 MyInt to or from JSON.
        /// </summary>
        public class MyIntSystemTextJsonConverter : global::System.Text.Json.Serialization.JsonConverter<MyInt>
        {
            public override MyInt 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, MyInt 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 MyInt 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, MyInt 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 MyInt DeserializeJson(System.Int32 value)
            {
                return new MyInt(value);
            }
        }

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

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