diff --git a/tests/SnapshotTests/BugFixes/snapshots/snap-v8.0/Bug625_EFCoreConverters_uses_wrong_marker_interface_name.A_marker_interface_not_named_EfCoreConverters_is_still_referenced_and_that_name_is_used_in_the_generated_code.verified.txt b/tests/SnapshotTests/BugFixes/snapshots/snap-v8.0/Bug625_EFCoreConverters_uses_wrong_marker_interface_name.A_marker_interface_not_named_EfCoreConverters_is_still_referenced_and_that_name_is_used_in_the_generated_code.verified.txt
index 5f282702bb..0008c87b49 100644
--- a/tests/SnapshotTests/BugFixes/snapshots/snap-v8.0/Bug625_EFCoreConverters_uses_wrong_marker_interface_name.A_marker_interface_not_named_EfCoreConverters_is_still_referenced_and_that_name_is_used_in_the_generated_code.verified.txt
+++ b/tests/SnapshotTests/BugFixes/snapshots/snap-v8.0/Bug625_EFCoreConverters_uses_wrong_marker_interface_name.A_marker_interface_not_named_EfCoreConverters_is_still_referenced_and_that_name_is_used_in_the_generated_code.verified.txt
@@ -1 +1,1789 @@
-
\ No newline at end of file
+[
+#if NET8_0_OR_GREATER
+
+// ------------------------------------------------------------------------------
+//
+// 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.
+//
+// ------------------------------------------------------------------------------
+
+// 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 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
+
+// Suppress warnings about CS1591: Missing XML comment for publicly visible type or member 'Type_or_Member'
+#pragma warning disable CS1591
+
+namespace Foo;
+
+ internal static class VogenEfCoreConverters__Ext
+ {
+ internal static global::Microsoft.EntityFrameworkCore.ModelConfigurationBuilder RegisterAllInVogenEfCoreConverters(this global::Microsoft.EntityFrameworkCore.ModelConfigurationBuilder configurationBuilder)
+ {
+ configurationBuilder.Properties().HaveConversion();
+configurationBuilder.Properties().HaveConversion();
+configurationBuilder.Properties().HaveConversion();
+
+
+ return configurationBuilder;
+ }
+ }
+
+#endif
+
+#if NET8_0_OR_GREATER
+
+// ------------------------------------------------------------------------------
+//
+// 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.
+//
+// ------------------------------------------------------------------------------
+
+// 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 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
+
+// Suppress warnings about CS1591: Missing XML comment for publicly visible type or member 'Type_or_Member'
+#pragma warning disable CS1591
+
+namespace Foo;
+
+internal partial class VogenEfCoreConverters
+{
+ public class HireDateEfCoreValueConverter : global::Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter
+ {
+ public HireDateEfCoreValueConverter() : this(null) { }
+ public HireDateEfCoreValueConverter(global::Microsoft.EntityFrameworkCore.Storage.ValueConversion.ConverterMappingHints mappingHints = null)
+ : base(
+ vo => vo.Value,
+ value => Deserialize(value),
+ mappingHints
+ ) { }
+
+ static Foo.HireDate Deserialize(System.DateTime value) => UnsafeDeserialize(default, value);
+
+ [global::System.Runtime.CompilerServices.UnsafeAccessor(global::System.Runtime.CompilerServices.UnsafeAccessorKind.StaticMethod, Name = "__Deserialize")]
+ static extern Foo.HireDate UnsafeDeserialize(Foo.HireDate @this, System.DateTime value);
+ }
+ public class HireDateEfCoreValueComparer : global::Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer
+ {
+ public HireDateEfCoreValueComparer() : base(
+ (left, right) => DoCompare(left, right),
+ instance => instance.IsInitialized() ? instance.GetHashCode() : 0)
+ {
+ }
+
+ static bool DoCompare(Foo.HireDate left, Foo.HireDate 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.DateTime UnderlyingValue(Foo.HireDate i) => UnsafeValueField(ref i);
+
+ [global::System.Runtime.CompilerServices.UnsafeAccessor(global::System.Runtime.CompilerServices.UnsafeAccessorKind.Field, Name = "_value")]
+ static extern ref System.DateTime UnsafeValueField(ref Foo.HireDate @this);
+ }
+}
+
+public static class HireDate__Ext
+{
+ public static global::Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder HasVogenConversion(this global::Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder propertyBuilder) =>
+ propertyBuilder.HasConversion();
+}
+
+
+#endif
+
+#if NET8_0_OR_GREATER
+
+// ------------------------------------------------------------------------------
+//
+// 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.
+//
+// ------------------------------------------------------------------------------
+
+// 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 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
+
+// Suppress warnings about CS1591: Missing XML comment for publicly visible type or member 'Type_or_Member'
+#pragma warning disable CS1591
+
+namespace Foo;
+
+internal partial class VogenEfCoreConverters
+{
+ public class NameEfCoreValueConverter : global::Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter
+ {
+ public NameEfCoreValueConverter() : this(null) { }
+ public NameEfCoreValueConverter(global::Microsoft.EntityFrameworkCore.Storage.ValueConversion.ConverterMappingHints mappingHints = null)
+ : base(
+ vo => vo.Value,
+ value => Deserialize(value),
+ mappingHints
+ ) { }
+
+ static Foo.Name Deserialize(System.String value) => UnsafeDeserialize(default, value);
+
+ [global::System.Runtime.CompilerServices.UnsafeAccessor(global::System.Runtime.CompilerServices.UnsafeAccessorKind.StaticMethod, Name = "__Deserialize")]
+ static extern Foo.Name UnsafeDeserialize(Foo.Name @this, System.String value);
+ }
+ public class NameEfCoreValueComparer : global::Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer
+ {
+ public NameEfCoreValueComparer() : base(
+ (left, right) => DoCompare(left, right),
+ instance => instance.IsInitialized() ? instance.GetHashCode() : 0)
+ {
+ }
+
+ static bool DoCompare(Foo.Name left, Foo.Name 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(Foo.Name i) => UnsafeValueField(ref i);
+
+ [global::System.Runtime.CompilerServices.UnsafeAccessor(global::System.Runtime.CompilerServices.UnsafeAccessorKind.Field, Name = "_value")]
+ static extern ref System.String UnsafeValueField(ref Foo.Name @this);
+ }
+}
+
+public static class Name__Ext
+{
+ public static global::Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder HasVogenConversion(this global::Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder propertyBuilder) =>
+ propertyBuilder.HasConversion();
+}
+
+
+#endif
+
+#if NET8_0_OR_GREATER
+
+// ------------------------------------------------------------------------------
+//
+// 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.
+//
+// ------------------------------------------------------------------------------
+
+// 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 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
+
+// Suppress warnings about CS1591: Missing XML comment for publicly visible type or member 'Type_or_Member'
+#pragma warning disable CS1591
+
+namespace Foo;
+
+internal partial class VogenEfCoreConverters
+{
+ public class AgeEfCoreValueConverter : global::Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter
+ {
+ public AgeEfCoreValueConverter() : this(null) { }
+ public AgeEfCoreValueConverter(global::Microsoft.EntityFrameworkCore.Storage.ValueConversion.ConverterMappingHints mappingHints = null)
+ : base(
+ vo => vo.Value,
+ value => Deserialize(value),
+ mappingHints
+ ) { }
+
+ static Foo.Age Deserialize(System.Int32 value) => UnsafeDeserialize(default, value);
+
+ [global::System.Runtime.CompilerServices.UnsafeAccessor(global::System.Runtime.CompilerServices.UnsafeAccessorKind.StaticMethod, Name = "__Deserialize")]
+ static extern Foo.Age UnsafeDeserialize(Foo.Age @this, System.Int32 value);
+ }
+ public class AgeEfCoreValueComparer : global::Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer
+ {
+ public AgeEfCoreValueComparer() : base(
+ (left, right) => DoCompare(left, right),
+ instance => instance.IsInitialized() ? instance.GetHashCode() : 0)
+ {
+ }
+
+ static bool DoCompare(Foo.Age left, Foo.Age 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(Foo.Age i) => UnsafeValueField(ref i);
+
+ [global::System.Runtime.CompilerServices.UnsafeAccessor(global::System.Runtime.CompilerServices.UnsafeAccessorKind.Field, Name = "_value")]
+ static extern ref System.Int32 UnsafeValueField(ref Foo.Age @this);
+ }
+}
+
+public static class Age__Ext
+{
+ public static global::Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder HasVogenConversion(this global::Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder propertyBuilder) =>
+ propertyBuilder.HasConversion();
+}
+
+
+#endif
+
+// ------------------------------------------------------------------------------
+//
+// 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.
+//
+// ------------------------------------------------------------------------------
+
+// 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 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
+
+// Suppress warnings about CS1591: Missing XML comment for publicly visible type or member 'Type_or_Member'
+#pragma warning disable CS1591
+
+using Vogen;
+
+namespace Foo
+{
+
+ [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Vogen", "1.0.0.0")]
+ [global::System.Text.Json.Serialization.JsonConverter(typeof(HireDateSystemTextJsonConverter))]
+[global::System.ComponentModel.TypeConverter(typeof(HireDateTypeConverter))]
+
+ [global::System.Diagnostics.DebuggerTypeProxyAttribute(typeof(HireDateDebugView))]
+ [global::System.Diagnostics.DebuggerDisplayAttribute("Underlying type: System.DateTime, Value = { _value }")]
+ public partial struct HireDate : global::System.IEquatable, global::System.IEquatable , global::System.IComparable, global::System.IComparable, global::System.IParsable, global::System.ISpanParsable
+ {
+#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.DateTime _value;
+
+ ///
+ /// Gets the underlying value if set, otherwise a is thrown.
+ ///
+ public readonly System.DateTime Value
+ {
+ [global::System.Diagnostics.DebuggerStepThroughAttribute]
+ get
+ {
+ EnsureInitialized();
+ return _value;
+ }
+ }
+
+
+ [global::System.Diagnostics.DebuggerStepThroughAttribute]
+ [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]
+ public HireDate()
+ {
+#if DEBUG
+ _stackTrace = new global::System.Diagnostics.StackTrace();
+#endif
+
+#if !VOGEN_NO_VALIDATION
+ _isInitialized = false;
+#endif
+ _value = default;
+ }
+
+ [global::System.Diagnostics.DebuggerStepThroughAttribute]
+ private HireDate(System.DateTime value)
+ {
+ _value = value;
+#if !VOGEN_NO_VALIDATION
+ _isInitialized = true;
+#endif
+ }
+
+ ///
+ /// Builds an instance from the provided underlying type.
+ ///
+ /// The underlying type.
+ /// An instance of this type.
+ public static HireDate From(System.DateTime value)
+ {
+
+
+
+
+ HireDate instance = new HireDate(value);
+
+ return instance;
+ }
+
+ ///
+/// 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.
+///
+/// The underlying type.
+/// An instance of the value object.
+/// True if the value object can be built, otherwise false.
+public static bool TryFrom(System.DateTime value,
+#if NETCOREAPP3_0_OR_GREATER
+[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
+#endif
+ out HireDate vo)
+{
+
+
+
+
+
+ vo = new HireDate(value);
+
+ return true;
+}///
+/// 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.
+///
+/// The primitive value.
+/// A containing either the value object, or an error.
+public static ValueObjectOrError TryFrom(System.DateTime value)
+{
+
+
+
+
+
+
+ return new ValueObjectOrError(new HireDate(value));
+}
+
+[global::System.Runtime.CompilerServices.MethodImpl(global::System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
+#if VOGEN_NO_VALIDATION
+ public readonly bool IsInitialized() => true;
+#else
+ public readonly bool IsInitialized() => _isInitialized;
+#endif
+
+
+
+ public static explicit operator HireDate(System.DateTime value) => From(value);
+ public static explicit operator System.DateTime(HireDate value) => value.Value;
+
+ // only called internally when something has been deserialized into
+ // its primitive type.
+ private static HireDate __Deserialize(System.DateTime value)
+ {
+
+
+
+
+ return new HireDate(value);
+ }
+ public readonly global::System.Boolean Equals(HireDate 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.Default.Equals(Value, other.Value);
+ }
+ public global::System.Boolean Equals(HireDate other, global::System.Collections.Generic.IEqualityComparer comparer)
+ {
+ return comparer.Equals(this, other);
+ }
+
+
+ public readonly global::System.Boolean Equals(System.DateTime primitive)
+ {
+ return Value.Equals(primitive);
+ }
+
+ public readonly override global::System.Boolean Equals(global::System.Object obj)
+ {
+ return obj is HireDate && Equals((HireDate) obj);
+ }
+
+ public static global::System.Boolean operator ==(HireDate left, HireDate right) => Equals(left, right);
+ public static global::System.Boolean operator !=(HireDate left, HireDate right) => !(left == right);
+
+ public static global::System.Boolean operator ==(HireDate left, System.DateTime right) => Equals(left.Value, right);
+ public static global::System.Boolean operator !=(HireDate left, System.DateTime right) => !Equals(left.Value, right);
+
+ public static global::System.Boolean operator ==(System.DateTime left, HireDate right) => Equals(left, right.Value);
+ public static global::System.Boolean operator !=(System.DateTime left, HireDate right) => !Equals(left, right.Value);
+
+ public int CompareTo(HireDate other) => Value.CompareTo(other.Value);
+ public int CompareTo(object other) {
+ if(other is null) return 1;
+ if(other is HireDate x) return CompareTo(x);
+ throw new global::System.ArgumentException("Cannot compare to object as it is not of type HireDate", nameof(other));
+ }
+
+
+ ///
+ ///
+ ///
+ ///
+ /// True if the value could a) be parsed by the underlying type, and b) passes any validation (after running any optional normalization).
+ ///
+ public static global::System.Boolean TryParse(global::System.ReadOnlySpan s,
+#if NETCOREAPP3_0_OR_GREATER
+[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
+#endif
+ out HireDate result) {
+ if(System.DateTime.TryParse(s, out var __v)) {
+
+
+ result = new HireDate(__v);
+ return true;
+ }
+
+ result = default;
+ return false;
+ }
+
+ ///
+ ///
+ ///
+ ///
+ /// True if the value could a) be parsed by the underlying type, and b) passes any validation (after running any optional normalization).
+ ///
+ public static global::System.Boolean TryParse(global::System.ReadOnlySpan s, global::System.IFormatProvider provider,
+#if NETCOREAPP3_0_OR_GREATER
+[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
+#endif
+ out HireDate result) {
+ if(System.DateTime.TryParse(s, provider, out var __v)) {
+
+
+ result = new HireDate(__v);
+ return true;
+ }
+
+ result = default;
+ return false;
+ }
+
+ ///
+ ///
+ ///
+ ///
+ /// True if the value could a) be parsed by the underlying type, and b) passes any validation (after running any optional normalization).
+ ///
+ public static global::System.Boolean TryParse(global::System.ReadOnlySpan s, global::System.IFormatProvider provider, global::System.Globalization.DateTimeStyles styles,
+#if NETCOREAPP3_0_OR_GREATER
+[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
+#endif
+ out HireDate result) {
+ if(System.DateTime.TryParse(s, provider, styles, out var __v)) {
+
+
+ result = new HireDate(__v);
+ return true;
+ }
+
+ result = default;
+ return false;
+ }
+
+ ///
+ ///
+ ///
+ ///
+ /// True if the value could a) be parsed by the underlying type, and b) passes any validation (after running any optional normalization).
+ ///
+ public static global::System.Boolean TryParse(string s,
+#if NETCOREAPP3_0_OR_GREATER
+[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
+#endif
+ out HireDate result) {
+ if(System.DateTime.TryParse(s, out var __v)) {
+
+
+ result = new HireDate(__v);
+ return true;
+ }
+
+ result = default;
+ return false;
+ }
+
+ ///
+ ///
+ ///
+ ///
+ /// True if the value could a) be parsed by the underlying type, and b) passes any validation (after running any optional normalization).
+ ///
+ 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 HireDate result) {
+ if(System.DateTime.TryParse(s, provider, out var __v)) {
+
+
+ result = new HireDate(__v);
+ return true;
+ }
+
+ result = default;
+ return false;
+ }
+
+ ///
+ ///
+ ///
+ ///
+ /// True if the value could a) be parsed by the underlying type, and b) passes any validation (after running any optional normalization).
+ ///
+ public static global::System.Boolean TryParse(string s, global::System.IFormatProvider provider, global::System.Globalization.DateTimeStyles styles,
+#if NETCOREAPP3_0_OR_GREATER
+[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
+#endif
+ out HireDate result) {
+ if(System.DateTime.TryParse(s, provider, styles, out var __v)) {
+
+
+ result = new HireDate(__v);
+ return true;
+ }
+
+ result = default;
+ return false;
+ }
+
+ ///
+ ///
+ ///
+ ///
+ /// The value created by calling the Parse method on the primitive.
+ ///
+ /// Thrown when the value can be parsed, but is not valid.
+ public static HireDate Parse(global::System.ReadOnlySpan s, global::System.IFormatProvider provider) {
+ var r = System.DateTime.Parse(s, provider);
+ return From(r);
+ }
+
+ ///
+ ///
+ ///
+ ///
+ /// The value created by calling the Parse method on the primitive.
+ ///
+ /// Thrown when the value can be parsed, but is not valid.
+ public static HireDate Parse(global::System.ReadOnlySpan s, global::System.IFormatProvider provider, global::System.Globalization.DateTimeStyles styles) {
+ var r = System.DateTime.Parse(s, provider, styles);
+ return From(r);
+ }
+
+ ///
+ ///
+ ///
+ ///
+ /// The value created by calling the Parse method on the primitive.
+ ///
+ /// Thrown when the value can be parsed, but is not valid.
+ public static HireDate Parse(string s) {
+ var r = System.DateTime.Parse(s);
+ return From(r);
+ }
+
+ ///
+ ///
+ ///
+ ///
+ /// The value created by calling the Parse method on the primitive.
+ ///
+ /// Thrown when the value can be parsed, but is not valid.
+ public static HireDate Parse(string s, global::System.IFormatProvider provider) {
+ var r = System.DateTime.Parse(s, provider);
+ return From(r);
+ }
+
+ ///
+ ///
+ ///
+ ///
+ /// The value created by calling the Parse method on the primitive.
+ ///
+ /// Thrown when the value can be parsed, but is not valid.
+ public static HireDate Parse(string s, global::System.IFormatProvider provider, global::System.Globalization.DateTimeStyles styles) {
+ var r = System.DateTime.Parse(s, provider, styles);
+ return From(r);
+ }
+
+
+
+ public readonly override global::System.Int32 GetHashCode()
+ {
+ return global::System.Collections.Generic.EqualityComparer.Default.GetHashCode(Value);
+ }
+
+ /// Returns the string representation of the underlying .
+ public readonly override global::System.String ToString() =>IsInitialized() ? Value.ToString() : "[UNINITIALIZED]";
+
+ private readonly void EnsureInitialized()
+ {
+ if (!IsInitialized())
+ {
+#if DEBUG
+ global::System.String message = "Use of uninitialized Value Object at: " + _stackTrace ?? "";
+#else
+ global::System.String message = "Use of uninitialized Value Object.";
+#endif
+
+ throw new global::Vogen.ValueObjectValidationException(message);
+ }
+ }
+
+
+
+ ///
+ /// Converts a HireDate to or from JSON.
+ ///
+ public class HireDateSystemTextJsonConverter : global::System.Text.Json.Serialization.JsonConverter
+ {
+ public override HireDate Read(ref global::System.Text.Json.Utf8JsonReader reader, global::System.Type typeToConvert, global::System.Text.Json.JsonSerializerOptions options)
+ {
+ return HireDate.__Deserialize(reader.GetDateTime().ToUniversalTime());
+ }
+
+ public override void Write(System.Text.Json.Utf8JsonWriter writer, HireDate value, global::System.Text.Json.JsonSerializerOptions options)
+ {
+ writer.WriteStringValue(value.Value.ToUniversalTime());
+ }
+
+#if NET6_0_OR_GREATER
+ ///
+ /// Converts a HireDate to or from JSON.
+ ///
+ public override HireDate ReadAsPropertyName(ref global::System.Text.Json.Utf8JsonReader reader, global::System.Type typeToConvert, global::System.Text.Json.JsonSerializerOptions options)
+ {
+ return HireDate.__Deserialize(global::System.DateTime.ParseExact(reader.GetString(), "O", global::System.Globalization.CultureInfo.InvariantCulture, global::System.Globalization.DateTimeStyles.RoundtripKind));
+ }
+
+ public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, HireDate value, global::System.Text.Json.JsonSerializerOptions options)
+ {
+ writer.WritePropertyName(value.Value.ToUniversalTime().ToString("O", global::System.Globalization.CultureInfo.InvariantCulture));
+ }
+#endif
+ }
+
+
+ class HireDateTypeConverter : global::System.ComponentModel.TypeConverter
+ {
+ public override global::System.Boolean CanConvertFrom(global::System.ComponentModel.ITypeDescriptorContext context, global::System.Type sourceType)
+ {
+ return sourceType == typeof(global::System.DateTime) || 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.String stringValue when !global::System.String.IsNullOrEmpty(stringValue) && global::System.DateTime.TryParseExact(stringValue, "O", culture, global::System.Globalization.DateTimeStyles.RoundtripKind, out var result) => HireDate.__Deserialize(result),
+ global::System.DateTime dateTimeValue => HireDate.__Deserialize(dateTimeValue),
+ _ => base.ConvertFrom(context, culture, value),
+ };
+ }
+
+ public override bool CanConvertTo(global::System.ComponentModel.ITypeDescriptorContext context, global::System.Type sourceType)
+ {
+ return sourceType == typeof(global::System.DateTime) || 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 HireDate idValue)
+ {
+ if (destinationType == typeof(global::System.DateTime))
+ {
+ return idValue.Value;
+ }
+
+ if (destinationType == typeof(global::System.String))
+ {
+ return idValue.Value.ToString("O", culture);
+ }
+ }
+
+ return base.ConvertTo(context, culture, value, destinationType);
+ }
+ }
+
+
+
+
+
+
+ internal sealed class HireDateDebugView
+ {
+ private readonly HireDate _t;
+
+ HireDateDebugView(HireDate t)
+ {
+ _t = t;
+ }
+
+ public global::System.Boolean IsInitialized => _t.IsInitialized();
+ public global::System.String UnderlyingType => "System.DateTime";
+ 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";
+ }
+
+}
+
+}
+
+// ------------------------------------------------------------------------------
+//
+// 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.
+//
+// ------------------------------------------------------------------------------
+
+// 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 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
+
+// Suppress warnings about CS1591: Missing XML comment for publicly visible type or member 'Type_or_Member'
+#pragma warning disable CS1591
+
+using Vogen;
+
+namespace Foo
+{
+
+ [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Vogen", "1.0.0.0")]
+ [global::System.Text.Json.Serialization.JsonConverter(typeof(NameSystemTextJsonConverter))]
+[global::System.ComponentModel.TypeConverter(typeof(NameTypeConverter))]
+
+ [global::System.Diagnostics.DebuggerTypeProxyAttribute(typeof(NameDebugView))]
+ [global::System.Diagnostics.DebuggerDisplayAttribute("Underlying type: System.String, Value = { _value }")]
+ public partial struct Name : global::System.IEquatable, global::System.IEquatable , global::System.IComparable, global::System.IComparable, global::System.IParsable
+ {
+#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;
+
+ ///
+ /// Gets the underlying value if set, otherwise a is thrown.
+ ///
+ public readonly System.String Value
+ {
+ [global::System.Diagnostics.DebuggerStepThroughAttribute]
+ get
+ {
+ EnsureInitialized();
+ return _value;
+ }
+ }
+
+
+ [global::System.Diagnostics.DebuggerStepThroughAttribute]
+ [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]
+ public Name()
+ {
+#if DEBUG
+ _stackTrace = new global::System.Diagnostics.StackTrace();
+#endif
+
+#if !VOGEN_NO_VALIDATION
+ _isInitialized = false;
+#endif
+ _value = default;
+ }
+
+ [global::System.Diagnostics.DebuggerStepThroughAttribute]
+ private Name(System.String value)
+ {
+ _value = value;
+#if !VOGEN_NO_VALIDATION
+ _isInitialized = true;
+#endif
+ }
+
+ ///
+ /// Builds an instance from the provided underlying type.
+ ///
+ /// The underlying type.
+ /// An instance of this type.
+ public static Name From(System.String value)
+ {
+
+
+
+
+ Name instance = new Name(value);
+
+ return instance;
+ }
+
+ ///
+/// 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.
+///
+/// The underlying type.
+/// An instance of the value object.
+/// True if the value object can be built, otherwise false.
+public static bool TryFrom(System.String value,
+#if NETCOREAPP3_0_OR_GREATER
+[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
+#endif
+ out Name vo)
+{
+
+
+
+
+
+ vo = new Name(value);
+
+ return true;
+}///
+/// 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.
+///
+/// The primitive value.
+/// A containing either the value object, or an error.
+public static ValueObjectOrError TryFrom(System.String value)
+{
+
+
+
+
+
+
+ return new ValueObjectOrError(new Name(value));
+}
+
+[global::System.Runtime.CompilerServices.MethodImpl(global::System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
+#if VOGEN_NO_VALIDATION
+ public readonly bool IsInitialized() => true;
+#else
+ public readonly bool IsInitialized() => _isInitialized;
+#endif
+
+
+
+ public static explicit operator Name(System.String value) => From(value);
+ public static explicit operator System.String(Name value) => value.Value;
+
+ // only called internally when something has been deserialized into
+ // its primitive type.
+ private static Name __Deserialize(System.String value)
+ {
+
+
+
+
+ return new Name(value);
+ }
+ public readonly global::System.Boolean Equals(Name 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.Default.Equals(Value, other.Value);
+ }
+ public global::System.Boolean Equals(Name other, global::System.Collections.Generic.IEqualityComparer 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 Name && Equals((Name) obj);
+ }
+
+ public static global::System.Boolean operator ==(Name left, Name right) => Equals(left, right);
+ public static global::System.Boolean operator !=(Name left, Name right) => !(left == right);
+
+ public static global::System.Boolean operator ==(Name left, System.String right) => Equals(left.Value, right);
+ public static global::System.Boolean operator !=(Name left, System.String right) => !Equals(left.Value, right);
+
+ public static global::System.Boolean operator ==(System.String left, Name right) => Equals(left, right.Value);
+ public static global::System.Boolean operator !=(System.String left, Name right) => !Equals(left, right.Value);
+
+ public int CompareTo(Name other) => Value.CompareTo(other.Value);
+ public int CompareTo(object other) {
+ if(other is null) return 1;
+ if(other is Name x) return CompareTo(x);
+ throw new global::System.ArgumentException("Cannot compare to object as it is not of type Name", nameof(other));
+ }
+
+
+ ///
+ ///
+ ///
+ /// True if the value passes any validation (after running any optional normalization).
+ ///
+ public static global::System.Boolean TryParse(global::System.String s, global::System.IFormatProvider provider,
+#if NETCOREAPP3_0_OR_GREATER
+[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
+#endif
+ out Name result) {
+
+
+ result = new Name(s);
+ return true;
+ }
+ ///
+ ///
+ ///
+ /// The value created via the method.
+ ///
+ /// Thrown when the value can be parsed, but is not valid.
+ public static Name Parse(global::System.String s, global::System.IFormatProvider provider) {
+ return From(s);
+ }
+
+
+ public readonly override global::System.Int32 GetHashCode()
+ {
+ return global::System.Collections.Generic.EqualityComparer.Default.GetHashCode(Value);
+ }
+
+ /// Returns the string representation of the underlying .
+ public readonly override global::System.String ToString() =>IsInitialized() ? Value.ToString() : "[UNINITIALIZED]";
+
+ private readonly void EnsureInitialized()
+ {
+ if (!IsInitialized())
+ {
+#if DEBUG
+ global::System.String message = "Use of uninitialized Value Object at: " + _stackTrace ?? "";
+#else
+ global::System.String message = "Use of uninitialized Value Object.";
+#endif
+
+ throw new global::Vogen.ValueObjectValidationException(message);
+ }
+ }
+
+
+
+
+ ///
+ /// Converts a Name to or from JSON.
+ ///
+ public class NameSystemTextJsonConverter : global::System.Text.Json.Serialization.JsonConverter
+ {
+ public override Name Read(ref global::System.Text.Json.Utf8JsonReader reader, global::System.Type typeToConvert, global::System.Text.Json.JsonSerializerOptions options)
+ {
+ return Name.__Deserialize(reader.GetString());
+ }
+
+ public override void Write(System.Text.Json.Utf8JsonWriter writer, Name value, global::System.Text.Json.JsonSerializerOptions options)
+ {
+ writer.WriteStringValue(value.Value);
+ }
+
+#if NET6_0_OR_GREATER
+ public override Name ReadAsPropertyName(ref global::System.Text.Json.Utf8JsonReader reader, global::System.Type typeToConvert, global::System.Text.Json.JsonSerializerOptions options)
+ {
+ return Name.__Deserialize(reader.GetString());
+ }
+
+ public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, Name value, global::System.Text.Json.JsonSerializerOptions options)
+ {
+ writer.WritePropertyName(value.Value);
+ }
+#endif
+ }
+
+
+ class NameTypeConverter : 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 Name.__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 Name idValue)
+ {
+ if (destinationType == typeof(global::System.String))
+ {
+ return idValue.Value;
+ }
+ }
+
+ return base.ConvertTo(context, culture, value, destinationType);
+ }
+ }
+
+
+
+
+
+
+ internal sealed class NameDebugView
+ {
+ private readonly Name _t;
+
+ NameDebugView(Name 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";
+ }
+
+}
+
+}
+
+// ------------------------------------------------------------------------------
+//
+// 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.
+//
+// ------------------------------------------------------------------------------
+
+// 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 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
+
+// Suppress warnings about CS1591: Missing XML comment for publicly visible type or member 'Type_or_Member'
+#pragma warning disable CS1591
+
+using Vogen;
+
+namespace Foo
+{
+
+ [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Vogen", "1.0.0.0")]
+ [global::System.Text.Json.Serialization.JsonConverter(typeof(AgeSystemTextJsonConverter))]
+[global::System.ComponentModel.TypeConverter(typeof(AgeTypeConverter))]
+
+ [global::System.Diagnostics.DebuggerTypeProxyAttribute(typeof(AgeDebugView))]
+ [global::System.Diagnostics.DebuggerDisplayAttribute("Underlying type: System.Int32, Value = { _value }")]
+ public partial struct Age : global::System.IEquatable, global::System.IEquatable , global::System.IComparable, global::System.IComparable, global::System.IParsable, global::System.ISpanParsable, global::System.IUtf8SpanParsable
+ {
+#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;
+
+ ///
+ /// Gets the underlying value if set, otherwise a is thrown.
+ ///
+ public readonly System.Int32 Value
+ {
+ [global::System.Diagnostics.DebuggerStepThroughAttribute]
+ get
+ {
+ EnsureInitialized();
+ return _value;
+ }
+ }
+
+
+ [global::System.Diagnostics.DebuggerStepThroughAttribute]
+ [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]
+ public Age()
+ {
+#if DEBUG
+ _stackTrace = new global::System.Diagnostics.StackTrace();
+#endif
+
+#if !VOGEN_NO_VALIDATION
+ _isInitialized = false;
+#endif
+ _value = default;
+ }
+
+ [global::System.Diagnostics.DebuggerStepThroughAttribute]
+ private Age(System.Int32 value)
+ {
+ _value = value;
+#if !VOGEN_NO_VALIDATION
+ _isInitialized = true;
+#endif
+ }
+
+ ///
+ /// Builds an instance from the provided underlying type.
+ ///
+ /// The underlying type.
+ /// An instance of this type.
+ public static Age From(System.Int32 value)
+ {
+
+
+
+
+ Age instance = new Age(value);
+
+ return instance;
+ }
+
+ ///
+/// 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.
+///
+/// The underlying type.
+/// An instance of the value object.
+/// True if the value object can be built, otherwise false.
+public static bool TryFrom(System.Int32 value,
+#if NETCOREAPP3_0_OR_GREATER
+[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
+#endif
+ out Age vo)
+{
+
+
+
+
+
+ vo = new Age(value);
+
+ return true;
+}///
+/// 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.
+///
+/// The primitive value.
+/// A containing either the value object, or an error.
+public static ValueObjectOrError TryFrom(System.Int32 value)
+{
+
+
+
+
+
+
+ return new ValueObjectOrError(new Age(value));
+}
+
+[global::System.Runtime.CompilerServices.MethodImpl(global::System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
+#if VOGEN_NO_VALIDATION
+ public readonly bool IsInitialized() => true;
+#else
+ public readonly bool IsInitialized() => _isInitialized;
+#endif
+
+
+
+ public static explicit operator Age(System.Int32 value) => From(value);
+ public static explicit operator System.Int32(Age value) => value.Value;
+
+ // only called internally when something has been deserialized into
+ // its primitive type.
+ private static Age __Deserialize(System.Int32 value)
+ {
+
+
+
+
+ return new Age(value);
+ }
+ public readonly global::System.Boolean Equals(Age 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.Default.Equals(Value, other.Value);
+ }
+ public global::System.Boolean Equals(Age other, global::System.Collections.Generic.IEqualityComparer 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 Age && Equals((Age) obj);
+ }
+
+ public static global::System.Boolean operator ==(Age left, Age right) => Equals(left, right);
+ public static global::System.Boolean operator !=(Age left, Age right) => !(left == right);
+
+ public static global::System.Boolean operator ==(Age left, System.Int32 right) => Equals(left.Value, right);
+ public static global::System.Boolean operator !=(Age left, System.Int32 right) => !Equals(left.Value, right);
+
+ public static global::System.Boolean operator ==(System.Int32 left, Age right) => Equals(left, right.Value);
+ public static global::System.Boolean operator !=(System.Int32 left, Age right) => !Equals(left, right.Value);
+
+ public int CompareTo(Age other) => Value.CompareTo(other.Value);
+ public int CompareTo(object other) {
+ if(other is null) return 1;
+ if(other is Age x) return CompareTo(x);
+ throw new global::System.ArgumentException("Cannot compare to object as it is not of type Age", nameof(other));
+ }
+
+
+ ///
+ ///
+ ///
+ ///
+ /// True if the value could a) be parsed by the underlying type, and b) passes any validation (after running any optional normalization).
+ ///
+ public static global::System.Boolean TryParse(global::System.ReadOnlySpan utf8Text, global::System.Globalization.NumberStyles style, global::System.IFormatProvider provider,
+#if NETCOREAPP3_0_OR_GREATER
+[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
+#endif
+ out Age result) {
+ if(System.Int32.TryParse(utf8Text, style, provider, out var __v)) {
+
+
+ result = new Age(__v);
+ return true;
+ }
+
+ result = default;
+ return false;
+ }
+
+ ///
+ ///
+ ///
+ ///
+ /// True if the value could a) be parsed by the underlying type, and b) passes any validation (after running any optional normalization).
+ ///
+ public static global::System.Boolean TryParse(global::System.ReadOnlySpan utf8Text, global::System.IFormatProvider provider,
+#if NETCOREAPP3_0_OR_GREATER
+[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
+#endif
+ out Age result) {
+ if(System.Int32.TryParse(utf8Text, provider, out var __v)) {
+
+
+ result = new Age(__v);
+ return true;
+ }
+
+ result = default;
+ return false;
+ }
+
+ ///
+ ///
+ ///
+ ///
+ /// True if the value could a) be parsed by the underlying type, and b) passes any validation (after running any optional normalization).
+ ///
+ public static global::System.Boolean TryParse(global::System.ReadOnlySpan utf8Text,
+#if NETCOREAPP3_0_OR_GREATER
+[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
+#endif
+ out Age result) {
+ if(System.Int32.TryParse(utf8Text, out var __v)) {
+
+
+ result = new Age(__v);
+ return true;
+ }
+
+ result = default;
+ return false;
+ }
+
+ ///
+ ///
+ ///
+ ///
+ /// True if the value could a) be parsed by the underlying type, and b) passes any validation (after running any optional normalization).
+ ///
+ public static global::System.Boolean TryParse(global::System.ReadOnlySpan s, global::System.Globalization.NumberStyles style, global::System.IFormatProvider provider,
+#if NETCOREAPP3_0_OR_GREATER
+[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
+#endif
+ out Age result) {
+ if(System.Int32.TryParse(s, style, provider, out var __v)) {
+
+
+ result = new Age(__v);
+ return true;
+ }
+
+ result = default;
+ return false;
+ }
+
+ ///
+ ///
+ ///
+ ///
+ /// True if the value could a) be parsed by the underlying type, and b) passes any validation (after running any optional normalization).
+ ///
+ public static global::System.Boolean TryParse(global::System.ReadOnlySpan s, global::System.IFormatProvider provider,
+#if NETCOREAPP3_0_OR_GREATER
+[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
+#endif
+ out Age result) {
+ if(System.Int32.TryParse(s, provider, out var __v)) {
+
+
+ result = new Age(__v);
+ return true;
+ }
+
+ result = default;
+ return false;
+ }
+
+ ///
+ ///
+ ///
+ ///
+ /// True if the value could a) be parsed by the underlying type, and b) passes any validation (after running any optional normalization).
+ ///
+ public static global::System.Boolean TryParse(global::System.ReadOnlySpan s,
+#if NETCOREAPP3_0_OR_GREATER
+[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
+#endif
+ out Age result) {
+ if(System.Int32.TryParse(s, out var __v)) {
+
+
+ result = new Age(__v);
+ return true;
+ }
+
+ result = default;
+ return false;
+ }
+
+ ///
+ ///
+ ///
+ ///
+ /// True if the value could a) be parsed by the underlying type, and b) passes any validation (after running any optional normalization).
+ ///
+ 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 Age result) {
+ if(System.Int32.TryParse(s, style, provider, out var __v)) {
+
+
+ result = new Age(__v);
+ return true;
+ }
+
+ result = default;
+ return false;
+ }
+
+ ///
+ ///
+ ///
+ ///
+ /// True if the value could a) be parsed by the underlying type, and b) passes any validation (after running any optional normalization).
+ ///
+ 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 Age result) {
+ if(System.Int32.TryParse(s, provider, out var __v)) {
+
+
+ result = new Age(__v);
+ return true;
+ }
+
+ result = default;
+ return false;
+ }
+
+ ///
+ ///
+ ///
+ ///
+ /// True if the value could a) be parsed by the underlying type, and b) passes any validation (after running any optional normalization).
+ ///
+ public static global::System.Boolean TryParse(string s,
+#if NETCOREAPP3_0_OR_GREATER
+[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
+#endif
+ out Age result) {
+ if(System.Int32.TryParse(s, out var __v)) {
+
+
+ result = new Age(__v);
+ return true;
+ }
+
+ result = default;
+ return false;
+ }
+
+ ///
+ ///
+ ///
+ ///
+ /// The value created by calling the Parse method on the primitive.
+ ///
+ /// Thrown when the value can be parsed, but is not valid.
+ public static Age Parse(global::System.ReadOnlySpan utf8Text, global::System.Globalization.NumberStyles style, global::System.IFormatProvider provider) {
+ var r = System.Int32.Parse(utf8Text, style, provider);
+ return From(r);
+ }
+
+ ///
+ ///
+ ///
+ ///
+ /// The value created by calling the Parse method on the primitive.
+ ///
+ /// Thrown when the value can be parsed, but is not valid.
+ public static Age Parse(global::System.ReadOnlySpan utf8Text, global::System.IFormatProvider provider) {
+ var r = System.Int32.Parse(utf8Text, provider);
+ return From(r);
+ }
+
+ ///
+ ///
+ ///
+ ///
+ /// The value created by calling the Parse method on the primitive.
+ ///
+ /// Thrown when the value can be parsed, but is not valid.
+ public static Age Parse(global::System.ReadOnlySpan s, global::System.Globalization.NumberStyles style, global::System.IFormatProvider provider) {
+ var r = System.Int32.Parse(s, style, provider);
+ return From(r);
+ }
+
+ ///
+ ///
+ ///
+ ///
+ /// The value created by calling the Parse method on the primitive.
+ ///
+ /// Thrown when the value can be parsed, but is not valid.
+ public static Age Parse(global::System.ReadOnlySpan s, global::System.IFormatProvider provider) {
+ var r = System.Int32.Parse(s, provider);
+ return From(r);
+ }
+
+ ///
+ ///
+ ///
+ ///
+ /// The value created by calling the Parse method on the primitive.
+ ///
+ /// Thrown when the value can be parsed, but is not valid.
+ public static Age Parse(string s) {
+ var r = System.Int32.Parse(s);
+ return From(r);
+ }
+
+ ///
+ ///
+ ///
+ ///
+ /// The value created by calling the Parse method on the primitive.
+ ///
+ /// Thrown when the value can be parsed, but is not valid.
+ public static Age Parse(string s, global::System.Globalization.NumberStyles style) {
+ var r = System.Int32.Parse(s, style);
+ return From(r);
+ }
+
+ ///
+ ///
+ ///
+ ///
+ /// The value created by calling the Parse method on the primitive.
+ ///
+ /// Thrown when the value can be parsed, but is not valid.
+ public static Age Parse(string s, global::System.Globalization.NumberStyles style, global::System.IFormatProvider provider) {
+ var r = System.Int32.Parse(s, style, provider);
+ return From(r);
+ }
+
+ ///
+ ///
+ ///
+ ///
+ /// The value created by calling the Parse method on the primitive.
+ ///
+ /// Thrown when the value can be parsed, but is not valid.
+ public static Age Parse(string s, global::System.IFormatProvider provider) {
+ var r = System.Int32.Parse(s, provider);
+ return From(r);
+ }
+
+
+
+ public readonly override global::System.Int32 GetHashCode()
+ {
+ return global::System.Collections.Generic.EqualityComparer.Default.GetHashCode(Value);
+ }
+
+ /// Returns the string representation of the underlying .
+ public readonly override global::System.String ToString() =>IsInitialized() ? Value.ToString() : "[UNINITIALIZED]";
+
+ private readonly void EnsureInitialized()
+ {
+ if (!IsInitialized())
+ {
+#if DEBUG
+ global::System.String message = "Use of uninitialized Value Object at: " + _stackTrace ?? "";
+#else
+ global::System.String message = "Use of uninitialized Value Object.";
+#endif
+
+ throw new global::Vogen.ValueObjectValidationException(message);
+ }
+ }
+
+
+
+
+ ///
+ /// Converts a Age to or from JSON.
+ ///
+ public class AgeSystemTextJsonConverter : global::System.Text.Json.Serialization.JsonConverter
+ {
+ public override Age Read(ref global::System.Text.Json.Utf8JsonReader reader, global::System.Type typeToConvert, global::System.Text.Json.JsonSerializerOptions options)
+ {
+#if NET5_0_OR_GREATER
+ return Age.__Deserialize(global::System.Text.Json.JsonSerializer.Deserialize(ref reader, (global::System.Text.Json.Serialization.Metadata.JsonTypeInfo)options.GetTypeInfo(typeof(global::System.Int32))));
+#else
+ return Age.__Deserialize(reader.GetInt32());
+#endif
+ }
+
+ public override void Write(System.Text.Json.Utf8JsonWriter writer, Age 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 Age ReadAsPropertyName(ref global::System.Text.Json.Utf8JsonReader reader, global::System.Type typeToConvert, global::System.Text.Json.JsonSerializerOptions options)
+ {
+ return Age.__Deserialize(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, Age value, global::System.Text.Json.JsonSerializerOptions options)
+ {
+ writer.WritePropertyName(value.Value.ToString(global::System.Globalization.CultureInfo.InvariantCulture));
+ }
+#endif
+ }
+
+
+ class AgeTypeConverter : 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 => Age.__Deserialize(intValue),
+ global::System.String stringValue when !global::System.String.IsNullOrEmpty(stringValue) && global::System.Int32.TryParse(stringValue, out var result) => Age.__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 Age 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);
+ }
+ }
+
+
+
+
+
+
+ internal sealed class AgeDebugView
+ {
+ private readonly Age _t;
+
+ AgeDebugView(Age 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";
+ }
+
+}
+
+}
+]
\ No newline at end of file
diff --git a/tests/SnapshotTests/BugFixes/snapshots/snap-v8.0/Bug625_EFCoreConverters_uses_wrong_marker_interface_name.Setting_implicit_casting_to_primitive_in_global_config_should_not_write_a_primitive_cast_to_wrapper.verified.txt b/tests/SnapshotTests/BugFixes/snapshots/snap-v8.0/Bug625_EFCoreConverters_uses_wrong_marker_interface_name.Setting_implicit_casting_to_primitive_in_global_config_should_not_write_a_primitive_cast_to_wrapper.verified.txt
deleted file mode 100644
index 5f282702bb..0000000000
--- a/tests/SnapshotTests/BugFixes/snapshots/snap-v8.0/Bug625_EFCoreConverters_uses_wrong_marker_interface_name.Setting_implicit_casting_to_primitive_in_global_config_should_not_write_a_primitive_cast_to_wrapper.verified.txt
+++ /dev/null
@@ -1 +0,0 @@
-
\ No newline at end of file