From 1e8c9c7d845d24a5509de5a42fe964f4363f4448 Mon Sep 17 00:00:00 2001 From: Andreas Gullberg Larsen Date: Sun, 26 Feb 2023 18:21:27 +0100 Subject: [PATCH 1/4] =?UTF-8?q?=E2=9C=A8=20Add=20IEquatableQuantity?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ref #1193 In v5, equality changed to strict equality. This meant it became more cumbersome to compare equality for `IQuantity` objects of different units, but similar value when converted to the same unit. - Add interface `IEquatableQuantity` to help compare `IQuantity` objects with a tolerance for error Merge IEquatableQuantity into IQuantity interface --- .../UnitsNetGen/QuantityGenerator.cs | 57 +++++++++---- UnitsNet.Tests/CustomQuantities/HowMuch.cs | 7 ++ UnitsNet.Tests/DummyIQuantity.cs | 4 + UnitsNet.Tests/QuantityTests.cs | 81 +++++++++++++++++++ UnitsNet.Tests/UnitsNet.Tests.csproj | 2 +- .../Quantities/Acceleration.g.cs | 39 +++++++-- .../Quantities/AmountOfSubstance.g.cs | 39 +++++++-- .../Quantities/AmplitudeRatio.g.cs | 39 +++++++-- UnitsNet/GeneratedCode/Quantities/Angle.g.cs | 39 +++++++-- .../Quantities/ApparentEnergy.g.cs | 39 +++++++-- .../Quantities/ApparentPower.g.cs | 39 +++++++-- UnitsNet/GeneratedCode/Quantities/Area.g.cs | 39 +++++++-- .../GeneratedCode/Quantities/AreaDensity.g.cs | 39 +++++++-- .../Quantities/AreaMomentOfInertia.g.cs | 39 +++++++-- .../GeneratedCode/Quantities/BitRate.g.cs | 39 +++++++-- .../BrakeSpecificFuelConsumption.g.cs | 39 +++++++-- .../GeneratedCode/Quantities/Capacitance.g.cs | 39 +++++++-- .../CoefficientOfThermalExpansion.g.cs | 39 +++++++-- .../Quantities/Compressibility.g.cs | 39 +++++++-- .../GeneratedCode/Quantities/Density.g.cs | 39 +++++++-- .../GeneratedCode/Quantities/Duration.g.cs | 39 +++++++-- .../Quantities/DynamicViscosity.g.cs | 39 +++++++-- .../Quantities/ElectricAdmittance.g.cs | 39 +++++++-- .../Quantities/ElectricCharge.g.cs | 39 +++++++-- .../Quantities/ElectricChargeDensity.g.cs | 39 +++++++-- .../Quantities/ElectricConductance.g.cs | 39 +++++++-- .../Quantities/ElectricConductivity.g.cs | 39 +++++++-- .../Quantities/ElectricCurrent.g.cs | 39 +++++++-- .../Quantities/ElectricCurrentDensity.g.cs | 39 +++++++-- .../Quantities/ElectricCurrentGradient.g.cs | 39 +++++++-- .../Quantities/ElectricField.g.cs | 39 +++++++-- .../Quantities/ElectricInductance.g.cs | 39 +++++++-- .../Quantities/ElectricPotential.g.cs | 39 +++++++-- .../Quantities/ElectricPotentialAc.g.cs | 39 +++++++-- .../ElectricPotentialChangeRate.g.cs | 39 +++++++-- .../Quantities/ElectricPotentialDc.g.cs | 39 +++++++-- .../Quantities/ElectricResistance.g.cs | 39 +++++++-- .../Quantities/ElectricResistivity.g.cs | 39 +++++++-- .../ElectricSurfaceChargeDensity.g.cs | 39 +++++++-- UnitsNet/GeneratedCode/Quantities/Energy.g.cs | 39 +++++++-- .../Quantities/EnergyDensity.g.cs | 39 +++++++-- .../GeneratedCode/Quantities/Entropy.g.cs | 39 +++++++-- UnitsNet/GeneratedCode/Quantities/Force.g.cs | 39 +++++++-- .../Quantities/ForceChangeRate.g.cs | 39 +++++++-- .../Quantities/ForcePerLength.g.cs | 39 +++++++-- .../GeneratedCode/Quantities/Frequency.g.cs | 39 +++++++-- .../Quantities/FuelEfficiency.g.cs | 39 +++++++-- .../GeneratedCode/Quantities/HeatFlux.g.cs | 39 +++++++-- .../Quantities/HeatTransferCoefficient.g.cs | 39 +++++++-- .../GeneratedCode/Quantities/Illuminance.g.cs | 39 +++++++-- .../GeneratedCode/Quantities/Impulse.g.cs | 39 +++++++-- .../GeneratedCode/Quantities/Information.g.cs | 39 +++++++-- .../GeneratedCode/Quantities/Irradiance.g.cs | 39 +++++++-- .../GeneratedCode/Quantities/Irradiation.g.cs | 39 +++++++-- UnitsNet/GeneratedCode/Quantities/Jerk.g.cs | 39 +++++++-- .../Quantities/KinematicViscosity.g.cs | 39 +++++++-- .../GeneratedCode/Quantities/LeakRate.g.cs | 39 +++++++-- UnitsNet/GeneratedCode/Quantities/Length.g.cs | 39 +++++++-- UnitsNet/GeneratedCode/Quantities/Level.g.cs | 39 +++++++-- .../Quantities/LinearDensity.g.cs | 39 +++++++-- .../Quantities/LinearPowerDensity.g.cs | 39 +++++++-- .../GeneratedCode/Quantities/Luminance.g.cs | 39 +++++++-- .../GeneratedCode/Quantities/Luminosity.g.cs | 39 +++++++-- .../Quantities/LuminousFlux.g.cs | 39 +++++++-- .../Quantities/LuminousIntensity.g.cs | 39 +++++++-- .../Quantities/MagneticField.g.cs | 39 +++++++-- .../Quantities/MagneticFlux.g.cs | 39 +++++++-- .../Quantities/Magnetization.g.cs | 39 +++++++-- UnitsNet/GeneratedCode/Quantities/Mass.g.cs | 39 +++++++-- .../Quantities/MassConcentration.g.cs | 39 +++++++-- .../GeneratedCode/Quantities/MassFlow.g.cs | 39 +++++++-- .../GeneratedCode/Quantities/MassFlux.g.cs | 39 +++++++-- .../Quantities/MassFraction.g.cs | 39 +++++++-- .../Quantities/MassMomentOfInertia.g.cs | 39 +++++++-- .../GeneratedCode/Quantities/MolarEnergy.g.cs | 39 +++++++-- .../Quantities/MolarEntropy.g.cs | 39 +++++++-- .../GeneratedCode/Quantities/MolarFlow.g.cs | 39 +++++++-- .../GeneratedCode/Quantities/MolarMass.g.cs | 39 +++++++-- .../GeneratedCode/Quantities/Molarity.g.cs | 39 +++++++-- .../Quantities/Permeability.g.cs | 39 +++++++-- .../Quantities/Permittivity.g.cs | 39 +++++++-- .../Quantities/PorousMediumPermeability.g.cs | 39 +++++++-- UnitsNet/GeneratedCode/Quantities/Power.g.cs | 39 +++++++-- .../Quantities/PowerDensity.g.cs | 39 +++++++-- .../GeneratedCode/Quantities/PowerRatio.g.cs | 39 +++++++-- .../GeneratedCode/Quantities/Pressure.g.cs | 39 +++++++-- .../Quantities/PressureChangeRate.g.cs | 39 +++++++-- UnitsNet/GeneratedCode/Quantities/Ratio.g.cs | 39 +++++++-- .../Quantities/RatioChangeRate.g.cs | 39 +++++++-- .../Quantities/ReactiveEnergy.g.cs | 39 +++++++-- .../Quantities/ReactivePower.g.cs | 39 +++++++-- .../Quantities/ReciprocalArea.g.cs | 39 +++++++-- .../Quantities/ReciprocalLength.g.cs | 39 +++++++-- .../Quantities/RelativeHumidity.g.cs | 39 +++++++-- .../Quantities/RotationalAcceleration.g.cs | 39 +++++++-- .../Quantities/RotationalSpeed.g.cs | 39 +++++++-- .../Quantities/RotationalStiffness.g.cs | 39 +++++++-- .../RotationalStiffnessPerLength.g.cs | 39 +++++++-- UnitsNet/GeneratedCode/Quantities/Scalar.g.cs | 39 +++++++-- .../GeneratedCode/Quantities/SolidAngle.g.cs | 39 +++++++-- .../Quantities/SpecificEnergy.g.cs | 39 +++++++-- .../Quantities/SpecificEntropy.g.cs | 39 +++++++-- .../Quantities/SpecificFuelConsumption.g.cs | 39 +++++++-- .../Quantities/SpecificVolume.g.cs | 39 +++++++-- .../Quantities/SpecificWeight.g.cs | 39 +++++++-- UnitsNet/GeneratedCode/Quantities/Speed.g.cs | 39 +++++++-- .../Quantities/StandardVolumeFlow.g.cs | 39 +++++++-- .../GeneratedCode/Quantities/Temperature.g.cs | 39 +++++++-- .../Quantities/TemperatureChangeRate.g.cs | 39 +++++++-- .../Quantities/TemperatureDelta.g.cs | 39 +++++++-- .../Quantities/TemperatureGradient.g.cs | 39 +++++++-- .../Quantities/ThermalConductivity.g.cs | 39 +++++++-- .../Quantities/ThermalResistance.g.cs | 39 +++++++-- UnitsNet/GeneratedCode/Quantities/Torque.g.cs | 39 +++++++-- .../Quantities/TorquePerLength.g.cs | 39 +++++++-- .../GeneratedCode/Quantities/Turbidity.g.cs | 39 +++++++-- .../GeneratedCode/Quantities/VitaminA.g.cs | 39 +++++++-- UnitsNet/GeneratedCode/Quantities/Volume.g.cs | 39 +++++++-- .../Quantities/VolumeConcentration.g.cs | 39 +++++++-- .../GeneratedCode/Quantities/VolumeFlow.g.cs | 39 +++++++-- .../Quantities/VolumeFlowPerArea.g.cs | 39 +++++++-- .../Quantities/VolumePerLength.g.cs | 39 +++++++-- .../Quantities/VolumetricHeatCapacity.g.cs | 39 +++++++-- .../Quantities/WarpingMomentOfInertia.g.cs | 39 +++++++-- UnitsNet/IQuantity.cs | 50 +++++++++++- 125 files changed, 3871 insertions(+), 971 deletions(-) diff --git a/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs b/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs index 78a6c9fa59..2a0ec781bd 100644 --- a/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs +++ b/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs @@ -330,14 +330,14 @@ private void GenerateStaticMethods() /// The to register the default conversion functions in. internal static void RegisterDefaultConversions(UnitConverter unitConverter) {{ - // Register in unit converter: {_quantity.Name}Unit -> BaseUnit"); + // Register in unit converter: {_unitEnumName} -> BaseUnit"); foreach (Unit unit in _quantity.Units) { if (unit.SingularName == _quantity.BaseUnit) continue; Writer.WL($@" - unitConverter.SetConversionFunction<{_quantity.Name}>({_quantity.Name}Unit.{unit.SingularName}, {_unitEnumName}.{_quantity.BaseUnit}, quantity => quantity.ToUnit({_unitEnumName}.{_quantity.BaseUnit}));"); + unitConverter.SetConversionFunction<{_quantity.Name}>({_unitEnumName}.{unit.SingularName}, {_unitEnumName}.{_quantity.BaseUnit}, quantity => quantity.ToUnit({_unitEnumName}.{_quantity.BaseUnit}));"); } Writer.WL(); @@ -346,14 +346,14 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction<{_quantity.Name}>({_unitEnumName}.{_quantity.BaseUnit}, {_unitEnumName}.{_quantity.BaseUnit}, quantity => quantity); - // Register in unit converter: BaseUnit -> {_quantity.Name}Unit"); + // Register in unit converter: BaseUnit -> {_unitEnumName}"); foreach (Unit unit in _quantity.Units) { if (unit.SingularName == _quantity.BaseUnit) continue; Writer.WL($@" - unitConverter.SetConversionFunction<{_quantity.Name}>({_unitEnumName}.{_quantity.BaseUnit}, {_quantity.Name}Unit.{unit.SingularName}, quantity => quantity.ToUnit({_quantity.Name}Unit.{unit.SingularName}));"); + unitConverter.SetConversionFunction<{_quantity.Name}>({_unitEnumName}.{_quantity.BaseUnit}, {_unitEnumName}.{unit.SingularName}, quantity => quantity.ToUnit({_unitEnumName}.{unit.SingularName}));"); } Writer.WL($@" @@ -749,16 +749,14 @@ private void GenerateEqualityAndComparison() #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete(""For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals({_quantity.Name}, {_valueType}, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance."")] + [Obsolete(""For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals({_quantity.Name} other, {_quantity.Name} tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units."")] public static bool operator ==({_quantity.Name} left, {_quantity.Name} right) {{ return left.Equals(right); }} /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete(""For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals({_quantity.Name}, {_valueType}, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance."")] + [Obsolete(""For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals({_quantity.Name} other, {_quantity.Name} tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units."")] public static bool operator !=({_quantity.Name} left, {_quantity.Name} right) {{ return !(left == right); @@ -766,8 +764,7 @@ private void GenerateEqualityAndComparison() /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete(""Consider using Equals({_quantity.Name}, {_valueType}, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance."")] + [Obsolete(""Use Equals({_quantity.Name} other, {_quantity.Name} tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units."")] public override bool Equals(object? obj) {{ if (obj is null || !(obj is {_quantity.Name} otherQuantity)) @@ -778,8 +775,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete(""Consider using Equals({_quantity.Name}, {_valueType}, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance."")] + [Obsolete(""Use Equals({_quantity.Name} other, {_quantity.Name} tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units."")] public bool Equals({_quantity.Name} other) {{ return new {{ Value, Unit }}.Equals(new {{ other.Value, other.Unit }}); @@ -863,6 +859,7 @@ public int CompareTo({_quantity.Name} other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete(""Use Equals({_quantity.Name} other, {_quantity.Name} tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units."")] public bool Equals({_quantity.Name} other, {_quantity.ValueType} tolerance, ComparisonType comparisonType) {{ if (tolerance < 0) @@ -874,6 +871,32 @@ public bool Equals({_quantity.Name} other, {_quantity.ValueType} tolerance, Comp return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); }} + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + {{ + return other is {_quantity.Name} otherTyped + && (tolerance is {_quantity.Name} toleranceTyped + ? true + : throw new ArgumentException($""Tolerance quantity ({{tolerance.QuantityInfo.Name}}) did not match the other quantities of type '{_quantity.Name}'."", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + }} + + /// + public bool Equals({_quantity.Name} other, {_quantity.Name} tolerance) + {{ + if (tolerance < Zero) + throw new ArgumentOutOfRangeException(""tolerance"", ""Tolerance must be greater than or equal to 0.""); + + {_quantity.ValueType} thisValue = this.Value; + {_quantity.ValueType} otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + }} + /// /// Returns the hash code for this instance. /// @@ -1011,7 +1034,7 @@ double IQuantity.As(Enum unit) /// The unit to convert to. /// The converted in , if successful. /// True if successful, otherwise false. - private bool TryToUnit({_quantity.Name}Unit unit, [NotNullWhen(true)] out {_quantity.Name}? converted) + private bool TryToUnit({_unitEnumName} unit, [NotNullWhen(true)] out {_quantity.Name}? converted) {{ if (Unit == unit) {{ @@ -1021,7 +1044,7 @@ private bool TryToUnit({_quantity.Name}Unit unit, [NotNullWhen(true)] out {_quan {_quantity.Name}? convertedOrNull = (Unit, unit) switch {{ - // {_quantity.Name}Unit -> BaseUnit"); + // {_unitEnumName} -> BaseUnit"); foreach (Unit unit in _quantity.Units) { @@ -1029,20 +1052,20 @@ private bool TryToUnit({_quantity.Name}Unit unit, [NotNullWhen(true)] out {_quan var func = unit.FromUnitToBaseFunc.Replace("{x}", "_value"); Writer.WL($@" - ({_quantity.Name}Unit.{unit.SingularName}, {_unitEnumName}.{_quantity.BaseUnit}) => new {_quantity.Name}({func}, {_unitEnumName}.{_quantity.BaseUnit}),"); + ({_unitEnumName}.{unit.SingularName}, {_unitEnumName}.{_quantity.BaseUnit}) => new {_quantity.Name}({func}, {_unitEnumName}.{_quantity.BaseUnit}),"); } Writer.WL(); Writer.WL($@" - // BaseUnit -> {_quantity.Name}Unit"); + // BaseUnit -> {_unitEnumName}"); foreach(Unit unit in _quantity.Units) { if (unit.SingularName == _quantity.BaseUnit) continue; var func = unit.FromBaseToUnitFunc.Replace("{x}", "_value"); Writer.WL($@" - ({_unitEnumName}.{_quantity.BaseUnit}, {_quantity.Name}Unit.{unit.SingularName}) => new {_quantity.Name}({func}, {_quantity.Name}Unit.{unit.SingularName}),"); + ({_unitEnumName}.{_quantity.BaseUnit}, {_unitEnumName}.{unit.SingularName}) => new {_quantity.Name}({func}, {_unitEnumName}.{unit.SingularName}),"); } Writer.WL(); diff --git a/UnitsNet.Tests/CustomQuantities/HowMuch.cs b/UnitsNet.Tests/CustomQuantities/HowMuch.cs index bada53f7c8..c9d8a90647 100644 --- a/UnitsNet.Tests/CustomQuantities/HowMuch.cs +++ b/UnitsNet.Tests/CustomQuantities/HowMuch.cs @@ -14,6 +14,8 @@ public HowMuch(double value, HowMuchUnit unit) Value = value; } + public bool Equals(IQuantity? other, IQuantity tolerance) => throw new NotImplementedException(); + Enum IQuantity.Unit => Unit; public HowMuchUnit Unit { get; } @@ -42,6 +44,11 @@ public HowMuch(double value, HowMuchUnit unit) public double As(UnitSystem unitSystem) => throw new NotImplementedException(); + public bool Equals(IQuantity? other, double tolerance, ComparisonType comparisonType) + { + return other is HowMuch otherTyped && otherTyped.Unit == Unit && otherTyped.Value.Equals(Value); + } + public IQuantity ToUnit(Enum unit) { if (unit is HowMuchUnit howMuchUnit) return new HowMuch(As(unit), howMuchUnit); diff --git a/UnitsNet.Tests/DummyIQuantity.cs b/UnitsNet.Tests/DummyIQuantity.cs index bd9f57c2e7..01a39f4eb3 100644 --- a/UnitsNet.Tests/DummyIQuantity.cs +++ b/UnitsNet.Tests/DummyIQuantity.cs @@ -9,6 +9,8 @@ internal class DummyIQuantity : IQuantity public QuantityInfo QuantityInfo => throw new NotImplementedException(); + bool IQuantity.Equals(IQuantity? other, IQuantity tolerance) => throw new NotImplementedException(); + public Enum Unit => throw new NotImplementedException(); public QuantityValue Value => throw new NotImplementedException(); @@ -17,6 +19,8 @@ internal class DummyIQuantity : IQuantity public double As(UnitSystem unitSystem ) => throw new NotImplementedException(); + public bool Equals(IQuantity? other, double tolerance, ComparisonType comparisonType) => throw new NotImplementedException(); + public string ToString(IFormatProvider? provider) => throw new NotImplementedException(); public string ToString(string? format, IFormatProvider? formatProvider) => throw new NotImplementedException(); diff --git a/UnitsNet.Tests/QuantityTests.cs b/UnitsNet.Tests/QuantityTests.cs index 4e4ad0759c..98adbafa4a 100644 --- a/UnitsNet.Tests/QuantityTests.cs +++ b/UnitsNet.Tests/QuantityTests.cs @@ -1,6 +1,8 @@ // Licensed under MIT No Attribution, see LICENSE file at the root. // Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. +using System; +using System.Globalization; using UnitsNet.Units; using Xunit; @@ -16,5 +18,84 @@ public void GetHashCodeForDifferentQuantitiesWithSameValuesAreNotEqual() Assert.NotEqual(length.GetHashCode(), area.GetHashCode()); } + + [Theory] + [InlineData("10 m", "9.89 m" , "0.1 m", false)] // +/- 0.1m absolute tolerance and some additional margin tolerate rounding errors in test case. + [InlineData("10 m", "9.91 m" , "0.1 m", true)] + [InlineData("10 m", "10.09 m", "0.1 m", true)] + [InlineData("10 m", "1009 cm", "0.1 m", true)] // Different unit, still equal. + [InlineData("10 m", "10.11 m", "0.1 m", false)] + [InlineData("10 m", "8.9 m" , "0.1 m", false)] // +/- 1m relative tolerance (10%) and some additional margin tolerate rounding errors in test case. + public void Equals_IGenericEquatableQuantity(string q1String, string q2String, string toleranceString, bool expectedEqual) + { + // This interfaces implements .NET generic math interfaces. + IQuantity q1 = ParseLength(q1String); + IQuantity q2 = ParseLength(q2String); + IQuantity tolerance = ParseLength(toleranceString); + + Assert.Equal(expectedEqual, q1.Equals(q2, tolerance)); + } + + [Theory] + [InlineData("10 m", "9.89 m" , "0.1 m", false)] // +/- 0.1m absolute tolerance and some additional margin tolerate rounding errors in test case. + [InlineData("10 m", "9.91 m" , "0.1 m", true)] + [InlineData("10 m", "10.09 m", "0.1 m", true)] + [InlineData("10 m", "1009 cm", "0.1 m", true)] // Different unit, still equal. + [InlineData("10 m", "10.11 m", "0.1 m", false)] + [InlineData("10 m", "8.9 m" , "0.1 m", false)] // +/- 1m relative tolerance (10%) and some additional margin tolerate rounding errors in test case. + public void Equals_IQuantity(string q1String, string q2String, string toleranceString, bool expectedEqual) + { + IQuantity q1 = ParseLength(q1String); + IQuantity q2 = ParseLength(q2String); + IQuantity tolerance = ParseLength(toleranceString); + + Assert.NotEqual(q1, q2); // Strict equality should not be equal. + Assert.Equal(expectedEqual, q1.Equals(q2, tolerance)); + } + + [Fact] + public void Equals_IQuantity_OtherIsNull_ReturnsFalse() + { + IQuantity q1 = ParseLength("10 m"); + IQuantity? q2 = null; + IQuantity tolerance = ParseLength("0.1 m"); + + Assert.False(q1.Equals(q2, tolerance)); + } + + [Fact] + public void Equals_IQuantity_OtherIsDifferentType_ReturnsFalse() + { + IQuantity q1 = ParseLength("10 m"); + IQuantity q2 = Mass.FromKilograms(10); + IQuantity tolerance = Mass.FromKilograms(0.1); + + Assert.False(q1.Equals(q2, tolerance)); + } + + [Fact] + public void Equals_IQuantity_ToleranceIsDifferentType_Throws() + { + IQuantity q1 = ParseLength("10 m"); + IQuantity q2 = ParseLength("10 m"); + IQuantity tolerance = Mass.FromKilograms(0.1); + + Assert.Throws(() => q1.Equals(q2, tolerance)); + } + + [Fact] + public void Equals_GenericEquatableIQuantity_OtherIsNull_ReturnsFalse() + { + IQuantity q1 = ParseLength("10 m"); + IQuantity? q2 = null; + IQuantity tolerance = ParseLength("0.1 m"); + + Assert.False(q1.Equals(q2, tolerance)); + } + + private static Length ParseLength(string str) + { + return Length.Parse(str, CultureInfo.InvariantCulture); + } } } diff --git a/UnitsNet.Tests/UnitsNet.Tests.csproj b/UnitsNet.Tests/UnitsNet.Tests.csproj index 67cd43b1de..9fbd0a02f3 100644 --- a/UnitsNet.Tests/UnitsNet.Tests.csproj +++ b/UnitsNet.Tests/UnitsNet.Tests.csproj @@ -4,7 +4,7 @@ net7.0;net48 latest true - CS0618 + CS0618 enable diff --git a/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs b/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs index 50c61da5df..c44f91fe25 100644 --- a/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs @@ -727,16 +727,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Accel #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(Acceleration, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Acceleration other, Acceleration tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(Acceleration left, Acceleration right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(Acceleration, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Acceleration other, Acceleration tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(Acceleration left, Acceleration right) { return !(left == right); @@ -744,8 +742,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Accel /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(Acceleration, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(Acceleration other, Acceleration tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is Acceleration otherQuantity)) @@ -756,8 +753,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(Acceleration, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(Acceleration other, Acceleration tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(Acceleration other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -841,6 +837,7 @@ public int CompareTo(Acceleration other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(Acceleration other, Acceleration tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(Acceleration other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -852,6 +849,32 @@ public bool Equals(Acceleration other, double tolerance, ComparisonType comparis return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is Acceleration otherTyped + && (tolerance is Acceleration toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'Acceleration'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(Acceleration other, Acceleration tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs b/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs index d0e2a9b1ca..b182d26243 100644 --- a/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs @@ -732,16 +732,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Amoun #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(AmountOfSubstance, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(AmountOfSubstance other, AmountOfSubstance tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(AmountOfSubstance left, AmountOfSubstance right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(AmountOfSubstance, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(AmountOfSubstance other, AmountOfSubstance tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(AmountOfSubstance left, AmountOfSubstance right) { return !(left == right); @@ -749,8 +747,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Amoun /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(AmountOfSubstance, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(AmountOfSubstance other, AmountOfSubstance tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is AmountOfSubstance otherQuantity)) @@ -761,8 +758,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(AmountOfSubstance, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(AmountOfSubstance other, AmountOfSubstance tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(AmountOfSubstance other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -846,6 +842,7 @@ public int CompareTo(AmountOfSubstance other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(AmountOfSubstance other, AmountOfSubstance tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(AmountOfSubstance other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -857,6 +854,32 @@ public bool Equals(AmountOfSubstance other, double tolerance, ComparisonType com return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is AmountOfSubstance otherTyped + && (tolerance is AmountOfSubstance toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'AmountOfSubstance'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(AmountOfSubstance other, AmountOfSubstance tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.g.cs b/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.g.cs index 26a4b35dd2..f557d65e62 100644 --- a/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.g.cs @@ -531,16 +531,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Ampli #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(AmplitudeRatio, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(AmplitudeRatio other, AmplitudeRatio tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(AmplitudeRatio left, AmplitudeRatio right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(AmplitudeRatio, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(AmplitudeRatio other, AmplitudeRatio tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(AmplitudeRatio left, AmplitudeRatio right) { return !(left == right); @@ -548,8 +546,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Ampli /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(AmplitudeRatio, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(AmplitudeRatio other, AmplitudeRatio tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is AmplitudeRatio otherQuantity)) @@ -560,8 +557,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(AmplitudeRatio, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(AmplitudeRatio other, AmplitudeRatio tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(AmplitudeRatio other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -645,6 +641,7 @@ public int CompareTo(AmplitudeRatio other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(AmplitudeRatio other, AmplitudeRatio tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(AmplitudeRatio other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -656,6 +653,32 @@ public bool Equals(AmplitudeRatio other, double tolerance, ComparisonType compar return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is AmplitudeRatio otherTyped + && (tolerance is AmplitudeRatio toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'AmplitudeRatio'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(AmplitudeRatio other, AmplitudeRatio tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/Angle.g.cs b/UnitsNet/GeneratedCode/Quantities/Angle.g.cs index 27c248be69..5557327eec 100644 --- a/UnitsNet/GeneratedCode/Quantities/Angle.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Angle.g.cs @@ -763,16 +763,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Angle #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(Angle, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Angle other, Angle tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(Angle left, Angle right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(Angle, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Angle other, Angle tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(Angle left, Angle right) { return !(left == right); @@ -780,8 +778,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Angle /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(Angle, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(Angle other, Angle tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is Angle otherQuantity)) @@ -792,8 +789,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(Angle, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(Angle other, Angle tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(Angle other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -877,6 +873,7 @@ public int CompareTo(Angle other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(Angle other, Angle tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(Angle other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -888,6 +885,32 @@ public bool Equals(Angle other, double tolerance, ComparisonType comparisonType) return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is Angle otherTyped + && (tolerance is Angle toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'Angle'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(Angle other, Angle tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/ApparentEnergy.g.cs b/UnitsNet/GeneratedCode/Quantities/ApparentEnergy.g.cs index baf290ad86..d60d848267 100644 --- a/UnitsNet/GeneratedCode/Quantities/ApparentEnergy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ApparentEnergy.g.cs @@ -504,16 +504,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Appar #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(ApparentEnergy, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(ApparentEnergy other, ApparentEnergy tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(ApparentEnergy left, ApparentEnergy right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(ApparentEnergy, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(ApparentEnergy other, ApparentEnergy tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(ApparentEnergy left, ApparentEnergy right) { return !(left == right); @@ -521,8 +519,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Appar /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(ApparentEnergy, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(ApparentEnergy other, ApparentEnergy tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is ApparentEnergy otherQuantity)) @@ -533,8 +530,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(ApparentEnergy, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(ApparentEnergy other, ApparentEnergy tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(ApparentEnergy other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -618,6 +614,7 @@ public int CompareTo(ApparentEnergy other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(ApparentEnergy other, ApparentEnergy tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(ApparentEnergy other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -629,6 +626,32 @@ public bool Equals(ApparentEnergy other, double tolerance, ComparisonType compar return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is ApparentEnergy otherTyped + && (tolerance is ApparentEnergy toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'ApparentEnergy'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(ApparentEnergy other, ApparentEnergy tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/ApparentPower.g.cs b/UnitsNet/GeneratedCode/Quantities/ApparentPower.g.cs index bfc6980144..1bea929df7 100644 --- a/UnitsNet/GeneratedCode/Quantities/ApparentPower.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ApparentPower.g.cs @@ -561,16 +561,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Appar #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(ApparentPower, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(ApparentPower other, ApparentPower tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(ApparentPower left, ApparentPower right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(ApparentPower, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(ApparentPower other, ApparentPower tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(ApparentPower left, ApparentPower right) { return !(left == right); @@ -578,8 +576,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Appar /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(ApparentPower, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(ApparentPower other, ApparentPower tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is ApparentPower otherQuantity)) @@ -590,8 +587,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(ApparentPower, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(ApparentPower other, ApparentPower tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(ApparentPower other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -675,6 +671,7 @@ public int CompareTo(ApparentPower other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(ApparentPower other, ApparentPower tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(ApparentPower other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -686,6 +683,32 @@ public bool Equals(ApparentPower other, double tolerance, ComparisonType compari return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is ApparentPower otherTyped + && (tolerance is ApparentPower toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'ApparentPower'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(ApparentPower other, ApparentPower tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/Area.g.cs b/UnitsNet/GeneratedCode/Quantities/Area.g.cs index 4de92cb165..459705a580 100644 --- a/UnitsNet/GeneratedCode/Quantities/Area.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Area.g.cs @@ -740,16 +740,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out AreaU #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(Area, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Area other, Area tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(Area left, Area right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(Area, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Area other, Area tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(Area left, Area right) { return !(left == right); @@ -757,8 +755,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out AreaU /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(Area, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(Area other, Area tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is Area otherQuantity)) @@ -769,8 +766,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(Area, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(Area other, Area tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(Area other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -854,6 +850,7 @@ public int CompareTo(Area other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(Area other, Area tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(Area other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -865,6 +862,32 @@ public bool Equals(Area other, double tolerance, ComparisonType comparisonType) return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is Area otherTyped + && (tolerance is Area toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'Area'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(Area other, Area tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs index f989873016..20807d8c98 100644 --- a/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs @@ -504,16 +504,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out AreaD #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(AreaDensity, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(AreaDensity other, AreaDensity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(AreaDensity left, AreaDensity right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(AreaDensity, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(AreaDensity other, AreaDensity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(AreaDensity left, AreaDensity right) { return !(left == right); @@ -521,8 +519,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out AreaD /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(AreaDensity, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(AreaDensity other, AreaDensity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is AreaDensity otherQuantity)) @@ -533,8 +530,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(AreaDensity, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(AreaDensity other, AreaDensity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(AreaDensity other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -618,6 +614,7 @@ public int CompareTo(AreaDensity other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(AreaDensity other, AreaDensity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(AreaDensity other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -629,6 +626,32 @@ public bool Equals(AreaDensity other, double tolerance, ComparisonType compariso return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is AreaDensity otherTyped + && (tolerance is AreaDensity toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'AreaDensity'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(AreaDensity other, AreaDensity tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs b/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs index 2a63adeb01..235155f6cd 100644 --- a/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs @@ -561,16 +561,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out AreaM #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(AreaMomentOfInertia, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(AreaMomentOfInertia other, AreaMomentOfInertia tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(AreaMomentOfInertia left, AreaMomentOfInertia right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(AreaMomentOfInertia, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(AreaMomentOfInertia other, AreaMomentOfInertia tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(AreaMomentOfInertia left, AreaMomentOfInertia right) { return !(left == right); @@ -578,8 +576,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out AreaM /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(AreaMomentOfInertia, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(AreaMomentOfInertia other, AreaMomentOfInertia tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is AreaMomentOfInertia otherQuantity)) @@ -590,8 +587,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(AreaMomentOfInertia, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(AreaMomentOfInertia other, AreaMomentOfInertia tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(AreaMomentOfInertia other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -675,6 +671,7 @@ public int CompareTo(AreaMomentOfInertia other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(AreaMomentOfInertia other, AreaMomentOfInertia tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(AreaMomentOfInertia other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -686,6 +683,32 @@ public bool Equals(AreaMomentOfInertia other, double tolerance, ComparisonType c return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is AreaMomentOfInertia otherTyped + && (tolerance is AreaMomentOfInertia toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'AreaMomentOfInertia'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(AreaMomentOfInertia other, AreaMomentOfInertia tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs b/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs index 49e9903f31..96cb6b2aaf 100644 --- a/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs @@ -945,16 +945,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out BitRa #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(BitRate, decimal, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(BitRate other, BitRate tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(BitRate left, BitRate right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(BitRate, decimal, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(BitRate other, BitRate tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(BitRate left, BitRate right) { return !(left == right); @@ -962,8 +960,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out BitRa /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(BitRate, decimal, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(BitRate other, BitRate tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is BitRate otherQuantity)) @@ -974,8 +971,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(BitRate, decimal, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(BitRate other, BitRate tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(BitRate other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -1059,6 +1055,7 @@ public int CompareTo(BitRate other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(BitRate other, BitRate tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(BitRate other, decimal tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -1070,6 +1067,32 @@ public bool Equals(BitRate other, decimal tolerance, ComparisonType comparisonTy return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is BitRate otherTyped + && (tolerance is BitRate toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'BitRate'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(BitRate other, BitRate tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + decimal thisValue = this.Value; + decimal otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs b/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs index 3cb5f0382c..c807b8bb6c 100644 --- a/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs @@ -504,16 +504,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Brake #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(BrakeSpecificFuelConsumption, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(BrakeSpecificFuelConsumption other, BrakeSpecificFuelConsumption tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(BrakeSpecificFuelConsumption left, BrakeSpecificFuelConsumption right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(BrakeSpecificFuelConsumption, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(BrakeSpecificFuelConsumption other, BrakeSpecificFuelConsumption tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(BrakeSpecificFuelConsumption left, BrakeSpecificFuelConsumption right) { return !(left == right); @@ -521,8 +519,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Brake /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(BrakeSpecificFuelConsumption, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(BrakeSpecificFuelConsumption other, BrakeSpecificFuelConsumption tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is BrakeSpecificFuelConsumption otherQuantity)) @@ -533,8 +530,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(BrakeSpecificFuelConsumption, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(BrakeSpecificFuelConsumption other, BrakeSpecificFuelConsumption tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(BrakeSpecificFuelConsumption other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -618,6 +614,7 @@ public int CompareTo(BrakeSpecificFuelConsumption other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(BrakeSpecificFuelConsumption other, BrakeSpecificFuelConsumption tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(BrakeSpecificFuelConsumption other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -629,6 +626,32 @@ public bool Equals(BrakeSpecificFuelConsumption other, double tolerance, Compari return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is BrakeSpecificFuelConsumption otherTyped + && (tolerance is BrakeSpecificFuelConsumption toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'BrakeSpecificFuelConsumption'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(BrakeSpecificFuelConsumption other, BrakeSpecificFuelConsumption tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/Capacitance.g.cs b/UnitsNet/GeneratedCode/Quantities/Capacitance.g.cs index 26743b160c..b79e649a73 100644 --- a/UnitsNet/GeneratedCode/Quantities/Capacitance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Capacitance.g.cs @@ -583,16 +583,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Capac #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(Capacitance, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Capacitance other, Capacitance tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(Capacitance left, Capacitance right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(Capacitance, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Capacitance other, Capacitance tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(Capacitance left, Capacitance right) { return !(left == right); @@ -600,8 +598,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Capac /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(Capacitance, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(Capacitance other, Capacitance tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is Capacitance otherQuantity)) @@ -612,8 +609,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(Capacitance, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(Capacitance other, Capacitance tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(Capacitance other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -697,6 +693,7 @@ public int CompareTo(Capacitance other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(Capacitance other, Capacitance tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(Capacitance other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -708,6 +705,32 @@ public bool Equals(Capacitance other, double tolerance, ComparisonType compariso return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is Capacitance otherTyped + && (tolerance is Capacitance toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'Capacitance'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(Capacitance other, Capacitance tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs b/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs index 6b116c03db..980d4152d5 100644 --- a/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs @@ -504,16 +504,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Coeff #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(CoefficientOfThermalExpansion, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(CoefficientOfThermalExpansion other, CoefficientOfThermalExpansion tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(CoefficientOfThermalExpansion left, CoefficientOfThermalExpansion right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(CoefficientOfThermalExpansion, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(CoefficientOfThermalExpansion other, CoefficientOfThermalExpansion tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(CoefficientOfThermalExpansion left, CoefficientOfThermalExpansion right) { return !(left == right); @@ -521,8 +519,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Coeff /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(CoefficientOfThermalExpansion, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(CoefficientOfThermalExpansion other, CoefficientOfThermalExpansion tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is CoefficientOfThermalExpansion otherQuantity)) @@ -533,8 +530,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(CoefficientOfThermalExpansion, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(CoefficientOfThermalExpansion other, CoefficientOfThermalExpansion tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(CoefficientOfThermalExpansion other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -618,6 +614,7 @@ public int CompareTo(CoefficientOfThermalExpansion other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(CoefficientOfThermalExpansion other, CoefficientOfThermalExpansion tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(CoefficientOfThermalExpansion other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -629,6 +626,32 @@ public bool Equals(CoefficientOfThermalExpansion other, double tolerance, Compar return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is CoefficientOfThermalExpansion otherTyped + && (tolerance is CoefficientOfThermalExpansion toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'CoefficientOfThermalExpansion'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(CoefficientOfThermalExpansion other, CoefficientOfThermalExpansion tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/Compressibility.g.cs b/UnitsNet/GeneratedCode/Quantities/Compressibility.g.cs index d9745f5396..f80427543b 100644 --- a/UnitsNet/GeneratedCode/Quantities/Compressibility.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Compressibility.g.cs @@ -580,16 +580,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Compr #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(Compressibility, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Compressibility other, Compressibility tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(Compressibility left, Compressibility right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(Compressibility, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Compressibility other, Compressibility tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(Compressibility left, Compressibility right) { return !(left == right); @@ -597,8 +595,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Compr /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(Compressibility, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(Compressibility other, Compressibility tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is Compressibility otherQuantity)) @@ -609,8 +606,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(Compressibility, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(Compressibility other, Compressibility tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(Compressibility other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -694,6 +690,7 @@ public int CompareTo(Compressibility other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(Compressibility other, Compressibility tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(Compressibility other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -705,6 +702,32 @@ public bool Equals(Compressibility other, double tolerance, ComparisonType compa return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is Compressibility otherTyped + && (tolerance is Compressibility toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'Compressibility'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(Compressibility other, Compressibility tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/Density.g.cs b/UnitsNet/GeneratedCode/Quantities/Density.g.cs index ae27d2e4d7..72fc82ee79 100644 --- a/UnitsNet/GeneratedCode/Quantities/Density.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Density.g.cs @@ -1423,16 +1423,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Densi #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(Density, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Density other, Density tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(Density left, Density right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(Density, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Density other, Density tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(Density left, Density right) { return !(left == right); @@ -1440,8 +1438,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Densi /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(Density, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(Density other, Density tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is Density otherQuantity)) @@ -1452,8 +1449,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(Density, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(Density other, Density tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(Density other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -1537,6 +1533,7 @@ public int CompareTo(Density other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(Density other, Density tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(Density other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -1548,6 +1545,32 @@ public bool Equals(Density other, double tolerance, ComparisonType comparisonTyp return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is Density otherTyped + && (tolerance is Density toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'Density'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(Density other, Density tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/Duration.g.cs b/UnitsNet/GeneratedCode/Quantities/Duration.g.cs index ceea4f803a..26ed05b8f9 100644 --- a/UnitsNet/GeneratedCode/Quantities/Duration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Duration.g.cs @@ -666,16 +666,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Durat #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(Duration, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Duration other, Duration tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(Duration left, Duration right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(Duration, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Duration other, Duration tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(Duration left, Duration right) { return !(left == right); @@ -683,8 +681,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Durat /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(Duration, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(Duration other, Duration tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is Duration otherQuantity)) @@ -695,8 +692,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(Duration, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(Duration other, Duration tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(Duration other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -780,6 +776,7 @@ public int CompareTo(Duration other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(Duration other, Duration tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(Duration other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -791,6 +788,32 @@ public bool Equals(Duration other, double tolerance, ComparisonType comparisonTy return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is Duration otherTyped + && (tolerance is Duration toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'Duration'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(Duration other, Duration tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs b/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs index eb1ad0a3ae..8ae364a8e8 100644 --- a/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs @@ -640,16 +640,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Dynam #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(DynamicViscosity, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(DynamicViscosity other, DynamicViscosity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(DynamicViscosity left, DynamicViscosity right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(DynamicViscosity, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(DynamicViscosity other, DynamicViscosity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(DynamicViscosity left, DynamicViscosity right) { return !(left == right); @@ -657,8 +655,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Dynam /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(DynamicViscosity, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(DynamicViscosity other, DynamicViscosity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is DynamicViscosity otherQuantity)) @@ -669,8 +666,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(DynamicViscosity, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(DynamicViscosity other, DynamicViscosity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(DynamicViscosity other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -754,6 +750,7 @@ public int CompareTo(DynamicViscosity other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(DynamicViscosity other, DynamicViscosity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(DynamicViscosity other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -765,6 +762,32 @@ public bool Equals(DynamicViscosity other, double tolerance, ComparisonType comp return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is DynamicViscosity otherTyped + && (tolerance is DynamicViscosity toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'DynamicViscosity'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(DynamicViscosity other, DynamicViscosity tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.g.cs index e71b52a4ee..17715acdcd 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.g.cs @@ -523,16 +523,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(ElectricAdmittance, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(ElectricAdmittance other, ElectricAdmittance tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(ElectricAdmittance left, ElectricAdmittance right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(ElectricAdmittance, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(ElectricAdmittance other, ElectricAdmittance tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(ElectricAdmittance left, ElectricAdmittance right) { return !(left == right); @@ -540,8 +538,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(ElectricAdmittance, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(ElectricAdmittance other, ElectricAdmittance tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is ElectricAdmittance otherQuantity)) @@ -552,8 +549,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(ElectricAdmittance, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(ElectricAdmittance other, ElectricAdmittance tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(ElectricAdmittance other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -637,6 +633,7 @@ public int CompareTo(ElectricAdmittance other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(ElectricAdmittance other, ElectricAdmittance tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(ElectricAdmittance other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -648,6 +645,32 @@ public bool Equals(ElectricAdmittance other, double tolerance, ComparisonType co return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is ElectricAdmittance otherTyped + && (tolerance is ElectricAdmittance toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'ElectricAdmittance'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(ElectricAdmittance other, ElectricAdmittance tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs index 3c0b3b2ec7..c224797d62 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs @@ -659,16 +659,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(ElectricCharge, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(ElectricCharge other, ElectricCharge tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(ElectricCharge left, ElectricCharge right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(ElectricCharge, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(ElectricCharge other, ElectricCharge tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(ElectricCharge left, ElectricCharge right) { return !(left == right); @@ -676,8 +674,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(ElectricCharge, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(ElectricCharge other, ElectricCharge tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is ElectricCharge otherQuantity)) @@ -688,8 +685,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(ElectricCharge, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(ElectricCharge other, ElectricCharge tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(ElectricCharge other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -773,6 +769,7 @@ public int CompareTo(ElectricCharge other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(ElectricCharge other, ElectricCharge tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(ElectricCharge other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -784,6 +781,32 @@ public bool Equals(ElectricCharge other, double tolerance, ComparisonType compar return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is ElectricCharge otherTyped + && (tolerance is ElectricCharge toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'ElectricCharge'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(ElectricCharge other, ElectricCharge tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.g.cs index 5d22f8248d..a208db6e79 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.g.cs @@ -469,16 +469,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(ElectricChargeDensity, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(ElectricChargeDensity other, ElectricChargeDensity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(ElectricChargeDensity left, ElectricChargeDensity right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(ElectricChargeDensity, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(ElectricChargeDensity other, ElectricChargeDensity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(ElectricChargeDensity left, ElectricChargeDensity right) { return !(left == right); @@ -486,8 +484,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(ElectricChargeDensity, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(ElectricChargeDensity other, ElectricChargeDensity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is ElectricChargeDensity otherQuantity)) @@ -498,8 +495,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(ElectricChargeDensity, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(ElectricChargeDensity other, ElectricChargeDensity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(ElectricChargeDensity other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -583,6 +579,7 @@ public int CompareTo(ElectricChargeDensity other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(ElectricChargeDensity other, ElectricChargeDensity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(ElectricChargeDensity other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -594,6 +591,32 @@ public bool Equals(ElectricChargeDensity other, double tolerance, ComparisonType return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is ElectricChargeDensity otherTyped + && (tolerance is ElectricChargeDensity toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'ElectricChargeDensity'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(ElectricChargeDensity other, ElectricChargeDensity tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricConductance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricConductance.g.cs index d5b1e09d3d..e15e778af8 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricConductance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricConductance.g.cs @@ -545,16 +545,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(ElectricConductance, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(ElectricConductance other, ElectricConductance tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(ElectricConductance left, ElectricConductance right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(ElectricConductance, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(ElectricConductance other, ElectricConductance tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(ElectricConductance left, ElectricConductance right) { return !(left == right); @@ -562,8 +560,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(ElectricConductance, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(ElectricConductance other, ElectricConductance tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is ElectricConductance otherQuantity)) @@ -574,8 +571,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(ElectricConductance, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(ElectricConductance other, ElectricConductance tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(ElectricConductance other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -659,6 +655,7 @@ public int CompareTo(ElectricConductance other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(ElectricConductance other, ElectricConductance tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(ElectricConductance other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -670,6 +667,32 @@ public bool Equals(ElectricConductance other, double tolerance, ComparisonType c return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is ElectricConductance otherTyped + && (tolerance is ElectricConductance toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'ElectricConductance'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(ElectricConductance other, ElectricConductance tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs index 3e9c568fe9..6b91f67390 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs @@ -564,16 +564,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(ElectricConductivity, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(ElectricConductivity other, ElectricConductivity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(ElectricConductivity left, ElectricConductivity right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(ElectricConductivity, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(ElectricConductivity other, ElectricConductivity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(ElectricConductivity left, ElectricConductivity right) { return !(left == right); @@ -581,8 +579,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(ElectricConductivity, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(ElectricConductivity other, ElectricConductivity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is ElectricConductivity otherQuantity)) @@ -593,8 +590,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(ElectricConductivity, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(ElectricConductivity other, ElectricConductivity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(ElectricConductivity other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -678,6 +674,7 @@ public int CompareTo(ElectricConductivity other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(ElectricConductivity other, ElectricConductivity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(ElectricConductivity other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -689,6 +686,32 @@ public bool Equals(ElectricConductivity other, double tolerance, ComparisonType return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is ElectricConductivity otherTyped + && (tolerance is ElectricConductivity toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'ElectricConductivity'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(ElectricConductivity other, ElectricConductivity tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs index 5833e54875..22e760538b 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs @@ -618,16 +618,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(ElectricCurrent, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(ElectricCurrent other, ElectricCurrent tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(ElectricCurrent left, ElectricCurrent right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(ElectricCurrent, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(ElectricCurrent other, ElectricCurrent tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(ElectricCurrent left, ElectricCurrent right) { return !(left == right); @@ -635,8 +633,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(ElectricCurrent, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(ElectricCurrent other, ElectricCurrent tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is ElectricCurrent otherQuantity)) @@ -647,8 +644,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(ElectricCurrent, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(ElectricCurrent other, ElectricCurrent tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(ElectricCurrent other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -732,6 +728,7 @@ public int CompareTo(ElectricCurrent other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(ElectricCurrent other, ElectricCurrent tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(ElectricCurrent other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -743,6 +740,32 @@ public bool Equals(ElectricCurrent other, double tolerance, ComparisonType compa return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is ElectricCurrent otherTyped + && (tolerance is ElectricCurrent toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'ElectricCurrent'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(ElectricCurrent other, ElectricCurrent tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs index f73aa42c69..b017ef75ac 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs @@ -507,16 +507,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(ElectricCurrentDensity, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(ElectricCurrentDensity other, ElectricCurrentDensity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(ElectricCurrentDensity left, ElectricCurrentDensity right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(ElectricCurrentDensity, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(ElectricCurrentDensity other, ElectricCurrentDensity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(ElectricCurrentDensity left, ElectricCurrentDensity right) { return !(left == right); @@ -524,8 +522,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(ElectricCurrentDensity, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(ElectricCurrentDensity other, ElectricCurrentDensity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is ElectricCurrentDensity otherQuantity)) @@ -536,8 +533,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(ElectricCurrentDensity, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(ElectricCurrentDensity other, ElectricCurrentDensity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(ElectricCurrentDensity other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -621,6 +617,7 @@ public int CompareTo(ElectricCurrentDensity other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(ElectricCurrentDensity other, ElectricCurrentDensity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(ElectricCurrentDensity other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -632,6 +629,32 @@ public bool Equals(ElectricCurrentDensity other, double tolerance, ComparisonTyp return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is ElectricCurrentDensity otherTyped + && (tolerance is ElectricCurrentDensity toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'ElectricCurrentDensity'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(ElectricCurrentDensity other, ElectricCurrentDensity tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs index ee29ac5b7a..69118e2799 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs @@ -523,16 +523,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(ElectricCurrentGradient, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(ElectricCurrentGradient other, ElectricCurrentGradient tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(ElectricCurrentGradient left, ElectricCurrentGradient right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(ElectricCurrentGradient, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(ElectricCurrentGradient other, ElectricCurrentGradient tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(ElectricCurrentGradient left, ElectricCurrentGradient right) { return !(left == right); @@ -540,8 +538,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(ElectricCurrentGradient, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(ElectricCurrentGradient other, ElectricCurrentGradient tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is ElectricCurrentGradient otherQuantity)) @@ -552,8 +549,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(ElectricCurrentGradient, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(ElectricCurrentGradient other, ElectricCurrentGradient tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(ElectricCurrentGradient other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -637,6 +633,7 @@ public int CompareTo(ElectricCurrentGradient other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(ElectricCurrentGradient other, ElectricCurrentGradient tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(ElectricCurrentGradient other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -648,6 +645,32 @@ public bool Equals(ElectricCurrentGradient other, double tolerance, ComparisonTy return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is ElectricCurrentGradient otherTyped + && (tolerance is ElectricCurrentGradient toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'ElectricCurrentGradient'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(ElectricCurrentGradient other, ElectricCurrentGradient tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricField.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricField.g.cs index 8ab10f5056..51338291d9 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricField.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricField.g.cs @@ -469,16 +469,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(ElectricField, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(ElectricField other, ElectricField tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(ElectricField left, ElectricField right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(ElectricField, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(ElectricField other, ElectricField tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(ElectricField left, ElectricField right) { return !(left == right); @@ -486,8 +484,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(ElectricField, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(ElectricField other, ElectricField tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is ElectricField otherQuantity)) @@ -498,8 +495,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(ElectricField, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(ElectricField other, ElectricField tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(ElectricField other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -583,6 +579,7 @@ public int CompareTo(ElectricField other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(ElectricField other, ElectricField tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(ElectricField other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -594,6 +591,32 @@ public bool Equals(ElectricField other, double tolerance, ComparisonType compari return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is ElectricField otherTyped + && (tolerance is ElectricField toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'ElectricField'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(ElectricField other, ElectricField tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricInductance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricInductance.g.cs index 9fe8cc6a8c..88f6cc548d 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricInductance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricInductance.g.cs @@ -545,16 +545,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(ElectricInductance, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(ElectricInductance other, ElectricInductance tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(ElectricInductance left, ElectricInductance right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(ElectricInductance, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(ElectricInductance other, ElectricInductance tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(ElectricInductance left, ElectricInductance right) { return !(left == right); @@ -562,8 +560,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(ElectricInductance, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(ElectricInductance other, ElectricInductance tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is ElectricInductance otherQuantity)) @@ -574,8 +571,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(ElectricInductance, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(ElectricInductance other, ElectricInductance tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(ElectricInductance other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -659,6 +655,7 @@ public int CompareTo(ElectricInductance other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(ElectricInductance other, ElectricInductance tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(ElectricInductance other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -670,6 +667,32 @@ public bool Equals(ElectricInductance other, double tolerance, ComparisonType co return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is ElectricInductance otherTyped + && (tolerance is ElectricInductance toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'ElectricInductance'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(ElectricInductance other, ElectricInductance tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs index 1655b702a9..58be989bf1 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs @@ -567,16 +567,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(ElectricPotential, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(ElectricPotential other, ElectricPotential tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(ElectricPotential left, ElectricPotential right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(ElectricPotential, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(ElectricPotential other, ElectricPotential tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(ElectricPotential left, ElectricPotential right) { return !(left == right); @@ -584,8 +582,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(ElectricPotential, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(ElectricPotential other, ElectricPotential tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is ElectricPotential otherQuantity)) @@ -596,8 +593,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(ElectricPotential, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(ElectricPotential other, ElectricPotential tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(ElectricPotential other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -681,6 +677,7 @@ public int CompareTo(ElectricPotential other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(ElectricPotential other, ElectricPotential tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(ElectricPotential other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -692,6 +689,32 @@ public bool Equals(ElectricPotential other, double tolerance, ComparisonType com return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is ElectricPotential otherTyped + && (tolerance is ElectricPotential toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'ElectricPotential'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(ElectricPotential other, ElectricPotential tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialAc.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialAc.g.cs index 8c243b0b9b..4cf95ba360 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialAc.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialAc.g.cs @@ -542,16 +542,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(ElectricPotentialAc, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(ElectricPotentialAc other, ElectricPotentialAc tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(ElectricPotentialAc left, ElectricPotentialAc right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(ElectricPotentialAc, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(ElectricPotentialAc other, ElectricPotentialAc tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(ElectricPotentialAc left, ElectricPotentialAc right) { return !(left == right); @@ -559,8 +557,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(ElectricPotentialAc, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(ElectricPotentialAc other, ElectricPotentialAc tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is ElectricPotentialAc otherQuantity)) @@ -571,8 +568,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(ElectricPotentialAc, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(ElectricPotentialAc other, ElectricPotentialAc tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(ElectricPotentialAc other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -656,6 +652,7 @@ public int CompareTo(ElectricPotentialAc other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(ElectricPotentialAc other, ElectricPotentialAc tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(ElectricPotentialAc other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -667,6 +664,32 @@ public bool Equals(ElectricPotentialAc other, double tolerance, ComparisonType c return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is ElectricPotentialAc otherTyped + && (tolerance is ElectricPotentialAc toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'ElectricPotentialAc'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(ElectricPotentialAc other, ElectricPotentialAc tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs index 204fdb920b..c8c429f036 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs @@ -827,16 +827,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(ElectricPotentialChangeRate, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(ElectricPotentialChangeRate other, ElectricPotentialChangeRate tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(ElectricPotentialChangeRate left, ElectricPotentialChangeRate right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(ElectricPotentialChangeRate, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(ElectricPotentialChangeRate other, ElectricPotentialChangeRate tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(ElectricPotentialChangeRate left, ElectricPotentialChangeRate right) { return !(left == right); @@ -844,8 +842,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(ElectricPotentialChangeRate, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(ElectricPotentialChangeRate other, ElectricPotentialChangeRate tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is ElectricPotentialChangeRate otherQuantity)) @@ -856,8 +853,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(ElectricPotentialChangeRate, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(ElectricPotentialChangeRate other, ElectricPotentialChangeRate tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(ElectricPotentialChangeRate other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -941,6 +937,7 @@ public int CompareTo(ElectricPotentialChangeRate other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(ElectricPotentialChangeRate other, ElectricPotentialChangeRate tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(ElectricPotentialChangeRate other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -952,6 +949,32 @@ public bool Equals(ElectricPotentialChangeRate other, double tolerance, Comparis return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is ElectricPotentialChangeRate otherTyped + && (tolerance is ElectricPotentialChangeRate toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'ElectricPotentialChangeRate'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(ElectricPotentialChangeRate other, ElectricPotentialChangeRate tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialDc.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialDc.g.cs index 7e329382a4..c7f0607e24 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialDc.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialDc.g.cs @@ -542,16 +542,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(ElectricPotentialDc, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(ElectricPotentialDc other, ElectricPotentialDc tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(ElectricPotentialDc left, ElectricPotentialDc right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(ElectricPotentialDc, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(ElectricPotentialDc other, ElectricPotentialDc tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(ElectricPotentialDc left, ElectricPotentialDc right) { return !(left == right); @@ -559,8 +557,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(ElectricPotentialDc, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(ElectricPotentialDc other, ElectricPotentialDc tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is ElectricPotentialDc otherQuantity)) @@ -571,8 +568,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(ElectricPotentialDc, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(ElectricPotentialDc other, ElectricPotentialDc tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(ElectricPotentialDc other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -656,6 +652,7 @@ public int CompareTo(ElectricPotentialDc other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(ElectricPotentialDc other, ElectricPotentialDc tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(ElectricPotentialDc other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -667,6 +664,32 @@ public bool Equals(ElectricPotentialDc other, double tolerance, ComparisonType c return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is ElectricPotentialDc otherTyped + && (tolerance is ElectricPotentialDc toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'ElectricPotentialDc'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(ElectricPotentialDc other, ElectricPotentialDc tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs index dca339be01..f7f0b41058 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs @@ -580,16 +580,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(ElectricResistance, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(ElectricResistance other, ElectricResistance tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(ElectricResistance left, ElectricResistance right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(ElectricResistance, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(ElectricResistance other, ElectricResistance tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(ElectricResistance left, ElectricResistance right) { return !(left == right); @@ -597,8 +595,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(ElectricResistance, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(ElectricResistance other, ElectricResistance tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is ElectricResistance otherQuantity)) @@ -609,8 +606,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(ElectricResistance, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(ElectricResistance other, ElectricResistance tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(ElectricResistance other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -694,6 +690,7 @@ public int CompareTo(ElectricResistance other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(ElectricResistance other, ElectricResistance tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(ElectricResistance other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -705,6 +702,32 @@ public bool Equals(ElectricResistance other, double tolerance, ComparisonType co return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is ElectricResistance otherTyped + && (tolerance is ElectricResistance toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'ElectricResistance'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(ElectricResistance other, ElectricResistance tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs index 0159a5d433..777b62ad9a 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs @@ -716,16 +716,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(ElectricResistivity, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(ElectricResistivity other, ElectricResistivity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(ElectricResistivity left, ElectricResistivity right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(ElectricResistivity, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(ElectricResistivity other, ElectricResistivity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(ElectricResistivity left, ElectricResistivity right) { return !(left == right); @@ -733,8 +731,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(ElectricResistivity, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(ElectricResistivity other, ElectricResistivity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is ElectricResistivity otherQuantity)) @@ -745,8 +742,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(ElectricResistivity, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(ElectricResistivity other, ElectricResistivity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(ElectricResistivity other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -830,6 +826,7 @@ public int CompareTo(ElectricResistivity other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(ElectricResistivity other, ElectricResistivity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(ElectricResistivity other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -841,6 +838,32 @@ public bool Equals(ElectricResistivity other, double tolerance, ComparisonType c return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is ElectricResistivity otherTyped + && (tolerance is ElectricResistivity toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'ElectricResistivity'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(ElectricResistivity other, ElectricResistivity tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs index 6a79037987..e1535f7b33 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs @@ -507,16 +507,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(ElectricSurfaceChargeDensity, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(ElectricSurfaceChargeDensity other, ElectricSurfaceChargeDensity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(ElectricSurfaceChargeDensity left, ElectricSurfaceChargeDensity right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(ElectricSurfaceChargeDensity, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(ElectricSurfaceChargeDensity other, ElectricSurfaceChargeDensity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(ElectricSurfaceChargeDensity left, ElectricSurfaceChargeDensity right) { return !(left == right); @@ -524,8 +522,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(ElectricSurfaceChargeDensity, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(ElectricSurfaceChargeDensity other, ElectricSurfaceChargeDensity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is ElectricSurfaceChargeDensity otherQuantity)) @@ -536,8 +533,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(ElectricSurfaceChargeDensity, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(ElectricSurfaceChargeDensity other, ElectricSurfaceChargeDensity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(ElectricSurfaceChargeDensity other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -621,6 +617,7 @@ public int CompareTo(ElectricSurfaceChargeDensity other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(ElectricSurfaceChargeDensity other, ElectricSurfaceChargeDensity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(ElectricSurfaceChargeDensity other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -632,6 +629,32 @@ public bool Equals(ElectricSurfaceChargeDensity other, double tolerance, Compari return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is ElectricSurfaceChargeDensity otherTyped + && (tolerance is ElectricSurfaceChargeDensity toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'ElectricSurfaceChargeDensity'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(ElectricSurfaceChargeDensity other, ElectricSurfaceChargeDensity tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/Energy.g.cs b/UnitsNet/GeneratedCode/Quantities/Energy.g.cs index c762157cd9..0911c2f005 100644 --- a/UnitsNet/GeneratedCode/Quantities/Energy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Energy.g.cs @@ -1190,16 +1190,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Energ #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(Energy, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Energy other, Energy tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(Energy left, Energy right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(Energy, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Energy other, Energy tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(Energy left, Energy right) { return !(left == right); @@ -1207,8 +1205,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Energ /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(Energy, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(Energy other, Energy tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is Energy otherQuantity)) @@ -1219,8 +1216,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(Energy, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(Energy other, Energy tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(Energy other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -1304,6 +1300,7 @@ public int CompareTo(Energy other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(Energy other, Energy tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(Energy other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -1315,6 +1312,32 @@ public bool Equals(Energy other, double tolerance, ComparisonType comparisonType return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is Energy otherTyped + && (tolerance is Energy toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'Energy'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(Energy other, Energy tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/EnergyDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/EnergyDensity.g.cs index 280a9d6a72..760169c534 100644 --- a/UnitsNet/GeneratedCode/Quantities/EnergyDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/EnergyDensity.g.cs @@ -675,16 +675,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Energ #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(EnergyDensity, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(EnergyDensity other, EnergyDensity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(EnergyDensity left, EnergyDensity right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(EnergyDensity, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(EnergyDensity other, EnergyDensity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(EnergyDensity left, EnergyDensity right) { return !(left == right); @@ -692,8 +690,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Energ /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(EnergyDensity, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(EnergyDensity other, EnergyDensity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is EnergyDensity otherQuantity)) @@ -704,8 +701,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(EnergyDensity, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(EnergyDensity other, EnergyDensity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(EnergyDensity other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -789,6 +785,7 @@ public int CompareTo(EnergyDensity other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(EnergyDensity other, EnergyDensity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(EnergyDensity other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -800,6 +797,32 @@ public bool Equals(EnergyDensity other, double tolerance, ComparisonType compari return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is EnergyDensity otherTyped + && (tolerance is EnergyDensity toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'EnergyDensity'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(EnergyDensity other, EnergyDensity tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs b/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs index d66843e420..914bb6dab4 100644 --- a/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs @@ -580,16 +580,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Entro #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(Entropy, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Entropy other, Entropy tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(Entropy left, Entropy right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(Entropy, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Entropy other, Entropy tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(Entropy left, Entropy right) { return !(left == right); @@ -597,8 +595,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Entro /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(Entropy, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(Entropy other, Entropy tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is Entropy otherQuantity)) @@ -609,8 +606,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(Entropy, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(Entropy other, Entropy tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(Entropy other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -694,6 +690,7 @@ public int CompareTo(Entropy other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(Entropy other, Entropy tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(Entropy other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -705,6 +702,32 @@ public bool Equals(Entropy other, double tolerance, ComparisonType comparisonTyp return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is Entropy otherTyped + && (tolerance is Entropy toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'Entropy'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(Entropy other, Entropy tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/Force.g.cs b/UnitsNet/GeneratedCode/Quantities/Force.g.cs index 88c7b25449..44cd201da7 100644 --- a/UnitsNet/GeneratedCode/Quantities/Force.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Force.g.cs @@ -745,16 +745,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Force #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(Force, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Force other, Force tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(Force left, Force right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(Force, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Force other, Force tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(Force left, Force right) { return !(left == right); @@ -762,8 +760,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Force /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(Force, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(Force other, Force tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is Force otherQuantity)) @@ -774,8 +771,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(Force, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(Force other, Force tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(Force other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -859,6 +855,7 @@ public int CompareTo(Force other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(Force other, Force tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(Force other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -870,6 +867,32 @@ public bool Equals(Force other, double tolerance, ComparisonType comparisonType) return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is Force otherTyped + && (tolerance is Force toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'Force'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(Force other, Force tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs index c0bc760270..3be4add741 100644 --- a/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs @@ -732,16 +732,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Force #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(ForceChangeRate, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(ForceChangeRate other, ForceChangeRate tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(ForceChangeRate left, ForceChangeRate right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(ForceChangeRate, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(ForceChangeRate other, ForceChangeRate tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(ForceChangeRate left, ForceChangeRate right) { return !(left == right); @@ -749,8 +747,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Force /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(ForceChangeRate, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(ForceChangeRate other, ForceChangeRate tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is ForceChangeRate otherQuantity)) @@ -761,8 +758,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(ForceChangeRate, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(ForceChangeRate other, ForceChangeRate tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(ForceChangeRate other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -846,6 +842,7 @@ public int CompareTo(ForceChangeRate other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(ForceChangeRate other, ForceChangeRate tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(ForceChangeRate other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -857,6 +854,32 @@ public bool Equals(ForceChangeRate other, double tolerance, ComparisonType compa return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is ForceChangeRate otherTyped + && (tolerance is ForceChangeRate toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'ForceChangeRate'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(ForceChangeRate other, ForceChangeRate tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs b/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs index c147c0f280..546faf4f51 100644 --- a/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs @@ -1175,16 +1175,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Force #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(ForcePerLength, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(ForcePerLength other, ForcePerLength tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(ForcePerLength left, ForcePerLength right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(ForcePerLength, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(ForcePerLength other, ForcePerLength tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(ForcePerLength left, ForcePerLength right) { return !(left == right); @@ -1192,8 +1190,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Force /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(ForcePerLength, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(ForcePerLength other, ForcePerLength tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is ForcePerLength otherQuantity)) @@ -1204,8 +1201,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(ForcePerLength, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(ForcePerLength other, ForcePerLength tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(ForcePerLength other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -1289,6 +1285,7 @@ public int CompareTo(ForcePerLength other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(ForcePerLength other, ForcePerLength tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(ForcePerLength other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -1300,6 +1297,32 @@ public bool Equals(ForcePerLength other, double tolerance, ComparisonType compar return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is ForcePerLength otherTyped + && (tolerance is ForcePerLength toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'ForcePerLength'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(ForcePerLength other, ForcePerLength tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs b/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs index f0d6e735ed..3f394fd08f 100644 --- a/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs @@ -703,16 +703,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Frequ #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(Frequency, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Frequency other, Frequency tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(Frequency left, Frequency right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(Frequency, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Frequency other, Frequency tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(Frequency left, Frequency right) { return !(left == right); @@ -720,8 +718,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Frequ /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(Frequency, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(Frequency other, Frequency tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is Frequency otherQuantity)) @@ -732,8 +729,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(Frequency, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(Frequency other, Frequency tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(Frequency other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -817,6 +813,7 @@ public int CompareTo(Frequency other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(Frequency other, Frequency tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(Frequency other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -828,6 +825,32 @@ public bool Equals(Frequency other, double tolerance, ComparisonType comparisonT return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is Frequency otherTyped + && (tolerance is Frequency toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'Frequency'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(Frequency other, Frequency tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/FuelEfficiency.g.cs b/UnitsNet/GeneratedCode/Quantities/FuelEfficiency.g.cs index 7b513711f6..50578e201d 100644 --- a/UnitsNet/GeneratedCode/Quantities/FuelEfficiency.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/FuelEfficiency.g.cs @@ -526,16 +526,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out FuelE #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(FuelEfficiency, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(FuelEfficiency other, FuelEfficiency tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(FuelEfficiency left, FuelEfficiency right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(FuelEfficiency, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(FuelEfficiency other, FuelEfficiency tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(FuelEfficiency left, FuelEfficiency right) { return !(left == right); @@ -543,8 +541,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out FuelE /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(FuelEfficiency, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(FuelEfficiency other, FuelEfficiency tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is FuelEfficiency otherQuantity)) @@ -555,8 +552,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(FuelEfficiency, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(FuelEfficiency other, FuelEfficiency tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(FuelEfficiency other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -640,6 +636,7 @@ public int CompareTo(FuelEfficiency other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(FuelEfficiency other, FuelEfficiency tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(FuelEfficiency other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -651,6 +648,32 @@ public bool Equals(FuelEfficiency other, double tolerance, ComparisonType compar return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is FuelEfficiency otherTyped + && (tolerance is FuelEfficiency toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'FuelEfficiency'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(FuelEfficiency other, FuelEfficiency tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs b/UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs index 2e1587b1d6..d97972570d 100644 --- a/UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs @@ -789,16 +789,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out HeatF #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(HeatFlux, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(HeatFlux other, HeatFlux tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(HeatFlux left, HeatFlux right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(HeatFlux, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(HeatFlux other, HeatFlux tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(HeatFlux left, HeatFlux right) { return !(left == right); @@ -806,8 +804,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out HeatF /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(HeatFlux, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(HeatFlux other, HeatFlux tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is HeatFlux otherQuantity)) @@ -818,8 +815,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(HeatFlux, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(HeatFlux other, HeatFlux tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(HeatFlux other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -903,6 +899,7 @@ public int CompareTo(HeatFlux other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(HeatFlux other, HeatFlux tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(HeatFlux other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -914,6 +911,32 @@ public bool Equals(HeatFlux other, double tolerance, ComparisonType comparisonTy return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is HeatFlux otherTyped + && (tolerance is HeatFlux toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'HeatFlux'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(HeatFlux other, HeatFlux tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs b/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs index 36ebd8f183..e3599101a0 100644 --- a/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs @@ -563,16 +563,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out HeatT #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(HeatTransferCoefficient, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(HeatTransferCoefficient other, HeatTransferCoefficient tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(HeatTransferCoefficient left, HeatTransferCoefficient right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(HeatTransferCoefficient, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(HeatTransferCoefficient other, HeatTransferCoefficient tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(HeatTransferCoefficient left, HeatTransferCoefficient right) { return !(left == right); @@ -580,8 +578,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out HeatT /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(HeatTransferCoefficient, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(HeatTransferCoefficient other, HeatTransferCoefficient tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is HeatTransferCoefficient otherQuantity)) @@ -592,8 +589,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(HeatTransferCoefficient, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(HeatTransferCoefficient other, HeatTransferCoefficient tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(HeatTransferCoefficient other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -677,6 +673,7 @@ public int CompareTo(HeatTransferCoefficient other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(HeatTransferCoefficient other, HeatTransferCoefficient tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(HeatTransferCoefficient other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -688,6 +685,32 @@ public bool Equals(HeatTransferCoefficient other, double tolerance, ComparisonTy return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is HeatTransferCoefficient otherTyped + && (tolerance is HeatTransferCoefficient toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'HeatTransferCoefficient'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(HeatTransferCoefficient other, HeatTransferCoefficient tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/Illuminance.g.cs b/UnitsNet/GeneratedCode/Quantities/Illuminance.g.cs index 9a61690f4d..c7bd6bd202 100644 --- a/UnitsNet/GeneratedCode/Quantities/Illuminance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Illuminance.g.cs @@ -526,16 +526,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Illum #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(Illuminance, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Illuminance other, Illuminance tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(Illuminance left, Illuminance right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(Illuminance, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Illuminance other, Illuminance tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(Illuminance left, Illuminance right) { return !(left == right); @@ -543,8 +541,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Illum /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(Illuminance, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(Illuminance other, Illuminance tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is Illuminance otherQuantity)) @@ -555,8 +552,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(Illuminance, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(Illuminance other, Illuminance tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(Illuminance other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -640,6 +636,7 @@ public int CompareTo(Illuminance other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(Illuminance other, Illuminance tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(Illuminance other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -651,6 +648,32 @@ public bool Equals(Illuminance other, double tolerance, ComparisonType compariso return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is Illuminance otherTyped + && (tolerance is Illuminance toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'Illuminance'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(Illuminance other, Illuminance tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/Impulse.g.cs b/UnitsNet/GeneratedCode/Quantities/Impulse.g.cs index 7f106772e6..c4f4665eb2 100644 --- a/UnitsNet/GeneratedCode/Quantities/Impulse.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Impulse.g.cs @@ -694,16 +694,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Impul #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(Impulse, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Impulse other, Impulse tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(Impulse left, Impulse right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(Impulse, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Impulse other, Impulse tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(Impulse left, Impulse right) { return !(left == right); @@ -711,8 +709,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Impul /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(Impulse, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(Impulse other, Impulse tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is Impulse otherQuantity)) @@ -723,8 +720,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(Impulse, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(Impulse other, Impulse tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(Impulse other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -808,6 +804,7 @@ public int CompareTo(Impulse other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(Impulse other, Impulse tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(Impulse other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -819,6 +816,32 @@ public bool Equals(Impulse other, double tolerance, ComparisonType comparisonTyp return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is Impulse otherTyped + && (tolerance is Impulse toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'Impulse'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(Impulse other, Impulse tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/Information.g.cs b/UnitsNet/GeneratedCode/Quantities/Information.g.cs index 9bacae7e96..3a6b57db41 100644 --- a/UnitsNet/GeneratedCode/Quantities/Information.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Information.g.cs @@ -942,16 +942,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Infor #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(Information, decimal, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Information other, Information tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(Information left, Information right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(Information, decimal, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Information other, Information tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(Information left, Information right) { return !(left == right); @@ -959,8 +957,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Infor /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(Information, decimal, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(Information other, Information tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is Information otherQuantity)) @@ -971,8 +968,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(Information, decimal, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(Information other, Information tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(Information other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -1056,6 +1052,7 @@ public int CompareTo(Information other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(Information other, Information tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(Information other, decimal tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -1067,6 +1064,32 @@ public bool Equals(Information other, decimal tolerance, ComparisonType comparis return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is Information otherTyped + && (tolerance is Information toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'Information'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(Information other, Information tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + decimal thisValue = this.Value; + decimal otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/Irradiance.g.cs b/UnitsNet/GeneratedCode/Quantities/Irradiance.g.cs index d959da58da..1adc7b1745 100644 --- a/UnitsNet/GeneratedCode/Quantities/Irradiance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Irradiance.g.cs @@ -713,16 +713,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Irrad #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(Irradiance, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Irradiance other, Irradiance tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(Irradiance left, Irradiance right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(Irradiance, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Irradiance other, Irradiance tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(Irradiance left, Irradiance right) { return !(left == right); @@ -730,8 +728,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Irrad /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(Irradiance, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(Irradiance other, Irradiance tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is Irradiance otherQuantity)) @@ -742,8 +739,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(Irradiance, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(Irradiance other, Irradiance tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(Irradiance other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -827,6 +823,7 @@ public int CompareTo(Irradiance other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(Irradiance other, Irradiance tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(Irradiance other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -838,6 +835,32 @@ public bool Equals(Irradiance other, double tolerance, ComparisonType comparison return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is Irradiance otherTyped + && (tolerance is Irradiance toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'Irradiance'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(Irradiance other, Irradiance tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/Irradiation.g.cs b/UnitsNet/GeneratedCode/Quantities/Irradiation.g.cs index 49c9acc7ad..f62388ba2c 100644 --- a/UnitsNet/GeneratedCode/Quantities/Irradiation.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Irradiation.g.cs @@ -583,16 +583,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Irrad #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(Irradiation, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Irradiation other, Irradiation tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(Irradiation left, Irradiation right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(Irradiation, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Irradiation other, Irradiation tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(Irradiation left, Irradiation right) { return !(left == right); @@ -600,8 +598,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Irrad /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(Irradiation, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(Irradiation other, Irradiation tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is Irradiation otherQuantity)) @@ -612,8 +609,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(Irradiation, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(Irradiation other, Irradiation tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(Irradiation other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -697,6 +693,7 @@ public int CompareTo(Irradiation other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(Irradiation other, Irradiation tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(Irradiation other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -708,6 +705,32 @@ public bool Equals(Irradiation other, double tolerance, ComparisonType compariso return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is Irradiation otherTyped + && (tolerance is Irradiation toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'Irradiation'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(Irradiation other, Irradiation tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/Jerk.g.cs b/UnitsNet/GeneratedCode/Quantities/Jerk.g.cs index 8943c98193..7a165a3264 100644 --- a/UnitsNet/GeneratedCode/Quantities/Jerk.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Jerk.g.cs @@ -667,16 +667,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out JerkU #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(Jerk, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Jerk other, Jerk tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(Jerk left, Jerk right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(Jerk, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Jerk other, Jerk tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(Jerk left, Jerk right) { return !(left == right); @@ -684,8 +682,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out JerkU /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(Jerk, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(Jerk other, Jerk tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is Jerk otherQuantity)) @@ -696,8 +693,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(Jerk, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(Jerk other, Jerk tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(Jerk other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -781,6 +777,7 @@ public int CompareTo(Jerk other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(Jerk other, Jerk tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(Jerk other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -792,6 +789,32 @@ public bool Equals(Jerk other, double tolerance, ComparisonType comparisonType) return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is Jerk otherTyped + && (tolerance is Jerk toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'Jerk'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(Jerk other, Jerk tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs b/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs index c6b6d2d859..43ed81920a 100644 --- a/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs @@ -629,16 +629,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Kinem #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(KinematicViscosity, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(KinematicViscosity other, KinematicViscosity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(KinematicViscosity left, KinematicViscosity right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(KinematicViscosity, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(KinematicViscosity other, KinematicViscosity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(KinematicViscosity left, KinematicViscosity right) { return !(left == right); @@ -646,8 +644,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Kinem /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(KinematicViscosity, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(KinematicViscosity other, KinematicViscosity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is KinematicViscosity otherQuantity)) @@ -658,8 +655,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(KinematicViscosity, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(KinematicViscosity other, KinematicViscosity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(KinematicViscosity other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -743,6 +739,7 @@ public int CompareTo(KinematicViscosity other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(KinematicViscosity other, KinematicViscosity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(KinematicViscosity other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -754,6 +751,32 @@ public bool Equals(KinematicViscosity other, double tolerance, ComparisonType co return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is KinematicViscosity otherTyped + && (tolerance is KinematicViscosity toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'KinematicViscosity'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(KinematicViscosity other, KinematicViscosity tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/LeakRate.g.cs b/UnitsNet/GeneratedCode/Quantities/LeakRate.g.cs index 2c3fb9b3c6..1bbc3964c4 100644 --- a/UnitsNet/GeneratedCode/Quantities/LeakRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LeakRate.g.cs @@ -507,16 +507,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out LeakR #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(LeakRate, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(LeakRate other, LeakRate tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(LeakRate left, LeakRate right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(LeakRate, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(LeakRate other, LeakRate tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(LeakRate left, LeakRate right) { return !(left == right); @@ -524,8 +522,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out LeakR /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(LeakRate, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(LeakRate other, LeakRate tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is LeakRate otherQuantity)) @@ -536,8 +533,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(LeakRate, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(LeakRate other, LeakRate tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(LeakRate other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -621,6 +617,7 @@ public int CompareTo(LeakRate other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(LeakRate other, LeakRate tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(LeakRate other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -632,6 +629,32 @@ public bool Equals(LeakRate other, double tolerance, ComparisonType comparisonTy return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is LeakRate otherTyped + && (tolerance is LeakRate toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'LeakRate'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(LeakRate other, LeakRate tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/Length.g.cs b/UnitsNet/GeneratedCode/Quantities/Length.g.cs index bd0324ed5f..2084dcbbad 100644 --- a/UnitsNet/GeneratedCode/Quantities/Length.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Length.g.cs @@ -1184,16 +1184,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Lengt #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(Length, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Length other, Length tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(Length left, Length right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(Length, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Length other, Length tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(Length left, Length right) { return !(left == right); @@ -1201,8 +1199,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Lengt /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(Length, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(Length other, Length tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is Length otherQuantity)) @@ -1213,8 +1210,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(Length, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(Length other, Length tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(Length other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -1298,6 +1294,7 @@ public int CompareTo(Length other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(Length other, Length tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(Length other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -1309,6 +1306,32 @@ public bool Equals(Length other, double tolerance, ComparisonType comparisonType return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is Length otherTyped + && (tolerance is Length toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'Length'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(Length other, Length tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/Level.g.cs b/UnitsNet/GeneratedCode/Quantities/Level.g.cs index f175e4459b..59af9579a1 100644 --- a/UnitsNet/GeneratedCode/Quantities/Level.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Level.g.cs @@ -493,16 +493,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Level #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(Level, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Level other, Level tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(Level left, Level right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(Level, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Level other, Level tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(Level left, Level right) { return !(left == right); @@ -510,8 +508,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Level /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(Level, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(Level other, Level tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is Level otherQuantity)) @@ -522,8 +519,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(Level, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(Level other, Level tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(Level other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -607,6 +603,7 @@ public int CompareTo(Level other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(Level other, Level tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(Level other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -618,6 +615,32 @@ public bool Equals(Level other, double tolerance, ComparisonType comparisonType) return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is Level otherTyped + && (tolerance is Level toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'Level'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(Level other, Level tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/LinearDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/LinearDensity.g.cs index b0e899934d..e061bfd034 100644 --- a/UnitsNet/GeneratedCode/Quantities/LinearDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LinearDensity.g.cs @@ -716,16 +716,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Linea #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(LinearDensity, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(LinearDensity other, LinearDensity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(LinearDensity left, LinearDensity right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(LinearDensity, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(LinearDensity other, LinearDensity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(LinearDensity left, LinearDensity right) { return !(left == right); @@ -733,8 +731,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Linea /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(LinearDensity, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(LinearDensity other, LinearDensity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is LinearDensity otherQuantity)) @@ -745,8 +742,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(LinearDensity, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(LinearDensity other, LinearDensity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(LinearDensity other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -830,6 +826,7 @@ public int CompareTo(LinearDensity other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(LinearDensity other, LinearDensity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(LinearDensity other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -841,6 +838,32 @@ public bool Equals(LinearDensity other, double tolerance, ComparisonType compari return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is LinearDensity otherTyped + && (tolerance is LinearDensity toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'LinearDensity'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(LinearDensity other, LinearDensity tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/LinearPowerDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/LinearPowerDensity.g.cs index 671c648817..b03cee55ae 100644 --- a/UnitsNet/GeneratedCode/Quantities/LinearPowerDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LinearPowerDensity.g.cs @@ -925,16 +925,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Linea #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(LinearPowerDensity, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(LinearPowerDensity other, LinearPowerDensity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(LinearPowerDensity left, LinearPowerDensity right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(LinearPowerDensity, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(LinearPowerDensity other, LinearPowerDensity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(LinearPowerDensity left, LinearPowerDensity right) { return !(left == right); @@ -942,8 +940,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Linea /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(LinearPowerDensity, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(LinearPowerDensity other, LinearPowerDensity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is LinearPowerDensity otherQuantity)) @@ -954,8 +951,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(LinearPowerDensity, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(LinearPowerDensity other, LinearPowerDensity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(LinearPowerDensity other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -1039,6 +1035,7 @@ public int CompareTo(LinearPowerDensity other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(LinearPowerDensity other, LinearPowerDensity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(LinearPowerDensity other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -1050,6 +1047,32 @@ public bool Equals(LinearPowerDensity other, double tolerance, ComparisonType co return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is LinearPowerDensity otherTyped + && (tolerance is LinearPowerDensity toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'LinearPowerDensity'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(LinearPowerDensity other, LinearPowerDensity tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/Luminance.g.cs b/UnitsNet/GeneratedCode/Quantities/Luminance.g.cs index f1adbfe009..d8d8a0aafe 100644 --- a/UnitsNet/GeneratedCode/Quantities/Luminance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Luminance.g.cs @@ -640,16 +640,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Lumin #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(Luminance, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Luminance other, Luminance tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(Luminance left, Luminance right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(Luminance, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Luminance other, Luminance tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(Luminance left, Luminance right) { return !(left == right); @@ -657,8 +655,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Lumin /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(Luminance, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(Luminance other, Luminance tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is Luminance otherQuantity)) @@ -669,8 +666,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(Luminance, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(Luminance other, Luminance tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(Luminance other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -754,6 +750,7 @@ public int CompareTo(Luminance other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(Luminance other, Luminance tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(Luminance other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -765,6 +762,32 @@ public bool Equals(Luminance other, double tolerance, ComparisonType comparisonT return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is Luminance otherTyped + && (tolerance is Luminance toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'Luminance'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(Luminance other, Luminance tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/Luminosity.g.cs b/UnitsNet/GeneratedCode/Quantities/Luminosity.g.cs index e8b2c721b0..df19d1bc3e 100644 --- a/UnitsNet/GeneratedCode/Quantities/Luminosity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Luminosity.g.cs @@ -716,16 +716,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Lumin #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(Luminosity, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Luminosity other, Luminosity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(Luminosity left, Luminosity right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(Luminosity, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Luminosity other, Luminosity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(Luminosity left, Luminosity right) { return !(left == right); @@ -733,8 +731,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Lumin /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(Luminosity, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(Luminosity other, Luminosity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is Luminosity otherQuantity)) @@ -745,8 +742,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(Luminosity, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(Luminosity other, Luminosity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(Luminosity other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -830,6 +826,7 @@ public int CompareTo(Luminosity other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(Luminosity other, Luminosity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(Luminosity other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -841,6 +838,32 @@ public bool Equals(Luminosity other, double tolerance, ComparisonType comparison return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is Luminosity otherTyped + && (tolerance is Luminosity toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'Luminosity'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(Luminosity other, Luminosity tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/LuminousFlux.g.cs b/UnitsNet/GeneratedCode/Quantities/LuminousFlux.g.cs index 6b27265185..cb5f1bc5be 100644 --- a/UnitsNet/GeneratedCode/Quantities/LuminousFlux.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LuminousFlux.g.cs @@ -469,16 +469,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Lumin #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(LuminousFlux, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(LuminousFlux other, LuminousFlux tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(LuminousFlux left, LuminousFlux right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(LuminousFlux, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(LuminousFlux other, LuminousFlux tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(LuminousFlux left, LuminousFlux right) { return !(left == right); @@ -486,8 +484,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Lumin /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(LuminousFlux, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(LuminousFlux other, LuminousFlux tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is LuminousFlux otherQuantity)) @@ -498,8 +495,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(LuminousFlux, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(LuminousFlux other, LuminousFlux tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(LuminousFlux other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -583,6 +579,7 @@ public int CompareTo(LuminousFlux other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(LuminousFlux other, LuminousFlux tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(LuminousFlux other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -594,6 +591,32 @@ public bool Equals(LuminousFlux other, double tolerance, ComparisonType comparis return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is LuminousFlux otherTyped + && (tolerance is LuminousFlux toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'LuminousFlux'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(LuminousFlux other, LuminousFlux tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.g.cs b/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.g.cs index 4872fa2242..37bb04a52e 100644 --- a/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.g.cs @@ -469,16 +469,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Lumin #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(LuminousIntensity, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(LuminousIntensity other, LuminousIntensity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(LuminousIntensity left, LuminousIntensity right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(LuminousIntensity, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(LuminousIntensity other, LuminousIntensity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(LuminousIntensity left, LuminousIntensity right) { return !(left == right); @@ -486,8 +484,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Lumin /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(LuminousIntensity, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(LuminousIntensity other, LuminousIntensity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is LuminousIntensity otherQuantity)) @@ -498,8 +495,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(LuminousIntensity, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(LuminousIntensity other, LuminousIntensity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(LuminousIntensity other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -583,6 +579,7 @@ public int CompareTo(LuminousIntensity other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(LuminousIntensity other, LuminousIntensity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(LuminousIntensity other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -594,6 +591,32 @@ public bool Equals(LuminousIntensity other, double tolerance, ComparisonType com return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is LuminousIntensity otherTyped + && (tolerance is LuminousIntensity toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'LuminousIntensity'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(LuminousIntensity other, LuminousIntensity tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/MagneticField.g.cs b/UnitsNet/GeneratedCode/Quantities/MagneticField.g.cs index d8821319dc..19d2781d9e 100644 --- a/UnitsNet/GeneratedCode/Quantities/MagneticField.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MagneticField.g.cs @@ -564,16 +564,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Magne #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(MagneticField, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(MagneticField other, MagneticField tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(MagneticField left, MagneticField right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(MagneticField, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(MagneticField other, MagneticField tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(MagneticField left, MagneticField right) { return !(left == right); @@ -581,8 +579,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Magne /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(MagneticField, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(MagneticField other, MagneticField tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is MagneticField otherQuantity)) @@ -593,8 +590,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(MagneticField, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(MagneticField other, MagneticField tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(MagneticField other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -678,6 +674,7 @@ public int CompareTo(MagneticField other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(MagneticField other, MagneticField tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(MagneticField other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -689,6 +686,32 @@ public bool Equals(MagneticField other, double tolerance, ComparisonType compari return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is MagneticField otherTyped + && (tolerance is MagneticField toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'MagneticField'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(MagneticField other, MagneticField tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/MagneticFlux.g.cs b/UnitsNet/GeneratedCode/Quantities/MagneticFlux.g.cs index b4a02e2457..777537b8d2 100644 --- a/UnitsNet/GeneratedCode/Quantities/MagneticFlux.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MagneticFlux.g.cs @@ -469,16 +469,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Magne #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(MagneticFlux, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(MagneticFlux other, MagneticFlux tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(MagneticFlux left, MagneticFlux right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(MagneticFlux, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(MagneticFlux other, MagneticFlux tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(MagneticFlux left, MagneticFlux right) { return !(left == right); @@ -486,8 +484,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Magne /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(MagneticFlux, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(MagneticFlux other, MagneticFlux tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is MagneticFlux otherQuantity)) @@ -498,8 +495,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(MagneticFlux, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(MagneticFlux other, MagneticFlux tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(MagneticFlux other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -583,6 +579,7 @@ public int CompareTo(MagneticFlux other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(MagneticFlux other, MagneticFlux tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(MagneticFlux other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -594,6 +591,32 @@ public bool Equals(MagneticFlux other, double tolerance, ComparisonType comparis return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is MagneticFlux otherTyped + && (tolerance is MagneticFlux toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'MagneticFlux'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(MagneticFlux other, MagneticFlux tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/Magnetization.g.cs b/UnitsNet/GeneratedCode/Quantities/Magnetization.g.cs index 519e288d50..a029c3c0ac 100644 --- a/UnitsNet/GeneratedCode/Quantities/Magnetization.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Magnetization.g.cs @@ -469,16 +469,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Magne #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(Magnetization, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Magnetization other, Magnetization tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(Magnetization left, Magnetization right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(Magnetization, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Magnetization other, Magnetization tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(Magnetization left, Magnetization right) { return !(left == right); @@ -486,8 +484,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Magne /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(Magnetization, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(Magnetization other, Magnetization tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is Magnetization otherQuantity)) @@ -498,8 +495,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(Magnetization, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(Magnetization other, Magnetization tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(Magnetization other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -583,6 +579,7 @@ public int CompareTo(Magnetization other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(Magnetization other, Magnetization tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(Magnetization other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -594,6 +591,32 @@ public bool Equals(Magnetization other, double tolerance, ComparisonType compari return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is Magnetization otherTyped + && (tolerance is Magnetization toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'Magnetization'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(Magnetization other, Magnetization tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/Mass.g.cs b/UnitsNet/GeneratedCode/Quantities/Mass.g.cs index 396e002d58..c1abe4cc35 100644 --- a/UnitsNet/GeneratedCode/Quantities/Mass.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Mass.g.cs @@ -999,16 +999,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out MassU #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(Mass, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Mass other, Mass tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(Mass left, Mass right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(Mass, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Mass other, Mass tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(Mass left, Mass right) { return !(left == right); @@ -1016,8 +1014,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out MassU /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(Mass, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(Mass other, Mass tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is Mass otherQuantity)) @@ -1028,8 +1025,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(Mass, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(Mass other, Mass tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(Mass other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -1113,6 +1109,7 @@ public int CompareTo(Mass other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(Mass other, Mass tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(Mass other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -1124,6 +1121,32 @@ public bool Equals(Mass other, double tolerance, ComparisonType comparisonType) return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is Mass otherTyped + && (tolerance is Mass toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'Mass'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(Mass other, Mass tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/MassConcentration.g.cs b/UnitsNet/GeneratedCode/Quantities/MassConcentration.g.cs index 60036b0425..1d04b14f5d 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassConcentration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassConcentration.g.cs @@ -1385,16 +1385,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out MassC #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(MassConcentration, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(MassConcentration other, MassConcentration tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(MassConcentration left, MassConcentration right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(MassConcentration, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(MassConcentration other, MassConcentration tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(MassConcentration left, MassConcentration right) { return !(left == right); @@ -1402,8 +1400,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out MassC /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(MassConcentration, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(MassConcentration other, MassConcentration tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is MassConcentration otherQuantity)) @@ -1414,8 +1411,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(MassConcentration, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(MassConcentration other, MassConcentration tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(MassConcentration other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -1499,6 +1495,7 @@ public int CompareTo(MassConcentration other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(MassConcentration other, MassConcentration tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(MassConcentration other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -1510,6 +1507,32 @@ public bool Equals(MassConcentration other, double tolerance, ComparisonType com return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is MassConcentration otherTyped + && (tolerance is MassConcentration toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'MassConcentration'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(MassConcentration other, MassConcentration tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs b/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs index 408166d50a..22f538d457 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs @@ -1076,16 +1076,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out MassF #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(MassFlow, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(MassFlow other, MassFlow tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(MassFlow left, MassFlow right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(MassFlow, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(MassFlow other, MassFlow tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(MassFlow left, MassFlow right) { return !(left == right); @@ -1093,8 +1091,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out MassF /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(MassFlow, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(MassFlow other, MassFlow tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is MassFlow otherQuantity)) @@ -1105,8 +1102,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(MassFlow, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(MassFlow other, MassFlow tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(MassFlow other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -1190,6 +1186,7 @@ public int CompareTo(MassFlow other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(MassFlow other, MassFlow tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(MassFlow other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -1201,6 +1198,32 @@ public bool Equals(MassFlow other, double tolerance, ComparisonType comparisonTy return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is MassFlow otherTyped + && (tolerance is MassFlow toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'MassFlow'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(MassFlow other, MassFlow tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs b/UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs index 279e541850..0d7a255338 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs @@ -675,16 +675,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out MassF #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(MassFlux, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(MassFlux other, MassFlux tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(MassFlux left, MassFlux right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(MassFlux, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(MassFlux other, MassFlux tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(MassFlux left, MassFlux right) { return !(left == right); @@ -692,8 +690,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out MassF /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(MassFlux, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(MassFlux other, MassFlux tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is MassFlux otherQuantity)) @@ -704,8 +701,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(MassFlux, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(MassFlux other, MassFlux tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(MassFlux other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -789,6 +785,7 @@ public int CompareTo(MassFlux other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(MassFlux other, MassFlux tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(MassFlux other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -800,6 +797,32 @@ public bool Equals(MassFlux other, double tolerance, ComparisonType comparisonTy return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is MassFlux otherTyped + && (tolerance is MassFlux toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'MassFlux'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(MassFlux other, MassFlux tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/MassFraction.g.cs b/UnitsNet/GeneratedCode/Quantities/MassFraction.g.cs index 8c824f4dc5..ae089d1358 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassFraction.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassFraction.g.cs @@ -906,16 +906,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out MassF #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(MassFraction, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(MassFraction other, MassFraction tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(MassFraction left, MassFraction right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(MassFraction, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(MassFraction other, MassFraction tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(MassFraction left, MassFraction right) { return !(left == right); @@ -923,8 +921,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out MassF /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(MassFraction, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(MassFraction other, MassFraction tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is MassFraction otherQuantity)) @@ -935,8 +932,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(MassFraction, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(MassFraction other, MassFraction tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(MassFraction other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -1020,6 +1016,7 @@ public int CompareTo(MassFraction other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(MassFraction other, MassFraction tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(MassFraction other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -1031,6 +1028,32 @@ public bool Equals(MassFraction other, double tolerance, ComparisonType comparis return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is MassFraction otherTyped + && (tolerance is MassFraction toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'MassFraction'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(MassFraction other, MassFraction tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.g.cs b/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.g.cs index 4b67bdebff..da9aba3ed8 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.g.cs @@ -979,16 +979,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out MassM #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(MassMomentOfInertia, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(MassMomentOfInertia other, MassMomentOfInertia tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(MassMomentOfInertia left, MassMomentOfInertia right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(MassMomentOfInertia, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(MassMomentOfInertia other, MassMomentOfInertia tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(MassMomentOfInertia left, MassMomentOfInertia right) { return !(left == right); @@ -996,8 +994,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out MassM /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(MassMomentOfInertia, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(MassMomentOfInertia other, MassMomentOfInertia tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is MassMomentOfInertia otherQuantity)) @@ -1008,8 +1005,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(MassMomentOfInertia, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(MassMomentOfInertia other, MassMomentOfInertia tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(MassMomentOfInertia other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -1093,6 +1089,7 @@ public int CompareTo(MassMomentOfInertia other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(MassMomentOfInertia other, MassMomentOfInertia tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(MassMomentOfInertia other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -1104,6 +1101,32 @@ public bool Equals(MassMomentOfInertia other, double tolerance, ComparisonType c return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is MassMomentOfInertia otherTyped + && (tolerance is MassMomentOfInertia toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'MassMomentOfInertia'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(MassMomentOfInertia other, MassMomentOfInertia tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/MolarEnergy.g.cs b/UnitsNet/GeneratedCode/Quantities/MolarEnergy.g.cs index 6f67309dbd..5baca53347 100644 --- a/UnitsNet/GeneratedCode/Quantities/MolarEnergy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MolarEnergy.g.cs @@ -504,16 +504,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Molar #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(MolarEnergy, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(MolarEnergy other, MolarEnergy tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(MolarEnergy left, MolarEnergy right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(MolarEnergy, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(MolarEnergy other, MolarEnergy tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(MolarEnergy left, MolarEnergy right) { return !(left == right); @@ -521,8 +519,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Molar /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(MolarEnergy, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(MolarEnergy other, MolarEnergy tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is MolarEnergy otherQuantity)) @@ -533,8 +530,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(MolarEnergy, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(MolarEnergy other, MolarEnergy tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(MolarEnergy other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -618,6 +614,7 @@ public int CompareTo(MolarEnergy other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(MolarEnergy other, MolarEnergy tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(MolarEnergy other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -629,6 +626,32 @@ public bool Equals(MolarEnergy other, double tolerance, ComparisonType compariso return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is MolarEnergy otherTyped + && (tolerance is MolarEnergy toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'MolarEnergy'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(MolarEnergy other, MolarEnergy tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs b/UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs index cd79b26ad1..dfdf70e422 100644 --- a/UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs @@ -504,16 +504,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Molar #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(MolarEntropy, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(MolarEntropy other, MolarEntropy tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(MolarEntropy left, MolarEntropy right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(MolarEntropy, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(MolarEntropy other, MolarEntropy tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(MolarEntropy left, MolarEntropy right) { return !(left == right); @@ -521,8 +519,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Molar /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(MolarEntropy, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(MolarEntropy other, MolarEntropy tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is MolarEntropy otherQuantity)) @@ -533,8 +530,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(MolarEntropy, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(MolarEntropy other, MolarEntropy tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(MolarEntropy other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -618,6 +614,7 @@ public int CompareTo(MolarEntropy other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(MolarEntropy other, MolarEntropy tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(MolarEntropy other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -629,6 +626,32 @@ public bool Equals(MolarEntropy other, double tolerance, ComparisonType comparis return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is MolarEntropy otherTyped + && (tolerance is MolarEntropy toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'MolarEntropy'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(MolarEntropy other, MolarEntropy tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/MolarFlow.g.cs b/UnitsNet/GeneratedCode/Quantities/MolarFlow.g.cs index 9759e8d22d..ce4cbca245 100644 --- a/UnitsNet/GeneratedCode/Quantities/MolarFlow.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MolarFlow.g.cs @@ -618,16 +618,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Molar #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(MolarFlow, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(MolarFlow other, MolarFlow tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(MolarFlow left, MolarFlow right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(MolarFlow, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(MolarFlow other, MolarFlow tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(MolarFlow left, MolarFlow right) { return !(left == right); @@ -635,8 +633,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Molar /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(MolarFlow, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(MolarFlow other, MolarFlow tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is MolarFlow otherQuantity)) @@ -647,8 +644,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(MolarFlow, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(MolarFlow other, MolarFlow tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(MolarFlow other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -732,6 +728,7 @@ public int CompareTo(MolarFlow other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(MolarFlow other, MolarFlow tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(MolarFlow other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -743,6 +740,32 @@ public bool Equals(MolarFlow other, double tolerance, ComparisonType comparisonT return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is MolarFlow otherTyped + && (tolerance is MolarFlow toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'MolarFlow'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(MolarFlow other, MolarFlow tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs b/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs index 8de95c9961..9cc5fc51e0 100644 --- a/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs @@ -706,16 +706,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Molar #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(MolarMass, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(MolarMass other, MolarMass tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(MolarMass left, MolarMass right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(MolarMass, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(MolarMass other, MolarMass tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(MolarMass left, MolarMass right) { return !(left == right); @@ -723,8 +721,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Molar /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(MolarMass, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(MolarMass other, MolarMass tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is MolarMass otherQuantity)) @@ -735,8 +732,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(MolarMass, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(MolarMass other, MolarMass tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(MolarMass other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -820,6 +816,7 @@ public int CompareTo(MolarMass other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(MolarMass other, MolarMass tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(MolarMass other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -831,6 +828,32 @@ public bool Equals(MolarMass other, double tolerance, ComparisonType comparisonT return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is MolarMass otherTyped + && (tolerance is MolarMass toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'MolarMass'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(MolarMass other, MolarMass tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs b/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs index 6bbcc8ef82..ded7b4646e 100644 --- a/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs @@ -659,16 +659,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Molar #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(Molarity, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Molarity other, Molarity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(Molarity left, Molarity right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(Molarity, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Molarity other, Molarity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(Molarity left, Molarity right) { return !(left == right); @@ -676,8 +674,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Molar /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(Molarity, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(Molarity other, Molarity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is Molarity otherQuantity)) @@ -688,8 +685,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(Molarity, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(Molarity other, Molarity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(Molarity other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -773,6 +769,7 @@ public int CompareTo(Molarity other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(Molarity other, Molarity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(Molarity other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -784,6 +781,32 @@ public bool Equals(Molarity other, double tolerance, ComparisonType comparisonTy return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is Molarity otherTyped + && (tolerance is Molarity toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'Molarity'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(Molarity other, Molarity tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/Permeability.g.cs b/UnitsNet/GeneratedCode/Quantities/Permeability.g.cs index f799fbbd69..302cc08f65 100644 --- a/UnitsNet/GeneratedCode/Quantities/Permeability.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Permeability.g.cs @@ -469,16 +469,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Perme #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(Permeability, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Permeability other, Permeability tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(Permeability left, Permeability right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(Permeability, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Permeability other, Permeability tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(Permeability left, Permeability right) { return !(left == right); @@ -486,8 +484,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Perme /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(Permeability, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(Permeability other, Permeability tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is Permeability otherQuantity)) @@ -498,8 +495,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(Permeability, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(Permeability other, Permeability tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(Permeability other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -583,6 +579,7 @@ public int CompareTo(Permeability other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(Permeability other, Permeability tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(Permeability other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -594,6 +591,32 @@ public bool Equals(Permeability other, double tolerance, ComparisonType comparis return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is Permeability otherTyped + && (tolerance is Permeability toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'Permeability'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(Permeability other, Permeability tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/Permittivity.g.cs b/UnitsNet/GeneratedCode/Quantities/Permittivity.g.cs index a3ed041fde..d2d2f2cb8e 100644 --- a/UnitsNet/GeneratedCode/Quantities/Permittivity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Permittivity.g.cs @@ -469,16 +469,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Permi #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(Permittivity, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Permittivity other, Permittivity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(Permittivity left, Permittivity right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(Permittivity, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Permittivity other, Permittivity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(Permittivity left, Permittivity right) { return !(left == right); @@ -486,8 +484,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Permi /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(Permittivity, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(Permittivity other, Permittivity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is Permittivity otherQuantity)) @@ -498,8 +495,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(Permittivity, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(Permittivity other, Permittivity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(Permittivity other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -583,6 +579,7 @@ public int CompareTo(Permittivity other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(Permittivity other, Permittivity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(Permittivity other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -594,6 +591,32 @@ public bool Equals(Permittivity other, double tolerance, ComparisonType comparis return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is Permittivity otherTyped + && (tolerance is Permittivity toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'Permittivity'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(Permittivity other, Permittivity tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/PorousMediumPermeability.g.cs b/UnitsNet/GeneratedCode/Quantities/PorousMediumPermeability.g.cs index ca623e65f5..f52fe94bfb 100644 --- a/UnitsNet/GeneratedCode/Quantities/PorousMediumPermeability.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/PorousMediumPermeability.g.cs @@ -545,16 +545,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Porou #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(PorousMediumPermeability, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(PorousMediumPermeability other, PorousMediumPermeability tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(PorousMediumPermeability left, PorousMediumPermeability right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(PorousMediumPermeability, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(PorousMediumPermeability other, PorousMediumPermeability tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(PorousMediumPermeability left, PorousMediumPermeability right) { return !(left == right); @@ -562,8 +560,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Porou /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(PorousMediumPermeability, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(PorousMediumPermeability other, PorousMediumPermeability tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is PorousMediumPermeability otherQuantity)) @@ -574,8 +571,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(PorousMediumPermeability, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(PorousMediumPermeability other, PorousMediumPermeability tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(PorousMediumPermeability other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -659,6 +655,7 @@ public int CompareTo(PorousMediumPermeability other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(PorousMediumPermeability other, PorousMediumPermeability tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(PorousMediumPermeability other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -670,6 +667,32 @@ public bool Equals(PorousMediumPermeability other, double tolerance, ComparisonT return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is PorousMediumPermeability otherTyped + && (tolerance is PorousMediumPermeability toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'PorousMediumPermeability'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(PorousMediumPermeability other, PorousMediumPermeability tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/Power.g.cs b/UnitsNet/GeneratedCode/Quantities/Power.g.cs index bfdbd51162..21373845f2 100644 --- a/UnitsNet/GeneratedCode/Quantities/Power.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Power.g.cs @@ -942,16 +942,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Power #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(Power, decimal, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Power other, Power tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(Power left, Power right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(Power, decimal, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Power other, Power tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(Power left, Power right) { return !(left == right); @@ -959,8 +957,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Power /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(Power, decimal, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(Power other, Power tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is Power otherQuantity)) @@ -971,8 +968,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(Power, decimal, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(Power other, Power tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(Power other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -1056,6 +1052,7 @@ public int CompareTo(Power other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(Power other, Power tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(Power other, decimal tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -1067,6 +1064,32 @@ public bool Equals(Power other, decimal tolerance, ComparisonType comparisonType return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is Power otherTyped + && (tolerance is Power toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'Power'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(Power other, Power tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + decimal thisValue = this.Value; + decimal otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/PowerDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/PowerDensity.g.cs index 98524dd812..ead2926ad6 100644 --- a/UnitsNet/GeneratedCode/Quantities/PowerDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/PowerDensity.g.cs @@ -1283,16 +1283,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Power #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(PowerDensity, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(PowerDensity other, PowerDensity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(PowerDensity left, PowerDensity right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(PowerDensity, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(PowerDensity other, PowerDensity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(PowerDensity left, PowerDensity right) { return !(left == right); @@ -1300,8 +1298,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Power /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(PowerDensity, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(PowerDensity other, PowerDensity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is PowerDensity otherQuantity)) @@ -1312,8 +1309,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(PowerDensity, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(PowerDensity other, PowerDensity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(PowerDensity other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -1397,6 +1393,7 @@ public int CompareTo(PowerDensity other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(PowerDensity other, PowerDensity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(PowerDensity other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -1408,6 +1405,32 @@ public bool Equals(PowerDensity other, double tolerance, ComparisonType comparis return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is PowerDensity otherTyped + && (tolerance is PowerDensity toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'PowerDensity'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(PowerDensity other, PowerDensity tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/PowerRatio.g.cs b/UnitsNet/GeneratedCode/Quantities/PowerRatio.g.cs index cbbd8c2b8f..f33d7b05f7 100644 --- a/UnitsNet/GeneratedCode/Quantities/PowerRatio.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/PowerRatio.g.cs @@ -493,16 +493,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Power #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(PowerRatio, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(PowerRatio other, PowerRatio tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(PowerRatio left, PowerRatio right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(PowerRatio, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(PowerRatio other, PowerRatio tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(PowerRatio left, PowerRatio right) { return !(left == right); @@ -510,8 +508,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Power /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(PowerRatio, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(PowerRatio other, PowerRatio tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is PowerRatio otherQuantity)) @@ -522,8 +519,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(PowerRatio, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(PowerRatio other, PowerRatio tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(PowerRatio other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -607,6 +603,7 @@ public int CompareTo(PowerRatio other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(PowerRatio other, PowerRatio tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(PowerRatio other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -618,6 +615,32 @@ public bool Equals(PowerRatio other, double tolerance, ComparisonType comparison return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is PowerRatio otherTyped + && (tolerance is PowerRatio toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'PowerRatio'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(PowerRatio other, PowerRatio tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/Pressure.g.cs b/UnitsNet/GeneratedCode/Quantities/Pressure.g.cs index f9abbb6f9b..f07c8f541a 100644 --- a/UnitsNet/GeneratedCode/Quantities/Pressure.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Pressure.g.cs @@ -1409,16 +1409,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Press #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(Pressure, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Pressure other, Pressure tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(Pressure left, Pressure right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(Pressure, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Pressure other, Pressure tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(Pressure left, Pressure right) { return !(left == right); @@ -1426,8 +1424,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Press /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(Pressure, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(Pressure other, Pressure tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is Pressure otherQuantity)) @@ -1438,8 +1435,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(Pressure, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(Pressure other, Pressure tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(Pressure other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -1523,6 +1519,7 @@ public int CompareTo(Pressure other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(Pressure other, Pressure tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(Pressure other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -1534,6 +1531,32 @@ public bool Equals(Pressure other, double tolerance, ComparisonType comparisonTy return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is Pressure otherTyped + && (tolerance is Pressure toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'Pressure'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(Pressure other, Pressure tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.g.cs index e1976e3ace..8ae812e370 100644 --- a/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.g.cs @@ -727,16 +727,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Press #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(PressureChangeRate, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(PressureChangeRate other, PressureChangeRate tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(PressureChangeRate left, PressureChangeRate right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(PressureChangeRate, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(PressureChangeRate other, PressureChangeRate tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(PressureChangeRate left, PressureChangeRate right) { return !(left == right); @@ -744,8 +742,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Press /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(PressureChangeRate, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(PressureChangeRate other, PressureChangeRate tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is PressureChangeRate otherQuantity)) @@ -756,8 +753,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(PressureChangeRate, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(PressureChangeRate other, PressureChangeRate tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(PressureChangeRate other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -841,6 +837,7 @@ public int CompareTo(PressureChangeRate other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(PressureChangeRate other, PressureChangeRate tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(PressureChangeRate other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -852,6 +849,32 @@ public bool Equals(PressureChangeRate other, double tolerance, ComparisonType co return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is PressureChangeRate otherTyped + && (tolerance is PressureChangeRate toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'PressureChangeRate'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(PressureChangeRate other, PressureChangeRate tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/Ratio.g.cs b/UnitsNet/GeneratedCode/Quantities/Ratio.g.cs index bb44dc2933..9892a1ab74 100644 --- a/UnitsNet/GeneratedCode/Quantities/Ratio.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Ratio.g.cs @@ -561,16 +561,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Ratio #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(Ratio, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Ratio other, Ratio tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(Ratio left, Ratio right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(Ratio, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Ratio other, Ratio tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(Ratio left, Ratio right) { return !(left == right); @@ -578,8 +576,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Ratio /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(Ratio, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(Ratio other, Ratio tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is Ratio otherQuantity)) @@ -590,8 +587,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(Ratio, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(Ratio other, Ratio tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(Ratio other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -675,6 +671,7 @@ public int CompareTo(Ratio other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(Ratio other, Ratio tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(Ratio other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -686,6 +683,32 @@ public bool Equals(Ratio other, double tolerance, ComparisonType comparisonType) return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is Ratio otherTyped + && (tolerance is Ratio toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'Ratio'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(Ratio other, Ratio tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/RatioChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/RatioChangeRate.g.cs index 6267989315..80076c3bea 100644 --- a/UnitsNet/GeneratedCode/Quantities/RatioChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RatioChangeRate.g.cs @@ -485,16 +485,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Ratio #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(RatioChangeRate, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(RatioChangeRate other, RatioChangeRate tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(RatioChangeRate left, RatioChangeRate right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(RatioChangeRate, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(RatioChangeRate other, RatioChangeRate tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(RatioChangeRate left, RatioChangeRate right) { return !(left == right); @@ -502,8 +500,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Ratio /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(RatioChangeRate, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(RatioChangeRate other, RatioChangeRate tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is RatioChangeRate otherQuantity)) @@ -514,8 +511,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(RatioChangeRate, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(RatioChangeRate other, RatioChangeRate tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(RatioChangeRate other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -599,6 +595,7 @@ public int CompareTo(RatioChangeRate other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(RatioChangeRate other, RatioChangeRate tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(RatioChangeRate other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -610,6 +607,32 @@ public bool Equals(RatioChangeRate other, double tolerance, ComparisonType compa return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is RatioChangeRate otherTyped + && (tolerance is RatioChangeRate toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'RatioChangeRate'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(RatioChangeRate other, RatioChangeRate tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/ReactiveEnergy.g.cs b/UnitsNet/GeneratedCode/Quantities/ReactiveEnergy.g.cs index 7f6dfffdc7..5f3ac6ca76 100644 --- a/UnitsNet/GeneratedCode/Quantities/ReactiveEnergy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ReactiveEnergy.g.cs @@ -504,16 +504,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out React #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(ReactiveEnergy, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(ReactiveEnergy other, ReactiveEnergy tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(ReactiveEnergy left, ReactiveEnergy right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(ReactiveEnergy, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(ReactiveEnergy other, ReactiveEnergy tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(ReactiveEnergy left, ReactiveEnergy right) { return !(left == right); @@ -521,8 +519,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out React /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(ReactiveEnergy, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(ReactiveEnergy other, ReactiveEnergy tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is ReactiveEnergy otherQuantity)) @@ -533,8 +530,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(ReactiveEnergy, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(ReactiveEnergy other, ReactiveEnergy tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(ReactiveEnergy other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -618,6 +614,7 @@ public int CompareTo(ReactiveEnergy other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(ReactiveEnergy other, ReactiveEnergy tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(ReactiveEnergy other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -629,6 +626,32 @@ public bool Equals(ReactiveEnergy other, double tolerance, ComparisonType compar return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is ReactiveEnergy otherTyped + && (tolerance is ReactiveEnergy toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'ReactiveEnergy'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(ReactiveEnergy other, ReactiveEnergy tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/ReactivePower.g.cs b/UnitsNet/GeneratedCode/Quantities/ReactivePower.g.cs index 5a1776d5e2..2d6527438e 100644 --- a/UnitsNet/GeneratedCode/Quantities/ReactivePower.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ReactivePower.g.cs @@ -523,16 +523,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out React #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(ReactivePower, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(ReactivePower other, ReactivePower tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(ReactivePower left, ReactivePower right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(ReactivePower, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(ReactivePower other, ReactivePower tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(ReactivePower left, ReactivePower right) { return !(left == right); @@ -540,8 +538,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out React /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(ReactivePower, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(ReactivePower other, ReactivePower tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is ReactivePower otherQuantity)) @@ -552,8 +549,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(ReactivePower, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(ReactivePower other, ReactivePower tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(ReactivePower other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -637,6 +633,7 @@ public int CompareTo(ReactivePower other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(ReactivePower other, ReactivePower tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(ReactivePower other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -648,6 +645,32 @@ public bool Equals(ReactivePower other, double tolerance, ComparisonType compari return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is ReactivePower otherTyped + && (tolerance is ReactivePower toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'ReactivePower'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(ReactivePower other, ReactivePower tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/ReciprocalArea.g.cs b/UnitsNet/GeneratedCode/Quantities/ReciprocalArea.g.cs index c5ffc1a5c4..417904b46c 100644 --- a/UnitsNet/GeneratedCode/Quantities/ReciprocalArea.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ReciprocalArea.g.cs @@ -659,16 +659,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Recip #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(ReciprocalArea, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(ReciprocalArea other, ReciprocalArea tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(ReciprocalArea left, ReciprocalArea right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(ReciprocalArea, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(ReciprocalArea other, ReciprocalArea tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(ReciprocalArea left, ReciprocalArea right) { return !(left == right); @@ -676,8 +674,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Recip /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(ReciprocalArea, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(ReciprocalArea other, ReciprocalArea tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is ReciprocalArea otherQuantity)) @@ -688,8 +685,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(ReciprocalArea, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(ReciprocalArea other, ReciprocalArea tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(ReciprocalArea other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -773,6 +769,7 @@ public int CompareTo(ReciprocalArea other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(ReciprocalArea other, ReciprocalArea tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(ReciprocalArea other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -784,6 +781,32 @@ public bool Equals(ReciprocalArea other, double tolerance, ComparisonType compar return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is ReciprocalArea otherTyped + && (tolerance is ReciprocalArea toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'ReciprocalArea'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(ReciprocalArea other, ReciprocalArea tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/ReciprocalLength.g.cs b/UnitsNet/GeneratedCode/Quantities/ReciprocalLength.g.cs index 80cc1cb9d4..89226957f1 100644 --- a/UnitsNet/GeneratedCode/Quantities/ReciprocalLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ReciprocalLength.g.cs @@ -640,16 +640,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Recip #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(ReciprocalLength, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(ReciprocalLength other, ReciprocalLength tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(ReciprocalLength left, ReciprocalLength right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(ReciprocalLength, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(ReciprocalLength other, ReciprocalLength tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(ReciprocalLength left, ReciprocalLength right) { return !(left == right); @@ -657,8 +655,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Recip /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(ReciprocalLength, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(ReciprocalLength other, ReciprocalLength tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is ReciprocalLength otherQuantity)) @@ -669,8 +666,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(ReciprocalLength, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(ReciprocalLength other, ReciprocalLength tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(ReciprocalLength other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -754,6 +750,7 @@ public int CompareTo(ReciprocalLength other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(ReciprocalLength other, ReciprocalLength tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(ReciprocalLength other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -765,6 +762,32 @@ public bool Equals(ReciprocalLength other, double tolerance, ComparisonType comp return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is ReciprocalLength otherTyped + && (tolerance is ReciprocalLength toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'ReciprocalLength'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(ReciprocalLength other, ReciprocalLength tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/RelativeHumidity.g.cs b/UnitsNet/GeneratedCode/Quantities/RelativeHumidity.g.cs index cd5e296d3c..e3e524f782 100644 --- a/UnitsNet/GeneratedCode/Quantities/RelativeHumidity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RelativeHumidity.g.cs @@ -466,16 +466,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Relat #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(RelativeHumidity, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(RelativeHumidity other, RelativeHumidity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(RelativeHumidity left, RelativeHumidity right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(RelativeHumidity, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(RelativeHumidity other, RelativeHumidity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(RelativeHumidity left, RelativeHumidity right) { return !(left == right); @@ -483,8 +481,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Relat /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(RelativeHumidity, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(RelativeHumidity other, RelativeHumidity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is RelativeHumidity otherQuantity)) @@ -495,8 +492,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(RelativeHumidity, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(RelativeHumidity other, RelativeHumidity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(RelativeHumidity other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -580,6 +576,7 @@ public int CompareTo(RelativeHumidity other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(RelativeHumidity other, RelativeHumidity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(RelativeHumidity other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -591,6 +588,32 @@ public bool Equals(RelativeHumidity other, double tolerance, ComparisonType comp return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is RelativeHumidity otherTyped + && (tolerance is RelativeHumidity toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'RelativeHumidity'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(RelativeHumidity other, RelativeHumidity tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalAcceleration.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalAcceleration.g.cs index f11b7e848f..2af78f9e65 100644 --- a/UnitsNet/GeneratedCode/Quantities/RotationalAcceleration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RotationalAcceleration.g.cs @@ -523,16 +523,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Rotat #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(RotationalAcceleration, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(RotationalAcceleration other, RotationalAcceleration tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(RotationalAcceleration left, RotationalAcceleration right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(RotationalAcceleration, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(RotationalAcceleration other, RotationalAcceleration tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(RotationalAcceleration left, RotationalAcceleration right) { return !(left == right); @@ -540,8 +538,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Rotat /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(RotationalAcceleration, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(RotationalAcceleration other, RotationalAcceleration tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is RotationalAcceleration otherQuantity)) @@ -552,8 +549,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(RotationalAcceleration, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(RotationalAcceleration other, RotationalAcceleration tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(RotationalAcceleration other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -637,6 +633,7 @@ public int CompareTo(RotationalAcceleration other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(RotationalAcceleration other, RotationalAcceleration tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(RotationalAcceleration other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -648,6 +645,32 @@ public bool Equals(RotationalAcceleration other, double tolerance, ComparisonTyp return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is RotationalAcceleration otherTyped + && (tolerance is RotationalAcceleration toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'RotationalAcceleration'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(RotationalAcceleration other, RotationalAcceleration tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.g.cs index 9d1abc24bb..fe9967bca0 100644 --- a/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.g.cs @@ -706,16 +706,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Rotat #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(RotationalSpeed, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(RotationalSpeed other, RotationalSpeed tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(RotationalSpeed left, RotationalSpeed right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(RotationalSpeed, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(RotationalSpeed other, RotationalSpeed tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(RotationalSpeed left, RotationalSpeed right) { return !(left == right); @@ -723,8 +721,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Rotat /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(RotationalSpeed, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(RotationalSpeed other, RotationalSpeed tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is RotationalSpeed otherQuantity)) @@ -735,8 +732,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(RotationalSpeed, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(RotationalSpeed other, RotationalSpeed tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(RotationalSpeed other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -820,6 +816,7 @@ public int CompareTo(RotationalSpeed other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(RotationalSpeed other, RotationalSpeed tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(RotationalSpeed other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -831,6 +828,32 @@ public bool Equals(RotationalSpeed other, double tolerance, ComparisonType compa return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is RotationalSpeed otherTyped + && (tolerance is RotationalSpeed toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'RotationalSpeed'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(RotationalSpeed other, RotationalSpeed tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.g.cs index 3b5c25472e..9cfbb07bf6 100644 --- a/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.g.cs @@ -1074,16 +1074,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Rotat #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(RotationalStiffness, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(RotationalStiffness other, RotationalStiffness tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(RotationalStiffness left, RotationalStiffness right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(RotationalStiffness, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(RotationalStiffness other, RotationalStiffness tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(RotationalStiffness left, RotationalStiffness right) { return !(left == right); @@ -1091,8 +1089,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Rotat /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(RotationalStiffness, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(RotationalStiffness other, RotationalStiffness tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is RotationalStiffness otherQuantity)) @@ -1103,8 +1100,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(RotationalStiffness, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(RotationalStiffness other, RotationalStiffness tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(RotationalStiffness other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -1188,6 +1184,7 @@ public int CompareTo(RotationalStiffness other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(RotationalStiffness other, RotationalStiffness tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(RotationalStiffness other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -1199,6 +1196,32 @@ public bool Equals(RotationalStiffness other, double tolerance, ComparisonType c return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is RotationalStiffness otherTyped + && (tolerance is RotationalStiffness toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'RotationalStiffness'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(RotationalStiffness other, RotationalStiffness tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs index 45eab6c224..ef5edd1430 100644 --- a/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs @@ -542,16 +542,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Rotat #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(RotationalStiffnessPerLength, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(RotationalStiffnessPerLength other, RotationalStiffnessPerLength tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(RotationalStiffnessPerLength left, RotationalStiffnessPerLength right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(RotationalStiffnessPerLength, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(RotationalStiffnessPerLength other, RotationalStiffnessPerLength tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(RotationalStiffnessPerLength left, RotationalStiffnessPerLength right) { return !(left == right); @@ -559,8 +557,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Rotat /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(RotationalStiffnessPerLength, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(RotationalStiffnessPerLength other, RotationalStiffnessPerLength tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is RotationalStiffnessPerLength otherQuantity)) @@ -571,8 +568,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(RotationalStiffnessPerLength, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(RotationalStiffnessPerLength other, RotationalStiffnessPerLength tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(RotationalStiffnessPerLength other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -656,6 +652,7 @@ public int CompareTo(RotationalStiffnessPerLength other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(RotationalStiffnessPerLength other, RotationalStiffnessPerLength tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(RotationalStiffnessPerLength other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -667,6 +664,32 @@ public bool Equals(RotationalStiffnessPerLength other, double tolerance, Compari return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is RotationalStiffnessPerLength otherTyped + && (tolerance is RotationalStiffnessPerLength toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'RotationalStiffnessPerLength'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(RotationalStiffnessPerLength other, RotationalStiffnessPerLength tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/Scalar.g.cs b/UnitsNet/GeneratedCode/Quantities/Scalar.g.cs index 869da4bfc8..baa01bd6e2 100644 --- a/UnitsNet/GeneratedCode/Quantities/Scalar.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Scalar.g.cs @@ -466,16 +466,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Scala #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(Scalar, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Scalar other, Scalar tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(Scalar left, Scalar right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(Scalar, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Scalar other, Scalar tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(Scalar left, Scalar right) { return !(left == right); @@ -483,8 +481,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Scala /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(Scalar, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(Scalar other, Scalar tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is Scalar otherQuantity)) @@ -495,8 +492,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(Scalar, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(Scalar other, Scalar tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(Scalar other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -580,6 +576,7 @@ public int CompareTo(Scalar other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(Scalar other, Scalar tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(Scalar other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -591,6 +588,32 @@ public bool Equals(Scalar other, double tolerance, ComparisonType comparisonType return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is Scalar otherTyped + && (tolerance is Scalar toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'Scalar'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(Scalar other, Scalar tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/SolidAngle.g.cs b/UnitsNet/GeneratedCode/Quantities/SolidAngle.g.cs index a47828309c..3e03a1ae0f 100644 --- a/UnitsNet/GeneratedCode/Quantities/SolidAngle.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SolidAngle.g.cs @@ -469,16 +469,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Solid #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(SolidAngle, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(SolidAngle other, SolidAngle tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(SolidAngle left, SolidAngle right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(SolidAngle, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(SolidAngle other, SolidAngle tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(SolidAngle left, SolidAngle right) { return !(left == right); @@ -486,8 +484,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Solid /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(SolidAngle, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(SolidAngle other, SolidAngle tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is SolidAngle otherQuantity)) @@ -498,8 +495,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(SolidAngle, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(SolidAngle other, SolidAngle tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(SolidAngle other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -583,6 +579,7 @@ public int CompareTo(SolidAngle other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(SolidAngle other, SolidAngle tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(SolidAngle other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -594,6 +591,32 @@ public bool Equals(SolidAngle other, double tolerance, ComparisonType comparison return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is SolidAngle otherTyped + && (tolerance is SolidAngle toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'SolidAngle'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(SolidAngle other, SolidAngle tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.g.cs index 5bc5bb4b01..6cc429804b 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.g.cs @@ -1020,16 +1020,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Speci #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(SpecificEnergy, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(SpecificEnergy other, SpecificEnergy tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(SpecificEnergy left, SpecificEnergy right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(SpecificEnergy, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(SpecificEnergy other, SpecificEnergy tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(SpecificEnergy left, SpecificEnergy right) { return !(left == right); @@ -1037,8 +1035,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Speci /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(SpecificEnergy, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(SpecificEnergy other, SpecificEnergy tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is SpecificEnergy otherQuantity)) @@ -1049,8 +1046,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(SpecificEnergy, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(SpecificEnergy other, SpecificEnergy tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(SpecificEnergy other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -1134,6 +1130,7 @@ public int CompareTo(SpecificEnergy other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(SpecificEnergy other, SpecificEnergy tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(SpecificEnergy other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -1145,6 +1142,32 @@ public bool Equals(SpecificEnergy other, double tolerance, ComparisonType compar return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is SpecificEnergy otherTyped + && (tolerance is SpecificEnergy toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'SpecificEnergy'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(SpecificEnergy other, SpecificEnergy tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.g.cs index 2b5330fc24..7c641ed47b 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.g.cs @@ -618,16 +618,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Speci #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(SpecificEntropy, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(SpecificEntropy other, SpecificEntropy tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(SpecificEntropy left, SpecificEntropy right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(SpecificEntropy, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(SpecificEntropy other, SpecificEntropy tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(SpecificEntropy left, SpecificEntropy right) { return !(left == right); @@ -635,8 +633,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Speci /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(SpecificEntropy, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(SpecificEntropy other, SpecificEntropy tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is SpecificEntropy otherQuantity)) @@ -647,8 +644,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(SpecificEntropy, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(SpecificEntropy other, SpecificEntropy tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(SpecificEntropy other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -732,6 +728,7 @@ public int CompareTo(SpecificEntropy other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(SpecificEntropy other, SpecificEntropy tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(SpecificEntropy other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -743,6 +740,32 @@ public bool Equals(SpecificEntropy other, double tolerance, ComparisonType compa return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is SpecificEntropy otherTyped + && (tolerance is SpecificEntropy toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'SpecificEntropy'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(SpecificEntropy other, SpecificEntropy tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs index 5ad44da6c1..7c8ea1941a 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs @@ -526,16 +526,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Speci #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(SpecificFuelConsumption, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(SpecificFuelConsumption other, SpecificFuelConsumption tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(SpecificFuelConsumption left, SpecificFuelConsumption right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(SpecificFuelConsumption, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(SpecificFuelConsumption other, SpecificFuelConsumption tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(SpecificFuelConsumption left, SpecificFuelConsumption right) { return !(left == right); @@ -543,8 +541,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Speci /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(SpecificFuelConsumption, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(SpecificFuelConsumption other, SpecificFuelConsumption tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is SpecificFuelConsumption otherQuantity)) @@ -555,8 +552,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(SpecificFuelConsumption, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(SpecificFuelConsumption other, SpecificFuelConsumption tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(SpecificFuelConsumption other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -640,6 +636,7 @@ public int CompareTo(SpecificFuelConsumption other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(SpecificFuelConsumption other, SpecificFuelConsumption tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(SpecificFuelConsumption other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -651,6 +648,32 @@ public bool Equals(SpecificFuelConsumption other, double tolerance, ComparisonTy return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is SpecificFuelConsumption otherTyped + && (tolerance is SpecificFuelConsumption toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'SpecificFuelConsumption'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(SpecificFuelConsumption other, SpecificFuelConsumption tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs index 8bf013ba2d..7c698584f3 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs @@ -504,16 +504,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Speci #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(SpecificVolume, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(SpecificVolume other, SpecificVolume tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(SpecificVolume left, SpecificVolume right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(SpecificVolume, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(SpecificVolume other, SpecificVolume tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(SpecificVolume left, SpecificVolume right) { return !(left == right); @@ -521,8 +519,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Speci /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(SpecificVolume, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(SpecificVolume other, SpecificVolume tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is SpecificVolume otherQuantity)) @@ -533,8 +530,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(SpecificVolume, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(SpecificVolume other, SpecificVolume tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(SpecificVolume other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -618,6 +614,7 @@ public int CompareTo(SpecificVolume other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(SpecificVolume other, SpecificVolume tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(SpecificVolume other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -629,6 +626,32 @@ public bool Equals(SpecificVolume other, double tolerance, ComparisonType compar return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is SpecificVolume otherTyped + && (tolerance is SpecificVolume toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'SpecificVolume'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(SpecificVolume other, SpecificVolume tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificWeight.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificWeight.g.cs index 07c10183ef..b70522683b 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificWeight.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificWeight.g.cs @@ -773,16 +773,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Speci #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(SpecificWeight, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(SpecificWeight other, SpecificWeight tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(SpecificWeight left, SpecificWeight right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(SpecificWeight, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(SpecificWeight other, SpecificWeight tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(SpecificWeight left, SpecificWeight right) { return !(left == right); @@ -790,8 +788,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Speci /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(SpecificWeight, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(SpecificWeight other, SpecificWeight tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is SpecificWeight otherQuantity)) @@ -802,8 +799,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(SpecificWeight, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(SpecificWeight other, SpecificWeight tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(SpecificWeight other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -887,6 +883,7 @@ public int CompareTo(SpecificWeight other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(SpecificWeight other, SpecificWeight tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(SpecificWeight other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -898,6 +895,32 @@ public bool Equals(SpecificWeight other, double tolerance, ComparisonType compar return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is SpecificWeight otherTyped + && (tolerance is SpecificWeight toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'SpecificWeight'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(SpecificWeight other, SpecificWeight tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/Speed.g.cs b/UnitsNet/GeneratedCode/Quantities/Speed.g.cs index 1fccc6e4b3..3dcb691c4e 100644 --- a/UnitsNet/GeneratedCode/Quantities/Speed.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Speed.g.cs @@ -1098,16 +1098,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Speed #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(Speed, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Speed other, Speed tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(Speed left, Speed right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(Speed, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Speed other, Speed tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(Speed left, Speed right) { return !(left == right); @@ -1115,8 +1113,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Speed /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(Speed, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(Speed other, Speed tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is Speed otherQuantity)) @@ -1127,8 +1124,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(Speed, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(Speed other, Speed tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(Speed other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -1212,6 +1208,7 @@ public int CompareTo(Speed other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(Speed other, Speed tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(Speed other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -1223,6 +1220,32 @@ public bool Equals(Speed other, double tolerance, ComparisonType comparisonType) return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is Speed otherTyped + && (tolerance is Speed toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'Speed'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(Speed other, Speed tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/StandardVolumeFlow.g.cs b/UnitsNet/GeneratedCode/Quantities/StandardVolumeFlow.g.cs index f89661aea9..161cf86ef0 100644 --- a/UnitsNet/GeneratedCode/Quantities/StandardVolumeFlow.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/StandardVolumeFlow.g.cs @@ -618,16 +618,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Stand #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(StandardVolumeFlow, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(StandardVolumeFlow other, StandardVolumeFlow tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(StandardVolumeFlow left, StandardVolumeFlow right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(StandardVolumeFlow, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(StandardVolumeFlow other, StandardVolumeFlow tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(StandardVolumeFlow left, StandardVolumeFlow right) { return !(left == right); @@ -635,8 +633,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Stand /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(StandardVolumeFlow, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(StandardVolumeFlow other, StandardVolumeFlow tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is StandardVolumeFlow otherQuantity)) @@ -647,8 +644,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(StandardVolumeFlow, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(StandardVolumeFlow other, StandardVolumeFlow tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(StandardVolumeFlow other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -732,6 +728,7 @@ public int CompareTo(StandardVolumeFlow other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(StandardVolumeFlow other, StandardVolumeFlow tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(StandardVolumeFlow other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -743,6 +740,32 @@ public bool Equals(StandardVolumeFlow other, double tolerance, ComparisonType co return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is StandardVolumeFlow otherTyped + && (tolerance is StandardVolumeFlow toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'StandardVolumeFlow'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(StandardVolumeFlow other, StandardVolumeFlow tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/Temperature.g.cs b/UnitsNet/GeneratedCode/Quantities/Temperature.g.cs index eca5bdb8b4..4414f9de4a 100644 --- a/UnitsNet/GeneratedCode/Quantities/Temperature.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Temperature.g.cs @@ -588,16 +588,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Tempe #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(Temperature, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Temperature other, Temperature tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(Temperature left, Temperature right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(Temperature, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Temperature other, Temperature tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(Temperature left, Temperature right) { return !(left == right); @@ -605,8 +603,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Tempe /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(Temperature, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(Temperature other, Temperature tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is Temperature otherQuantity)) @@ -617,8 +614,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(Temperature, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(Temperature other, Temperature tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(Temperature other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -702,6 +698,7 @@ public int CompareTo(Temperature other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(Temperature other, Temperature tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(Temperature other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -713,6 +710,32 @@ public bool Equals(Temperature other, double tolerance, ComparisonType compariso return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is Temperature otherTyped + && (tolerance is Temperature toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'Temperature'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(Temperature other, Temperature tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.g.cs index 0e449a91cc..0f48a297ff 100644 --- a/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.g.cs @@ -637,16 +637,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Tempe #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(TemperatureChangeRate, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(TemperatureChangeRate other, TemperatureChangeRate tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(TemperatureChangeRate left, TemperatureChangeRate right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(TemperatureChangeRate, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(TemperatureChangeRate other, TemperatureChangeRate tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(TemperatureChangeRate left, TemperatureChangeRate right) { return !(left == right); @@ -654,8 +652,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Tempe /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(TemperatureChangeRate, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(TemperatureChangeRate other, TemperatureChangeRate tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is TemperatureChangeRate otherQuantity)) @@ -666,8 +663,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(TemperatureChangeRate, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(TemperatureChangeRate other, TemperatureChangeRate tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(TemperatureChangeRate other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -751,6 +747,7 @@ public int CompareTo(TemperatureChangeRate other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(TemperatureChangeRate other, TemperatureChangeRate tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(TemperatureChangeRate other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -762,6 +759,32 @@ public bool Equals(TemperatureChangeRate other, double tolerance, ComparisonType return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is TemperatureChangeRate otherTyped + && (tolerance is TemperatureChangeRate toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'TemperatureChangeRate'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(TemperatureChangeRate other, TemperatureChangeRate tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs b/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs index 3e2be136aa..94afcc325d 100644 --- a/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs @@ -618,16 +618,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Tempe #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(TemperatureDelta, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(TemperatureDelta other, TemperatureDelta tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(TemperatureDelta left, TemperatureDelta right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(TemperatureDelta, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(TemperatureDelta other, TemperatureDelta tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(TemperatureDelta left, TemperatureDelta right) { return !(left == right); @@ -635,8 +633,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Tempe /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(TemperatureDelta, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(TemperatureDelta other, TemperatureDelta tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is TemperatureDelta otherQuantity)) @@ -647,8 +644,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(TemperatureDelta, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(TemperatureDelta other, TemperatureDelta tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(TemperatureDelta other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -732,6 +728,7 @@ public int CompareTo(TemperatureDelta other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(TemperatureDelta other, TemperatureDelta tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(TemperatureDelta other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -743,6 +740,32 @@ public bool Equals(TemperatureDelta other, double tolerance, ComparisonType comp return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is TemperatureDelta otherTyped + && (tolerance is TemperatureDelta toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'TemperatureDelta'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(TemperatureDelta other, TemperatureDelta tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/TemperatureGradient.g.cs b/UnitsNet/GeneratedCode/Quantities/TemperatureGradient.g.cs index 972b7a4cf8..3d5255c5b2 100644 --- a/UnitsNet/GeneratedCode/Quantities/TemperatureGradient.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/TemperatureGradient.g.cs @@ -523,16 +523,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Tempe #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(TemperatureGradient, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(TemperatureGradient other, TemperatureGradient tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(TemperatureGradient left, TemperatureGradient right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(TemperatureGradient, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(TemperatureGradient other, TemperatureGradient tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(TemperatureGradient left, TemperatureGradient right) { return !(left == right); @@ -540,8 +538,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Tempe /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(TemperatureGradient, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(TemperatureGradient other, TemperatureGradient tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is TemperatureGradient otherQuantity)) @@ -552,8 +549,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(TemperatureGradient, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(TemperatureGradient other, TemperatureGradient tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(TemperatureGradient other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -637,6 +633,7 @@ public int CompareTo(TemperatureGradient other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(TemperatureGradient other, TemperatureGradient tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(TemperatureGradient other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -648,6 +645,32 @@ public bool Equals(TemperatureGradient other, double tolerance, ComparisonType c return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is TemperatureGradient otherTyped + && (tolerance is TemperatureGradient toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'TemperatureGradient'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(TemperatureGradient other, TemperatureGradient tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/ThermalConductivity.g.cs b/UnitsNet/GeneratedCode/Quantities/ThermalConductivity.g.cs index 38984e4055..92cef2d503 100644 --- a/UnitsNet/GeneratedCode/Quantities/ThermalConductivity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ThermalConductivity.g.cs @@ -488,16 +488,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Therm #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(ThermalConductivity, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(ThermalConductivity other, ThermalConductivity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(ThermalConductivity left, ThermalConductivity right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(ThermalConductivity, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(ThermalConductivity other, ThermalConductivity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(ThermalConductivity left, ThermalConductivity right) { return !(left == right); @@ -505,8 +503,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Therm /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(ThermalConductivity, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(ThermalConductivity other, ThermalConductivity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is ThermalConductivity otherQuantity)) @@ -517,8 +514,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(ThermalConductivity, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(ThermalConductivity other, ThermalConductivity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(ThermalConductivity other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -602,6 +598,7 @@ public int CompareTo(ThermalConductivity other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(ThermalConductivity other, ThermalConductivity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(ThermalConductivity other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -613,6 +610,32 @@ public bool Equals(ThermalConductivity other, double tolerance, ComparisonType c return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is ThermalConductivity otherTyped + && (tolerance is ThermalConductivity toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'ThermalConductivity'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(ThermalConductivity other, ThermalConductivity tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/ThermalResistance.g.cs b/UnitsNet/GeneratedCode/Quantities/ThermalResistance.g.cs index 8f1d252108..be9949bd06 100644 --- a/UnitsNet/GeneratedCode/Quantities/ThermalResistance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ThermalResistance.g.cs @@ -561,16 +561,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Therm #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(ThermalResistance, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(ThermalResistance other, ThermalResistance tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(ThermalResistance left, ThermalResistance right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(ThermalResistance, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(ThermalResistance other, ThermalResistance tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(ThermalResistance left, ThermalResistance right) { return !(left == right); @@ -578,8 +576,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Therm /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(ThermalResistance, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(ThermalResistance other, ThermalResistance tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is ThermalResistance otherQuantity)) @@ -590,8 +587,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(ThermalResistance, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(ThermalResistance other, ThermalResistance tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(ThermalResistance other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -675,6 +671,7 @@ public int CompareTo(ThermalResistance other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(ThermalResistance other, ThermalResistance tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(ThermalResistance other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -686,6 +683,32 @@ public bool Equals(ThermalResistance other, double tolerance, ComparisonType com return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is ThermalResistance otherTyped + && (tolerance is ThermalResistance toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'ThermalResistance'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(ThermalResistance other, ThermalResistance tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/Torque.g.cs b/UnitsNet/GeneratedCode/Quantities/Torque.g.cs index ab2fd891e1..f0d0874ec3 100644 --- a/UnitsNet/GeneratedCode/Quantities/Torque.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Torque.g.cs @@ -925,16 +925,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Torqu #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(Torque, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Torque other, Torque tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(Torque left, Torque right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(Torque, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Torque other, Torque tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(Torque left, Torque right) { return !(left == right); @@ -942,8 +940,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Torqu /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(Torque, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(Torque other, Torque tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is Torque otherQuantity)) @@ -954,8 +951,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(Torque, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(Torque other, Torque tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(Torque other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -1039,6 +1035,7 @@ public int CompareTo(Torque other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(Torque other, Torque tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(Torque other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -1050,6 +1047,32 @@ public bool Equals(Torque other, double tolerance, ComparisonType comparisonType return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is Torque otherTyped + && (tolerance is Torque toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'Torque'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(Torque other, Torque tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/TorquePerLength.g.cs b/UnitsNet/GeneratedCode/Quantities/TorquePerLength.g.cs index 1c230398b6..d35cd3daa4 100644 --- a/UnitsNet/GeneratedCode/Quantities/TorquePerLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/TorquePerLength.g.cs @@ -849,16 +849,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Torqu #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(TorquePerLength, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(TorquePerLength other, TorquePerLength tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(TorquePerLength left, TorquePerLength right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(TorquePerLength, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(TorquePerLength other, TorquePerLength tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(TorquePerLength left, TorquePerLength right) { return !(left == right); @@ -866,8 +864,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Torqu /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(TorquePerLength, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(TorquePerLength other, TorquePerLength tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is TorquePerLength otherQuantity)) @@ -878,8 +875,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(TorquePerLength, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(TorquePerLength other, TorquePerLength tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(TorquePerLength other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -963,6 +959,7 @@ public int CompareTo(TorquePerLength other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(TorquePerLength other, TorquePerLength tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(TorquePerLength other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -974,6 +971,32 @@ public bool Equals(TorquePerLength other, double tolerance, ComparisonType compa return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is TorquePerLength otherTyped + && (tolerance is TorquePerLength toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'TorquePerLength'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(TorquePerLength other, TorquePerLength tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/Turbidity.g.cs b/UnitsNet/GeneratedCode/Quantities/Turbidity.g.cs index f4e8f29989..985cfe683f 100644 --- a/UnitsNet/GeneratedCode/Quantities/Turbidity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Turbidity.g.cs @@ -469,16 +469,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Turbi #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(Turbidity, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Turbidity other, Turbidity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(Turbidity left, Turbidity right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(Turbidity, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Turbidity other, Turbidity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(Turbidity left, Turbidity right) { return !(left == right); @@ -486,8 +484,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Turbi /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(Turbidity, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(Turbidity other, Turbidity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is Turbidity otherQuantity)) @@ -498,8 +495,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(Turbidity, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(Turbidity other, Turbidity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(Turbidity other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -583,6 +579,7 @@ public int CompareTo(Turbidity other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(Turbidity other, Turbidity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(Turbidity other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -594,6 +591,32 @@ public bool Equals(Turbidity other, double tolerance, ComparisonType comparisonT return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is Turbidity otherTyped + && (tolerance is Turbidity toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'Turbidity'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(Turbidity other, Turbidity tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/VitaminA.g.cs b/UnitsNet/GeneratedCode/Quantities/VitaminA.g.cs index bdd6fade1e..fa668b06ea 100644 --- a/UnitsNet/GeneratedCode/Quantities/VitaminA.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VitaminA.g.cs @@ -466,16 +466,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Vitam #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(VitaminA, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(VitaminA other, VitaminA tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(VitaminA left, VitaminA right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(VitaminA, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(VitaminA other, VitaminA tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(VitaminA left, VitaminA right) { return !(left == right); @@ -483,8 +481,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Vitam /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(VitaminA, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(VitaminA other, VitaminA tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is VitaminA otherQuantity)) @@ -495,8 +492,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(VitaminA, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(VitaminA other, VitaminA tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(VitaminA other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -580,6 +576,7 @@ public int CompareTo(VitaminA other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(VitaminA other, VitaminA tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(VitaminA other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -591,6 +588,32 @@ public bool Equals(VitaminA other, double tolerance, ComparisonType comparisonTy return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is VitaminA otherTyped + && (tolerance is VitaminA toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'VitaminA'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(VitaminA other, VitaminA tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/Volume.g.cs b/UnitsNet/GeneratedCode/Quantities/Volume.g.cs index 80e98d96b9..34e942af8f 100644 --- a/UnitsNet/GeneratedCode/Quantities/Volume.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Volume.g.cs @@ -1502,16 +1502,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Volum #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(Volume, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Volume other, Volume tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(Volume left, Volume right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(Volume, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Volume other, Volume tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(Volume left, Volume right) { return !(left == right); @@ -1519,8 +1517,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Volum /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(Volume, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(Volume other, Volume tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is Volume otherQuantity)) @@ -1531,8 +1528,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(Volume, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(Volume other, Volume tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(Volume other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -1616,6 +1612,7 @@ public int CompareTo(Volume other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(Volume other, Volume tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(Volume other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -1627,6 +1624,32 @@ public bool Equals(Volume other, double tolerance, ComparisonType comparisonType return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is Volume otherTyped + && (tolerance is Volume toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'Volume'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(Volume other, Volume tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/VolumeConcentration.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumeConcentration.g.cs index ecf7511ad6..0587d0fe28 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumeConcentration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumeConcentration.g.cs @@ -830,16 +830,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Volum #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(VolumeConcentration, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(VolumeConcentration other, VolumeConcentration tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(VolumeConcentration left, VolumeConcentration right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(VolumeConcentration, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(VolumeConcentration other, VolumeConcentration tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(VolumeConcentration left, VolumeConcentration right) { return !(left == right); @@ -847,8 +845,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Volum /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(VolumeConcentration, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(VolumeConcentration other, VolumeConcentration tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is VolumeConcentration otherQuantity)) @@ -859,8 +856,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(VolumeConcentration, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(VolumeConcentration other, VolumeConcentration tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(VolumeConcentration other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -944,6 +940,7 @@ public int CompareTo(VolumeConcentration other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(VolumeConcentration other, VolumeConcentration tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(VolumeConcentration other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -955,6 +952,32 @@ public bool Equals(VolumeConcentration other, double tolerance, ComparisonType c return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is VolumeConcentration otherTyped + && (tolerance is VolumeConcentration toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'VolumeConcentration'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(VolumeConcentration other, VolumeConcentration tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs index b5804aaf97..3448d3b1c6 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs @@ -1750,16 +1750,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Volum #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(VolumeFlow, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(VolumeFlow other, VolumeFlow tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(VolumeFlow left, VolumeFlow right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(VolumeFlow, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(VolumeFlow other, VolumeFlow tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(VolumeFlow left, VolumeFlow right) { return !(left == right); @@ -1767,8 +1765,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Volum /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(VolumeFlow, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(VolumeFlow other, VolumeFlow tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is VolumeFlow otherQuantity)) @@ -1779,8 +1776,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(VolumeFlow, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(VolumeFlow other, VolumeFlow tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(VolumeFlow other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -1864,6 +1860,7 @@ public int CompareTo(VolumeFlow other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(VolumeFlow other, VolumeFlow tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(VolumeFlow other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -1875,6 +1872,32 @@ public bool Equals(VolumeFlow other, double tolerance, ComparisonType comparison return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is VolumeFlow otherTyped + && (tolerance is VolumeFlow toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'VolumeFlow'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(VolumeFlow other, VolumeFlow tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/VolumeFlowPerArea.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumeFlowPerArea.g.cs index 8aeb0f5041..4bc0515f50 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumeFlowPerArea.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumeFlowPerArea.g.cs @@ -485,16 +485,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Volum #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(VolumeFlowPerArea, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(VolumeFlowPerArea other, VolumeFlowPerArea tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(VolumeFlowPerArea left, VolumeFlowPerArea right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(VolumeFlowPerArea, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(VolumeFlowPerArea other, VolumeFlowPerArea tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(VolumeFlowPerArea left, VolumeFlowPerArea right) { return !(left == right); @@ -502,8 +500,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Volum /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(VolumeFlowPerArea, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(VolumeFlowPerArea other, VolumeFlowPerArea tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is VolumeFlowPerArea otherQuantity)) @@ -514,8 +511,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(VolumeFlowPerArea, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(VolumeFlowPerArea other, VolumeFlowPerArea tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(VolumeFlowPerArea other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -599,6 +595,7 @@ public int CompareTo(VolumeFlowPerArea other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(VolumeFlowPerArea other, VolumeFlowPerArea tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(VolumeFlowPerArea other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -610,6 +607,32 @@ public bool Equals(VolumeFlowPerArea other, double tolerance, ComparisonType com return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is VolumeFlowPerArea otherTyped + && (tolerance is VolumeFlowPerArea toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'VolumeFlowPerArea'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(VolumeFlowPerArea other, VolumeFlowPerArea tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/VolumePerLength.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumePerLength.g.cs index 508b97ebc6..3064e671f7 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumePerLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumePerLength.g.cs @@ -618,16 +618,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Volum #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(VolumePerLength, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(VolumePerLength other, VolumePerLength tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(VolumePerLength left, VolumePerLength right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(VolumePerLength, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(VolumePerLength other, VolumePerLength tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(VolumePerLength left, VolumePerLength right) { return !(left == right); @@ -635,8 +633,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Volum /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(VolumePerLength, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(VolumePerLength other, VolumePerLength tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is VolumePerLength otherQuantity)) @@ -647,8 +644,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(VolumePerLength, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(VolumePerLength other, VolumePerLength tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(VolumePerLength other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -732,6 +728,7 @@ public int CompareTo(VolumePerLength other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(VolumePerLength other, VolumePerLength tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(VolumePerLength other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -743,6 +740,32 @@ public bool Equals(VolumePerLength other, double tolerance, ComparisonType compa return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is VolumePerLength otherTyped + && (tolerance is VolumePerLength toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'VolumePerLength'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(VolumePerLength other, VolumePerLength tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs index f00234e5a9..3af9069504 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs @@ -621,16 +621,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Volum #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(VolumetricHeatCapacity, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(VolumetricHeatCapacity other, VolumetricHeatCapacity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(VolumetricHeatCapacity left, VolumetricHeatCapacity right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(VolumetricHeatCapacity, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(VolumetricHeatCapacity other, VolumetricHeatCapacity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(VolumetricHeatCapacity left, VolumetricHeatCapacity right) { return !(left == right); @@ -638,8 +636,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Volum /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(VolumetricHeatCapacity, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(VolumetricHeatCapacity other, VolumetricHeatCapacity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is VolumetricHeatCapacity otherQuantity)) @@ -650,8 +647,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(VolumetricHeatCapacity, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(VolumetricHeatCapacity other, VolumetricHeatCapacity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(VolumetricHeatCapacity other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -735,6 +731,7 @@ public int CompareTo(VolumetricHeatCapacity other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(VolumetricHeatCapacity other, VolumetricHeatCapacity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(VolumetricHeatCapacity other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -746,6 +743,32 @@ public bool Equals(VolumetricHeatCapacity other, double tolerance, ComparisonTyp return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is VolumetricHeatCapacity otherTyped + && (tolerance is VolumetricHeatCapacity toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'VolumetricHeatCapacity'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(VolumetricHeatCapacity other, VolumetricHeatCapacity tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs b/UnitsNet/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs index 1eadff1253..0f6da74854 100644 --- a/UnitsNet/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs @@ -561,16 +561,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Warpi #pragma warning disable CS0809 /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For quantity comparisons, use Equals(WarpingMomentOfInertia, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(WarpingMomentOfInertia other, WarpingMomentOfInertia tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator ==(WarpingMomentOfInertia left, WarpingMomentOfInertia right) { return left.Equals(right); } /// Indicates strict inequality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("For null checks, use `x is not null` syntax to not invoke overloads. For quantity comparisons, use Equals(WarpingMomentOfInertia, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(WarpingMomentOfInertia other, WarpingMomentOfInertia tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public static bool operator !=(WarpingMomentOfInertia left, WarpingMomentOfInertia right) { return !(left == right); @@ -578,8 +576,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Warpi /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(WarpingMomentOfInertia, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(WarpingMomentOfInertia other, WarpingMomentOfInertia tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public override bool Equals(object? obj) { if (obj is null || !(obj is WarpingMomentOfInertia otherQuantity)) @@ -590,8 +587,7 @@ public override bool Equals(object? obj) /// /// Indicates strict equality of two quantities, where both and are exactly equal. - /// Consider using to check equality across different units and to specify a floating-point number error tolerance. - [Obsolete("Consider using Equals(WarpingMomentOfInertia, double, ComparisonType) to check equality across different units and to specify a floating-point number error tolerance.")] + [Obsolete("Use Equals(WarpingMomentOfInertia other, WarpingMomentOfInertia tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(WarpingMomentOfInertia other) { return new { Value, Unit }.Equals(new { other.Value, other.Unit }); @@ -675,6 +671,7 @@ public int CompareTo(WarpingMomentOfInertia other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(WarpingMomentOfInertia other, WarpingMomentOfInertia tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] public bool Equals(WarpingMomentOfInertia other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) @@ -686,6 +683,32 @@ public bool Equals(WarpingMomentOfInertia other, double tolerance, ComparisonTyp return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is WarpingMomentOfInertia otherTyped + && (tolerance is WarpingMomentOfInertia toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'WarpingMomentOfInertia'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(WarpingMomentOfInertia other, WarpingMomentOfInertia tolerance) + { + if (tolerance < Zero) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + + double thisValue = this.Value; + double otherValueInThisUnits = other.As(this.Unit); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + /// /// Returns the hash code for this instance. /// diff --git a/UnitsNet/IQuantity.cs b/UnitsNet/IQuantity.cs index cb4ebdb6a4..a67d33d382 100644 --- a/UnitsNet/IQuantity.cs +++ b/UnitsNet/IQuantity.cs @@ -41,6 +41,29 @@ public interface IQuantity : IFormattable /// The converted value. double As(UnitSystem unitSystem); + /// + /// + /// Compare equality to given a for the maximum allowed +/- difference. + /// + /// + /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). + /// + /// var a = Length.FromMeters(2.0); + /// var b = Length.FromMeters(2.1); + /// var tolerance = Length.FromCentimeters(10); + /// a.Equals(b, tolerance); // true, 2m equals 2.1m +/- 0.1m + /// + /// + /// + /// It is generally advised against specifying "zero" tolerance, due to the nature of floating-point operations. + /// + /// + /// The other quantity to compare to. Not equal if the quantity types are different. + /// The absolute tolerance value. Must be greater than or equal to zero. Must be same quantity type as . + /// True if the absolute difference between the two values is not greater than the specified tolerance. + /// Tolerance must be of the same quantity type. + bool Equals(IQuantity? other, IQuantity tolerance); + /// /// The unit this quantity was constructed with -or- BaseUnit if default ctor was used. /// @@ -146,10 +169,14 @@ public interface IQuantity : IQuantity, IV /// The type itself, for the CRT pattern. /// The underlying unit enum type. /// The underlying value type for internal representation. - public interface IQuantity : IQuantity #if NET7_0_OR_GREATER + public interface IQuantity + : IQuantity , IComparisonOperators , IParsable +#else + public interface IQuantity + : IQuantity #endif where TSelf : IQuantity where TUnitType : Enum @@ -159,5 +186,26 @@ public interface IQuantity : IQuantity + /// + /// Compare equality to given a for the maximum allowed +/- difference. + /// + /// + /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). + /// + /// var a = Length.FromMeters(2.0); + /// var b = Length.FromMeters(2.1); + /// var tolerance = Length.FromCentimeters(10); + /// a.Equals(b, tolerance); // true, 2m equals 2.1m +/- 0.1m + /// + /// + /// + /// It is generally advised against specifying "zero" tolerance, due to the nature of floating-point operations. + /// + /// + /// The other quantity to compare to. + /// The absolute tolerance value. Must be greater than or equal to zero. + /// True if the absolute difference between the two values is not greater than the specified tolerance. + bool Equals(TSelf? other, TSelf tolerance); } } From ba568cf97e7b007c74dced227ffde55beb203051 Mon Sep 17 00:00:00 2001 From: Andreas Gullberg Larsen Date: Sat, 27 May 2023 01:15:02 +0200 Subject: [PATCH 2/4] revert HowMuch.Equals --- UnitsNet.Tests/CustomQuantities/HowMuch.cs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/UnitsNet.Tests/CustomQuantities/HowMuch.cs b/UnitsNet.Tests/CustomQuantities/HowMuch.cs index c9d8a90647..f9b39f918b 100644 --- a/UnitsNet.Tests/CustomQuantities/HowMuch.cs +++ b/UnitsNet.Tests/CustomQuantities/HowMuch.cs @@ -44,11 +44,6 @@ public HowMuch(double value, HowMuchUnit unit) public double As(UnitSystem unitSystem) => throw new NotImplementedException(); - public bool Equals(IQuantity? other, double tolerance, ComparisonType comparisonType) - { - return other is HowMuch otherTyped && otherTyped.Unit == Unit && otherTyped.Value.Equals(Value); - } - public IQuantity ToUnit(Enum unit) { if (unit is HowMuchUnit howMuchUnit) return new HowMuch(As(unit), howMuchUnit); From 4cdc1ba4cc4022ab6ee784dae5cde06ab981baad Mon Sep 17 00:00:00 2001 From: Andreas Gullberg Larsen Date: Sat, 27 May 2023 01:17:54 +0200 Subject: [PATCH 3/4] nameof --- UnitsNet/Comparison.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/UnitsNet/Comparison.cs b/UnitsNet/Comparison.cs index ac6726c3e2..6c5a405a9d 100644 --- a/UnitsNet/Comparison.cs +++ b/UnitsNet/Comparison.cs @@ -52,7 +52,7 @@ public static class Comparison public static bool Equals(double referenceValue, double otherValue, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0"); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); switch (comparisonType) { @@ -107,7 +107,7 @@ public static bool Equals(double referenceValue, double otherValue, double toler public static bool Equals(decimal referenceValue, decimal otherValue, decimal tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0"); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); switch (comparisonType) { @@ -144,7 +144,7 @@ public static bool Equals(decimal referenceValue, decimal otherValue, decimal to public static bool EqualsRelative(double referenceValue, double otherValue, double tolerance) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0"); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); var maxVariation = Math.Abs(referenceValue * tolerance); return Math.Abs(referenceValue - otherValue) <= maxVariation; @@ -174,7 +174,7 @@ public static bool EqualsRelative(double referenceValue, double otherValue, doub public static bool EqualsRelative(decimal referenceValue, decimal otherValue, decimal tolerance) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0"); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); var maxVariation = Math.Abs(referenceValue * tolerance); return Math.Abs(referenceValue - otherValue) <= maxVariation; @@ -202,7 +202,7 @@ public static bool EqualsRelative(decimal referenceValue, decimal otherValue, de public static bool EqualsAbsolute(double value1, double value2, double tolerance) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0"); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); return Math.Abs(value1 - value2) <= tolerance; } @@ -229,7 +229,7 @@ public static bool EqualsAbsolute(double value1, double value2, double tolerance public static bool EqualsAbsolute(decimal value1, decimal value2, decimal tolerance) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0"); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); return Math.Abs(value1 - value2) <= tolerance; } From c7c0dfac92648b6d5d1cead97c0e15cd7fcb9817 Mon Sep 17 00:00:00 2001 From: Andreas Gullberg Larsen Date: Sat, 27 May 2023 01:27:56 +0200 Subject: [PATCH 4/4] cleanup --- .../UnitsNetGen/QuantityGenerator.cs | 17 ++++++----------- .../Quantities/Acceleration.g.cs | 19 +++++++------------ .../Quantities/AmountOfSubstance.g.cs | 17 ++++++----------- .../Quantities/AmplitudeRatio.g.cs | 17 ++++++----------- UnitsNet/GeneratedCode/Quantities/Angle.g.cs | 17 ++++++----------- .../Quantities/ApparentEnergy.g.cs | 17 ++++++----------- .../Quantities/ApparentPower.g.cs | 17 ++++++----------- UnitsNet/GeneratedCode/Quantities/Area.g.cs | 17 ++++++----------- .../GeneratedCode/Quantities/AreaDensity.g.cs | 17 ++++++----------- .../Quantities/AreaMomentOfInertia.g.cs | 17 ++++++----------- .../GeneratedCode/Quantities/BitRate.g.cs | 17 ++++++----------- .../BrakeSpecificFuelConsumption.g.cs | 17 ++++++----------- .../GeneratedCode/Quantities/Capacitance.g.cs | 17 ++++++----------- .../CoefficientOfThermalExpansion.g.cs | 17 ++++++----------- .../Quantities/Compressibility.g.cs | 17 ++++++----------- .../GeneratedCode/Quantities/Density.g.cs | 17 ++++++----------- .../GeneratedCode/Quantities/Duration.g.cs | 17 ++++++----------- .../Quantities/DynamicViscosity.g.cs | 17 ++++++----------- .../Quantities/ElectricAdmittance.g.cs | 17 ++++++----------- .../Quantities/ElectricCharge.g.cs | 17 ++++++----------- .../Quantities/ElectricChargeDensity.g.cs | 17 ++++++----------- .../Quantities/ElectricConductance.g.cs | 17 ++++++----------- .../Quantities/ElectricConductivity.g.cs | 17 ++++++----------- .../Quantities/ElectricCurrent.g.cs | 17 ++++++----------- .../Quantities/ElectricCurrentDensity.g.cs | 17 ++++++----------- .../Quantities/ElectricCurrentGradient.g.cs | 17 ++++++----------- .../Quantities/ElectricField.g.cs | 17 ++++++----------- .../Quantities/ElectricInductance.g.cs | 17 ++++++----------- .../Quantities/ElectricPotential.g.cs | 17 ++++++----------- .../Quantities/ElectricPotentialAc.g.cs | 17 ++++++----------- .../ElectricPotentialChangeRate.g.cs | 17 ++++++----------- .../Quantities/ElectricPotentialDc.g.cs | 17 ++++++----------- .../Quantities/ElectricResistance.g.cs | 17 ++++++----------- .../Quantities/ElectricResistivity.g.cs | 17 ++++++----------- .../ElectricSurfaceChargeDensity.g.cs | 17 ++++++----------- UnitsNet/GeneratedCode/Quantities/Energy.g.cs | 17 ++++++----------- .../Quantities/EnergyDensity.g.cs | 17 ++++++----------- .../GeneratedCode/Quantities/Entropy.g.cs | 17 ++++++----------- UnitsNet/GeneratedCode/Quantities/Force.g.cs | 17 ++++++----------- .../Quantities/ForceChangeRate.g.cs | 17 ++++++----------- .../Quantities/ForcePerLength.g.cs | 17 ++++++----------- .../GeneratedCode/Quantities/Frequency.g.cs | 17 ++++++----------- .../Quantities/FuelEfficiency.g.cs | 17 ++++++----------- .../GeneratedCode/Quantities/HeatFlux.g.cs | 17 ++++++----------- .../Quantities/HeatTransferCoefficient.g.cs | 17 ++++++----------- .../GeneratedCode/Quantities/Illuminance.g.cs | 17 ++++++----------- .../GeneratedCode/Quantities/Impulse.g.cs | 17 ++++++----------- .../GeneratedCode/Quantities/Information.g.cs | 17 ++++++----------- .../GeneratedCode/Quantities/Irradiance.g.cs | 17 ++++++----------- .../GeneratedCode/Quantities/Irradiation.g.cs | 17 ++++++----------- UnitsNet/GeneratedCode/Quantities/Jerk.g.cs | 17 ++++++----------- .../Quantities/KinematicViscosity.g.cs | 17 ++++++----------- .../GeneratedCode/Quantities/LeakRate.g.cs | 17 ++++++----------- UnitsNet/GeneratedCode/Quantities/Length.g.cs | 17 ++++++----------- UnitsNet/GeneratedCode/Quantities/Level.g.cs | 17 ++++++----------- .../Quantities/LinearDensity.g.cs | 17 ++++++----------- .../Quantities/LinearPowerDensity.g.cs | 17 ++++++----------- .../GeneratedCode/Quantities/Luminance.g.cs | 17 ++++++----------- .../GeneratedCode/Quantities/Luminosity.g.cs | 17 ++++++----------- .../Quantities/LuminousFlux.g.cs | 17 ++++++----------- .../Quantities/LuminousIntensity.g.cs | 17 ++++++----------- .../Quantities/MagneticField.g.cs | 17 ++++++----------- .../Quantities/MagneticFlux.g.cs | 17 ++++++----------- .../Quantities/Magnetization.g.cs | 17 ++++++----------- UnitsNet/GeneratedCode/Quantities/Mass.g.cs | 17 ++++++----------- .../Quantities/MassConcentration.g.cs | 17 ++++++----------- .../GeneratedCode/Quantities/MassFlow.g.cs | 17 ++++++----------- .../GeneratedCode/Quantities/MassFlux.g.cs | 17 ++++++----------- .../Quantities/MassFraction.g.cs | 17 ++++++----------- .../Quantities/MassMomentOfInertia.g.cs | 17 ++++++----------- .../GeneratedCode/Quantities/MolarEnergy.g.cs | 17 ++++++----------- .../Quantities/MolarEntropy.g.cs | 17 ++++++----------- .../GeneratedCode/Quantities/MolarFlow.g.cs | 17 ++++++----------- .../GeneratedCode/Quantities/MolarMass.g.cs | 17 ++++++----------- .../GeneratedCode/Quantities/Molarity.g.cs | 17 ++++++----------- .../Quantities/Permeability.g.cs | 17 ++++++----------- .../Quantities/Permittivity.g.cs | 17 ++++++----------- .../Quantities/PorousMediumPermeability.g.cs | 17 ++++++----------- UnitsNet/GeneratedCode/Quantities/Power.g.cs | 17 ++++++----------- .../Quantities/PowerDensity.g.cs | 17 ++++++----------- .../GeneratedCode/Quantities/PowerRatio.g.cs | 17 ++++++----------- .../GeneratedCode/Quantities/Pressure.g.cs | 17 ++++++----------- .../Quantities/PressureChangeRate.g.cs | 17 ++++++----------- UnitsNet/GeneratedCode/Quantities/Ratio.g.cs | 17 ++++++----------- .../Quantities/RatioChangeRate.g.cs | 17 ++++++----------- .../Quantities/ReactiveEnergy.g.cs | 17 ++++++----------- .../Quantities/ReactivePower.g.cs | 17 ++++++----------- .../Quantities/ReciprocalArea.g.cs | 17 ++++++----------- .../Quantities/ReciprocalLength.g.cs | 17 ++++++----------- .../Quantities/RelativeHumidity.g.cs | 17 ++++++----------- .../Quantities/RotationalAcceleration.g.cs | 17 ++++++----------- .../Quantities/RotationalSpeed.g.cs | 17 ++++++----------- .../Quantities/RotationalStiffness.g.cs | 17 ++++++----------- .../RotationalStiffnessPerLength.g.cs | 17 ++++++----------- UnitsNet/GeneratedCode/Quantities/Scalar.g.cs | 17 ++++++----------- .../GeneratedCode/Quantities/SolidAngle.g.cs | 17 ++++++----------- .../Quantities/SpecificEnergy.g.cs | 17 ++++++----------- .../Quantities/SpecificEntropy.g.cs | 17 ++++++----------- .../Quantities/SpecificFuelConsumption.g.cs | 17 ++++++----------- .../Quantities/SpecificVolume.g.cs | 17 ++++++----------- .../Quantities/SpecificWeight.g.cs | 17 ++++++----------- UnitsNet/GeneratedCode/Quantities/Speed.g.cs | 17 ++++++----------- .../Quantities/StandardVolumeFlow.g.cs | 17 ++++++----------- .../GeneratedCode/Quantities/Temperature.g.cs | 17 ++++++----------- .../Quantities/TemperatureChangeRate.g.cs | 17 ++++++----------- .../Quantities/TemperatureDelta.g.cs | 17 ++++++----------- .../Quantities/TemperatureGradient.g.cs | 17 ++++++----------- .../Quantities/ThermalConductivity.g.cs | 17 ++++++----------- .../Quantities/ThermalResistance.g.cs | 17 ++++++----------- UnitsNet/GeneratedCode/Quantities/Torque.g.cs | 17 ++++++----------- .../Quantities/TorquePerLength.g.cs | 17 ++++++----------- .../GeneratedCode/Quantities/Turbidity.g.cs | 17 ++++++----------- .../GeneratedCode/Quantities/VitaminA.g.cs | 17 ++++++----------- UnitsNet/GeneratedCode/Quantities/Volume.g.cs | 17 ++++++----------- .../Quantities/VolumeConcentration.g.cs | 17 ++++++----------- .../GeneratedCode/Quantities/VolumeFlow.g.cs | 17 ++++++----------- .../Quantities/VolumeFlowPerArea.g.cs | 17 ++++++----------- .../Quantities/VolumePerLength.g.cs | 17 ++++++----------- .../Quantities/VolumetricHeatCapacity.g.cs | 17 ++++++----------- .../Quantities/WarpingMomentOfInertia.g.cs | 17 ++++++----------- 120 files changed, 721 insertions(+), 1321 deletions(-) diff --git a/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs b/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs index 2a0ec781bd..66d033f8bc 100644 --- a/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs +++ b/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs @@ -863,12 +863,13 @@ public int CompareTo({_quantity.Name} other) public bool Equals({_quantity.Name} other, {_quantity.ValueType} tolerance, ComparisonType comparisonType) {{ if (tolerance < 0) - throw new ArgumentOutOfRangeException(""tolerance"", ""Tolerance must be greater than or equal to 0.""); + throw new ArgumentOutOfRangeException(nameof(tolerance), ""Tolerance must be greater than or equal to 0.""); - {_quantity.ValueType} thisValue = this.Value; - {_quantity.ValueType} otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); }} /// @@ -884,12 +885,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals({_quantity.Name} other, {_quantity.Name} tolerance) {{ - if (tolerance < Zero) - throw new ArgumentOutOfRangeException(""tolerance"", ""Tolerance must be greater than or equal to 0.""); - - {_quantity.ValueType} thisValue = this.Value; - {_quantity.ValueType} otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs b/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs index c44f91fe25..6d6e96aef6 100644 --- a/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs @@ -151,7 +151,7 @@ public Acceleration(double value, UnitSystem unitSystem) public static Acceleration AdditiveIdentity => Zero; #endregion - + #region Properties /// @@ -841,12 +841,13 @@ public int CompareTo(Acceleration other) public bool Equals(Acceleration other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -862,12 +863,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(Acceleration other, Acceleration tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs b/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs index b182d26243..7937aeb386 100644 --- a/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs @@ -846,12 +846,13 @@ public int CompareTo(AmountOfSubstance other) public bool Equals(AmountOfSubstance other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -867,12 +868,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(AmountOfSubstance other, AmountOfSubstance tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.g.cs b/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.g.cs index f557d65e62..969d381adb 100644 --- a/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.g.cs @@ -645,12 +645,13 @@ public int CompareTo(AmplitudeRatio other) public bool Equals(AmplitudeRatio other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -666,12 +667,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(AmplitudeRatio other, AmplitudeRatio tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/Angle.g.cs b/UnitsNet/GeneratedCode/Quantities/Angle.g.cs index 5557327eec..b4cda3142d 100644 --- a/UnitsNet/GeneratedCode/Quantities/Angle.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Angle.g.cs @@ -877,12 +877,13 @@ public int CompareTo(Angle other) public bool Equals(Angle other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -898,12 +899,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(Angle other, Angle tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/ApparentEnergy.g.cs b/UnitsNet/GeneratedCode/Quantities/ApparentEnergy.g.cs index d60d848267..ced57734a1 100644 --- a/UnitsNet/GeneratedCode/Quantities/ApparentEnergy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ApparentEnergy.g.cs @@ -618,12 +618,13 @@ public int CompareTo(ApparentEnergy other) public bool Equals(ApparentEnergy other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -639,12 +640,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(ApparentEnergy other, ApparentEnergy tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/ApparentPower.g.cs b/UnitsNet/GeneratedCode/Quantities/ApparentPower.g.cs index 1bea929df7..b2d646fb8c 100644 --- a/UnitsNet/GeneratedCode/Quantities/ApparentPower.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ApparentPower.g.cs @@ -675,12 +675,13 @@ public int CompareTo(ApparentPower other) public bool Equals(ApparentPower other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -696,12 +697,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(ApparentPower other, ApparentPower tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/Area.g.cs b/UnitsNet/GeneratedCode/Quantities/Area.g.cs index 459705a580..368dc2eeed 100644 --- a/UnitsNet/GeneratedCode/Quantities/Area.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Area.g.cs @@ -854,12 +854,13 @@ public int CompareTo(Area other) public bool Equals(Area other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -875,12 +876,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(Area other, Area tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs index 20807d8c98..bd3eb2c19a 100644 --- a/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs @@ -618,12 +618,13 @@ public int CompareTo(AreaDensity other) public bool Equals(AreaDensity other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -639,12 +640,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(AreaDensity other, AreaDensity tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs b/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs index 235155f6cd..100e1f3a4e 100644 --- a/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs @@ -675,12 +675,13 @@ public int CompareTo(AreaMomentOfInertia other) public bool Equals(AreaMomentOfInertia other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -696,12 +697,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(AreaMomentOfInertia other, AreaMomentOfInertia tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs b/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs index 96cb6b2aaf..6444f5e964 100644 --- a/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs @@ -1059,12 +1059,13 @@ public int CompareTo(BitRate other) public bool Equals(BitRate other, decimal tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - decimal thisValue = this.Value; - decimal otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -1080,12 +1081,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(BitRate other, BitRate tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - decimal thisValue = this.Value; - decimal otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs b/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs index c807b8bb6c..61bd08bd7c 100644 --- a/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs @@ -618,12 +618,13 @@ public int CompareTo(BrakeSpecificFuelConsumption other) public bool Equals(BrakeSpecificFuelConsumption other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -639,12 +640,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(BrakeSpecificFuelConsumption other, BrakeSpecificFuelConsumption tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/Capacitance.g.cs b/UnitsNet/GeneratedCode/Quantities/Capacitance.g.cs index b79e649a73..b30bee2741 100644 --- a/UnitsNet/GeneratedCode/Quantities/Capacitance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Capacitance.g.cs @@ -697,12 +697,13 @@ public int CompareTo(Capacitance other) public bool Equals(Capacitance other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -718,12 +719,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(Capacitance other, Capacitance tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs b/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs index 980d4152d5..509cd8018a 100644 --- a/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs @@ -618,12 +618,13 @@ public int CompareTo(CoefficientOfThermalExpansion other) public bool Equals(CoefficientOfThermalExpansion other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -639,12 +640,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(CoefficientOfThermalExpansion other, CoefficientOfThermalExpansion tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/Compressibility.g.cs b/UnitsNet/GeneratedCode/Quantities/Compressibility.g.cs index f80427543b..9dc6d3682b 100644 --- a/UnitsNet/GeneratedCode/Quantities/Compressibility.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Compressibility.g.cs @@ -694,12 +694,13 @@ public int CompareTo(Compressibility other) public bool Equals(Compressibility other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -715,12 +716,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(Compressibility other, Compressibility tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/Density.g.cs b/UnitsNet/GeneratedCode/Quantities/Density.g.cs index 72fc82ee79..0eac171657 100644 --- a/UnitsNet/GeneratedCode/Quantities/Density.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Density.g.cs @@ -1537,12 +1537,13 @@ public int CompareTo(Density other) public bool Equals(Density other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -1558,12 +1559,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(Density other, Density tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/Duration.g.cs b/UnitsNet/GeneratedCode/Quantities/Duration.g.cs index 26ed05b8f9..9bb094d8b1 100644 --- a/UnitsNet/GeneratedCode/Quantities/Duration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Duration.g.cs @@ -780,12 +780,13 @@ public int CompareTo(Duration other) public bool Equals(Duration other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -801,12 +802,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(Duration other, Duration tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs b/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs index 8ae364a8e8..3732303070 100644 --- a/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs @@ -754,12 +754,13 @@ public int CompareTo(DynamicViscosity other) public bool Equals(DynamicViscosity other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -775,12 +776,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(DynamicViscosity other, DynamicViscosity tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.g.cs index 17715acdcd..676cefe537 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.g.cs @@ -637,12 +637,13 @@ public int CompareTo(ElectricAdmittance other) public bool Equals(ElectricAdmittance other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -658,12 +659,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(ElectricAdmittance other, ElectricAdmittance tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs index c224797d62..bed8124cdd 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs @@ -773,12 +773,13 @@ public int CompareTo(ElectricCharge other) public bool Equals(ElectricCharge other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -794,12 +795,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(ElectricCharge other, ElectricCharge tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.g.cs index a208db6e79..d003058b2b 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.g.cs @@ -583,12 +583,13 @@ public int CompareTo(ElectricChargeDensity other) public bool Equals(ElectricChargeDensity other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -604,12 +605,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(ElectricChargeDensity other, ElectricChargeDensity tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricConductance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricConductance.g.cs index e15e778af8..0969dfe189 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricConductance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricConductance.g.cs @@ -659,12 +659,13 @@ public int CompareTo(ElectricConductance other) public bool Equals(ElectricConductance other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -680,12 +681,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(ElectricConductance other, ElectricConductance tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs index 6b91f67390..0f771dcc46 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs @@ -678,12 +678,13 @@ public int CompareTo(ElectricConductivity other) public bool Equals(ElectricConductivity other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -699,12 +700,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(ElectricConductivity other, ElectricConductivity tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs index 22e760538b..e1e497fde6 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs @@ -732,12 +732,13 @@ public int CompareTo(ElectricCurrent other) public bool Equals(ElectricCurrent other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -753,12 +754,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(ElectricCurrent other, ElectricCurrent tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs index b017ef75ac..7f87d89d75 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs @@ -621,12 +621,13 @@ public int CompareTo(ElectricCurrentDensity other) public bool Equals(ElectricCurrentDensity other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -642,12 +643,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(ElectricCurrentDensity other, ElectricCurrentDensity tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs index 69118e2799..d1aadf044a 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs @@ -637,12 +637,13 @@ public int CompareTo(ElectricCurrentGradient other) public bool Equals(ElectricCurrentGradient other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -658,12 +659,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(ElectricCurrentGradient other, ElectricCurrentGradient tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricField.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricField.g.cs index 51338291d9..50b53bb4a8 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricField.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricField.g.cs @@ -583,12 +583,13 @@ public int CompareTo(ElectricField other) public bool Equals(ElectricField other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -604,12 +605,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(ElectricField other, ElectricField tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricInductance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricInductance.g.cs index 88f6cc548d..e9ed0530c7 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricInductance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricInductance.g.cs @@ -659,12 +659,13 @@ public int CompareTo(ElectricInductance other) public bool Equals(ElectricInductance other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -680,12 +681,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(ElectricInductance other, ElectricInductance tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs index 58be989bf1..29f9e8b35f 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs @@ -681,12 +681,13 @@ public int CompareTo(ElectricPotential other) public bool Equals(ElectricPotential other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -702,12 +703,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(ElectricPotential other, ElectricPotential tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialAc.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialAc.g.cs index 4cf95ba360..102bfe9304 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialAc.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialAc.g.cs @@ -656,12 +656,13 @@ public int CompareTo(ElectricPotentialAc other) public bool Equals(ElectricPotentialAc other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -677,12 +678,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(ElectricPotentialAc other, ElectricPotentialAc tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs index c8c429f036..c562f5df94 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs @@ -941,12 +941,13 @@ public int CompareTo(ElectricPotentialChangeRate other) public bool Equals(ElectricPotentialChangeRate other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -962,12 +963,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(ElectricPotentialChangeRate other, ElectricPotentialChangeRate tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialDc.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialDc.g.cs index c7f0607e24..210101cc08 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialDc.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialDc.g.cs @@ -656,12 +656,13 @@ public int CompareTo(ElectricPotentialDc other) public bool Equals(ElectricPotentialDc other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -677,12 +678,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(ElectricPotentialDc other, ElectricPotentialDc tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs index f7f0b41058..ed228d427a 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs @@ -694,12 +694,13 @@ public int CompareTo(ElectricResistance other) public bool Equals(ElectricResistance other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -715,12 +716,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(ElectricResistance other, ElectricResistance tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs index 777b62ad9a..c88e4b639e 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs @@ -830,12 +830,13 @@ public int CompareTo(ElectricResistivity other) public bool Equals(ElectricResistivity other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -851,12 +852,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(ElectricResistivity other, ElectricResistivity tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs index e1535f7b33..211dd2fb47 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs @@ -621,12 +621,13 @@ public int CompareTo(ElectricSurfaceChargeDensity other) public bool Equals(ElectricSurfaceChargeDensity other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -642,12 +643,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(ElectricSurfaceChargeDensity other, ElectricSurfaceChargeDensity tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/Energy.g.cs b/UnitsNet/GeneratedCode/Quantities/Energy.g.cs index 0911c2f005..90d82917f7 100644 --- a/UnitsNet/GeneratedCode/Quantities/Energy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Energy.g.cs @@ -1304,12 +1304,13 @@ public int CompareTo(Energy other) public bool Equals(Energy other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -1325,12 +1326,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(Energy other, Energy tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/EnergyDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/EnergyDensity.g.cs index 760169c534..ddfd162708 100644 --- a/UnitsNet/GeneratedCode/Quantities/EnergyDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/EnergyDensity.g.cs @@ -789,12 +789,13 @@ public int CompareTo(EnergyDensity other) public bool Equals(EnergyDensity other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -810,12 +811,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(EnergyDensity other, EnergyDensity tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs b/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs index 914bb6dab4..5244cc9452 100644 --- a/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs @@ -694,12 +694,13 @@ public int CompareTo(Entropy other) public bool Equals(Entropy other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -715,12 +716,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(Entropy other, Entropy tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/Force.g.cs b/UnitsNet/GeneratedCode/Quantities/Force.g.cs index 44cd201da7..ec80001397 100644 --- a/UnitsNet/GeneratedCode/Quantities/Force.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Force.g.cs @@ -859,12 +859,13 @@ public int CompareTo(Force other) public bool Equals(Force other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -880,12 +881,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(Force other, Force tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs index 3be4add741..1b3e5b7b74 100644 --- a/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs @@ -846,12 +846,13 @@ public int CompareTo(ForceChangeRate other) public bool Equals(ForceChangeRate other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -867,12 +868,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(ForceChangeRate other, ForceChangeRate tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs b/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs index 546faf4f51..37dcc95e9e 100644 --- a/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs @@ -1289,12 +1289,13 @@ public int CompareTo(ForcePerLength other) public bool Equals(ForcePerLength other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -1310,12 +1311,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(ForcePerLength other, ForcePerLength tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs b/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs index 3f394fd08f..f79728e42c 100644 --- a/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs @@ -817,12 +817,13 @@ public int CompareTo(Frequency other) public bool Equals(Frequency other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -838,12 +839,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(Frequency other, Frequency tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/FuelEfficiency.g.cs b/UnitsNet/GeneratedCode/Quantities/FuelEfficiency.g.cs index 50578e201d..130b3bd329 100644 --- a/UnitsNet/GeneratedCode/Quantities/FuelEfficiency.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/FuelEfficiency.g.cs @@ -640,12 +640,13 @@ public int CompareTo(FuelEfficiency other) public bool Equals(FuelEfficiency other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -661,12 +662,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(FuelEfficiency other, FuelEfficiency tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs b/UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs index d97972570d..2398e95f5c 100644 --- a/UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs @@ -903,12 +903,13 @@ public int CompareTo(HeatFlux other) public bool Equals(HeatFlux other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -924,12 +925,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(HeatFlux other, HeatFlux tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs b/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs index e3599101a0..1f9df7a7cf 100644 --- a/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs @@ -677,12 +677,13 @@ public int CompareTo(HeatTransferCoefficient other) public bool Equals(HeatTransferCoefficient other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -698,12 +699,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(HeatTransferCoefficient other, HeatTransferCoefficient tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/Illuminance.g.cs b/UnitsNet/GeneratedCode/Quantities/Illuminance.g.cs index c7bd6bd202..ed7c4316c2 100644 --- a/UnitsNet/GeneratedCode/Quantities/Illuminance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Illuminance.g.cs @@ -640,12 +640,13 @@ public int CompareTo(Illuminance other) public bool Equals(Illuminance other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -661,12 +662,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(Illuminance other, Illuminance tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/Impulse.g.cs b/UnitsNet/GeneratedCode/Quantities/Impulse.g.cs index c4f4665eb2..3bf1a6d8e7 100644 --- a/UnitsNet/GeneratedCode/Quantities/Impulse.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Impulse.g.cs @@ -808,12 +808,13 @@ public int CompareTo(Impulse other) public bool Equals(Impulse other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -829,12 +830,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(Impulse other, Impulse tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/Information.g.cs b/UnitsNet/GeneratedCode/Quantities/Information.g.cs index 3a6b57db41..0640c7dbff 100644 --- a/UnitsNet/GeneratedCode/Quantities/Information.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Information.g.cs @@ -1056,12 +1056,13 @@ public int CompareTo(Information other) public bool Equals(Information other, decimal tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - decimal thisValue = this.Value; - decimal otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -1077,12 +1078,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(Information other, Information tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - decimal thisValue = this.Value; - decimal otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/Irradiance.g.cs b/UnitsNet/GeneratedCode/Quantities/Irradiance.g.cs index 1adc7b1745..96c0516301 100644 --- a/UnitsNet/GeneratedCode/Quantities/Irradiance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Irradiance.g.cs @@ -827,12 +827,13 @@ public int CompareTo(Irradiance other) public bool Equals(Irradiance other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -848,12 +849,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(Irradiance other, Irradiance tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/Irradiation.g.cs b/UnitsNet/GeneratedCode/Quantities/Irradiation.g.cs index f62388ba2c..58f32c713e 100644 --- a/UnitsNet/GeneratedCode/Quantities/Irradiation.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Irradiation.g.cs @@ -697,12 +697,13 @@ public int CompareTo(Irradiation other) public bool Equals(Irradiation other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -718,12 +719,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(Irradiation other, Irradiation tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/Jerk.g.cs b/UnitsNet/GeneratedCode/Quantities/Jerk.g.cs index 7a165a3264..c2227502c4 100644 --- a/UnitsNet/GeneratedCode/Quantities/Jerk.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Jerk.g.cs @@ -781,12 +781,13 @@ public int CompareTo(Jerk other) public bool Equals(Jerk other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -802,12 +803,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(Jerk other, Jerk tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs b/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs index 43ed81920a..e55cb266b9 100644 --- a/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs @@ -743,12 +743,13 @@ public int CompareTo(KinematicViscosity other) public bool Equals(KinematicViscosity other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -764,12 +765,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(KinematicViscosity other, KinematicViscosity tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/LeakRate.g.cs b/UnitsNet/GeneratedCode/Quantities/LeakRate.g.cs index 1bbc3964c4..914bb5c26c 100644 --- a/UnitsNet/GeneratedCode/Quantities/LeakRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LeakRate.g.cs @@ -621,12 +621,13 @@ public int CompareTo(LeakRate other) public bool Equals(LeakRate other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -642,12 +643,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(LeakRate other, LeakRate tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/Length.g.cs b/UnitsNet/GeneratedCode/Quantities/Length.g.cs index 2084dcbbad..1fd58e04f2 100644 --- a/UnitsNet/GeneratedCode/Quantities/Length.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Length.g.cs @@ -1298,12 +1298,13 @@ public int CompareTo(Length other) public bool Equals(Length other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -1319,12 +1320,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(Length other, Length tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/Level.g.cs b/UnitsNet/GeneratedCode/Quantities/Level.g.cs index 59af9579a1..c763e65424 100644 --- a/UnitsNet/GeneratedCode/Quantities/Level.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Level.g.cs @@ -607,12 +607,13 @@ public int CompareTo(Level other) public bool Equals(Level other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -628,12 +629,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(Level other, Level tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/LinearDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/LinearDensity.g.cs index e061bfd034..6fcb4fad2e 100644 --- a/UnitsNet/GeneratedCode/Quantities/LinearDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LinearDensity.g.cs @@ -830,12 +830,13 @@ public int CompareTo(LinearDensity other) public bool Equals(LinearDensity other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -851,12 +852,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(LinearDensity other, LinearDensity tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/LinearPowerDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/LinearPowerDensity.g.cs index b03cee55ae..76510cb5e5 100644 --- a/UnitsNet/GeneratedCode/Quantities/LinearPowerDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LinearPowerDensity.g.cs @@ -1039,12 +1039,13 @@ public int CompareTo(LinearPowerDensity other) public bool Equals(LinearPowerDensity other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -1060,12 +1061,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(LinearPowerDensity other, LinearPowerDensity tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/Luminance.g.cs b/UnitsNet/GeneratedCode/Quantities/Luminance.g.cs index d8d8a0aafe..87836693de 100644 --- a/UnitsNet/GeneratedCode/Quantities/Luminance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Luminance.g.cs @@ -754,12 +754,13 @@ public int CompareTo(Luminance other) public bool Equals(Luminance other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -775,12 +776,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(Luminance other, Luminance tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/Luminosity.g.cs b/UnitsNet/GeneratedCode/Quantities/Luminosity.g.cs index df19d1bc3e..eb943f5f1c 100644 --- a/UnitsNet/GeneratedCode/Quantities/Luminosity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Luminosity.g.cs @@ -830,12 +830,13 @@ public int CompareTo(Luminosity other) public bool Equals(Luminosity other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -851,12 +852,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(Luminosity other, Luminosity tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/LuminousFlux.g.cs b/UnitsNet/GeneratedCode/Quantities/LuminousFlux.g.cs index cb5f1bc5be..bae3ab5606 100644 --- a/UnitsNet/GeneratedCode/Quantities/LuminousFlux.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LuminousFlux.g.cs @@ -583,12 +583,13 @@ public int CompareTo(LuminousFlux other) public bool Equals(LuminousFlux other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -604,12 +605,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(LuminousFlux other, LuminousFlux tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.g.cs b/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.g.cs index 37bb04a52e..0663d94938 100644 --- a/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.g.cs @@ -583,12 +583,13 @@ public int CompareTo(LuminousIntensity other) public bool Equals(LuminousIntensity other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -604,12 +605,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(LuminousIntensity other, LuminousIntensity tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/MagneticField.g.cs b/UnitsNet/GeneratedCode/Quantities/MagneticField.g.cs index 19d2781d9e..16bb353b2f 100644 --- a/UnitsNet/GeneratedCode/Quantities/MagneticField.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MagneticField.g.cs @@ -678,12 +678,13 @@ public int CompareTo(MagneticField other) public bool Equals(MagneticField other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -699,12 +700,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(MagneticField other, MagneticField tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/MagneticFlux.g.cs b/UnitsNet/GeneratedCode/Quantities/MagneticFlux.g.cs index 777537b8d2..f169a23961 100644 --- a/UnitsNet/GeneratedCode/Quantities/MagneticFlux.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MagneticFlux.g.cs @@ -583,12 +583,13 @@ public int CompareTo(MagneticFlux other) public bool Equals(MagneticFlux other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -604,12 +605,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(MagneticFlux other, MagneticFlux tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/Magnetization.g.cs b/UnitsNet/GeneratedCode/Quantities/Magnetization.g.cs index a029c3c0ac..53efd310f1 100644 --- a/UnitsNet/GeneratedCode/Quantities/Magnetization.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Magnetization.g.cs @@ -583,12 +583,13 @@ public int CompareTo(Magnetization other) public bool Equals(Magnetization other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -604,12 +605,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(Magnetization other, Magnetization tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/Mass.g.cs b/UnitsNet/GeneratedCode/Quantities/Mass.g.cs index c1abe4cc35..010b169b2d 100644 --- a/UnitsNet/GeneratedCode/Quantities/Mass.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Mass.g.cs @@ -1113,12 +1113,13 @@ public int CompareTo(Mass other) public bool Equals(Mass other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -1134,12 +1135,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(Mass other, Mass tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/MassConcentration.g.cs b/UnitsNet/GeneratedCode/Quantities/MassConcentration.g.cs index 1d04b14f5d..67a832bf71 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassConcentration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassConcentration.g.cs @@ -1499,12 +1499,13 @@ public int CompareTo(MassConcentration other) public bool Equals(MassConcentration other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -1520,12 +1521,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(MassConcentration other, MassConcentration tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs b/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs index 22f538d457..ed74027626 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs @@ -1190,12 +1190,13 @@ public int CompareTo(MassFlow other) public bool Equals(MassFlow other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -1211,12 +1212,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(MassFlow other, MassFlow tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs b/UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs index 0d7a255338..35cbf6ad04 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs @@ -789,12 +789,13 @@ public int CompareTo(MassFlux other) public bool Equals(MassFlux other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -810,12 +811,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(MassFlux other, MassFlux tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/MassFraction.g.cs b/UnitsNet/GeneratedCode/Quantities/MassFraction.g.cs index ae089d1358..ea44af973b 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassFraction.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassFraction.g.cs @@ -1020,12 +1020,13 @@ public int CompareTo(MassFraction other) public bool Equals(MassFraction other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -1041,12 +1042,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(MassFraction other, MassFraction tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.g.cs b/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.g.cs index da9aba3ed8..49442ddc3e 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.g.cs @@ -1093,12 +1093,13 @@ public int CompareTo(MassMomentOfInertia other) public bool Equals(MassMomentOfInertia other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -1114,12 +1115,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(MassMomentOfInertia other, MassMomentOfInertia tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/MolarEnergy.g.cs b/UnitsNet/GeneratedCode/Quantities/MolarEnergy.g.cs index 5baca53347..0ccc2dfb10 100644 --- a/UnitsNet/GeneratedCode/Quantities/MolarEnergy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MolarEnergy.g.cs @@ -618,12 +618,13 @@ public int CompareTo(MolarEnergy other) public bool Equals(MolarEnergy other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -639,12 +640,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(MolarEnergy other, MolarEnergy tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs b/UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs index dfdf70e422..71460a5bcd 100644 --- a/UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs @@ -618,12 +618,13 @@ public int CompareTo(MolarEntropy other) public bool Equals(MolarEntropy other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -639,12 +640,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(MolarEntropy other, MolarEntropy tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/MolarFlow.g.cs b/UnitsNet/GeneratedCode/Quantities/MolarFlow.g.cs index ce4cbca245..d0ef8f0754 100644 --- a/UnitsNet/GeneratedCode/Quantities/MolarFlow.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MolarFlow.g.cs @@ -732,12 +732,13 @@ public int CompareTo(MolarFlow other) public bool Equals(MolarFlow other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -753,12 +754,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(MolarFlow other, MolarFlow tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs b/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs index 9cc5fc51e0..caabb8d00c 100644 --- a/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs @@ -820,12 +820,13 @@ public int CompareTo(MolarMass other) public bool Equals(MolarMass other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -841,12 +842,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(MolarMass other, MolarMass tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs b/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs index ded7b4646e..8861e28cc0 100644 --- a/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs @@ -773,12 +773,13 @@ public int CompareTo(Molarity other) public bool Equals(Molarity other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -794,12 +795,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(Molarity other, Molarity tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/Permeability.g.cs b/UnitsNet/GeneratedCode/Quantities/Permeability.g.cs index 302cc08f65..5c7cd6d9df 100644 --- a/UnitsNet/GeneratedCode/Quantities/Permeability.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Permeability.g.cs @@ -583,12 +583,13 @@ public int CompareTo(Permeability other) public bool Equals(Permeability other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -604,12 +605,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(Permeability other, Permeability tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/Permittivity.g.cs b/UnitsNet/GeneratedCode/Quantities/Permittivity.g.cs index d2d2f2cb8e..908f12e4c5 100644 --- a/UnitsNet/GeneratedCode/Quantities/Permittivity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Permittivity.g.cs @@ -583,12 +583,13 @@ public int CompareTo(Permittivity other) public bool Equals(Permittivity other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -604,12 +605,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(Permittivity other, Permittivity tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/PorousMediumPermeability.g.cs b/UnitsNet/GeneratedCode/Quantities/PorousMediumPermeability.g.cs index f52fe94bfb..1dda135c8e 100644 --- a/UnitsNet/GeneratedCode/Quantities/PorousMediumPermeability.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/PorousMediumPermeability.g.cs @@ -659,12 +659,13 @@ public int CompareTo(PorousMediumPermeability other) public bool Equals(PorousMediumPermeability other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -680,12 +681,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(PorousMediumPermeability other, PorousMediumPermeability tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/Power.g.cs b/UnitsNet/GeneratedCode/Quantities/Power.g.cs index 21373845f2..ee45a674fe 100644 --- a/UnitsNet/GeneratedCode/Quantities/Power.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Power.g.cs @@ -1056,12 +1056,13 @@ public int CompareTo(Power other) public bool Equals(Power other, decimal tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - decimal thisValue = this.Value; - decimal otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -1077,12 +1078,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(Power other, Power tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - decimal thisValue = this.Value; - decimal otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/PowerDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/PowerDensity.g.cs index ead2926ad6..2b66d23aeb 100644 --- a/UnitsNet/GeneratedCode/Quantities/PowerDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/PowerDensity.g.cs @@ -1397,12 +1397,13 @@ public int CompareTo(PowerDensity other) public bool Equals(PowerDensity other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -1418,12 +1419,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(PowerDensity other, PowerDensity tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/PowerRatio.g.cs b/UnitsNet/GeneratedCode/Quantities/PowerRatio.g.cs index f33d7b05f7..97e51c30d0 100644 --- a/UnitsNet/GeneratedCode/Quantities/PowerRatio.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/PowerRatio.g.cs @@ -607,12 +607,13 @@ public int CompareTo(PowerRatio other) public bool Equals(PowerRatio other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -628,12 +629,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(PowerRatio other, PowerRatio tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/Pressure.g.cs b/UnitsNet/GeneratedCode/Quantities/Pressure.g.cs index f07c8f541a..251a1e968e 100644 --- a/UnitsNet/GeneratedCode/Quantities/Pressure.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Pressure.g.cs @@ -1523,12 +1523,13 @@ public int CompareTo(Pressure other) public bool Equals(Pressure other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -1544,12 +1545,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(Pressure other, Pressure tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.g.cs index 8ae812e370..253ca8ae73 100644 --- a/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.g.cs @@ -841,12 +841,13 @@ public int CompareTo(PressureChangeRate other) public bool Equals(PressureChangeRate other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -862,12 +863,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(PressureChangeRate other, PressureChangeRate tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/Ratio.g.cs b/UnitsNet/GeneratedCode/Quantities/Ratio.g.cs index 9892a1ab74..72bddc57fe 100644 --- a/UnitsNet/GeneratedCode/Quantities/Ratio.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Ratio.g.cs @@ -675,12 +675,13 @@ public int CompareTo(Ratio other) public bool Equals(Ratio other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -696,12 +697,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(Ratio other, Ratio tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/RatioChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/RatioChangeRate.g.cs index 80076c3bea..6218bbc2a1 100644 --- a/UnitsNet/GeneratedCode/Quantities/RatioChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RatioChangeRate.g.cs @@ -599,12 +599,13 @@ public int CompareTo(RatioChangeRate other) public bool Equals(RatioChangeRate other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -620,12 +621,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(RatioChangeRate other, RatioChangeRate tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/ReactiveEnergy.g.cs b/UnitsNet/GeneratedCode/Quantities/ReactiveEnergy.g.cs index 5f3ac6ca76..59930fef92 100644 --- a/UnitsNet/GeneratedCode/Quantities/ReactiveEnergy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ReactiveEnergy.g.cs @@ -618,12 +618,13 @@ public int CompareTo(ReactiveEnergy other) public bool Equals(ReactiveEnergy other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -639,12 +640,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(ReactiveEnergy other, ReactiveEnergy tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/ReactivePower.g.cs b/UnitsNet/GeneratedCode/Quantities/ReactivePower.g.cs index 2d6527438e..0f530580e8 100644 --- a/UnitsNet/GeneratedCode/Quantities/ReactivePower.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ReactivePower.g.cs @@ -637,12 +637,13 @@ public int CompareTo(ReactivePower other) public bool Equals(ReactivePower other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -658,12 +659,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(ReactivePower other, ReactivePower tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/ReciprocalArea.g.cs b/UnitsNet/GeneratedCode/Quantities/ReciprocalArea.g.cs index 417904b46c..e4c4204eec 100644 --- a/UnitsNet/GeneratedCode/Quantities/ReciprocalArea.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ReciprocalArea.g.cs @@ -773,12 +773,13 @@ public int CompareTo(ReciprocalArea other) public bool Equals(ReciprocalArea other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -794,12 +795,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(ReciprocalArea other, ReciprocalArea tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/ReciprocalLength.g.cs b/UnitsNet/GeneratedCode/Quantities/ReciprocalLength.g.cs index 89226957f1..252b52e59e 100644 --- a/UnitsNet/GeneratedCode/Quantities/ReciprocalLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ReciprocalLength.g.cs @@ -754,12 +754,13 @@ public int CompareTo(ReciprocalLength other) public bool Equals(ReciprocalLength other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -775,12 +776,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(ReciprocalLength other, ReciprocalLength tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/RelativeHumidity.g.cs b/UnitsNet/GeneratedCode/Quantities/RelativeHumidity.g.cs index e3e524f782..e4ae0327a5 100644 --- a/UnitsNet/GeneratedCode/Quantities/RelativeHumidity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RelativeHumidity.g.cs @@ -580,12 +580,13 @@ public int CompareTo(RelativeHumidity other) public bool Equals(RelativeHumidity other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -601,12 +602,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(RelativeHumidity other, RelativeHumidity tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalAcceleration.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalAcceleration.g.cs index 2af78f9e65..4104792881 100644 --- a/UnitsNet/GeneratedCode/Quantities/RotationalAcceleration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RotationalAcceleration.g.cs @@ -637,12 +637,13 @@ public int CompareTo(RotationalAcceleration other) public bool Equals(RotationalAcceleration other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -658,12 +659,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(RotationalAcceleration other, RotationalAcceleration tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.g.cs index fe9967bca0..5ac639715b 100644 --- a/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.g.cs @@ -820,12 +820,13 @@ public int CompareTo(RotationalSpeed other) public bool Equals(RotationalSpeed other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -841,12 +842,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(RotationalSpeed other, RotationalSpeed tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.g.cs index 9cfbb07bf6..7946dbf28c 100644 --- a/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.g.cs @@ -1188,12 +1188,13 @@ public int CompareTo(RotationalStiffness other) public bool Equals(RotationalStiffness other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -1209,12 +1210,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(RotationalStiffness other, RotationalStiffness tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs index ef5edd1430..b1735ce0b8 100644 --- a/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs @@ -656,12 +656,13 @@ public int CompareTo(RotationalStiffnessPerLength other) public bool Equals(RotationalStiffnessPerLength other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -677,12 +678,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(RotationalStiffnessPerLength other, RotationalStiffnessPerLength tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/Scalar.g.cs b/UnitsNet/GeneratedCode/Quantities/Scalar.g.cs index baa01bd6e2..375740fe5c 100644 --- a/UnitsNet/GeneratedCode/Quantities/Scalar.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Scalar.g.cs @@ -580,12 +580,13 @@ public int CompareTo(Scalar other) public bool Equals(Scalar other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -601,12 +602,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(Scalar other, Scalar tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/SolidAngle.g.cs b/UnitsNet/GeneratedCode/Quantities/SolidAngle.g.cs index 3e03a1ae0f..05e620b8c6 100644 --- a/UnitsNet/GeneratedCode/Quantities/SolidAngle.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SolidAngle.g.cs @@ -583,12 +583,13 @@ public int CompareTo(SolidAngle other) public bool Equals(SolidAngle other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -604,12 +605,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(SolidAngle other, SolidAngle tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.g.cs index 6cc429804b..46fe41bc7f 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.g.cs @@ -1134,12 +1134,13 @@ public int CompareTo(SpecificEnergy other) public bool Equals(SpecificEnergy other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -1155,12 +1156,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(SpecificEnergy other, SpecificEnergy tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.g.cs index 7c641ed47b..e83e66dae4 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.g.cs @@ -732,12 +732,13 @@ public int CompareTo(SpecificEntropy other) public bool Equals(SpecificEntropy other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -753,12 +754,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(SpecificEntropy other, SpecificEntropy tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs index 7c8ea1941a..18e8e24d04 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs @@ -640,12 +640,13 @@ public int CompareTo(SpecificFuelConsumption other) public bool Equals(SpecificFuelConsumption other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -661,12 +662,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(SpecificFuelConsumption other, SpecificFuelConsumption tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs index 7c698584f3..b59b7621c1 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs @@ -618,12 +618,13 @@ public int CompareTo(SpecificVolume other) public bool Equals(SpecificVolume other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -639,12 +640,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(SpecificVolume other, SpecificVolume tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificWeight.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificWeight.g.cs index b70522683b..4f378ea920 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificWeight.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificWeight.g.cs @@ -887,12 +887,13 @@ public int CompareTo(SpecificWeight other) public bool Equals(SpecificWeight other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -908,12 +909,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(SpecificWeight other, SpecificWeight tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/Speed.g.cs b/UnitsNet/GeneratedCode/Quantities/Speed.g.cs index 3dcb691c4e..9fe30f34df 100644 --- a/UnitsNet/GeneratedCode/Quantities/Speed.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Speed.g.cs @@ -1212,12 +1212,13 @@ public int CompareTo(Speed other) public bool Equals(Speed other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -1233,12 +1234,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(Speed other, Speed tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/StandardVolumeFlow.g.cs b/UnitsNet/GeneratedCode/Quantities/StandardVolumeFlow.g.cs index 161cf86ef0..5635b16c1e 100644 --- a/UnitsNet/GeneratedCode/Quantities/StandardVolumeFlow.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/StandardVolumeFlow.g.cs @@ -732,12 +732,13 @@ public int CompareTo(StandardVolumeFlow other) public bool Equals(StandardVolumeFlow other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -753,12 +754,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(StandardVolumeFlow other, StandardVolumeFlow tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/Temperature.g.cs b/UnitsNet/GeneratedCode/Quantities/Temperature.g.cs index 4414f9de4a..a5e0c7cc10 100644 --- a/UnitsNet/GeneratedCode/Quantities/Temperature.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Temperature.g.cs @@ -702,12 +702,13 @@ public int CompareTo(Temperature other) public bool Equals(Temperature other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -723,12 +724,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(Temperature other, Temperature tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.g.cs index 0f48a297ff..fc77391e9f 100644 --- a/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.g.cs @@ -751,12 +751,13 @@ public int CompareTo(TemperatureChangeRate other) public bool Equals(TemperatureChangeRate other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -772,12 +773,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(TemperatureChangeRate other, TemperatureChangeRate tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs b/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs index 94afcc325d..c360176612 100644 --- a/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs @@ -732,12 +732,13 @@ public int CompareTo(TemperatureDelta other) public bool Equals(TemperatureDelta other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -753,12 +754,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(TemperatureDelta other, TemperatureDelta tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/TemperatureGradient.g.cs b/UnitsNet/GeneratedCode/Quantities/TemperatureGradient.g.cs index 3d5255c5b2..b5dcf10547 100644 --- a/UnitsNet/GeneratedCode/Quantities/TemperatureGradient.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/TemperatureGradient.g.cs @@ -637,12 +637,13 @@ public int CompareTo(TemperatureGradient other) public bool Equals(TemperatureGradient other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -658,12 +659,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(TemperatureGradient other, TemperatureGradient tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/ThermalConductivity.g.cs b/UnitsNet/GeneratedCode/Quantities/ThermalConductivity.g.cs index 92cef2d503..3d579a5d62 100644 --- a/UnitsNet/GeneratedCode/Quantities/ThermalConductivity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ThermalConductivity.g.cs @@ -602,12 +602,13 @@ public int CompareTo(ThermalConductivity other) public bool Equals(ThermalConductivity other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -623,12 +624,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(ThermalConductivity other, ThermalConductivity tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/ThermalResistance.g.cs b/UnitsNet/GeneratedCode/Quantities/ThermalResistance.g.cs index be9949bd06..78e8ff9110 100644 --- a/UnitsNet/GeneratedCode/Quantities/ThermalResistance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ThermalResistance.g.cs @@ -675,12 +675,13 @@ public int CompareTo(ThermalResistance other) public bool Equals(ThermalResistance other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -696,12 +697,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(ThermalResistance other, ThermalResistance tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/Torque.g.cs b/UnitsNet/GeneratedCode/Quantities/Torque.g.cs index f0d0874ec3..850017d7dc 100644 --- a/UnitsNet/GeneratedCode/Quantities/Torque.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Torque.g.cs @@ -1039,12 +1039,13 @@ public int CompareTo(Torque other) public bool Equals(Torque other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -1060,12 +1061,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(Torque other, Torque tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/TorquePerLength.g.cs b/UnitsNet/GeneratedCode/Quantities/TorquePerLength.g.cs index d35cd3daa4..c7ceaf0637 100644 --- a/UnitsNet/GeneratedCode/Quantities/TorquePerLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/TorquePerLength.g.cs @@ -963,12 +963,13 @@ public int CompareTo(TorquePerLength other) public bool Equals(TorquePerLength other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -984,12 +985,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(TorquePerLength other, TorquePerLength tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/Turbidity.g.cs b/UnitsNet/GeneratedCode/Quantities/Turbidity.g.cs index 985cfe683f..0c0551f1e1 100644 --- a/UnitsNet/GeneratedCode/Quantities/Turbidity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Turbidity.g.cs @@ -583,12 +583,13 @@ public int CompareTo(Turbidity other) public bool Equals(Turbidity other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -604,12 +605,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(Turbidity other, Turbidity tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/VitaminA.g.cs b/UnitsNet/GeneratedCode/Quantities/VitaminA.g.cs index fa668b06ea..baf20d4890 100644 --- a/UnitsNet/GeneratedCode/Quantities/VitaminA.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VitaminA.g.cs @@ -580,12 +580,13 @@ public int CompareTo(VitaminA other) public bool Equals(VitaminA other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -601,12 +602,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(VitaminA other, VitaminA tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/Volume.g.cs b/UnitsNet/GeneratedCode/Quantities/Volume.g.cs index 34e942af8f..c64f46f91a 100644 --- a/UnitsNet/GeneratedCode/Quantities/Volume.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Volume.g.cs @@ -1616,12 +1616,13 @@ public int CompareTo(Volume other) public bool Equals(Volume other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -1637,12 +1638,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(Volume other, Volume tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/VolumeConcentration.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumeConcentration.g.cs index 0587d0fe28..991cde53af 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumeConcentration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumeConcentration.g.cs @@ -944,12 +944,13 @@ public int CompareTo(VolumeConcentration other) public bool Equals(VolumeConcentration other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -965,12 +966,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(VolumeConcentration other, VolumeConcentration tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs index 3448d3b1c6..1575560297 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs @@ -1864,12 +1864,13 @@ public int CompareTo(VolumeFlow other) public bool Equals(VolumeFlow other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -1885,12 +1886,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(VolumeFlow other, VolumeFlow tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/VolumeFlowPerArea.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumeFlowPerArea.g.cs index 4bc0515f50..363bc1e180 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumeFlowPerArea.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumeFlowPerArea.g.cs @@ -599,12 +599,13 @@ public int CompareTo(VolumeFlowPerArea other) public bool Equals(VolumeFlowPerArea other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -620,12 +621,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(VolumeFlowPerArea other, VolumeFlowPerArea tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/VolumePerLength.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumePerLength.g.cs index 3064e671f7..c3c5d1005f 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumePerLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumePerLength.g.cs @@ -732,12 +732,13 @@ public int CompareTo(VolumePerLength other) public bool Equals(VolumePerLength other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -753,12 +754,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(VolumePerLength other, VolumePerLength tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs index 3af9069504..e5e7fa821b 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs @@ -735,12 +735,13 @@ public int CompareTo(VolumetricHeatCapacity other) public bool Equals(VolumetricHeatCapacity other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -756,12 +757,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(VolumetricHeatCapacity other, VolumetricHeatCapacity tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), diff --git a/UnitsNet/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs b/UnitsNet/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs index 0f6da74854..28149b6b1e 100644 --- a/UnitsNet/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs @@ -675,12 +675,13 @@ public int CompareTo(WarpingMomentOfInertia other) public bool Equals(WarpingMomentOfInertia other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: ComparisonType.Absolute); } /// @@ -696,12 +697,6 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(WarpingMomentOfInertia other, WarpingMomentOfInertia tolerance) { - if (tolerance < Zero) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = this.Value; - double otherValueInThisUnits = other.As(this.Unit); - return UnitsNet.Comparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit),