From 4f863f06cf090cbf753bb40c09f841e27c6c768d Mon Sep 17 00:00:00 2001 From: Gregory Nikolaishvili Date: Tue, 7 May 2024 22:20:39 +0400 Subject: [PATCH] Refactor Equals and CompareTo method body generation s for improved functionality with ununitialized domain primitives --- Directory.Build.props | 2 +- .../Executor.cs | 4 ++-- .../Helpers/MethodGeneratorHelper.cs | 24 ++++++++++++++----- ...facesAndConverters#BoolValue.g.verified.cs | 16 +++++++++++-- ...facesAndConverters#ByteValue.g.verified.cs | 16 +++++++++++-- ...facesAndConverters#CharValue.g.verified.cs | 16 +++++++++++-- ...sAndConverters#DateOnlyValue.g.verified.cs | 16 +++++++++++-- ...nverters#DateTimeOffsetValue.g.verified.cs | 16 +++++++++++-- ...sAndConverters#DateTimeValue.g.verified.cs | 16 +++++++++++-- ...esAndConverters#DecimalValue.g.verified.cs | 16 +++++++++++-- ...cesAndConverters#DoubleValue.g.verified.cs | 16 +++++++++++-- ...acesAndConverters#FloatValue.g.verified.cs | 16 +++++++++++-- ...facesAndConverters#GuidValue.g.verified.cs | 16 +++++++++++-- ...acesAndConverters#ShortValue.g.verified.cs | 16 +++++++++++-- ...sAndConverters#IntOfIntValue.g.verified.cs | 16 +++++++++++-- ...rfacesAndConverters#IntValue.g.verified.cs | 16 +++++++++++-- ...rfacesAndConverters#IntValue.g.verified.cs | 16 +++++++++++-- ...facesAndConverters#LongValue.g.verified.cs | 16 +++++++++++-- ...acesAndConverters#SByteValue.g.verified.cs | 16 +++++++++++-- ...nverters#StringOfStringValue.g.verified.cs | 16 +++++++++++-- ...cesAndConverters#StringValue.g.verified.cs | 16 +++++++++++-- ...cesAndConverters#StringValue.g.verified.cs | 16 +++++++++++-- ...sAndConverters#TimeOnlyValue.g.verified.cs | 16 +++++++++++-- ...sAndConverters#TimeSpanValue.g.verified.cs | 16 +++++++++++-- ...cesAndConverters#UShortValue.g.verified.cs | 16 +++++++++++-- ...rfacesAndConverters#IntValue.g.verified.cs | 16 +++++++++++-- ...facesAndConverters#LongValue.g.verified.cs | 16 +++++++++++-- 27 files changed, 357 insertions(+), 57 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index 22049b1..de16c0f 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -9,7 +9,7 @@ Domain Primitives ALTA Software llc. Copyright © 2024 ALTA Software llc. - 3.0.0 + 3.0.1 diff --git a/src/AltaSoft.DomainPrimitives.Generator/Executor.cs b/src/AltaSoft.DomainPrimitives.Generator/Executor.cs index f96cc3c..8a65983 100644 --- a/src/AltaSoft.DomainPrimitives.Generator/Executor.cs +++ b/src/AltaSoft.DomainPrimitives.Generator/Executor.cs @@ -474,10 +474,10 @@ private static void Process(GeneratorData data, string ctorCode, DomainPrimitive .NewLine(); } - MethodGeneratorHelper.GenerateEquatableOperators(data.ClassName, data.FieldName, data.TypeSymbol.IsValueType, builder); + MethodGeneratorHelper.GenerateEquatableOperators(data.ClassName, data.TypeSymbol.IsValueType, builder); builder.NewLine(); - MethodGeneratorHelper.GenerateComparableCode(data.ClassName, data.FieldName, data.TypeSymbol.IsValueType, builder); + MethodGeneratorHelper.GenerateComparableCode(data.ClassName, data.TypeSymbol.IsValueType, builder); builder.NewLine(); if (data.GenerateImplicitOperators) diff --git a/src/AltaSoft.DomainPrimitives.Generator/Helpers/MethodGeneratorHelper.cs b/src/AltaSoft.DomainPrimitives.Generator/Helpers/MethodGeneratorHelper.cs index 5fbde3b..50374ec 100644 --- a/src/AltaSoft.DomainPrimitives.Generator/Helpers/MethodGeneratorHelper.cs +++ b/src/AltaSoft.DomainPrimitives.Generator/Helpers/MethodGeneratorHelper.cs @@ -441,10 +441,9 @@ internal static void GenerateAdditionCode(string className, string fieldName, So /// Generates code for implementing the IComparable interface for the specified type. /// /// The name of the class. - /// The name of the field to compare. /// A flag indicating if the type is a value type. /// The source code builder. - internal static void GenerateComparableCode(string className, string fieldName, bool isValueType, SourceCodeBuilder builder) + internal static void GenerateComparableCode(string className, bool isValueType, SourceCodeBuilder builder) { builder.AppendInheritDoc() .AppendLine("public int CompareTo(object? obj)") @@ -457,7 +456,16 @@ internal static void GenerateComparableCode(string className, string fieldName, .CloseBracket(); var nullable = isValueType ? "" : "?"; - builder.NewLine().AppendInheritDoc().AppendLine($"public int CompareTo({className}{nullable} other) => {fieldName}.CompareTo(other{nullable}.{fieldName});"); + + builder.NewLine().AppendInheritDoc() + .AppendLine($"public int CompareTo({className}{nullable} other)") + .OpenBracket() + .Append("if (").AppendIf(!isValueType, "other is null || ").AppendLine("!other._isInitialized)") + .AppendIndentation().AppendLine("return 1;") + .AppendLine("if (!_isInitialized)") + .AppendIndentation().AppendLine("return -1;") + .AppendLine("return _value.CompareTo(other._value);") + .CloseBracket(); } /// @@ -680,10 +688,9 @@ public static void GenerateParsable(GeneratorData data, SourceCodeBuilder builde /// Generates equality and inequality operators for the specified type. /// /// The name of the class. - /// The name of the field to compare. /// A flag indicating if the type is a value type. /// The source code builder. - public static void GenerateEquatableOperators(string className, string fieldName, bool isValueType, SourceCodeBuilder builder) + public static void GenerateEquatableOperators(string className, bool isValueType, SourceCodeBuilder builder) { builder.AppendInheritDoc() .AppendLine("[MethodImpl(MethodImplOptions.AggressiveInlining)]") @@ -693,7 +700,12 @@ public static void GenerateEquatableOperators(string className, string fieldName builder.AppendInheritDoc() .AppendLine("[MethodImpl(MethodImplOptions.AggressiveInlining)]") - .AppendLine($"public bool Equals({className}{nullable} other) => {fieldName} == other{nullable}.{fieldName};"); + .AppendLine($"public bool Equals({className}{nullable} other)") + .OpenBracket() + .Append("if (").AppendIf(!isValueType, "other is null || ").AppendLine("!_isInitialized || !other._isInitialized)") + .AppendIndentation().AppendLine("return false;") + .AppendLine("return _value.Equals(other._value);") + .CloseBracket(); builder.AppendInheritDoc() .AppendLine("[MethodImpl(MethodImplOptions.AggressiveInlining)]") diff --git a/tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.BoolValue_GeneratesAllInterfacesAndConverters#BoolValue.g.verified.cs b/tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.BoolValue_GeneratesAllInterfacesAndConverters#BoolValue.g.verified.cs index 22a8af8..3f86d06 100644 --- a/tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.BoolValue_GeneratesAllInterfacesAndConverters#BoolValue.g.verified.cs +++ b/tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.BoolValue_GeneratesAllInterfacesAndConverters#BoolValue.g.verified.cs @@ -63,7 +63,12 @@ public BoolValue() public override bool Equals(object? obj) => obj is BoolValue other && Equals(other); /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public bool Equals(BoolValue other) => _valueOrThrow == other._valueOrThrow; + public bool Equals(BoolValue other) + { + if (!_isInitialized || !other._isInitialized) + return false; + return _value.Equals(other._value); + } /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool operator ==(BoolValue left, BoolValue right) => left.Equals(right); @@ -84,7 +89,14 @@ public int CompareTo(object? obj) } /// - public int CompareTo(BoolValue other) => _valueOrThrow.CompareTo(other._valueOrThrow); + public int CompareTo(BoolValue other) + { + if (!other._isInitialized) + return 1; + if (!_isInitialized) + return -1; + return _value.CompareTo(other._value); + } /// /// Implicit conversion from to diff --git a/tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.ByteValue_GeneratesAllInterfacesAndConverters#ByteValue.g.verified.cs b/tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.ByteValue_GeneratesAllInterfacesAndConverters#ByteValue.g.verified.cs index 1548329..800fdbc 100644 --- a/tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.ByteValue_GeneratesAllInterfacesAndConverters#ByteValue.g.verified.cs +++ b/tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.ByteValue_GeneratesAllInterfacesAndConverters#ByteValue.g.verified.cs @@ -67,7 +67,12 @@ public ByteValue() public override bool Equals(object? obj) => obj is ByteValue other && Equals(other); /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public bool Equals(ByteValue other) => _valueOrThrow == other._valueOrThrow; + public bool Equals(ByteValue other) + { + if (!_isInitialized || !other._isInitialized) + return false; + return _value.Equals(other._value); + } /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool operator ==(ByteValue left, ByteValue right) => left.Equals(right); @@ -88,7 +93,14 @@ public int CompareTo(object? obj) } /// - public int CompareTo(ByteValue other) => _valueOrThrow.CompareTo(other._valueOrThrow); + public int CompareTo(ByteValue other) + { + if (!other._isInitialized) + return 1; + if (!_isInitialized) + return -1; + return _value.CompareTo(other._value); + } /// /// Implicit conversion from to diff --git a/tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.CharValue_GeneratesAllInterfacesAndConverters#CharValue.g.verified.cs b/tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.CharValue_GeneratesAllInterfacesAndConverters#CharValue.g.verified.cs index 7d76184..2ede1b9 100644 --- a/tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.CharValue_GeneratesAllInterfacesAndConverters#CharValue.g.verified.cs +++ b/tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.CharValue_GeneratesAllInterfacesAndConverters#CharValue.g.verified.cs @@ -67,7 +67,12 @@ public CharValue() public override bool Equals(object? obj) => obj is CharValue other && Equals(other); /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public bool Equals(CharValue other) => _valueOrThrow == other._valueOrThrow; + public bool Equals(CharValue other) + { + if (!_isInitialized || !other._isInitialized) + return false; + return _value.Equals(other._value); + } /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool operator ==(CharValue left, CharValue right) => left.Equals(right); @@ -88,7 +93,14 @@ public int CompareTo(object? obj) } /// - public int CompareTo(CharValue other) => _valueOrThrow.CompareTo(other._valueOrThrow); + public int CompareTo(CharValue other) + { + if (!other._isInitialized) + return 1; + if (!_isInitialized) + return -1; + return _value.CompareTo(other._value); + } /// /// Implicit conversion from to diff --git a/tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.DateOnlyValue_GeneratesAllInterfacesAndConverters#DateOnlyValue.g.verified.cs b/tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.DateOnlyValue_GeneratesAllInterfacesAndConverters#DateOnlyValue.g.verified.cs index fbc7ace..d35d268 100644 --- a/tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.DateOnlyValue_GeneratesAllInterfacesAndConverters#DateOnlyValue.g.verified.cs +++ b/tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.DateOnlyValue_GeneratesAllInterfacesAndConverters#DateOnlyValue.g.verified.cs @@ -68,7 +68,12 @@ public DateOnlyValue() public override bool Equals(object? obj) => obj is DateOnlyValue other && Equals(other); /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public bool Equals(DateOnlyValue other) => _valueOrThrow == other._valueOrThrow; + public bool Equals(DateOnlyValue other) + { + if (!_isInitialized || !other._isInitialized) + return false; + return _value.Equals(other._value); + } /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool operator ==(DateOnlyValue left, DateOnlyValue right) => left.Equals(right); @@ -89,7 +94,14 @@ public int CompareTo(object? obj) } /// - public int CompareTo(DateOnlyValue other) => _valueOrThrow.CompareTo(other._valueOrThrow); + public int CompareTo(DateOnlyValue other) + { + if (!other._isInitialized) + return 1; + if (!_isInitialized) + return -1; + return _value.CompareTo(other._value); + } /// /// Implicit conversion from to diff --git a/tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.DateTimeOffsetValue_GeneratesAllInterfacesAndConverters#DateTimeOffsetValue.g.verified.cs b/tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.DateTimeOffsetValue_GeneratesAllInterfacesAndConverters#DateTimeOffsetValue.g.verified.cs index d8eed18..9b46fee 100644 --- a/tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.DateTimeOffsetValue_GeneratesAllInterfacesAndConverters#DateTimeOffsetValue.g.verified.cs +++ b/tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.DateTimeOffsetValue_GeneratesAllInterfacesAndConverters#DateTimeOffsetValue.g.verified.cs @@ -68,7 +68,12 @@ public DateTimeOffsetValue() public override bool Equals(object? obj) => obj is DateTimeOffsetValue other && Equals(other); /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public bool Equals(DateTimeOffsetValue other) => _valueOrThrow == other._valueOrThrow; + public bool Equals(DateTimeOffsetValue other) + { + if (!_isInitialized || !other._isInitialized) + return false; + return _value.Equals(other._value); + } /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool operator ==(DateTimeOffsetValue left, DateTimeOffsetValue right) => left.Equals(right); @@ -89,7 +94,14 @@ public int CompareTo(object? obj) } /// - public int CompareTo(DateTimeOffsetValue other) => _valueOrThrow.CompareTo(other._valueOrThrow); + public int CompareTo(DateTimeOffsetValue other) + { + if (!other._isInitialized) + return 1; + if (!_isInitialized) + return -1; + return _value.CompareTo(other._value); + } /// /// Implicit conversion from to diff --git a/tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.DateTimeValue_GeneratesAllInterfacesAndConverters#DateTimeValue.g.verified.cs b/tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.DateTimeValue_GeneratesAllInterfacesAndConverters#DateTimeValue.g.verified.cs index 031d41a..4423efe 100644 --- a/tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.DateTimeValue_GeneratesAllInterfacesAndConverters#DateTimeValue.g.verified.cs +++ b/tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.DateTimeValue_GeneratesAllInterfacesAndConverters#DateTimeValue.g.verified.cs @@ -68,7 +68,12 @@ public DateTimeValue() public override bool Equals(object? obj) => obj is DateTimeValue other && Equals(other); /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public bool Equals(DateTimeValue other) => _valueOrThrow == other._valueOrThrow; + public bool Equals(DateTimeValue other) + { + if (!_isInitialized || !other._isInitialized) + return false; + return _value.Equals(other._value); + } /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool operator ==(DateTimeValue left, DateTimeValue right) => left.Equals(right); @@ -89,7 +94,14 @@ public int CompareTo(object? obj) } /// - public int CompareTo(DateTimeValue other) => _valueOrThrow.CompareTo(other._valueOrThrow); + public int CompareTo(DateTimeValue other) + { + if (!other._isInitialized) + return 1; + if (!_isInitialized) + return -1; + return _value.CompareTo(other._value); + } /// /// Implicit conversion from to diff --git a/tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.DecimalValue_GeneratesAllInterfacesAndConverters#DecimalValue.g.verified.cs b/tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.DecimalValue_GeneratesAllInterfacesAndConverters#DecimalValue.g.verified.cs index f65beaf..be3eb21 100644 --- a/tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.DecimalValue_GeneratesAllInterfacesAndConverters#DecimalValue.g.verified.cs +++ b/tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.DecimalValue_GeneratesAllInterfacesAndConverters#DecimalValue.g.verified.cs @@ -72,7 +72,12 @@ public DecimalValue() public override bool Equals(object? obj) => obj is DecimalValue other && Equals(other); /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public bool Equals(DecimalValue other) => _valueOrThrow == other._valueOrThrow; + public bool Equals(DecimalValue other) + { + if (!_isInitialized || !other._isInitialized) + return false; + return _value.Equals(other._value); + } /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool operator ==(DecimalValue left, DecimalValue right) => left.Equals(right); @@ -93,7 +98,14 @@ public int CompareTo(object? obj) } /// - public int CompareTo(DecimalValue other) => _valueOrThrow.CompareTo(other._valueOrThrow); + public int CompareTo(DecimalValue other) + { + if (!other._isInitialized) + return 1; + if (!_isInitialized) + return -1; + return _value.CompareTo(other._value); + } /// /// Implicit conversion from to diff --git a/tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.DoubleValue_GeneratesAllInterfacesAndConverters#DoubleValue.g.verified.cs b/tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.DoubleValue_GeneratesAllInterfacesAndConverters#DoubleValue.g.verified.cs index a962b95..97d067c 100644 --- a/tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.DoubleValue_GeneratesAllInterfacesAndConverters#DoubleValue.g.verified.cs +++ b/tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.DoubleValue_GeneratesAllInterfacesAndConverters#DoubleValue.g.verified.cs @@ -72,7 +72,12 @@ public DoubleValue() public override bool Equals(object? obj) => obj is DoubleValue other && Equals(other); /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public bool Equals(DoubleValue other) => _valueOrThrow == other._valueOrThrow; + public bool Equals(DoubleValue other) + { + if (!_isInitialized || !other._isInitialized) + return false; + return _value.Equals(other._value); + } /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool operator ==(DoubleValue left, DoubleValue right) => left.Equals(right); @@ -93,7 +98,14 @@ public int CompareTo(object? obj) } /// - public int CompareTo(DoubleValue other) => _valueOrThrow.CompareTo(other._valueOrThrow); + public int CompareTo(DoubleValue other) + { + if (!other._isInitialized) + return 1; + if (!_isInitialized) + return -1; + return _value.CompareTo(other._value); + } /// /// Implicit conversion from to diff --git a/tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.FloatValue_GeneratesAllInterfacesAndConverters#FloatValue.g.verified.cs b/tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.FloatValue_GeneratesAllInterfacesAndConverters#FloatValue.g.verified.cs index 2f43885..da37796 100644 --- a/tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.FloatValue_GeneratesAllInterfacesAndConverters#FloatValue.g.verified.cs +++ b/tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.FloatValue_GeneratesAllInterfacesAndConverters#FloatValue.g.verified.cs @@ -72,7 +72,12 @@ public FloatValue() public override bool Equals(object? obj) => obj is FloatValue other && Equals(other); /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public bool Equals(FloatValue other) => _valueOrThrow == other._valueOrThrow; + public bool Equals(FloatValue other) + { + if (!_isInitialized || !other._isInitialized) + return false; + return _value.Equals(other._value); + } /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool operator ==(FloatValue left, FloatValue right) => left.Equals(right); @@ -93,7 +98,14 @@ public int CompareTo(object? obj) } /// - public int CompareTo(FloatValue other) => _valueOrThrow.CompareTo(other._valueOrThrow); + public int CompareTo(FloatValue other) + { + if (!other._isInitialized) + return 1; + if (!_isInitialized) + return -1; + return _value.CompareTo(other._value); + } /// /// Implicit conversion from to diff --git a/tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.GuidValue_GeneratesAllInterfacesAndConverters#GuidValue.g.verified.cs b/tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.GuidValue_GeneratesAllInterfacesAndConverters#GuidValue.g.verified.cs index 03389c4..6896317 100644 --- a/tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.GuidValue_GeneratesAllInterfacesAndConverters#GuidValue.g.verified.cs +++ b/tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.GuidValue_GeneratesAllInterfacesAndConverters#GuidValue.g.verified.cs @@ -66,7 +66,12 @@ public GuidValue() public override bool Equals(object? obj) => obj is GuidValue other && Equals(other); /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public bool Equals(GuidValue other) => _valueOrThrow == other._valueOrThrow; + public bool Equals(GuidValue other) + { + if (!_isInitialized || !other._isInitialized) + return false; + return _value.Equals(other._value); + } /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool operator ==(GuidValue left, GuidValue right) => left.Equals(right); @@ -87,7 +92,14 @@ public int CompareTo(object? obj) } /// - public int CompareTo(GuidValue other) => _valueOrThrow.CompareTo(other._valueOrThrow); + public int CompareTo(GuidValue other) + { + if (!other._isInitialized) + return 1; + if (!_isInitialized) + return -1; + return _value.CompareTo(other._value); + } /// /// Implicit conversion from to diff --git a/tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.Int16Value_GeneratesAllInterfacesAndConverters#ShortValue.g.verified.cs b/tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.Int16Value_GeneratesAllInterfacesAndConverters#ShortValue.g.verified.cs index 4eef374..faacb7a 100644 --- a/tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.Int16Value_GeneratesAllInterfacesAndConverters#ShortValue.g.verified.cs +++ b/tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.Int16Value_GeneratesAllInterfacesAndConverters#ShortValue.g.verified.cs @@ -67,7 +67,12 @@ public ShortValue() public override bool Equals(object? obj) => obj is ShortValue other && Equals(other); /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public bool Equals(ShortValue other) => _valueOrThrow == other._valueOrThrow; + public bool Equals(ShortValue other) + { + if (!_isInitialized || !other._isInitialized) + return false; + return _value.Equals(other._value); + } /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool operator ==(ShortValue left, ShortValue right) => left.Equals(right); @@ -88,7 +93,14 @@ public int CompareTo(object? obj) } /// - public int CompareTo(ShortValue other) => _valueOrThrow.CompareTo(other._valueOrThrow); + public int CompareTo(ShortValue other) + { + if (!other._isInitialized) + return 1; + if (!_isInitialized) + return -1; + return _value.CompareTo(other._value); + } /// /// Implicit conversion from to diff --git a/tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.IntOfIntValue_GeneratesAllInterfacesAndConverters#IntOfIntValue.g.verified.cs b/tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.IntOfIntValue_GeneratesAllInterfacesAndConverters#IntOfIntValue.g.verified.cs index 22cd0b1..9a62978 100644 --- a/tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.IntOfIntValue_GeneratesAllInterfacesAndConverters#IntOfIntValue.g.verified.cs +++ b/tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.IntOfIntValue_GeneratesAllInterfacesAndConverters#IntOfIntValue.g.verified.cs @@ -69,7 +69,12 @@ public IntOfIntValue() public override bool Equals(object? obj) => obj is IntOfIntValue other && Equals(other); /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public bool Equals(IntOfIntValue other) => _valueOrThrow == other._valueOrThrow; + public bool Equals(IntOfIntValue other) + { + if (!_isInitialized || !other._isInitialized) + return false; + return _value.Equals(other._value); + } /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool operator ==(IntOfIntValue left, IntOfIntValue right) => left.Equals(right); @@ -90,7 +95,14 @@ public int CompareTo(object? obj) } /// - public int CompareTo(IntOfIntValue other) => _valueOrThrow.CompareTo(other._valueOrThrow); + public int CompareTo(IntOfIntValue other) + { + if (!other._isInitialized) + return 1; + if (!_isInitialized) + return -1; + return _value.CompareTo(other._value); + } /// /// Implicit conversion from to diff --git a/tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.IntOfIntValue_GeneratesAllInterfacesAndConverters#IntValue.g.verified.cs b/tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.IntOfIntValue_GeneratesAllInterfacesAndConverters#IntValue.g.verified.cs index 6ac9a9a..ed9a820 100644 --- a/tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.IntOfIntValue_GeneratesAllInterfacesAndConverters#IntValue.g.verified.cs +++ b/tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.IntOfIntValue_GeneratesAllInterfacesAndConverters#IntValue.g.verified.cs @@ -72,7 +72,12 @@ public IntValue() public override bool Equals(object? obj) => obj is IntValue other && Equals(other); /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public bool Equals(IntValue other) => _valueOrThrow == other._valueOrThrow; + public bool Equals(IntValue other) + { + if (!_isInitialized || !other._isInitialized) + return false; + return _value.Equals(other._value); + } /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool operator ==(IntValue left, IntValue right) => left.Equals(right); @@ -93,7 +98,14 @@ public int CompareTo(object? obj) } /// - public int CompareTo(IntValue other) => _valueOrThrow.CompareTo(other._valueOrThrow); + public int CompareTo(IntValue other) + { + if (!other._isInitialized) + return 1; + if (!_isInitialized) + return -1; + return _value.CompareTo(other._value); + } /// /// Implicit conversion from to diff --git a/tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.IntValue_GeneratesAllInterfacesAndConverters#IntValue.g.verified.cs b/tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.IntValue_GeneratesAllInterfacesAndConverters#IntValue.g.verified.cs index 6ac9a9a..ed9a820 100644 --- a/tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.IntValue_GeneratesAllInterfacesAndConverters#IntValue.g.verified.cs +++ b/tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.IntValue_GeneratesAllInterfacesAndConverters#IntValue.g.verified.cs @@ -72,7 +72,12 @@ public IntValue() public override bool Equals(object? obj) => obj is IntValue other && Equals(other); /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public bool Equals(IntValue other) => _valueOrThrow == other._valueOrThrow; + public bool Equals(IntValue other) + { + if (!_isInitialized || !other._isInitialized) + return false; + return _value.Equals(other._value); + } /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool operator ==(IntValue left, IntValue right) => left.Equals(right); @@ -93,7 +98,14 @@ public int CompareTo(object? obj) } /// - public int CompareTo(IntValue other) => _valueOrThrow.CompareTo(other._valueOrThrow); + public int CompareTo(IntValue other) + { + if (!other._isInitialized) + return 1; + if (!_isInitialized) + return -1; + return _value.CompareTo(other._value); + } /// /// Implicit conversion from to diff --git a/tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.LongValue_GeneratesAllInterfacesAndConverters#LongValue.g.verified.cs b/tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.LongValue_GeneratesAllInterfacesAndConverters#LongValue.g.verified.cs index e0d134e..a912c2b 100644 --- a/tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.LongValue_GeneratesAllInterfacesAndConverters#LongValue.g.verified.cs +++ b/tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.LongValue_GeneratesAllInterfacesAndConverters#LongValue.g.verified.cs @@ -72,7 +72,12 @@ public LongValue() public override bool Equals(object? obj) => obj is LongValue other && Equals(other); /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public bool Equals(LongValue other) => _valueOrThrow == other._valueOrThrow; + public bool Equals(LongValue other) + { + if (!_isInitialized || !other._isInitialized) + return false; + return _value.Equals(other._value); + } /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool operator ==(LongValue left, LongValue right) => left.Equals(right); @@ -93,7 +98,14 @@ public int CompareTo(object? obj) } /// - public int CompareTo(LongValue other) => _valueOrThrow.CompareTo(other._valueOrThrow); + public int CompareTo(LongValue other) + { + if (!other._isInitialized) + return 1; + if (!_isInitialized) + return -1; + return _value.CompareTo(other._value); + } /// /// Implicit conversion from to diff --git a/tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.SByteValue_GeneratesAllInterfacesAndConverters#SByteValue.g.verified.cs b/tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.SByteValue_GeneratesAllInterfacesAndConverters#SByteValue.g.verified.cs index bec106d..c1d1677 100644 --- a/tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.SByteValue_GeneratesAllInterfacesAndConverters#SByteValue.g.verified.cs +++ b/tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.SByteValue_GeneratesAllInterfacesAndConverters#SByteValue.g.verified.cs @@ -67,7 +67,12 @@ public SByteValue() public override bool Equals(object? obj) => obj is SByteValue other && Equals(other); /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public bool Equals(SByteValue other) => _valueOrThrow == other._valueOrThrow; + public bool Equals(SByteValue other) + { + if (!_isInitialized || !other._isInitialized) + return false; + return _value.Equals(other._value); + } /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool operator ==(SByteValue left, SByteValue right) => left.Equals(right); @@ -88,7 +93,14 @@ public int CompareTo(object? obj) } /// - public int CompareTo(SByteValue other) => _valueOrThrow.CompareTo(other._valueOrThrow); + public int CompareTo(SByteValue other) + { + if (!other._isInitialized) + return 1; + if (!_isInitialized) + return -1; + return _value.CompareTo(other._value); + } /// /// Implicit conversion from to diff --git a/tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.StringOfStringValue_GeneratesAllInterfacesAndConverters#StringOfStringValue.g.verified.cs b/tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.StringOfStringValue_GeneratesAllInterfacesAndConverters#StringOfStringValue.g.verified.cs index 29db4e6..acb94ea 100644 --- a/tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.StringOfStringValue_GeneratesAllInterfacesAndConverters#StringOfStringValue.g.verified.cs +++ b/tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.StringOfStringValue_GeneratesAllInterfacesAndConverters#StringOfStringValue.g.verified.cs @@ -65,7 +65,12 @@ public StringOfStringValue() public override bool Equals(object? obj) => obj is StringOfStringValue other && Equals(other); /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public bool Equals(StringOfStringValue? other) => _valueOrThrow == other?._valueOrThrow; + public bool Equals(StringOfStringValue? other) + { + if (other is null || !_isInitialized || !other._isInitialized) + return false; + return _value.Equals(other._value); + } /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool operator ==(StringOfStringValue? left, StringOfStringValue? right) @@ -93,7 +98,14 @@ public int CompareTo(object? obj) } /// - public int CompareTo(StringOfStringValue? other) => _valueOrThrow.CompareTo(other?._valueOrThrow); + public int CompareTo(StringOfStringValue? other) + { + if (other is null || !other._isInitialized) + return 1; + if (!_isInitialized) + return -1; + return _value.CompareTo(other._value); + } /// /// Implicit conversion from (nullable) to (nullable) diff --git a/tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.StringOfStringValue_GeneratesAllInterfacesAndConverters#StringValue.g.verified.cs b/tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.StringOfStringValue_GeneratesAllInterfacesAndConverters#StringValue.g.verified.cs index 6460425..77ac287 100644 --- a/tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.StringOfStringValue_GeneratesAllInterfacesAndConverters#StringValue.g.verified.cs +++ b/tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.StringOfStringValue_GeneratesAllInterfacesAndConverters#StringValue.g.verified.cs @@ -65,7 +65,12 @@ public StringValue() public override bool Equals(object? obj) => obj is StringValue other && Equals(other); /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public bool Equals(StringValue? other) => _valueOrThrow == other?._valueOrThrow; + public bool Equals(StringValue? other) + { + if (other is null || !_isInitialized || !other._isInitialized) + return false; + return _value.Equals(other._value); + } /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool operator ==(StringValue? left, StringValue? right) @@ -93,7 +98,14 @@ public int CompareTo(object? obj) } /// - public int CompareTo(StringValue? other) => _valueOrThrow.CompareTo(other?._valueOrThrow); + public int CompareTo(StringValue? other) + { + if (other is null || !other._isInitialized) + return 1; + if (!_isInitialized) + return -1; + return _value.CompareTo(other._value); + } /// /// Implicit conversion from (nullable) to (nullable) diff --git a/tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.StringValue_GeneratesAllInterfacesAndConverters#StringValue.g.verified.cs b/tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.StringValue_GeneratesAllInterfacesAndConverters#StringValue.g.verified.cs index 6460425..77ac287 100644 --- a/tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.StringValue_GeneratesAllInterfacesAndConverters#StringValue.g.verified.cs +++ b/tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.StringValue_GeneratesAllInterfacesAndConverters#StringValue.g.verified.cs @@ -65,7 +65,12 @@ public StringValue() public override bool Equals(object? obj) => obj is StringValue other && Equals(other); /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public bool Equals(StringValue? other) => _valueOrThrow == other?._valueOrThrow; + public bool Equals(StringValue? other) + { + if (other is null || !_isInitialized || !other._isInitialized) + return false; + return _value.Equals(other._value); + } /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool operator ==(StringValue? left, StringValue? right) @@ -93,7 +98,14 @@ public int CompareTo(object? obj) } /// - public int CompareTo(StringValue? other) => _valueOrThrow.CompareTo(other?._valueOrThrow); + public int CompareTo(StringValue? other) + { + if (other is null || !other._isInitialized) + return 1; + if (!_isInitialized) + return -1; + return _value.CompareTo(other._value); + } /// /// Implicit conversion from (nullable) to (nullable) diff --git a/tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.TimeOnlyValue_GeneratesAllInterfacesAndConverters#TimeOnlyValue.g.verified.cs b/tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.TimeOnlyValue_GeneratesAllInterfacesAndConverters#TimeOnlyValue.g.verified.cs index 28c6a2d..8bd929e 100644 --- a/tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.TimeOnlyValue_GeneratesAllInterfacesAndConverters#TimeOnlyValue.g.verified.cs +++ b/tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.TimeOnlyValue_GeneratesAllInterfacesAndConverters#TimeOnlyValue.g.verified.cs @@ -68,7 +68,12 @@ public TimeOnlyValue() public override bool Equals(object? obj) => obj is TimeOnlyValue other && Equals(other); /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public bool Equals(TimeOnlyValue other) => _valueOrThrow == other._valueOrThrow; + public bool Equals(TimeOnlyValue other) + { + if (!_isInitialized || !other._isInitialized) + return false; + return _value.Equals(other._value); + } /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool operator ==(TimeOnlyValue left, TimeOnlyValue right) => left.Equals(right); @@ -89,7 +94,14 @@ public int CompareTo(object? obj) } /// - public int CompareTo(TimeOnlyValue other) => _valueOrThrow.CompareTo(other._valueOrThrow); + public int CompareTo(TimeOnlyValue other) + { + if (!other._isInitialized) + return 1; + if (!_isInitialized) + return -1; + return _value.CompareTo(other._value); + } /// /// Implicit conversion from to diff --git a/tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.TimeSpanValue_GeneratesAllInterfacesAndConverters#TimeSpanValue.g.verified.cs b/tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.TimeSpanValue_GeneratesAllInterfacesAndConverters#TimeSpanValue.g.verified.cs index 5df208e..b0b40b3 100644 --- a/tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.TimeSpanValue_GeneratesAllInterfacesAndConverters#TimeSpanValue.g.verified.cs +++ b/tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.TimeSpanValue_GeneratesAllInterfacesAndConverters#TimeSpanValue.g.verified.cs @@ -68,7 +68,12 @@ public TimeSpanValue() public override bool Equals(object? obj) => obj is TimeSpanValue other && Equals(other); /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public bool Equals(TimeSpanValue other) => _valueOrThrow == other._valueOrThrow; + public bool Equals(TimeSpanValue other) + { + if (!_isInitialized || !other._isInitialized) + return false; + return _value.Equals(other._value); + } /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool operator ==(TimeSpanValue left, TimeSpanValue right) => left.Equals(right); @@ -89,7 +94,14 @@ public int CompareTo(object? obj) } /// - public int CompareTo(TimeSpanValue other) => _valueOrThrow.CompareTo(other._valueOrThrow); + public int CompareTo(TimeSpanValue other) + { + if (!other._isInitialized) + return 1; + if (!_isInitialized) + return -1; + return _value.CompareTo(other._value); + } /// /// Implicit conversion from to diff --git a/tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.UInt16Value_GeneratesAllInterfacesAndConverters#UShortValue.g.verified.cs b/tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.UInt16Value_GeneratesAllInterfacesAndConverters#UShortValue.g.verified.cs index ba60924..a07cccc 100644 --- a/tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.UInt16Value_GeneratesAllInterfacesAndConverters#UShortValue.g.verified.cs +++ b/tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.UInt16Value_GeneratesAllInterfacesAndConverters#UShortValue.g.verified.cs @@ -67,7 +67,12 @@ public UShortValue() public override bool Equals(object? obj) => obj is UShortValue other && Equals(other); /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public bool Equals(UShortValue other) => _valueOrThrow == other._valueOrThrow; + public bool Equals(UShortValue other) + { + if (!_isInitialized || !other._isInitialized) + return false; + return _value.Equals(other._value); + } /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool operator ==(UShortValue left, UShortValue right) => left.Equals(right); @@ -88,7 +93,14 @@ public int CompareTo(object? obj) } /// - public int CompareTo(UShortValue other) => _valueOrThrow.CompareTo(other._valueOrThrow); + public int CompareTo(UShortValue other) + { + if (!other._isInitialized) + return 1; + if (!_isInitialized) + return -1; + return _value.CompareTo(other._value); + } /// /// Implicit conversion from to diff --git a/tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.UIntValue_GeneratesAllInterfacesAndConverters#IntValue.g.verified.cs b/tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.UIntValue_GeneratesAllInterfacesAndConverters#IntValue.g.verified.cs index c200c1e..ab1d24e 100644 --- a/tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.UIntValue_GeneratesAllInterfacesAndConverters#IntValue.g.verified.cs +++ b/tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.UIntValue_GeneratesAllInterfacesAndConverters#IntValue.g.verified.cs @@ -72,7 +72,12 @@ public IntValue() public override bool Equals(object? obj) => obj is IntValue other && Equals(other); /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public bool Equals(IntValue other) => _valueOrThrow == other._valueOrThrow; + public bool Equals(IntValue other) + { + if (!_isInitialized || !other._isInitialized) + return false; + return _value.Equals(other._value); + } /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool operator ==(IntValue left, IntValue right) => left.Equals(right); @@ -93,7 +98,14 @@ public int CompareTo(object? obj) } /// - public int CompareTo(IntValue other) => _valueOrThrow.CompareTo(other._valueOrThrow); + public int CompareTo(IntValue other) + { + if (!other._isInitialized) + return 1; + if (!_isInitialized) + return -1; + return _value.CompareTo(other._value); + } /// /// Implicit conversion from to diff --git a/tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.ULongValue_GeneratesAllInterfacesAndConverters#LongValue.g.verified.cs b/tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.ULongValue_GeneratesAllInterfacesAndConverters#LongValue.g.verified.cs index cc0de60..517659c 100644 --- a/tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.ULongValue_GeneratesAllInterfacesAndConverters#LongValue.g.verified.cs +++ b/tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.ULongValue_GeneratesAllInterfacesAndConverters#LongValue.g.verified.cs @@ -72,7 +72,12 @@ public LongValue() public override bool Equals(object? obj) => obj is LongValue other && Equals(other); /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public bool Equals(LongValue other) => _valueOrThrow == other._valueOrThrow; + public bool Equals(LongValue other) + { + if (!_isInitialized || !other._isInitialized) + return false; + return _value.Equals(other._value); + } /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool operator ==(LongValue left, LongValue right) => left.Equals(right); @@ -93,7 +98,14 @@ public int CompareTo(object? obj) } /// - public int CompareTo(LongValue other) => _valueOrThrow.CompareTo(other._valueOrThrow); + public int CompareTo(LongValue other) + { + if (!other._isInitialized) + return 1; + if (!_isInitialized) + return -1; + return _value.CompareTo(other._value); + } /// /// Implicit conversion from to