Skip to content

Removing equality methods/operators that do not accept a relative/abs… #489

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 28, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 0 additions & 24 deletions Common/GeneratedCode/Quantities/Acceleration.Common.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -469,16 +469,6 @@ int CompareTo(Acceleration other)
return _value.CompareTo(other.AsBaseNumericType(this.Unit));
}

[Obsolete("It is not safe to compare equality due to using System.Double as the internal representation. It is very easy to get slightly different values due to floating point operations. Instead use Equals($quantityName, double, ComparisonType) to provide the max allowed absolute or relative error.")]
public override bool Equals(object obj)
{
if(obj is null || !(obj is Acceleration))
return false;

var objQuantity = (Acceleration)obj;
return _value.Equals(objQuantity.AsBaseNumericType(this.Unit));
}

/// <summary>
/// <para>
/// Compare equality to another Acceleration within the given absolute or relative tolerance.
Expand Down Expand Up @@ -530,20 +520,6 @@ public bool Equals(Acceleration other, double tolerance, ComparisonType comparis
return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType);
}

/// <summary>
/// Compare equality to another Acceleration by specifying a max allowed difference.
/// Note that it is advised against specifying zero difference, due to the nature
/// of floating point operations and using System.Double internally.
/// </summary>
/// <param name="other">Other quantity to compare to.</param>
/// <param name="maxError">Max error allowed.</param>
/// <returns>True if the difference between the two values is not greater than the specified max.</returns>
[Obsolete("Please use the Equals(Acceleration, double, ComparisonType) overload. This method will be removed in a future version.")]
public bool Equals(Acceleration other, Acceleration maxError)
{
return Math.Abs(_value - other.AsBaseNumericType(this.Unit)) <= maxError.AsBaseNumericType(this.Unit);
}

/// <summary>
/// Returns the hash code for this instance.
/// </summary>
Expand Down
24 changes: 0 additions & 24 deletions Common/GeneratedCode/Quantities/AmountOfSubstance.Common.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -488,16 +488,6 @@ int CompareTo(AmountOfSubstance other)
return _value.CompareTo(other.AsBaseNumericType(this.Unit));
}

[Obsolete("It is not safe to compare equality due to using System.Double as the internal representation. It is very easy to get slightly different values due to floating point operations. Instead use Equals($quantityName, double, ComparisonType) to provide the max allowed absolute or relative error.")]
public override bool Equals(object obj)
{
if(obj is null || !(obj is AmountOfSubstance))
return false;

var objQuantity = (AmountOfSubstance)obj;
return _value.Equals(objQuantity.AsBaseNumericType(this.Unit));
}

/// <summary>
/// <para>
/// Compare equality to another AmountOfSubstance within the given absolute or relative tolerance.
Expand Down Expand Up @@ -549,20 +539,6 @@ public bool Equals(AmountOfSubstance other, double tolerance, ComparisonType com
return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType);
}

/// <summary>
/// Compare equality to another AmountOfSubstance by specifying a max allowed difference.
/// Note that it is advised against specifying zero difference, due to the nature
/// of floating point operations and using System.Double internally.
/// </summary>
/// <param name="other">Other quantity to compare to.</param>
/// <param name="maxError">Max error allowed.</param>
/// <returns>True if the difference between the two values is not greater than the specified max.</returns>
[Obsolete("Please use the Equals(AmountOfSubstance, double, ComparisonType) overload. This method will be removed in a future version.")]
public bool Equals(AmountOfSubstance other, AmountOfSubstance maxError)
{
return Math.Abs(_value - other.AsBaseNumericType(this.Unit)) <= maxError.AsBaseNumericType(this.Unit);
}

/// <summary>
/// Returns the hash code for this instance.
/// </summary>
Expand Down
24 changes: 0 additions & 24 deletions Common/GeneratedCode/Quantities/AmplitudeRatio.Common.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -297,16 +297,6 @@ int CompareTo(AmplitudeRatio other)
return _value.CompareTo(other.AsBaseNumericType(this.Unit));
}

[Obsolete("It is not safe to compare equality due to using System.Double as the internal representation. It is very easy to get slightly different values due to floating point operations. Instead use Equals($quantityName, double, ComparisonType) to provide the max allowed absolute or relative error.")]
public override bool Equals(object obj)
{
if(obj is null || !(obj is AmplitudeRatio))
return false;

var objQuantity = (AmplitudeRatio)obj;
return _value.Equals(objQuantity.AsBaseNumericType(this.Unit));
}

/// <summary>
/// <para>
/// Compare equality to another AmplitudeRatio within the given absolute or relative tolerance.
Expand Down Expand Up @@ -358,20 +348,6 @@ public bool Equals(AmplitudeRatio other, double tolerance, ComparisonType compar
return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType);
}

/// <summary>
/// Compare equality to another AmplitudeRatio by specifying a max allowed difference.
/// Note that it is advised against specifying zero difference, due to the nature
/// of floating point operations and using System.Double internally.
/// </summary>
/// <param name="other">Other quantity to compare to.</param>
/// <param name="maxError">Max error allowed.</param>
/// <returns>True if the difference between the two values is not greater than the specified max.</returns>
[Obsolete("Please use the Equals(AmplitudeRatio, double, ComparisonType) overload. This method will be removed in a future version.")]
public bool Equals(AmplitudeRatio other, AmplitudeRatio maxError)
{
return Math.Abs(_value - other.AsBaseNumericType(this.Unit)) <= maxError.AsBaseNumericType(this.Unit);
}

/// <summary>
/// Returns the hash code for this instance.
/// </summary>
Expand Down
24 changes: 0 additions & 24 deletions Common/GeneratedCode/Quantities/Angle.Common.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -487,16 +487,6 @@ int CompareTo(Angle other)
return _value.CompareTo(other.AsBaseNumericType(this.Unit));
}

[Obsolete("It is not safe to compare equality due to using System.Double as the internal representation. It is very easy to get slightly different values due to floating point operations. Instead use Equals($quantityName, double, ComparisonType) to provide the max allowed absolute or relative error.")]
public override bool Equals(object obj)
{
if(obj is null || !(obj is Angle))
return false;

var objQuantity = (Angle)obj;
return _value.Equals(objQuantity.AsBaseNumericType(this.Unit));
}

/// <summary>
/// <para>
/// Compare equality to another Angle within the given absolute or relative tolerance.
Expand Down Expand Up @@ -548,20 +538,6 @@ public bool Equals(Angle other, double tolerance, ComparisonType comparisonType)
return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType);
}

/// <summary>
/// Compare equality to another Angle by specifying a max allowed difference.
/// Note that it is advised against specifying zero difference, due to the nature
/// of floating point operations and using System.Double internally.
/// </summary>
/// <param name="other">Other quantity to compare to.</param>
/// <param name="maxError">Max error allowed.</param>
/// <returns>True if the difference between the two values is not greater than the specified max.</returns>
[Obsolete("Please use the Equals(Angle, double, ComparisonType) overload. This method will be removed in a future version.")]
public bool Equals(Angle other, Angle maxError)
{
return Math.Abs(_value - other.AsBaseNumericType(this.Unit)) <= maxError.AsBaseNumericType(this.Unit);
}

/// <summary>
/// Returns the hash code for this instance.
/// </summary>
Expand Down
24 changes: 0 additions & 24 deletions Common/GeneratedCode/Quantities/ApparentEnergy.Common.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -279,16 +279,6 @@ int CompareTo(ApparentEnergy other)
return _value.CompareTo(other.AsBaseNumericType(this.Unit));
}

[Obsolete("It is not safe to compare equality due to using System.Double as the internal representation. It is very easy to get slightly different values due to floating point operations. Instead use Equals($quantityName, double, ComparisonType) to provide the max allowed absolute or relative error.")]
public override bool Equals(object obj)
{
if(obj is null || !(obj is ApparentEnergy))
return false;

var objQuantity = (ApparentEnergy)obj;
return _value.Equals(objQuantity.AsBaseNumericType(this.Unit));
}

/// <summary>
/// <para>
/// Compare equality to another ApparentEnergy within the given absolute or relative tolerance.
Expand Down Expand Up @@ -340,20 +330,6 @@ public bool Equals(ApparentEnergy other, double tolerance, ComparisonType compar
return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType);
}

/// <summary>
/// Compare equality to another ApparentEnergy by specifying a max allowed difference.
/// Note that it is advised against specifying zero difference, due to the nature
/// of floating point operations and using System.Double internally.
/// </summary>
/// <param name="other">Other quantity to compare to.</param>
/// <param name="maxError">Max error allowed.</param>
/// <returns>True if the difference between the two values is not greater than the specified max.</returns>
[Obsolete("Please use the Equals(ApparentEnergy, double, ComparisonType) overload. This method will be removed in a future version.")]
public bool Equals(ApparentEnergy other, ApparentEnergy maxError)
{
return Math.Abs(_value - other.AsBaseNumericType(this.Unit)) <= maxError.AsBaseNumericType(this.Unit);
}

/// <summary>
/// Returns the hash code for this instance.
/// </summary>
Expand Down
24 changes: 0 additions & 24 deletions Common/GeneratedCode/Quantities/ApparentPower.Common.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -298,16 +298,6 @@ int CompareTo(ApparentPower other)
return _value.CompareTo(other.AsBaseNumericType(this.Unit));
}

[Obsolete("It is not safe to compare equality due to using System.Double as the internal representation. It is very easy to get slightly different values due to floating point operations. Instead use Equals($quantityName, double, ComparisonType) to provide the max allowed absolute or relative error.")]
public override bool Equals(object obj)
{
if(obj is null || !(obj is ApparentPower))
return false;

var objQuantity = (ApparentPower)obj;
return _value.Equals(objQuantity.AsBaseNumericType(this.Unit));
}

/// <summary>
/// <para>
/// Compare equality to another ApparentPower within the given absolute or relative tolerance.
Expand Down Expand Up @@ -359,20 +349,6 @@ public bool Equals(ApparentPower other, double tolerance, ComparisonType compari
return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType);
}

/// <summary>
/// Compare equality to another ApparentPower by specifying a max allowed difference.
/// Note that it is advised against specifying zero difference, due to the nature
/// of floating point operations and using System.Double internally.
/// </summary>
/// <param name="other">Other quantity to compare to.</param>
/// <param name="maxError">Max error allowed.</param>
/// <returns>True if the difference between the two values is not greater than the specified max.</returns>
[Obsolete("Please use the Equals(ApparentPower, double, ComparisonType) overload. This method will be removed in a future version.")]
public bool Equals(ApparentPower other, ApparentPower maxError)
{
return Math.Abs(_value - other.AsBaseNumericType(this.Unit)) <= maxError.AsBaseNumericType(this.Unit);
}

/// <summary>
/// Returns the hash code for this instance.
/// </summary>
Expand Down
24 changes: 0 additions & 24 deletions Common/GeneratedCode/Quantities/Area.Common.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -469,16 +469,6 @@ int CompareTo(Area other)
return _value.CompareTo(other.AsBaseNumericType(this.Unit));
}

[Obsolete("It is not safe to compare equality due to using System.Double as the internal representation. It is very easy to get slightly different values due to floating point operations. Instead use Equals($quantityName, double, ComparisonType) to provide the max allowed absolute or relative error.")]
public override bool Equals(object obj)
{
if(obj is null || !(obj is Area))
return false;

var objQuantity = (Area)obj;
return _value.Equals(objQuantity.AsBaseNumericType(this.Unit));
}

/// <summary>
/// <para>
/// Compare equality to another Area within the given absolute or relative tolerance.
Expand Down Expand Up @@ -530,20 +520,6 @@ public bool Equals(Area other, double tolerance, ComparisonType comparisonType)
return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType);
}

/// <summary>
/// Compare equality to another Area by specifying a max allowed difference.
/// Note that it is advised against specifying zero difference, due to the nature
/// of floating point operations and using System.Double internally.
/// </summary>
/// <param name="other">Other quantity to compare to.</param>
/// <param name="maxError">Max error allowed.</param>
/// <returns>True if the difference between the two values is not greater than the specified max.</returns>
[Obsolete("Please use the Equals(Area, double, ComparisonType) overload. This method will be removed in a future version.")]
public bool Equals(Area other, Area maxError)
{
return Math.Abs(_value - other.AsBaseNumericType(this.Unit)) <= maxError.AsBaseNumericType(this.Unit);
}

/// <summary>
/// Returns the hash code for this instance.
/// </summary>
Expand Down
24 changes: 0 additions & 24 deletions Common/GeneratedCode/Quantities/AreaDensity.Common.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -241,16 +241,6 @@ int CompareTo(AreaDensity other)
return _value.CompareTo(other.AsBaseNumericType(this.Unit));
}

[Obsolete("It is not safe to compare equality due to using System.Double as the internal representation. It is very easy to get slightly different values due to floating point operations. Instead use Equals($quantityName, double, ComparisonType) to provide the max allowed absolute or relative error.")]
public override bool Equals(object obj)
{
if(obj is null || !(obj is AreaDensity))
return false;

var objQuantity = (AreaDensity)obj;
return _value.Equals(objQuantity.AsBaseNumericType(this.Unit));
}

/// <summary>
/// <para>
/// Compare equality to another AreaDensity within the given absolute or relative tolerance.
Expand Down Expand Up @@ -302,20 +292,6 @@ public bool Equals(AreaDensity other, double tolerance, ComparisonType compariso
return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType);
}

/// <summary>
/// Compare equality to another AreaDensity by specifying a max allowed difference.
/// Note that it is advised against specifying zero difference, due to the nature
/// of floating point operations and using System.Double internally.
/// </summary>
/// <param name="other">Other quantity to compare to.</param>
/// <param name="maxError">Max error allowed.</param>
/// <returns>True if the difference between the two values is not greater than the specified max.</returns>
[Obsolete("Please use the Equals(AreaDensity, double, ComparisonType) overload. This method will be removed in a future version.")]
public bool Equals(AreaDensity other, AreaDensity maxError)
{
return Math.Abs(_value - other.AsBaseNumericType(this.Unit)) <= maxError.AsBaseNumericType(this.Unit);
}

/// <summary>
/// Returns the hash code for this instance.
/// </summary>
Expand Down
24 changes: 0 additions & 24 deletions Common/GeneratedCode/Quantities/AreaMomentOfInertia.Common.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -336,16 +336,6 @@ int CompareTo(AreaMomentOfInertia other)
return _value.CompareTo(other.AsBaseNumericType(this.Unit));
}

[Obsolete("It is not safe to compare equality due to using System.Double as the internal representation. It is very easy to get slightly different values due to floating point operations. Instead use Equals($quantityName, double, ComparisonType) to provide the max allowed absolute or relative error.")]
public override bool Equals(object obj)
{
if(obj is null || !(obj is AreaMomentOfInertia))
return false;

var objQuantity = (AreaMomentOfInertia)obj;
return _value.Equals(objQuantity.AsBaseNumericType(this.Unit));
}

/// <summary>
/// <para>
/// Compare equality to another AreaMomentOfInertia within the given absolute or relative tolerance.
Expand Down Expand Up @@ -397,20 +387,6 @@ public bool Equals(AreaMomentOfInertia other, double tolerance, ComparisonType c
return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType);
}

/// <summary>
/// Compare equality to another AreaMomentOfInertia by specifying a max allowed difference.
/// Note that it is advised against specifying zero difference, due to the nature
/// of floating point operations and using System.Double internally.
/// </summary>
/// <param name="other">Other quantity to compare to.</param>
/// <param name="maxError">Max error allowed.</param>
/// <returns>True if the difference between the two values is not greater than the specified max.</returns>
[Obsolete("Please use the Equals(AreaMomentOfInertia, double, ComparisonType) overload. This method will be removed in a future version.")]
public bool Equals(AreaMomentOfInertia other, AreaMomentOfInertia maxError)
{
return Math.Abs(_value - other.AsBaseNumericType(this.Unit)) <= maxError.AsBaseNumericType(this.Unit);
}

/// <summary>
/// Returns the hash code for this instance.
/// </summary>
Expand Down
Loading