Skip to content

Commit 8fe07c8

Browse files
committed
mark equality members obsolete with instructions
1 parent 1ebc3a3 commit 8fe07c8

File tree

118 files changed

+3186
-2714
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

118 files changed

+3186
-2714
lines changed

CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -752,20 +752,43 @@ private void GenerateEqualityAndComparison()
752752
return left.Value > right.ToUnit(left.Unit).Value;
753753
}}
754754
755-
/// <summary>Returns true if both <see cref=""Value"" /> and <see cref=""Unit"" /> are exactly equal for both quantities.</summary>
756-
/// <remarks>Consider using <see cref=""Equals({_quantity.Name}, double, ComparisonType)""/> for comparing floating-point values with rounding error tolerances.</remarks>
755+
/// <summary>Indicates strict equality of two <see cref=""{_quantity.Name}""/> quantities, where both <see cref=""Value"" /> and <see cref=""Unit"" /> are exactly equal.</summary>
756+
/// <remarks>Consider using <see cref=""Equals({_quantity.Name}, double, ComparisonType)""/> to check equality across different units and to specify a floating-point number error tolerance.</remarks>
757+
[Obsolete(""Consider using Equals(Angle, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance."")]
757758
public static bool operator ==({_quantity.Name} left, {_quantity.Name} right)
758759
{{
759760
return left.Equals(right);
760761
}}
761762
762-
/// <summary>Returns true if either <see cref=""Value"" /> or <see cref=""Unit"" /> are not exactly equal for both quantities.</summary>
763-
/// <remarks>Consider using <see cref=""Equals({_quantity.Name}, double, ComparisonType)""/> for comparing floating-point values with rounding error tolerances.</remarks>
763+
/// <summary>Indicates strict inequality of two <see cref=""{_quantity.Name}""/> quantities, where both <see cref=""Value"" /> and <see cref=""Unit"" /> are exactly equal.</summary>
764+
/// <remarks>Consider using <see cref=""Equals({_quantity.Name}, double, ComparisonType)""/> to check equality across different units and to specify a floating-point number error tolerance.</remarks>
765+
[Obsolete(""Consider using Equals(Angle, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance."")]
764766
public static bool operator !=({_quantity.Name} left, {_quantity.Name} right)
765767
{{
766768
return !(left == right);
767769
}}
768770
771+
/// <inheritdoc />
772+
/// <summary>Indicates strict equality of two <see cref=""{_quantity.Name}""/> quantities, where both <see cref=""Value"" /> and <see cref=""Unit"" /> are exactly equal.</summary>
773+
/// <remarks>Consider using <see cref=""Equals({_quantity.Name}, double, ComparisonType)""/> to check equality across different units and to specify a floating-point number error tolerance.</remarks>
774+
[Obsolete(""Consider using Equals(Angle, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance."")]
775+
public override bool Equals(object obj)
776+
{{
777+
if (obj is null || !(obj is {_quantity.Name} otherQuantity))
778+
return false;
779+
780+
return Equals(otherQuantity);
781+
}}
782+
783+
/// <inheritdoc />
784+
/// <summary>Indicates strict equality of two <see cref=""{_quantity.Name}""/> quantities, where both <see cref=""Value"" /> and <see cref=""Unit"" /> are exactly equal.</summary>
785+
/// <remarks>Consider using <see cref=""Equals({_quantity.Name}, double, ComparisonType)""/> to check equality across different units and to specify a floating-point number error tolerance.</remarks>
786+
[Obsolete(""Consider using Equals(Angle, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance."")]
787+
public bool Equals({_quantity.Name} other)
788+
{{
789+
return new {{ Value, Unit }}.Equals(new {{ other.Value, other.Unit }});
790+
}}
791+
769792
/// <summary>Compares the current <see cref=""{_quantity.Name}""/> with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit.</summary>
770793
/// <param name=""obj"">An object to compare with this instance.</param>
771794
/// <exception cref=""T:System.ArgumentException"">
@@ -802,25 +825,6 @@ public int CompareTo({_quantity.Name} other)
802825
return _value.CompareTo(other.ToUnit(this.Unit).Value);
803826
}}
804827
805-
/// <inheritdoc />
806-
/// <summary>Indicates strict equality of two <see cref=""{_quantity.Name}""/> quantities, where both <see cref=""Value"" /> and <see cref=""Unit"" /> are exactly equal.</summary>
807-
/// <remarks>Consider using <see cref=""Equals({_quantity.Name}, double, ComparisonType)""/> to check equality across different units and to specify a floating-point number error tolerance.</remarks>
808-
public override bool Equals(object obj)
809-
{{
810-
if (obj is null || !(obj is {_quantity.Name} otherQuantity))
811-
return false;
812-
813-
return Equals(otherQuantity);
814-
}}
815-
816-
/// <inheritdoc />
817-
/// <summary>Indicates strict equality of two <see cref=""{_quantity.Name}""/> quantities, where both <see cref=""Value"" /> and <see cref=""Unit"" /> are exactly equal.</summary>
818-
/// <remarks>Consider using <see cref=""Equals({_quantity.Name}, double, ComparisonType)""/> to check equality across different units and to specify a floating-point number error tolerance.</remarks>
819-
public bool Equals({_quantity.Name} other)
820-
{{
821-
return new {{ Value, Unit }}.Equals(new {{ other.Value, other.Unit }});
822-
}}
823-
824828
/// <summary>
825829
/// <para>
826830
/// Compare equality to another {_quantity.Name} within the given absolute or relative tolerance.

UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs

Lines changed: 27 additions & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs

Lines changed: 27 additions & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)