From e65c0d8ac3cbd5809322582cb7bf056c6a892806 Mon Sep 17 00:00:00 2001 From: lipchev Date: Sun, 27 Jul 2025 17:19:57 +0300 Subject: [PATCH 1/8] - refactored the IQuantity interface: removed the Equals with tolerance and the ToString overloads - introduced IAffineQuantity (see Temperature), ILogarithmicQuantity (see AmplitudeRatio) and ILinearQuantity (see Mass) - introduced extension methods for Equals with tolerance as well as Sum/Average --- .../UnitsNetGen/QuantityGenerator.cs | 241 ++++---- .../UnitsNetGen/UnitTestBaseClassGenerator.cs | 103 +++- CodeGen/JsonTypes/Quantity.cs | 5 +- Common/UnitDefinitions/Temperature.json | 1 + UnitsNet.Tests/CustomCode/TemperatureTests.cs | 254 +++++---- UnitsNet.Tests/CustomQuantities/HowMuch.cs | 19 +- ...orbedDoseOfIonizingRadiationTestsBase.g.cs | 41 +- .../TestsBase/AccelerationTestsBase.g.cs | 41 +- .../TestsBase/AmountOfSubstanceTestsBase.g.cs | 41 +- .../TestsBase/AmplitudeRatioTestsBase.g.cs | 45 +- .../TestsBase/AngleTestsBase.g.cs | 41 +- .../TestsBase/AreaDensityTestsBase.g.cs | 41 +- .../AreaMomentOfInertiaTestsBase.g.cs | 41 +- .../TestsBase/AreaTestsBase.g.cs | 41 +- .../TestsBase/BitRateTestsBase.g.cs | 41 +- ...BrakeSpecificFuelConsumptionTestsBase.g.cs | 41 +- ...oefficientOfThermalExpansionTestsBase.g.cs | 41 +- .../TestsBase/CompressibilityTestsBase.g.cs | 41 +- .../TestsBase/DensityTestsBase.g.cs | 41 +- .../TestsBase/DoseAreaProductTestsBase.g.cs | 41 +- .../TestsBase/DurationTestsBase.g.cs | 41 +- .../TestsBase/DynamicViscosityTestsBase.g.cs | 41 +- .../ElectricAdmittanceTestsBase.g.cs | 41 +- .../ElectricApparentEnergyTestsBase.g.cs | 41 +- .../ElectricApparentPowerTestsBase.g.cs | 41 +- .../ElectricCapacitanceTestsBase.g.cs | 41 +- .../ElectricChargeDensityTestsBase.g.cs | 41 +- .../TestsBase/ElectricChargeTestsBase.g.cs | 41 +- .../ElectricConductanceTestsBase.g.cs | 41 +- .../ElectricConductivityTestsBase.g.cs | 41 +- .../ElectricCurrentDensityTestsBase.g.cs | 41 +- .../ElectricCurrentGradientTestsBase.g.cs | 41 +- .../TestsBase/ElectricCurrentTestsBase.g.cs | 41 +- .../TestsBase/ElectricFieldTestsBase.g.cs | 41 +- .../TestsBase/ElectricImpedanceTestsBase.g.cs | 41 +- .../ElectricInductanceTestsBase.g.cs | 41 +- .../ElectricPotentialChangeRateTestsBase.g.cs | 41 +- .../TestsBase/ElectricPotentialTestsBase.g.cs | 41 +- .../TestsBase/ElectricReactanceTestsBase.g.cs | 41 +- .../ElectricReactiveEnergyTestsBase.g.cs | 41 +- .../ElectricReactivePowerTestsBase.g.cs | 41 +- .../ElectricResistanceTestsBase.g.cs | 41 +- .../ElectricResistivityTestsBase.g.cs | 41 +- ...ElectricSurfaceChargeDensityTestsBase.g.cs | 41 +- .../ElectricSusceptanceTestsBase.g.cs | 41 +- .../TestsBase/EnergyDensityTestsBase.g.cs | 41 +- .../TestsBase/EnergyTestsBase.g.cs | 41 +- .../TestsBase/EntropyTestsBase.g.cs | 41 +- .../TestsBase/FluidResistanceTestsBase.g.cs | 41 +- .../TestsBase/ForceChangeRateTestsBase.g.cs | 41 +- .../TestsBase/ForcePerLengthTestsBase.g.cs | 41 +- .../TestsBase/ForceTestsBase.g.cs | 41 +- .../TestsBase/FrequencyTestsBase.g.cs | 41 +- .../TestsBase/FuelEfficiencyTestsBase.g.cs | 41 +- .../TestsBase/HeatFluxTestsBase.g.cs | 41 +- .../HeatTransferCoefficientTestsBase.g.cs | 41 +- .../TestsBase/IlluminanceTestsBase.g.cs | 41 +- .../TestsBase/ImpulseTestsBase.g.cs | 41 +- .../TestsBase/InformationTestsBase.g.cs | 41 +- .../TestsBase/IrradianceTestsBase.g.cs | 41 +- .../TestsBase/IrradiationTestsBase.g.cs | 41 +- .../TestsBase/JerkTestsBase.g.cs | 41 +- .../KinematicViscosityTestsBase.g.cs | 41 +- .../TestsBase/LeakRateTestsBase.g.cs | 41 +- .../TestsBase/LengthTestsBase.g.cs | 41 +- .../TestsBase/LevelTestsBase.g.cs | 45 +- .../TestsBase/LinearDensityTestsBase.g.cs | 41 +- .../LinearPowerDensityTestsBase.g.cs | 41 +- .../TestsBase/LuminanceTestsBase.g.cs | 41 +- .../TestsBase/LuminosityTestsBase.g.cs | 41 +- .../TestsBase/LuminousFluxTestsBase.g.cs | 41 +- .../TestsBase/LuminousIntensityTestsBase.g.cs | 41 +- .../TestsBase/MagneticFieldTestsBase.g.cs | 41 +- .../TestsBase/MagneticFluxTestsBase.g.cs | 41 +- .../TestsBase/MagnetizationTestsBase.g.cs | 41 +- .../TestsBase/MassConcentrationTestsBase.g.cs | 41 +- .../TestsBase/MassFlowTestsBase.g.cs | 41 +- .../TestsBase/MassFluxTestsBase.g.cs | 41 +- .../TestsBase/MassFractionTestsBase.g.cs | 41 +- .../MassMomentOfInertiaTestsBase.g.cs | 41 +- .../TestsBase/MassTestsBase.g.cs | 41 +- .../TestsBase/MolalityTestsBase.g.cs | 41 +- .../TestsBase/MolarEnergyTestsBase.g.cs | 41 +- .../TestsBase/MolarEntropyTestsBase.g.cs | 41 +- .../TestsBase/MolarFlowTestsBase.g.cs | 41 +- .../TestsBase/MolarMassTestsBase.g.cs | 41 +- .../TestsBase/MolarityTestsBase.g.cs | 41 +- .../TestsBase/PermeabilityTestsBase.g.cs | 41 +- .../TestsBase/PermittivityTestsBase.g.cs | 41 +- .../PorousMediumPermeabilityTestsBase.g.cs | 41 +- .../TestsBase/PowerDensityTestsBase.g.cs | 41 +- .../TestsBase/PowerRatioTestsBase.g.cs | 45 +- .../TestsBase/PowerTestsBase.g.cs | 41 +- .../PressureChangeRateTestsBase.g.cs | 41 +- .../TestsBase/PressureTestsBase.g.cs | 41 +- .../RadiationEquivalentDoseRateTestsBase.g.cs | 41 +- .../RadiationEquivalentDoseTestsBase.g.cs | 41 +- .../TestsBase/RadiationExposureTestsBase.g.cs | 41 +- .../TestsBase/RadioactivityTestsBase.g.cs | 41 +- .../TestsBase/RatioChangeRateTestsBase.g.cs | 41 +- .../TestsBase/RatioTestsBase.g.cs | 41 +- .../TestsBase/ReciprocalAreaTestsBase.g.cs | 41 +- .../TestsBase/ReciprocalLengthTestsBase.g.cs | 41 +- .../TestsBase/RelativeHumidityTestsBase.g.cs | 41 +- .../RotationalAccelerationTestsBase.g.cs | 41 +- .../TestsBase/RotationalSpeedTestsBase.g.cs | 41 +- ...RotationalStiffnessPerLengthTestsBase.g.cs | 41 +- .../RotationalStiffnessTestsBase.g.cs | 41 +- .../TestsBase/ScalarTestsBase.g.cs | 41 +- .../TestsBase/SolidAngleTestsBase.g.cs | 41 +- .../TestsBase/SpecificEnergyTestsBase.g.cs | 41 +- .../TestsBase/SpecificEntropyTestsBase.g.cs | 41 +- .../SpecificFuelConsumptionTestsBase.g.cs | 41 +- .../TestsBase/SpecificVolumeTestsBase.g.cs | 41 +- .../TestsBase/SpecificWeightTestsBase.g.cs | 41 +- .../TestsBase/SpeedTestsBase.g.cs | 41 +- .../StandardVolumeFlowTestsBase.g.cs | 41 +- .../TemperatureChangeRateTestsBase.g.cs | 41 +- .../TestsBase/TemperatureDeltaTestsBase.g.cs | 41 +- .../TemperatureGradientTestsBase.g.cs | 41 +- .../TestsBase/TemperatureTestsBase.g.cs | 41 +- .../ThermalConductivityTestsBase.g.cs | 41 +- .../TestsBase/ThermalInsulanceTestsBase.g.cs | 41 +- .../TestsBase/ThermalResistanceTestsBase.g.cs | 41 +- .../TestsBase/TorqueTestsBase.g.cs | 41 +- .../TestsBase/TurbidityTestsBase.g.cs | 41 +- .../TestsBase/VitaminATestsBase.g.cs | 41 +- .../VolumeConcentrationTestsBase.g.cs | 41 +- .../TestsBase/VolumeFlowPerAreaTestsBase.g.cs | 41 +- .../TestsBase/VolumeFlowTestsBase.g.cs | 41 +- .../TestsBase/VolumePerLengthTestsBase.g.cs | 41 +- .../TestsBase/VolumeTestsBase.g.cs | 41 +- .../VolumetricHeatCapacityTestsBase.g.cs | 41 +- .../WarpingMomentOfInertiaTestsBase.g.cs | 41 +- UnitsNet.Tests/GeneratedQuantityCodeTests.cs | 10 +- UnitsNet.Tests/QuantityTests.cs | 74 --- .../Quantities/Temperature.extra.cs | 15 + UnitsNet/ExceptionHelper.cs | 32 ++ .../Extensions/AffineQuantityExtensions.cs | 187 +++++++ .../Extensions/LinearQuantityExtensions.cs | 274 ++++++++++ .../LogarithmicQuantityExtensions.cs | 516 ++++++++++++++++++ UnitsNet/Extensions/QuantityExtensions.cs | 139 +++++ .../AbsorbedDoseOfIonizingRadiation.g.cs | 126 +---- .../Quantities/Acceleration.g.cs | 126 +---- .../Quantities/AmountOfSubstance.g.cs | 126 +---- .../Quantities/AmplitudeRatio.g.cs | 133 +---- UnitsNet/GeneratedCode/Quantities/Angle.g.cs | 126 +---- UnitsNet/GeneratedCode/Quantities/Area.g.cs | 126 +---- .../GeneratedCode/Quantities/AreaDensity.g.cs | 126 +---- .../Quantities/AreaMomentOfInertia.g.cs | 126 +---- .../GeneratedCode/Quantities/BitRate.g.cs | 126 +---- .../BrakeSpecificFuelConsumption.g.cs | 126 +---- .../CoefficientOfThermalExpansion.g.cs | 126 +---- .../Quantities/Compressibility.g.cs | 126 +---- .../GeneratedCode/Quantities/Density.g.cs | 126 +---- .../Quantities/DoseAreaProduct.g.cs | 126 +---- .../GeneratedCode/Quantities/Duration.g.cs | 126 +---- .../Quantities/DynamicViscosity.g.cs | 126 +---- .../Quantities/ElectricAdmittance.g.cs | 126 +---- .../Quantities/ElectricApparentEnergy.g.cs | 126 +---- .../Quantities/ElectricApparentPower.g.cs | 126 +---- .../Quantities/ElectricCapacitance.g.cs | 126 +---- .../Quantities/ElectricCharge.g.cs | 126 +---- .../Quantities/ElectricChargeDensity.g.cs | 126 +---- .../Quantities/ElectricConductance.g.cs | 126 +---- .../Quantities/ElectricConductivity.g.cs | 126 +---- .../Quantities/ElectricCurrent.g.cs | 126 +---- .../Quantities/ElectricCurrentDensity.g.cs | 126 +---- .../Quantities/ElectricCurrentGradient.g.cs | 126 +---- .../Quantities/ElectricField.g.cs | 126 +---- .../Quantities/ElectricImpedance.g.cs | 126 +---- .../Quantities/ElectricInductance.g.cs | 126 +---- .../Quantities/ElectricPotential.g.cs | 126 +---- .../ElectricPotentialChangeRate.g.cs | 126 +---- .../Quantities/ElectricReactance.g.cs | 126 +---- .../Quantities/ElectricReactiveEnergy.g.cs | 126 +---- .../Quantities/ElectricReactivePower.g.cs | 126 +---- .../Quantities/ElectricResistance.g.cs | 126 +---- .../Quantities/ElectricResistivity.g.cs | 126 +---- .../ElectricSurfaceChargeDensity.g.cs | 126 +---- .../Quantities/ElectricSusceptance.g.cs | 126 +---- UnitsNet/GeneratedCode/Quantities/Energy.g.cs | 126 +---- .../Quantities/EnergyDensity.g.cs | 126 +---- .../GeneratedCode/Quantities/Entropy.g.cs | 126 +---- .../Quantities/FluidResistance.g.cs | 126 +---- UnitsNet/GeneratedCode/Quantities/Force.g.cs | 126 +---- .../Quantities/ForceChangeRate.g.cs | 126 +---- .../Quantities/ForcePerLength.g.cs | 126 +---- .../GeneratedCode/Quantities/Frequency.g.cs | 126 +---- .../Quantities/FuelEfficiency.g.cs | 126 +---- .../GeneratedCode/Quantities/HeatFlux.g.cs | 126 +---- .../Quantities/HeatTransferCoefficient.g.cs | 126 +---- .../GeneratedCode/Quantities/Illuminance.g.cs | 126 +---- .../GeneratedCode/Quantities/Impulse.g.cs | 126 +---- .../GeneratedCode/Quantities/Information.g.cs | 126 +---- .../GeneratedCode/Quantities/Irradiance.g.cs | 126 +---- .../GeneratedCode/Quantities/Irradiation.g.cs | 126 +---- UnitsNet/GeneratedCode/Quantities/Jerk.g.cs | 126 +---- .../Quantities/KinematicViscosity.g.cs | 126 +---- .../GeneratedCode/Quantities/LeakRate.g.cs | 126 +---- UnitsNet/GeneratedCode/Quantities/Length.g.cs | 126 +---- UnitsNet/GeneratedCode/Quantities/Level.g.cs | 133 +---- .../Quantities/LinearDensity.g.cs | 126 +---- .../Quantities/LinearPowerDensity.g.cs | 126 +---- .../GeneratedCode/Quantities/Luminance.g.cs | 126 +---- .../GeneratedCode/Quantities/Luminosity.g.cs | 126 +---- .../Quantities/LuminousFlux.g.cs | 126 +---- .../Quantities/LuminousIntensity.g.cs | 126 +---- .../Quantities/MagneticField.g.cs | 126 +---- .../Quantities/MagneticFlux.g.cs | 126 +---- .../Quantities/Magnetization.g.cs | 126 +---- UnitsNet/GeneratedCode/Quantities/Mass.g.cs | 126 +---- .../Quantities/MassConcentration.g.cs | 126 +---- .../GeneratedCode/Quantities/MassFlow.g.cs | 126 +---- .../GeneratedCode/Quantities/MassFlux.g.cs | 126 +---- .../Quantities/MassFraction.g.cs | 126 +---- .../Quantities/MassMomentOfInertia.g.cs | 126 +---- .../GeneratedCode/Quantities/Molality.g.cs | 126 +---- .../GeneratedCode/Quantities/MolarEnergy.g.cs | 126 +---- .../Quantities/MolarEntropy.g.cs | 126 +---- .../GeneratedCode/Quantities/MolarFlow.g.cs | 126 +---- .../GeneratedCode/Quantities/MolarMass.g.cs | 126 +---- .../GeneratedCode/Quantities/Molarity.g.cs | 126 +---- .../Quantities/Permeability.g.cs | 126 +---- .../Quantities/Permittivity.g.cs | 126 +---- .../Quantities/PorousMediumPermeability.g.cs | 126 +---- UnitsNet/GeneratedCode/Quantities/Power.g.cs | 126 +---- .../Quantities/PowerDensity.g.cs | 126 +---- .../GeneratedCode/Quantities/PowerRatio.g.cs | 133 +---- .../GeneratedCode/Quantities/Pressure.g.cs | 126 +---- .../Quantities/PressureChangeRate.g.cs | 126 +---- .../Quantities/RadiationEquivalentDose.g.cs | 126 +---- .../RadiationEquivalentDoseRate.g.cs | 126 +---- .../Quantities/RadiationExposure.g.cs | 126 +---- .../Quantities/Radioactivity.g.cs | 126 +---- UnitsNet/GeneratedCode/Quantities/Ratio.g.cs | 126 +---- .../Quantities/RatioChangeRate.g.cs | 126 +---- .../Quantities/ReciprocalArea.g.cs | 126 +---- .../Quantities/ReciprocalLength.g.cs | 126 +---- .../Quantities/RelativeHumidity.g.cs | 126 +---- .../Quantities/RotationalAcceleration.g.cs | 126 +---- .../Quantities/RotationalSpeed.g.cs | 126 +---- .../Quantities/RotationalStiffness.g.cs | 126 +---- .../RotationalStiffnessPerLength.g.cs | 126 +---- UnitsNet/GeneratedCode/Quantities/Scalar.g.cs | 126 +---- .../GeneratedCode/Quantities/SolidAngle.g.cs | 126 +---- .../Quantities/SpecificEnergy.g.cs | 126 +---- .../Quantities/SpecificEntropy.g.cs | 126 +---- .../Quantities/SpecificFuelConsumption.g.cs | 126 +---- .../Quantities/SpecificVolume.g.cs | 126 +---- .../Quantities/SpecificWeight.g.cs | 126 +---- UnitsNet/GeneratedCode/Quantities/Speed.g.cs | 126 +---- .../Quantities/StandardVolumeFlow.g.cs | 126 +---- .../GeneratedCode/Quantities/Temperature.g.cs | 125 +---- .../Quantities/TemperatureChangeRate.g.cs | 126 +---- .../Quantities/TemperatureDelta.g.cs | 126 +---- .../Quantities/TemperatureGradient.g.cs | 126 +---- .../Quantities/ThermalConductivity.g.cs | 126 +---- .../Quantities/ThermalInsulance.g.cs | 126 +---- .../Quantities/ThermalResistance.g.cs | 126 +---- UnitsNet/GeneratedCode/Quantities/Torque.g.cs | 126 +---- .../GeneratedCode/Quantities/Turbidity.g.cs | 126 +---- .../GeneratedCode/Quantities/VitaminA.g.cs | 126 +---- UnitsNet/GeneratedCode/Quantities/Volume.g.cs | 126 +---- .../Quantities/VolumeConcentration.g.cs | 126 +---- .../GeneratedCode/Quantities/VolumeFlow.g.cs | 126 +---- .../Quantities/VolumeFlowPerArea.g.cs | 126 +---- .../Quantities/VolumePerLength.g.cs | 126 +---- .../Quantities/VolumetricHeatCapacity.g.cs | 126 +---- .../Quantities/WarpingMomentOfInertia.g.cs | 126 +---- UnitsNet/IArithmeticQuantity.cs | 56 +- UnitsNet/IQuantity.cs | 212 ++++--- UnitsNet/QuantityTypeConverter.cs | 12 +- UnitsNet/UnitMath.cs | 132 ++--- 274 files changed, 7524 insertions(+), 16166 deletions(-) create mode 100644 UnitsNet/ExceptionHelper.cs create mode 100644 UnitsNet/Extensions/AffineQuantityExtensions.cs create mode 100644 UnitsNet/Extensions/LinearQuantityExtensions.cs create mode 100644 UnitsNet/Extensions/LogarithmicQuantityExtensions.cs create mode 100644 UnitsNet/Extensions/QuantityExtensions.cs diff --git a/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs b/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs index eea1a6378a..d2ff4a76f7 100644 --- a/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs +++ b/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs @@ -63,8 +63,62 @@ namespace UnitsNet Writer.WL(@$" [DataContract] [DebuggerTypeProxy(typeof(QuantityDisplay))] - public readonly partial struct {_quantity.Name} : - {(_quantity.GenerateArithmetic ? "IArithmeticQuantity" : "IQuantity")}<{_quantity.Name}, {_unitEnumName}>,"); + public readonly partial struct {_quantity.Name} :"); + GenerateInterfaceExtensions(); + + Writer.WL($@" + {{ + /// + /// The numeric value this quantity was constructed with. + /// + [DataMember(Name = ""Value"", Order = 1)] + private readonly double _value; + + /// + /// The unit this quantity was constructed with. + /// + [DataMember(Name = ""Unit"", Order = 2)] + private readonly {_unitEnumName}? _unit; +"); + GenerateQuantityInfo(); + GenerateStaticConstructor(); + GenerateInstanceConstructors(); + GenerateStaticProperties(); + GenerateProperties(); + GenerateConversionProperties(); + GenerateStaticMethods(); + GenerateStaticFactoryMethods(); + GenerateStaticParseMethods(); + GenerateArithmeticOperators(); + GenerateRelationalOperators(); + GenerateEqualityAndComparison(); + GenerateConversionMethods(); + GenerateToString(); + + Writer.WL($@" + }} +}}"); + return Writer.ToString(); + } + + private void GenerateInterfaceExtensions() + { + // generate the base interface (either IVectorQuantity, IAffineQuantity or ILogarithmicQuantity) + if (_quantity.Logarithmic) + { + Writer.WL(@$" + ILogarithmicQuantity<{_quantity.Name}, {_unitEnumName}>,"); + } + else if (!string.IsNullOrEmpty(_quantity.AffineOffsetType)) + { + Writer.WL(@$" + IAffineQuantity<{_quantity.Name}, {_unitEnumName}, {_quantity.AffineOffsetType}>,"); + } + else // the default quantity type implements the IVectorQuantity interface + { + Writer.WL(@$" + IArithmeticQuantity<{_quantity.Name}, {_unitEnumName}>,"); + } if (_quantity.Relations.Any(r => r.Operator is "*" or "/")) { @@ -94,7 +148,6 @@ namespace UnitsNet Writer.WL(@$" #endif"); } - Writer.WL(@$" #if NET7_0_OR_GREATER IComparisonOperators<{_quantity.Name}, {_quantity.Name}, bool>, @@ -104,42 +157,8 @@ namespace UnitsNet IComparable<{_quantity.Name}>, IEquatable<{_quantity.Name}>, IFormattable"); - - Writer.WL($@" - {{ - /// - /// The numeric value this quantity was constructed with. - /// - [DataMember(Name = ""Value"", Order = 1)] - private readonly double _value; - - /// - /// The unit this quantity was constructed with. - /// - [DataMember(Name = ""Unit"", Order = 2)] - private readonly {_unitEnumName}? _unit; -"); - GenerateQuantityInfo(); - GenerateStaticConstructor(); - GenerateInstanceConstructors(); - GenerateStaticProperties(); - GenerateProperties(); - GenerateConversionProperties(); - GenerateStaticMethods(); - GenerateStaticFactoryMethods(); - GenerateStaticParseMethods(); - GenerateArithmeticOperators(); - GenerateRelationalOperators(); - GenerateEqualityAndComparison(); - GenerateConversionMethods(); - GenerateToString(); - - Writer.WL($@" - }} -}}"); - return Writer.ToString(); } - + private void GenerateQuantityInfo() { var quantityInfoClassName = $"{_quantity.Name}Info"; @@ -323,12 +342,12 @@ private void GenerateStaticProperties() /// public static {_quantity.Name} Zero => Info.Zero; "); - - if (_quantity.GenerateArithmetic) + + if (_quantity.Logarithmic) { Writer.WL($@" - /// - public static {_quantity.Name} AdditiveIdentity => Zero; + /// + public static double LogarithmicScalingFactor {{get;}} = {10 * _quantity.LogarithmicScalingFactor}; "); } @@ -372,6 +391,21 @@ private void GenerateProperties() [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo<{_unitEnumName}> IQuantity<{_unitEnumName}>.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo<{_quantity.Name}> IQuantityInstance<{_quantity.Name}>.QuantityInfo => Info; +#endif +"); + if (_quantity.Logarithmic) + { + Writer.WL($@" +#if NETSTANDARD2_0 + double ILogarithmicQuantity<{_quantity.Name}>.LogarithmicScalingFactor => LogarithmicScalingFactor; +#endif +"); + } + + Writer.WL($@" #endregion #endregion @@ -658,7 +692,7 @@ public static bool TryParseUnit([NotNullWhen(true)]string? str, IFormatProvider? private void GenerateArithmeticOperators() { - if (!_quantity.GenerateArithmetic) return; + if (_quantity.IsAffine) return; // Logarithmic units required different arithmetic if (_quantity.Logarithmic) @@ -919,6 +953,15 @@ public bool Equals({_quantity.Name} other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current {_quantity.Name}. + public override int GetHashCode() + {{ + return new {{ Info.Name, Value, Unit }}.GetHashCode(); + }} + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -955,88 +998,6 @@ public int CompareTo({_quantity.Name} other) return _value.CompareTo(other.ToUnit(this.Unit).Value); }} - /// - /// - /// Compare equality to another {_quantity.Name} within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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, double tolerance, ComparisonType comparisonType) - {{ - if (tolerance < 0) - throw new ArgumentOutOfRangeException(nameof(tolerance), ""Tolerance must be greater than or equal to 0.""); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: 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) - {{ - 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. - /// - /// A hash code for the current {_quantity.Name}. - public override int GetHashCode() - {{ - return new {{ Info.Name, Value, Unit }}.GetHashCode(); - }} - #endregion "); } @@ -1061,6 +1022,15 @@ public double As({_unitEnumName} unit) Writer.WL( $@" + /// + public double As(UnitKey unitKey) + {{ + return As(unitKey.ToUnit<{_unitEnumName}>()); + }} +"); + + Writer.WL( $@" + /// public double As(UnitSystem unitSystem) {{ @@ -1222,27 +1192,6 @@ public override string ToString() return ToString(null, null); }} - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - {{ - return ToString(null, provider); - }} - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - {{ - return ToString(format, null); - }} - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/CodeGen/Generators/UnitsNetGen/UnitTestBaseClassGenerator.cs b/CodeGen/Generators/UnitsNetGen/UnitTestBaseClassGenerator.cs index ba43729679..6504e3eb85 100644 --- a/CodeGen/Generators/UnitsNetGen/UnitTestBaseClassGenerator.cs +++ b/CodeGen/Generators/UnitsNetGen/UnitTestBaseClassGenerator.cs @@ -868,7 +868,7 @@ public void LogarithmicArithmeticOperators() protected abstract void AssertLogarithmicSubtraction(); "); } - else if (_quantity.GenerateArithmetic) + else if (!_quantity.IsAffine) { Writer.WL($@" [Fact] @@ -978,35 +978,104 @@ public void Equals_Null_ReturnsFalse() }} [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() {{ - var v = {_quantity.Name}.From{_baseUnit.PluralName}(1); - Assert.True(v.Equals({_quantity.Name}.From{_baseUnit.PluralName}(1), {_baseUnit.PluralName}Tolerance, ComparisonType.Relative)); - Assert.False(v.Equals({_quantity.Name}.Zero, {_baseUnit.PluralName}Tolerance, ComparisonType.Relative)); - Assert.True({_quantity.Name}.From{_baseUnit.PluralName}(100).Equals({_quantity.Name}.From{_baseUnit.PluralName}(120), 0.3, ComparisonType.Relative)); - Assert.False({_quantity.Name}.From{_baseUnit.PluralName}(100).Equals({_quantity.Name}.From{_baseUnit.PluralName}(120), 0.1, ComparisonType.Relative)); + {_quantity.Name} {baseUnitVariableName} = {_quantity.Name}.From{_baseUnit.PluralName}(1); + Assert.False({baseUnitVariableName}.Equals(new object())); }} [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() + {{ + {_quantity.Name} {baseUnitVariableName} = {_quantity.Name}.From{_baseUnit.PluralName}(1); + Assert.False({baseUnitVariableName}.Equals(null)); + }} +"); + var differenceResultType = _quantity.AffineOffsetType ?? _quantity.Name; + if (_quantity.Logarithmic) + { + Writer.WL($@" + + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) {{ - var v = {_quantity.Name}.From{_baseUnit.PluralName}(1); - Assert.Throws(() => v.Equals({_quantity.Name}.From{_baseUnit.PluralName}(1), -1, ComparisonType.Relative)); + var quantity = {_quantity.Name}.From{_baseUnit.PluralName}(firstValue); + var otherQuantity = {_quantity.Name}.From{_baseUnit.PluralName}(secondValue); + {differenceResultType} maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, {differenceResultType}.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); + // note: it's currently not possible to test this due to the rounding error from (quantity - otherQuantity) + // Assert.True(quantity.Equals(otherQuantity, maxTolerance)); }} [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + public void Equals_WithNegativeTolerance_DoesNotThrowArgumentOutOfRangeException() {{ - {_quantity.Name} {baseUnitVariableName} = {_quantity.Name}.From{_baseUnit.PluralName}(1); - Assert.False({baseUnitVariableName}.Equals(new object())); + // note: unlike with vector quantities- a small tolerance maybe positive in one unit and negative in another + var quantity = {_quantity.Name}.From{_baseUnit.PluralName}(1); + var negativeTolerance = {_quantity.Name}.From{_baseUnit.PluralName}(-1); + Assert.True(quantity.Equals(quantity, negativeTolerance)); }} +"); + } + else // quantities with a linear scale + { + Writer.WL($@" + + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + {{ + var quantity = {_quantity.Name}.From{_baseUnit.PluralName}(firstValue); + var otherQuantity = {_quantity.Name}.From{_baseUnit.PluralName}(secondValue); + {differenceResultType} maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, {differenceResultType}.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); + }} +"); + if (_quantity.IsAffine) + { + Writer.WL($@" [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() {{ - {_quantity.Name} {baseUnitVariableName} = {_quantity.Name}.From{_baseUnit.PluralName}(1); - Assert.False({baseUnitVariableName}.Equals(null)); + var quantity = {_quantity.Name}.From{_baseUnit.PluralName}(1); + {differenceResultType} negativeTolerance = quantity - {_quantity.Name}.From{_baseUnit.PluralName}(2); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); }} +"); + } + else // vector quantities + { + Writer.WL($@" + + [Fact] + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() + {{ + var quantity = {_quantity.Name}.From{_baseUnit.PluralName}(1); + var negativeTolerance = {_quantity.Name}.From{_baseUnit.PluralName}(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); + }} +"); + } + } + + Writer.WL($@" [Fact] public void HasAtLeastOneAbbreviationSpecified() @@ -1100,7 +1169,7 @@ public void GetHashCode_Equals() }} "); - if (_quantity.GenerateArithmetic) + if (!_quantity.IsAffine) { Writer.WL($@" [Theory] diff --git a/CodeGen/JsonTypes/Quantity.cs b/CodeGen/JsonTypes/Quantity.cs index f471225ad8..ac92ed51d8 100644 --- a/CodeGen/JsonTypes/Quantity.cs +++ b/CodeGen/JsonTypes/Quantity.cs @@ -1,4 +1,4 @@ -// Licensed under MIT No Attribution, see LICENSE file at the root. +// 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; @@ -14,7 +14,10 @@ internal record Quantity public BaseDimensions BaseDimensions = new(); // Default to empty public string BaseUnit = null!; + [Obsolete] public bool GenerateArithmetic = true; + public string? AffineOffsetType; + public bool IsAffine => !string.IsNullOrEmpty(AffineOffsetType); public bool Logarithmic = false; public int LogarithmicScalingFactor = 1; public string Name = null!; diff --git a/Common/UnitDefinitions/Temperature.json b/Common/UnitDefinitions/Temperature.json index c782600ae7..625bffa81e 100644 --- a/Common/UnitDefinitions/Temperature.json +++ b/Common/UnitDefinitions/Temperature.json @@ -3,6 +3,7 @@ "BaseUnit": "Kelvin", "XmlDocSummary": "A temperature is a numerical measure of hot or cold. Its measurement is by detection of heat radiation or particle velocity or kinetic energy, or by the bulk behavior of a thermometric material. It may be calibrated in any of various temperature scales, Celsius, Fahrenheit, Kelvin, etc. The fundamental physical definition of temperature is provided by thermodynamics.", "GenerateArithmetic": false, + "AffineOffsetType": "TemperatureDelta", "BaseDimensions": { "Θ": 1 }, diff --git a/UnitsNet.Tests/CustomCode/TemperatureTests.cs b/UnitsNet.Tests/CustomCode/TemperatureTests.cs index 40dbd962f7..c71845b64d 100644 --- a/UnitsNet.Tests/CustomCode/TemperatureTests.cs +++ b/UnitsNet.Tests/CustomCode/TemperatureTests.cs @@ -1,137 +1,151 @@ // 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.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using Xunit; +namespace UnitsNet.Tests; -namespace UnitsNet.Tests +public class TemperatureTests : TemperatureTestsBase { - public class TemperatureTests : TemperatureTestsBase - { - protected override double DegreesCelsiusInOneKelvin => -272.15; + protected override double DegreesCelsiusInOneKelvin => -272.15; + + protected override double DegreesDelisleInOneKelvin => 558.2249999999999; - protected override double DegreesDelisleInOneKelvin => 558.2249999999999; + protected override double DegreesFahrenheitInOneKelvin => -457.87; - protected override double DegreesFahrenheitInOneKelvin => -457.87; + protected override double DegreesNewtonInOneKelvin => -89.8095; - protected override double DegreesNewtonInOneKelvin => -89.8095; + protected override double DegreesRankineInOneKelvin => 1.8; - protected override double DegreesRankineInOneKelvin => 1.8; + protected override double DegreesReaumurInOneKelvin => -217.72; - protected override double DegreesReaumurInOneKelvin => -217.72; + protected override double DegreesRoemerInOneKelvin => -135.378750000; - protected override double DegreesRoemerInOneKelvin => -135.378750000; + protected override double KelvinsInOneKelvin => 1; - protected override double KelvinsInOneKelvin => 1; + protected override double MillidegreesCelsiusInOneKelvin => -272150; - protected override double MillidegreesCelsiusInOneKelvin => -272150; + protected override double SolarTemperaturesInOneKelvin => 1.73070266528210E-04; + + [Fact] + public void AllBaseQuantityUnitsAreBaseUnits() + { + Assert.All(Temperature.Info.UnitInfos, unitInfo => Assert.Equal(new BaseUnits(temperature: unitInfo.Value), unitInfo.BaseUnits)); + } - protected override double SolarTemperaturesInOneKelvin => 1.73070266528210E-04; + public static IEnumerable DividedByTemperatureDeltaEqualsTemperatureData { get; } = + [ + [(10d, TemperatureUnit.DegreeCelsius), 1d, (10d, TemperatureUnit.DegreeCelsius)], + [(10d, TemperatureUnit.DegreeCelsius), 5d, (2d, TemperatureUnit.DegreeCelsius)], + [(10d, TemperatureUnit.DegreeCelsius), -10d, (-1d, TemperatureUnit.DegreeCelsius)], + [(10d, TemperatureUnit.DegreeFahrenheit), 1d, (10d, TemperatureUnit.DegreeFahrenheit)], + [(10d, TemperatureUnit.DegreeFahrenheit), 5d, (2d, TemperatureUnit.DegreeFahrenheit)], + [(10d, TemperatureUnit.DegreeFahrenheit), -10d, (-1d, TemperatureUnit.DegreeFahrenheit)] + ]; + + [Theory] + [MemberData(nameof(DividedByTemperatureDeltaEqualsTemperatureData))] + public void DividedByTemperatureDeltaEqualsTemperature((double Value, TemperatureUnit Unit) temperature, double divisor, + (double Value, TemperatureUnit Unit) expected) + { + var temp = new Temperature(temperature.Value, temperature.Unit); + var expectedTemperature = new Temperature(expected.Value, expected.Unit); + + Temperature result = temp.Divide(divisor, temperature.Unit); + + Assert.True(expectedTemperature.Equals(result, Temperature.FromKelvins(KelvinsTolerance))); + } + + public static IEnumerable MultiplyByTemperatureDeltaEqualsTemperatureData { get; } = + [ + [(10d, TemperatureUnit.DegreeCelsius), 0d, (0d, TemperatureUnit.DegreeCelsius)], + [(10d, TemperatureUnit.DegreeCelsius), 5d, (50d, TemperatureUnit.DegreeCelsius)], + [(10d, TemperatureUnit.DegreeCelsius), -5d, (-50d, TemperatureUnit.DegreeCelsius)], + [(10d, TemperatureUnit.DegreeFahrenheit), 0d, (0d, TemperatureUnit.DegreeFahrenheit)], + [(10d, TemperatureUnit.DegreeFahrenheit), 5d, (50d, TemperatureUnit.DegreeFahrenheit)], + [(10d, TemperatureUnit.DegreeFahrenheit), -5d, (-50d, TemperatureUnit.DegreeFahrenheit)] + ]; + + [Theory] + [MemberData(nameof(MultiplyByTemperatureDeltaEqualsTemperatureData))] + public void MultiplyByTemperatureDeltaEqualsTemperature((double Value, TemperatureUnit Unit) temperature, double factor, + (double Value, TemperatureUnit Unit) expected) + { + var temp = new Temperature(temperature.Value, temperature.Unit); + var expectedTemperature = new Temperature(expected.Value, expected.Unit); - [Fact] - public void AllBaseQuantityUnitsAreBaseUnits() - { - Assert.All(Temperature.Info.UnitInfos, unitInfo => Assert.Equal(new BaseUnits(temperature: unitInfo.Value), unitInfo.BaseUnits)); - } - - public static IEnumerable DividedByTemperatureDeltaEqualsTemperatureData { get; } = - new List - { - new object[] { Temperature.FromDegreesCelsius(10), 1, Temperature.FromDegreesCelsius(10) }, - new object[] { Temperature.FromDegreesCelsius(10), 5, Temperature.FromDegreesCelsius(2) }, - new object[] { Temperature.FromDegreesCelsius(10), -10, Temperature.FromDegreesCelsius(-1) }, - new object[] { Temperature.FromDegreesFahrenheit(10), 1, Temperature.FromDegreesFahrenheit(10) }, - new object[] { Temperature.FromDegreesFahrenheit(10), 5, Temperature.FromDegreesFahrenheit(2) }, - new object[] { Temperature.FromDegreesFahrenheit(10), -10, Temperature.FromDegreesFahrenheit(-1) } - }; - - [SuppressMessage("ReSharper", "ImpureMethodCallOnReadonlyValueField", - Justification = "R# incorrectly identifies method as impure, due to internal method calls.")] - [Theory] - [MemberData(nameof(DividedByTemperatureDeltaEqualsTemperatureData))] - public void DividedByTemperatureDeltaEqualsTemperature(Temperature temperature, int divisor, Temperature expected) - { - Temperature resultTemp = temperature.Divide(divisor, temperature.Unit); - Assert.True(expected.Equals(resultTemp, 1e-5, ComparisonType.Absolute)); - } - - public static IEnumerable MultiplyByTemperatureDeltaEqualsTemperatureData { get; } = - new List - { - new object[] { Temperature.FromDegreesCelsius(10), 0, Temperature.FromDegreesCelsius(0) }, - new object[] { Temperature.FromDegreesCelsius(10), 5, Temperature.FromDegreesCelsius(50) }, - new object[] { Temperature.FromDegreesCelsius(10), -5, Temperature.FromDegreesCelsius(-50) }, - new object[] { Temperature.FromDegreesFahrenheit(10), 0, Temperature.FromDegreesFahrenheit(0) }, - new object[] { Temperature.FromDegreesFahrenheit(10), 5, Temperature.FromDegreesFahrenheit(50) }, - new object[] { Temperature.FromDegreesFahrenheit(10), -5, Temperature.FromDegreesFahrenheit(-50) } - }; - - [SuppressMessage("ReSharper", "ImpureMethodCallOnReadonlyValueField", - Justification = "R# incorrectly identifies method as impure, due to internal method calls.")] - [Theory] - [MemberData(nameof(MultiplyByTemperatureDeltaEqualsTemperatureData))] - public void MultiplyByTemperatureDeltaEqualsTemperature(Temperature temperature, int factor, Temperature expected) - { - Temperature resultTemp = temperature.Multiply(factor, temperature.Unit); - Assert.True(expected.Equals(resultTemp, 1e-5, ComparisonType.Absolute)); - } - - public static IEnumerable TemperatureDeltaPlusTemperatureEqualsTemperatureData { get; } = - new List - { - new object[] { Temperature.FromDegreesCelsius(-10), TemperatureDelta.FromDegreesCelsius(0), Temperature.FromDegreesCelsius(-10) }, - new object[] { Temperature.FromDegreesCelsius(-10), TemperatureDelta.FromDegreesCelsius(10), Temperature.FromDegreesCelsius(0) }, - new object[] { Temperature.FromDegreesCelsius(-10), TemperatureDelta.FromDegreesCelsius(20), Temperature.FromDegreesCelsius(10) }, - new object[] { Temperature.FromDegreesFahrenheit(-10), TemperatureDelta.FromDegreesFahrenheit(0), Temperature.FromDegreesFahrenheit(-10) }, - new object[] { Temperature.FromDegreesFahrenheit(-10), TemperatureDelta.FromDegreesFahrenheit(10), Temperature.FromDegreesFahrenheit(0) }, - new object[] { Temperature.FromDegreesFahrenheit(-10), TemperatureDelta.FromDegreesFahrenheit(20), Temperature.FromDegreesFahrenheit(10) } - }; - - [Theory] - [MemberData(nameof(TemperatureDeltaPlusTemperatureEqualsTemperatureData))] - public void TemperatureDeltaPlusTemperatureEqualsTemperature(Temperature temperature, TemperatureDelta delta, Temperature expected) - { - Temperature resultTemp = delta + temperature; - Assert.True(expected.Equals(resultTemp, 1e-5, ComparisonType.Absolute)); - } - - public static IEnumerable TemperatureMinusTemperatureDeltaEqualsTemperatureData { get; } = - new List - { - new object[] { Temperature.FromDegreesCelsius(20), TemperatureDelta.FromDegreesCelsius(10), Temperature.FromDegreesCelsius(10) }, - new object[] { Temperature.FromDegreesCelsius(20), TemperatureDelta.FromDegreesCelsius(20), Temperature.FromDegreesCelsius(0) }, - new object[] { Temperature.FromDegreesCelsius(20), TemperatureDelta.FromDegreesCelsius(30), Temperature.FromDegreesCelsius(-10) }, - new object[] { Temperature.FromDegreesFahrenheit(20), TemperatureDelta.FromDegreesFahrenheit(10), Temperature.FromDegreesFahrenheit(10) }, - new object[] { Temperature.FromDegreesFahrenheit(20), TemperatureDelta.FromDegreesFahrenheit(20), Temperature.FromDegreesFahrenheit(0) }, - new object[] { Temperature.FromDegreesFahrenheit(20), TemperatureDelta.FromDegreesFahrenheit(30), Temperature.FromDegreesFahrenheit(-10) } - }; - - [Theory] - [MemberData(nameof(TemperatureMinusTemperatureDeltaEqualsTemperatureData))] - public void TemperatureMinusTemperatureDeltaEqualsTemperature(Temperature temperature, TemperatureDelta delta, Temperature expected) - { - Temperature resultTemp = temperature - delta; - Assert.True(expected.Equals(resultTemp, 1e-5, ComparisonType.Absolute)); - } - - public static IEnumerable TemperaturePlusTemperatureDeltaEqualsTemperatureData { get; } = - new List - { - new object[] { Temperature.FromDegreesCelsius(-10), TemperatureDelta.FromDegreesCelsius(0), Temperature.FromDegreesCelsius(-10) }, - new object[] { Temperature.FromDegreesCelsius(-10), TemperatureDelta.FromDegreesCelsius(10), Temperature.FromDegreesCelsius(0) }, - new object[] { Temperature.FromDegreesCelsius(-10), TemperatureDelta.FromDegreesCelsius(20), Temperature.FromDegreesCelsius(10) }, - new object[] { Temperature.FromDegreesFahrenheit(-10), TemperatureDelta.FromDegreesFahrenheit(0), Temperature.FromDegreesFahrenheit(-10) }, - new object[] { Temperature.FromDegreesFahrenheit(-10), TemperatureDelta.FromDegreesFahrenheit(10), Temperature.FromDegreesFahrenheit(0) }, - new object[] { Temperature.FromDegreesFahrenheit(-10), TemperatureDelta.FromDegreesFahrenheit(20), Temperature.FromDegreesFahrenheit(10) } - }; - - [Theory] - [MemberData(nameof(TemperaturePlusTemperatureDeltaEqualsTemperatureData))] - public void TemperaturePlusTemperatureDeltaEqualsTemperature(Temperature temperature, TemperatureDelta delta, Temperature expected) - { - Temperature resultTemp = temperature + delta; - Assert.True(expected.Equals(resultTemp, 1e-5, ComparisonType.Absolute)); - } + Temperature result = temp.Multiply(factor, temperature.Unit); + + Assert.True(expectedTemperature.Equals(result, Temperature.FromKelvins(KelvinsTolerance))); + } + + public static IEnumerable TemperatureDeltaPlusTemperatureEqualsTemperatureData { get; } = + [ + [-10d, TemperatureUnit.DegreeCelsius, 0d, TemperatureDeltaUnit.DegreeCelsius, -10d, TemperatureUnit.DegreeCelsius], + [-10d, TemperatureUnit.DegreeCelsius, 10d, TemperatureDeltaUnit.DegreeCelsius, 0d, TemperatureUnit.DegreeCelsius], + [-10d, TemperatureUnit.DegreeCelsius, 20d, TemperatureDeltaUnit.DegreeCelsius, 10d, TemperatureUnit.DegreeCelsius], + [-10d, TemperatureUnit.DegreeFahrenheit, 0d, TemperatureDeltaUnit.DegreeFahrenheit, -10d, TemperatureUnit.DegreeFahrenheit], + [-10d, TemperatureUnit.DegreeFahrenheit, 10d, TemperatureDeltaUnit.DegreeFahrenheit, 0d, TemperatureUnit.DegreeFahrenheit], + [-10d, TemperatureUnit.DegreeFahrenheit, 20d, TemperatureDeltaUnit.DegreeFahrenheit, 10d, TemperatureUnit.DegreeFahrenheit] + ]; + + [Theory] + [MemberData(nameof(TemperatureDeltaPlusTemperatureEqualsTemperatureData))] + public void TemperatureDeltaPlusTemperatureEqualsTemperature(double temperatureValue, TemperatureUnit temperatureUnit, double deltaValue, + TemperatureDeltaUnit deltaUnit, double expectedValue, TemperatureUnit expectedUnit) + { + var temperature = new Temperature(temperatureValue, temperatureUnit); + var temperatureDelta = new TemperatureDelta(deltaValue, deltaUnit); + var expectedTemperature = new Temperature(expectedValue, expectedUnit); + + Temperature result = temperature + temperatureDelta; + + Assert.True(expectedTemperature.Equals(result, Temperature.FromKelvins(KelvinsTolerance))); + } + + public static IEnumerable TemperatureMinusTemperatureDeltaEqualsTemperatureData { get; } = + [ + [20d, TemperatureUnit.DegreeCelsius, 10d, TemperatureDeltaUnit.DegreeCelsius, 10d, TemperatureUnit.DegreeCelsius], + [20d, TemperatureUnit.DegreeCelsius, 20d, TemperatureDeltaUnit.DegreeCelsius, 0d, TemperatureUnit.DegreeCelsius], + [20d, TemperatureUnit.DegreeCelsius, 30d, TemperatureDeltaUnit.DegreeCelsius, -10d, TemperatureUnit.DegreeCelsius], + [20d, TemperatureUnit.DegreeFahrenheit, 10d, TemperatureDeltaUnit.DegreeFahrenheit, 10d, TemperatureUnit.DegreeFahrenheit], + [20d, TemperatureUnit.DegreeFahrenheit, 20d, TemperatureDeltaUnit.DegreeFahrenheit, 0d, TemperatureUnit.DegreeFahrenheit], + [20d, TemperatureUnit.DegreeFahrenheit, 30d, TemperatureDeltaUnit.DegreeFahrenheit, -10d, TemperatureUnit.DegreeFahrenheit] + ]; + + [Theory] + [MemberData(nameof(TemperatureMinusTemperatureDeltaEqualsTemperatureData))] + public void TemperatureMinusTemperatureDeltaEqualsTemperature(double temperatureValue, TemperatureUnit temperatureUnit, double deltaValue, + TemperatureDeltaUnit deltaUnit, double expectedValue, TemperatureUnit expectedUnit) + { + var temp = new Temperature(temperatureValue, temperatureUnit); + var delta = new TemperatureDelta(deltaValue, deltaUnit); + var expectedTemperature = new Temperature(expectedValue, expectedUnit); + + Temperature result = temp - delta; + + Assert.True(expectedTemperature.Equals(result, Temperature.FromKelvins(KelvinsTolerance))); + } + + public static IEnumerable TemperaturePlusTemperatureDeltaEqualsTemperatureData { get; } = + [ + [-10d, TemperatureUnit.DegreeCelsius, 0d, TemperatureDeltaUnit.DegreeCelsius, -10d, TemperatureUnit.DegreeCelsius], + [-10d, TemperatureUnit.DegreeCelsius, 10d, TemperatureDeltaUnit.DegreeCelsius, 0d, TemperatureUnit.DegreeCelsius], + [-10d, TemperatureUnit.DegreeCelsius, 20d, TemperatureDeltaUnit.DegreeCelsius, 10d, TemperatureUnit.DegreeCelsius], + [-10d, TemperatureUnit.DegreeFahrenheit, 0d, TemperatureDeltaUnit.DegreeFahrenheit, -10d, TemperatureUnit.DegreeFahrenheit], + [-10d, TemperatureUnit.DegreeFahrenheit, 10d, TemperatureDeltaUnit.DegreeFahrenheit, 0d, TemperatureUnit.DegreeFahrenheit], + [-10d, TemperatureUnit.DegreeFahrenheit, 20d, TemperatureDeltaUnit.DegreeFahrenheit, 10d, TemperatureUnit.DegreeFahrenheit] + ]; + + [Theory] + [MemberData(nameof(TemperaturePlusTemperatureDeltaEqualsTemperatureData))] + public void TemperaturePlusTemperatureDeltaEqualsTemperature(double temperatureValue, TemperatureUnit temperatureUnit, double deltaValue, + TemperatureDeltaUnit deltaUnit, double expectedValue, TemperatureUnit expectedUnit) + { + var temp = new Temperature(temperatureValue, temperatureUnit); + var delta = new TemperatureDelta(deltaValue, deltaUnit); + var expectedTemperature = new Temperature(expectedValue, expectedUnit); + + Temperature result = temp + delta; + + Assert.True(expectedTemperature.Equals(result, Temperature.FromKelvins(KelvinsTolerance))); } } diff --git a/UnitsNet.Tests/CustomQuantities/HowMuch.cs b/UnitsNet.Tests/CustomQuantities/HowMuch.cs index 6703471241..026d1ec5fb 100644 --- a/UnitsNet.Tests/CustomQuantities/HowMuch.cs +++ b/UnitsNet.Tests/CustomQuantities/HowMuch.cs @@ -68,6 +68,10 @@ UnitKey IQuantity.UnitKey } public double As(Enum unit) => Convert.ToDouble(unit); + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } public double As(UnitSystem unitSystem) => throw new NotImplementedException(); @@ -89,17 +93,16 @@ IQuantity IQuantity.ToUnit(UnitSystem unitSystem) public IQuantity ToUnit(UnitSystem unitSystem) => throw new NotImplementedException(); - public override string ToString() => $"{Value} {Unit}"; - public string ToString(string? format, IFormatProvider? formatProvider) => $"HowMuch ({format}, {formatProvider})"; - public string ToString(IFormatProvider? provider) => $"HowMuch ({provider})"; - - public bool Equals(IQuantity? other, IQuantity tolerance) => throw new NotImplementedException(); + public override string ToString() + { + return $"{Value} {Unit}"; + } - public bool Equals(HowMuch other, HowMuch tolerance) + public string ToString(string? format, IFormatProvider? formatProvider) { - throw new NotImplementedException(); + return $"HowMuch ({format}, {formatProvider})"; } - + #if !NET QuantityInfo IQuantity.QuantityInfo diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AbsorbedDoseOfIonizingRadiationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AbsorbedDoseOfIonizingRadiationTestsBase.g.cs index b2f089aeff..a3802c7c1b 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AbsorbedDoseOfIonizingRadiationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AbsorbedDoseOfIonizingRadiationTestsBase.g.cs @@ -1256,34 +1256,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = AbsorbedDoseOfIonizingRadiation.FromGrays(1); - Assert.True(v.Equals(AbsorbedDoseOfIonizingRadiation.FromGrays(1), GraysTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(AbsorbedDoseOfIonizingRadiation.Zero, GraysTolerance, ComparisonType.Relative)); - Assert.True(AbsorbedDoseOfIonizingRadiation.FromGrays(100).Equals(AbsorbedDoseOfIonizingRadiation.FromGrays(120), 0.3, ComparisonType.Relative)); - Assert.False(AbsorbedDoseOfIonizingRadiation.FromGrays(100).Equals(AbsorbedDoseOfIonizingRadiation.FromGrays(120), 0.1, ComparisonType.Relative)); + AbsorbedDoseOfIonizingRadiation gray = AbsorbedDoseOfIonizingRadiation.FromGrays(1); + Assert.False(gray.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = AbsorbedDoseOfIonizingRadiation.FromGrays(1); - Assert.Throws(() => v.Equals(AbsorbedDoseOfIonizingRadiation.FromGrays(1), -1, ComparisonType.Relative)); + AbsorbedDoseOfIonizingRadiation gray = AbsorbedDoseOfIonizingRadiation.FromGrays(1); + Assert.False(gray.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - AbsorbedDoseOfIonizingRadiation gray = AbsorbedDoseOfIonizingRadiation.FromGrays(1); - Assert.False(gray.Equals(new object())); + var quantity = AbsorbedDoseOfIonizingRadiation.FromGrays(firstValue); + var otherQuantity = AbsorbedDoseOfIonizingRadiation.FromGrays(secondValue); + AbsorbedDoseOfIonizingRadiation maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, AbsorbedDoseOfIonizingRadiation.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - AbsorbedDoseOfIonizingRadiation gray = AbsorbedDoseOfIonizingRadiation.FromGrays(1); - Assert.False(gray.Equals(null)); + var quantity = AbsorbedDoseOfIonizingRadiation.FromGrays(1); + var negativeTolerance = AbsorbedDoseOfIonizingRadiation.FromGrays(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AccelerationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AccelerationTestsBase.g.cs index 3e0bdd7cde..f2f34d4775 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AccelerationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AccelerationTestsBase.g.cs @@ -1181,34 +1181,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = Acceleration.FromMetersPerSecondSquared(1); - Assert.True(v.Equals(Acceleration.FromMetersPerSecondSquared(1), MetersPerSecondSquaredTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(Acceleration.Zero, MetersPerSecondSquaredTolerance, ComparisonType.Relative)); - Assert.True(Acceleration.FromMetersPerSecondSquared(100).Equals(Acceleration.FromMetersPerSecondSquared(120), 0.3, ComparisonType.Relative)); - Assert.False(Acceleration.FromMetersPerSecondSquared(100).Equals(Acceleration.FromMetersPerSecondSquared(120), 0.1, ComparisonType.Relative)); + Acceleration meterpersecondsquared = Acceleration.FromMetersPerSecondSquared(1); + Assert.False(meterpersecondsquared.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = Acceleration.FromMetersPerSecondSquared(1); - Assert.Throws(() => v.Equals(Acceleration.FromMetersPerSecondSquared(1), -1, ComparisonType.Relative)); + Acceleration meterpersecondsquared = Acceleration.FromMetersPerSecondSquared(1); + Assert.False(meterpersecondsquared.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - Acceleration meterpersecondsquared = Acceleration.FromMetersPerSecondSquared(1); - Assert.False(meterpersecondsquared.Equals(new object())); + var quantity = Acceleration.FromMetersPerSecondSquared(firstValue); + var otherQuantity = Acceleration.FromMetersPerSecondSquared(secondValue); + Acceleration maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, Acceleration.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - Acceleration meterpersecondsquared = Acceleration.FromMetersPerSecondSquared(1); - Assert.False(meterpersecondsquared.Equals(null)); + var quantity = Acceleration.FromMetersPerSecondSquared(1); + var negativeTolerance = Acceleration.FromMetersPerSecondSquared(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AmountOfSubstanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AmountOfSubstanceTestsBase.g.cs index 707a0a4a6c..1525e1ac31 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AmountOfSubstanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AmountOfSubstanceTestsBase.g.cs @@ -1027,34 +1027,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = AmountOfSubstance.FromMoles(1); - Assert.True(v.Equals(AmountOfSubstance.FromMoles(1), MolesTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(AmountOfSubstance.Zero, MolesTolerance, ComparisonType.Relative)); - Assert.True(AmountOfSubstance.FromMoles(100).Equals(AmountOfSubstance.FromMoles(120), 0.3, ComparisonType.Relative)); - Assert.False(AmountOfSubstance.FromMoles(100).Equals(AmountOfSubstance.FromMoles(120), 0.1, ComparisonType.Relative)); + AmountOfSubstance mole = AmountOfSubstance.FromMoles(1); + Assert.False(mole.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = AmountOfSubstance.FromMoles(1); - Assert.Throws(() => v.Equals(AmountOfSubstance.FromMoles(1), -1, ComparisonType.Relative)); + AmountOfSubstance mole = AmountOfSubstance.FromMoles(1); + Assert.False(mole.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - AmountOfSubstance mole = AmountOfSubstance.FromMoles(1); - Assert.False(mole.Equals(new object())); + var quantity = AmountOfSubstance.FromMoles(firstValue); + var otherQuantity = AmountOfSubstance.FromMoles(secondValue); + AmountOfSubstance maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, AmountOfSubstance.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - AmountOfSubstance mole = AmountOfSubstance.FromMoles(1); - Assert.False(mole.Equals(null)); + var quantity = AmountOfSubstance.FromMoles(1); + var negativeTolerance = AmountOfSubstance.FromMoles(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AmplitudeRatioTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AmplitudeRatioTestsBase.g.cs index abd8d41bab..868f742e67 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AmplitudeRatioTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AmplitudeRatioTestsBase.g.cs @@ -566,23 +566,6 @@ public void Equals_Null_ReturnsFalse() #pragma warning restore CS8073 } - [Fact] - public void Equals_RelativeTolerance_IsImplemented() - { - var v = AmplitudeRatio.FromDecibelVolts(1); - Assert.True(v.Equals(AmplitudeRatio.FromDecibelVolts(1), DecibelVoltsTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(AmplitudeRatio.Zero, DecibelVoltsTolerance, ComparisonType.Relative)); - Assert.True(AmplitudeRatio.FromDecibelVolts(100).Equals(AmplitudeRatio.FromDecibelVolts(120), 0.3, ComparisonType.Relative)); - Assert.False(AmplitudeRatio.FromDecibelVolts(100).Equals(AmplitudeRatio.FromDecibelVolts(120), 0.1, ComparisonType.Relative)); - } - - [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() - { - var v = AmplitudeRatio.FromDecibelVolts(1); - Assert.Throws(() => v.Equals(AmplitudeRatio.FromDecibelVolts(1), -1, ComparisonType.Relative)); - } - [Fact] public void EqualsReturnsFalseOnTypeMismatch() { @@ -597,6 +580,34 @@ public void EqualsReturnsFalseOnNull() Assert.False(decibelvolt.Equals(null)); } + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + { + var quantity = AmplitudeRatio.FromDecibelVolts(firstValue); + var otherQuantity = AmplitudeRatio.FromDecibelVolts(secondValue); + AmplitudeRatio maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, AmplitudeRatio.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); + // note: it's currently not possible to test this due to the rounding error from (quantity - otherQuantity) + // Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + } + + [Fact] + public void Equals_WithNegativeTolerance_DoesNotThrowArgumentOutOfRangeException() + { + // note: unlike with vector quantities- a small tolerance maybe positive in one unit and negative in another + var quantity = AmplitudeRatio.FromDecibelVolts(1); + var negativeTolerance = AmplitudeRatio.FromDecibelVolts(-1); + Assert.True(quantity.Equals(quantity, negativeTolerance)); + } + [Fact] public void HasAtLeastOneAbbreviationSpecified() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AngleTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AngleTestsBase.g.cs index 3c831101e2..d47d722c1a 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AngleTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AngleTestsBase.g.cs @@ -1329,34 +1329,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = Angle.FromRadians(1); - Assert.True(v.Equals(Angle.FromRadians(1), RadiansTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(Angle.Zero, RadiansTolerance, ComparisonType.Relative)); - Assert.True(Angle.FromRadians(100).Equals(Angle.FromRadians(120), 0.3, ComparisonType.Relative)); - Assert.False(Angle.FromRadians(100).Equals(Angle.FromRadians(120), 0.1, ComparisonType.Relative)); + Angle radian = Angle.FromRadians(1); + Assert.False(radian.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = Angle.FromRadians(1); - Assert.Throws(() => v.Equals(Angle.FromRadians(1), -1, ComparisonType.Relative)); + Angle radian = Angle.FromRadians(1); + Assert.False(radian.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - Angle radian = Angle.FromRadians(1); - Assert.False(radian.Equals(new object())); + var quantity = Angle.FromRadians(firstValue); + var otherQuantity = Angle.FromRadians(secondValue); + Angle maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, Angle.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - Angle radian = Angle.FromRadians(1); - Assert.False(radian.Equals(null)); + var quantity = Angle.FromRadians(1); + var negativeTolerance = Angle.FromRadians(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaDensityTestsBase.g.cs index b275a78209..00891c8b6f 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaDensityTestsBase.g.cs @@ -612,34 +612,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = AreaDensity.FromKilogramsPerSquareMeter(1); - Assert.True(v.Equals(AreaDensity.FromKilogramsPerSquareMeter(1), KilogramsPerSquareMeterTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(AreaDensity.Zero, KilogramsPerSquareMeterTolerance, ComparisonType.Relative)); - Assert.True(AreaDensity.FromKilogramsPerSquareMeter(100).Equals(AreaDensity.FromKilogramsPerSquareMeter(120), 0.3, ComparisonType.Relative)); - Assert.False(AreaDensity.FromKilogramsPerSquareMeter(100).Equals(AreaDensity.FromKilogramsPerSquareMeter(120), 0.1, ComparisonType.Relative)); + AreaDensity kilogrampersquaremeter = AreaDensity.FromKilogramsPerSquareMeter(1); + Assert.False(kilogrampersquaremeter.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = AreaDensity.FromKilogramsPerSquareMeter(1); - Assert.Throws(() => v.Equals(AreaDensity.FromKilogramsPerSquareMeter(1), -1, ComparisonType.Relative)); + AreaDensity kilogrampersquaremeter = AreaDensity.FromKilogramsPerSquareMeter(1); + Assert.False(kilogrampersquaremeter.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - AreaDensity kilogrampersquaremeter = AreaDensity.FromKilogramsPerSquareMeter(1); - Assert.False(kilogrampersquaremeter.Equals(new object())); + var quantity = AreaDensity.FromKilogramsPerSquareMeter(firstValue); + var otherQuantity = AreaDensity.FromKilogramsPerSquareMeter(secondValue); + AreaDensity maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, AreaDensity.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - AreaDensity kilogrampersquaremeter = AreaDensity.FromKilogramsPerSquareMeter(1); - Assert.False(kilogrampersquaremeter.Equals(null)); + var quantity = AreaDensity.FromKilogramsPerSquareMeter(1); + var negativeTolerance = AreaDensity.FromKilogramsPerSquareMeter(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaMomentOfInertiaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaMomentOfInertiaTestsBase.g.cs index 23c476062b..448ee85799 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaMomentOfInertiaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaMomentOfInertiaTestsBase.g.cs @@ -687,34 +687,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = AreaMomentOfInertia.FromMetersToTheFourth(1); - Assert.True(v.Equals(AreaMomentOfInertia.FromMetersToTheFourth(1), MetersToTheFourthTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(AreaMomentOfInertia.Zero, MetersToTheFourthTolerance, ComparisonType.Relative)); - Assert.True(AreaMomentOfInertia.FromMetersToTheFourth(100).Equals(AreaMomentOfInertia.FromMetersToTheFourth(120), 0.3, ComparisonType.Relative)); - Assert.False(AreaMomentOfInertia.FromMetersToTheFourth(100).Equals(AreaMomentOfInertia.FromMetersToTheFourth(120), 0.1, ComparisonType.Relative)); + AreaMomentOfInertia metertothefourth = AreaMomentOfInertia.FromMetersToTheFourth(1); + Assert.False(metertothefourth.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = AreaMomentOfInertia.FromMetersToTheFourth(1); - Assert.Throws(() => v.Equals(AreaMomentOfInertia.FromMetersToTheFourth(1), -1, ComparisonType.Relative)); + AreaMomentOfInertia metertothefourth = AreaMomentOfInertia.FromMetersToTheFourth(1); + Assert.False(metertothefourth.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - AreaMomentOfInertia metertothefourth = AreaMomentOfInertia.FromMetersToTheFourth(1); - Assert.False(metertothefourth.Equals(new object())); + var quantity = AreaMomentOfInertia.FromMetersToTheFourth(firstValue); + var otherQuantity = AreaMomentOfInertia.FromMetersToTheFourth(secondValue); + AreaMomentOfInertia maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, AreaMomentOfInertia.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - AreaMomentOfInertia metertothefourth = AreaMomentOfInertia.FromMetersToTheFourth(1); - Assert.False(metertothefourth.Equals(null)); + var quantity = AreaMomentOfInertia.FromMetersToTheFourth(1); + var negativeTolerance = AreaMomentOfInertia.FromMetersToTheFourth(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaTestsBase.g.cs index 95cf522c99..2421ef2f4f 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaTestsBase.g.cs @@ -1396,34 +1396,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = Area.FromSquareMeters(1); - Assert.True(v.Equals(Area.FromSquareMeters(1), SquareMetersTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(Area.Zero, SquareMetersTolerance, ComparisonType.Relative)); - Assert.True(Area.FromSquareMeters(100).Equals(Area.FromSquareMeters(120), 0.3, ComparisonType.Relative)); - Assert.False(Area.FromSquareMeters(100).Equals(Area.FromSquareMeters(120), 0.1, ComparisonType.Relative)); + Area squaremeter = Area.FromSquareMeters(1); + Assert.False(squaremeter.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = Area.FromSquareMeters(1); - Assert.Throws(() => v.Equals(Area.FromSquareMeters(1), -1, ComparisonType.Relative)); + Area squaremeter = Area.FromSquareMeters(1); + Assert.False(squaremeter.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - Area squaremeter = Area.FromSquareMeters(1); - Assert.False(squaremeter.Equals(new object())); + var quantity = Area.FromSquareMeters(firstValue); + var otherQuantity = Area.FromSquareMeters(secondValue); + Area maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, Area.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - Area squaremeter = Area.FromSquareMeters(1); - Assert.False(squaremeter.Equals(null)); + var quantity = Area.FromSquareMeters(1); + var negativeTolerance = Area.FromSquareMeters(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/BitRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/BitRateTestsBase.g.cs index b0aebc901d..d2a26f6627 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/BitRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/BitRateTestsBase.g.cs @@ -2016,34 +2016,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = BitRate.FromBitsPerSecond(1); - Assert.True(v.Equals(BitRate.FromBitsPerSecond(1), BitsPerSecondTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(BitRate.Zero, BitsPerSecondTolerance, ComparisonType.Relative)); - Assert.True(BitRate.FromBitsPerSecond(100).Equals(BitRate.FromBitsPerSecond(120), 0.3, ComparisonType.Relative)); - Assert.False(BitRate.FromBitsPerSecond(100).Equals(BitRate.FromBitsPerSecond(120), 0.1, ComparisonType.Relative)); + BitRate bitpersecond = BitRate.FromBitsPerSecond(1); + Assert.False(bitpersecond.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = BitRate.FromBitsPerSecond(1); - Assert.Throws(() => v.Equals(BitRate.FromBitsPerSecond(1), -1, ComparisonType.Relative)); + BitRate bitpersecond = BitRate.FromBitsPerSecond(1); + Assert.False(bitpersecond.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - BitRate bitpersecond = BitRate.FromBitsPerSecond(1); - Assert.False(bitpersecond.Equals(new object())); + var quantity = BitRate.FromBitsPerSecond(firstValue); + var otherQuantity = BitRate.FromBitsPerSecond(secondValue); + BitRate maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, BitRate.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - BitRate bitpersecond = BitRate.FromBitsPerSecond(1); - Assert.False(bitpersecond.Equals(null)); + var quantity = BitRate.FromBitsPerSecond(1); + var negativeTolerance = BitRate.FromBitsPerSecond(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/BrakeSpecificFuelConsumptionTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/BrakeSpecificFuelConsumptionTestsBase.g.cs index 149607cfd2..8e9cc99bd0 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/BrakeSpecificFuelConsumptionTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/BrakeSpecificFuelConsumptionTestsBase.g.cs @@ -591,34 +591,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1); - Assert.True(v.Equals(BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1), KilogramsPerJouleTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(BrakeSpecificFuelConsumption.Zero, KilogramsPerJouleTolerance, ComparisonType.Relative)); - Assert.True(BrakeSpecificFuelConsumption.FromKilogramsPerJoule(100).Equals(BrakeSpecificFuelConsumption.FromKilogramsPerJoule(120), 0.3, ComparisonType.Relative)); - Assert.False(BrakeSpecificFuelConsumption.FromKilogramsPerJoule(100).Equals(BrakeSpecificFuelConsumption.FromKilogramsPerJoule(120), 0.1, ComparisonType.Relative)); + BrakeSpecificFuelConsumption kilogramperjoule = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1); + Assert.False(kilogramperjoule.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1); - Assert.Throws(() => v.Equals(BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1), -1, ComparisonType.Relative)); + BrakeSpecificFuelConsumption kilogramperjoule = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1); + Assert.False(kilogramperjoule.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - BrakeSpecificFuelConsumption kilogramperjoule = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1); - Assert.False(kilogramperjoule.Equals(new object())); + var quantity = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(firstValue); + var otherQuantity = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(secondValue); + BrakeSpecificFuelConsumption maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, BrakeSpecificFuelConsumption.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - BrakeSpecificFuelConsumption kilogramperjoule = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1); - Assert.False(kilogramperjoule.Equals(null)); + var quantity = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1); + var negativeTolerance = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/CoefficientOfThermalExpansionTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/CoefficientOfThermalExpansionTestsBase.g.cs index 065ae984ab..e7420018a6 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/CoefficientOfThermalExpansionTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/CoefficientOfThermalExpansionTestsBase.g.cs @@ -687,34 +687,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = CoefficientOfThermalExpansion.FromPerKelvin(1); - Assert.True(v.Equals(CoefficientOfThermalExpansion.FromPerKelvin(1), PerKelvinTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(CoefficientOfThermalExpansion.Zero, PerKelvinTolerance, ComparisonType.Relative)); - Assert.True(CoefficientOfThermalExpansion.FromPerKelvin(100).Equals(CoefficientOfThermalExpansion.FromPerKelvin(120), 0.3, ComparisonType.Relative)); - Assert.False(CoefficientOfThermalExpansion.FromPerKelvin(100).Equals(CoefficientOfThermalExpansion.FromPerKelvin(120), 0.1, ComparisonType.Relative)); + CoefficientOfThermalExpansion perkelvin = CoefficientOfThermalExpansion.FromPerKelvin(1); + Assert.False(perkelvin.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = CoefficientOfThermalExpansion.FromPerKelvin(1); - Assert.Throws(() => v.Equals(CoefficientOfThermalExpansion.FromPerKelvin(1), -1, ComparisonType.Relative)); + CoefficientOfThermalExpansion perkelvin = CoefficientOfThermalExpansion.FromPerKelvin(1); + Assert.False(perkelvin.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - CoefficientOfThermalExpansion perkelvin = CoefficientOfThermalExpansion.FromPerKelvin(1); - Assert.False(perkelvin.Equals(new object())); + var quantity = CoefficientOfThermalExpansion.FromPerKelvin(firstValue); + var otherQuantity = CoefficientOfThermalExpansion.FromPerKelvin(secondValue); + CoefficientOfThermalExpansion maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, CoefficientOfThermalExpansion.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - CoefficientOfThermalExpansion perkelvin = CoefficientOfThermalExpansion.FromPerKelvin(1); - Assert.False(perkelvin.Equals(null)); + var quantity = CoefficientOfThermalExpansion.FromPerKelvin(1); + var negativeTolerance = CoefficientOfThermalExpansion.FromPerKelvin(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/CompressibilityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/CompressibilityTestsBase.g.cs index 8650c7b42f..f4024ae93c 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/CompressibilityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/CompressibilityTestsBase.g.cs @@ -866,34 +866,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = Compressibility.FromInversePascals(1); - Assert.True(v.Equals(Compressibility.FromInversePascals(1), InversePascalsTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(Compressibility.Zero, InversePascalsTolerance, ComparisonType.Relative)); - Assert.True(Compressibility.FromInversePascals(100).Equals(Compressibility.FromInversePascals(120), 0.3, ComparisonType.Relative)); - Assert.False(Compressibility.FromInversePascals(100).Equals(Compressibility.FromInversePascals(120), 0.1, ComparisonType.Relative)); + Compressibility inversepascal = Compressibility.FromInversePascals(1); + Assert.False(inversepascal.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = Compressibility.FromInversePascals(1); - Assert.Throws(() => v.Equals(Compressibility.FromInversePascals(1), -1, ComparisonType.Relative)); + Compressibility inversepascal = Compressibility.FromInversePascals(1); + Assert.False(inversepascal.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - Compressibility inversepascal = Compressibility.FromInversePascals(1); - Assert.False(inversepascal.Equals(new object())); + var quantity = Compressibility.FromInversePascals(firstValue); + var otherQuantity = Compressibility.FromInversePascals(secondValue); + Compressibility maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, Compressibility.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - Compressibility inversepascal = Compressibility.FromInversePascals(1); - Assert.False(inversepascal.Equals(null)); + var quantity = Compressibility.FromInversePascals(1); + var negativeTolerance = Compressibility.FromInversePascals(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/DensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/DensityTestsBase.g.cs index 45eb200af2..1f56da3a97 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/DensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/DensityTestsBase.g.cs @@ -2481,34 +2481,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = Density.FromKilogramsPerCubicMeter(1); - Assert.True(v.Equals(Density.FromKilogramsPerCubicMeter(1), KilogramsPerCubicMeterTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(Density.Zero, KilogramsPerCubicMeterTolerance, ComparisonType.Relative)); - Assert.True(Density.FromKilogramsPerCubicMeter(100).Equals(Density.FromKilogramsPerCubicMeter(120), 0.3, ComparisonType.Relative)); - Assert.False(Density.FromKilogramsPerCubicMeter(100).Equals(Density.FromKilogramsPerCubicMeter(120), 0.1, ComparisonType.Relative)); + Density kilogrampercubicmeter = Density.FromKilogramsPerCubicMeter(1); + Assert.False(kilogrampercubicmeter.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = Density.FromKilogramsPerCubicMeter(1); - Assert.Throws(() => v.Equals(Density.FromKilogramsPerCubicMeter(1), -1, ComparisonType.Relative)); + Density kilogrampercubicmeter = Density.FromKilogramsPerCubicMeter(1); + Assert.False(kilogrampercubicmeter.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - Density kilogrampercubicmeter = Density.FromKilogramsPerCubicMeter(1); - Assert.False(kilogrampercubicmeter.Equals(new object())); + var quantity = Density.FromKilogramsPerCubicMeter(firstValue); + var otherQuantity = Density.FromKilogramsPerCubicMeter(secondValue); + Density maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, Density.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - Density kilogrampercubicmeter = Density.FromKilogramsPerCubicMeter(1); - Assert.False(kilogrampercubicmeter.Equals(null)); + var quantity = Density.FromKilogramsPerCubicMeter(1); + var negativeTolerance = Density.FromKilogramsPerCubicMeter(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/DoseAreaProductTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/DoseAreaProductTestsBase.g.cs index aea2ea8599..c143f12f0e 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/DoseAreaProductTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/DoseAreaProductTestsBase.g.cs @@ -1720,34 +1720,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = DoseAreaProduct.FromGraySquareMeters(1); - Assert.True(v.Equals(DoseAreaProduct.FromGraySquareMeters(1), GraySquareMetersTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(DoseAreaProduct.Zero, GraySquareMetersTolerance, ComparisonType.Relative)); - Assert.True(DoseAreaProduct.FromGraySquareMeters(100).Equals(DoseAreaProduct.FromGraySquareMeters(120), 0.3, ComparisonType.Relative)); - Assert.False(DoseAreaProduct.FromGraySquareMeters(100).Equals(DoseAreaProduct.FromGraySquareMeters(120), 0.1, ComparisonType.Relative)); + DoseAreaProduct graysquaremeter = DoseAreaProduct.FromGraySquareMeters(1); + Assert.False(graysquaremeter.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = DoseAreaProduct.FromGraySquareMeters(1); - Assert.Throws(() => v.Equals(DoseAreaProduct.FromGraySquareMeters(1), -1, ComparisonType.Relative)); + DoseAreaProduct graysquaremeter = DoseAreaProduct.FromGraySquareMeters(1); + Assert.False(graysquaremeter.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - DoseAreaProduct graysquaremeter = DoseAreaProduct.FromGraySquareMeters(1); - Assert.False(graysquaremeter.Equals(new object())); + var quantity = DoseAreaProduct.FromGraySquareMeters(firstValue); + var otherQuantity = DoseAreaProduct.FromGraySquareMeters(secondValue); + DoseAreaProduct maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, DoseAreaProduct.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - DoseAreaProduct graysquaremeter = DoseAreaProduct.FromGraySquareMeters(1); - Assert.False(graysquaremeter.Equals(null)); + var quantity = DoseAreaProduct.FromGraySquareMeters(1); + var negativeTolerance = DoseAreaProduct.FromGraySquareMeters(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/DurationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/DurationTestsBase.g.cs index 9dec63ca39..ee72161019 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/DurationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/DurationTestsBase.g.cs @@ -1994,34 +1994,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = Duration.FromSeconds(1); - Assert.True(v.Equals(Duration.FromSeconds(1), SecondsTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(Duration.Zero, SecondsTolerance, ComparisonType.Relative)); - Assert.True(Duration.FromSeconds(100).Equals(Duration.FromSeconds(120), 0.3, ComparisonType.Relative)); - Assert.False(Duration.FromSeconds(100).Equals(Duration.FromSeconds(120), 0.1, ComparisonType.Relative)); + Duration second = Duration.FromSeconds(1); + Assert.False(second.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = Duration.FromSeconds(1); - Assert.Throws(() => v.Equals(Duration.FromSeconds(1), -1, ComparisonType.Relative)); + Duration second = Duration.FromSeconds(1); + Assert.False(second.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - Duration second = Duration.FromSeconds(1); - Assert.False(second.Equals(new object())); + var quantity = Duration.FromSeconds(firstValue); + var otherQuantity = Duration.FromSeconds(secondValue); + Duration maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, Duration.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - Duration second = Duration.FromSeconds(1); - Assert.False(second.Equals(null)); + var quantity = Duration.FromSeconds(1); + var negativeTolerance = Duration.FromSeconds(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/DynamicViscosityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/DynamicViscosityTestsBase.g.cs index ca5587a154..c34b4bfbf3 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/DynamicViscosityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/DynamicViscosityTestsBase.g.cs @@ -878,34 +878,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = DynamicViscosity.FromNewtonSecondsPerMeterSquared(1); - Assert.True(v.Equals(DynamicViscosity.FromNewtonSecondsPerMeterSquared(1), NewtonSecondsPerMeterSquaredTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(DynamicViscosity.Zero, NewtonSecondsPerMeterSquaredTolerance, ComparisonType.Relative)); - Assert.True(DynamicViscosity.FromNewtonSecondsPerMeterSquared(100).Equals(DynamicViscosity.FromNewtonSecondsPerMeterSquared(120), 0.3, ComparisonType.Relative)); - Assert.False(DynamicViscosity.FromNewtonSecondsPerMeterSquared(100).Equals(DynamicViscosity.FromNewtonSecondsPerMeterSquared(120), 0.1, ComparisonType.Relative)); + DynamicViscosity newtonsecondpermetersquared = DynamicViscosity.FromNewtonSecondsPerMeterSquared(1); + Assert.False(newtonsecondpermetersquared.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = DynamicViscosity.FromNewtonSecondsPerMeterSquared(1); - Assert.Throws(() => v.Equals(DynamicViscosity.FromNewtonSecondsPerMeterSquared(1), -1, ComparisonType.Relative)); + DynamicViscosity newtonsecondpermetersquared = DynamicViscosity.FromNewtonSecondsPerMeterSquared(1); + Assert.False(newtonsecondpermetersquared.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - DynamicViscosity newtonsecondpermetersquared = DynamicViscosity.FromNewtonSecondsPerMeterSquared(1); - Assert.False(newtonsecondpermetersquared.Equals(new object())); + var quantity = DynamicViscosity.FromNewtonSecondsPerMeterSquared(firstValue); + var otherQuantity = DynamicViscosity.FromNewtonSecondsPerMeterSquared(secondValue); + DynamicViscosity maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, DynamicViscosity.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - DynamicViscosity newtonsecondpermetersquared = DynamicViscosity.FromNewtonSecondsPerMeterSquared(1); - Assert.False(newtonsecondpermetersquared.Equals(null)); + var quantity = DynamicViscosity.FromNewtonSecondsPerMeterSquared(1); + var negativeTolerance = DynamicViscosity.FromNewtonSecondsPerMeterSquared(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricAdmittanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricAdmittanceTestsBase.g.cs index 1a2e062af3..1c26420706 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricAdmittanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricAdmittanceTestsBase.g.cs @@ -983,34 +983,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = ElectricAdmittance.FromSiemens(1); - Assert.True(v.Equals(ElectricAdmittance.FromSiemens(1), SiemensTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(ElectricAdmittance.Zero, SiemensTolerance, ComparisonType.Relative)); - Assert.True(ElectricAdmittance.FromSiemens(100).Equals(ElectricAdmittance.FromSiemens(120), 0.3, ComparisonType.Relative)); - Assert.False(ElectricAdmittance.FromSiemens(100).Equals(ElectricAdmittance.FromSiemens(120), 0.1, ComparisonType.Relative)); + ElectricAdmittance siemens = ElectricAdmittance.FromSiemens(1); + Assert.False(siemens.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = ElectricAdmittance.FromSiemens(1); - Assert.Throws(() => v.Equals(ElectricAdmittance.FromSiemens(1), -1, ComparisonType.Relative)); + ElectricAdmittance siemens = ElectricAdmittance.FromSiemens(1); + Assert.False(siemens.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - ElectricAdmittance siemens = ElectricAdmittance.FromSiemens(1); - Assert.False(siemens.Equals(new object())); + var quantity = ElectricAdmittance.FromSiemens(firstValue); + var otherQuantity = ElectricAdmittance.FromSiemens(secondValue); + ElectricAdmittance maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, ElectricAdmittance.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - ElectricAdmittance siemens = ElectricAdmittance.FromSiemens(1); - Assert.False(siemens.Equals(null)); + var quantity = ElectricAdmittance.FromSiemens(1); + var negativeTolerance = ElectricAdmittance.FromSiemens(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricApparentEnergyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricApparentEnergyTestsBase.g.cs index 24709357f8..740eff4eb3 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricApparentEnergyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricApparentEnergyTestsBase.g.cs @@ -591,34 +591,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = ElectricApparentEnergy.FromVoltampereHours(1); - Assert.True(v.Equals(ElectricApparentEnergy.FromVoltampereHours(1), VoltampereHoursTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(ElectricApparentEnergy.Zero, VoltampereHoursTolerance, ComparisonType.Relative)); - Assert.True(ElectricApparentEnergy.FromVoltampereHours(100).Equals(ElectricApparentEnergy.FromVoltampereHours(120), 0.3, ComparisonType.Relative)); - Assert.False(ElectricApparentEnergy.FromVoltampereHours(100).Equals(ElectricApparentEnergy.FromVoltampereHours(120), 0.1, ComparisonType.Relative)); + ElectricApparentEnergy voltamperehour = ElectricApparentEnergy.FromVoltampereHours(1); + Assert.False(voltamperehour.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = ElectricApparentEnergy.FromVoltampereHours(1); - Assert.Throws(() => v.Equals(ElectricApparentEnergy.FromVoltampereHours(1), -1, ComparisonType.Relative)); + ElectricApparentEnergy voltamperehour = ElectricApparentEnergy.FromVoltampereHours(1); + Assert.False(voltamperehour.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - ElectricApparentEnergy voltamperehour = ElectricApparentEnergy.FromVoltampereHours(1); - Assert.False(voltamperehour.Equals(new object())); + var quantity = ElectricApparentEnergy.FromVoltampereHours(firstValue); + var otherQuantity = ElectricApparentEnergy.FromVoltampereHours(secondValue); + ElectricApparentEnergy maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, ElectricApparentEnergy.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - ElectricApparentEnergy voltamperehour = ElectricApparentEnergy.FromVoltampereHours(1); - Assert.False(voltamperehour.Equals(null)); + var quantity = ElectricApparentEnergy.FromVoltampereHours(1); + var negativeTolerance = ElectricApparentEnergy.FromVoltampereHours(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricApparentPowerTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricApparentPowerTestsBase.g.cs index 4dae41520a..e646f22d37 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricApparentPowerTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricApparentPowerTestsBase.g.cs @@ -675,34 +675,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = ElectricApparentPower.FromVoltamperes(1); - Assert.True(v.Equals(ElectricApparentPower.FromVoltamperes(1), VoltamperesTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(ElectricApparentPower.Zero, VoltamperesTolerance, ComparisonType.Relative)); - Assert.True(ElectricApparentPower.FromVoltamperes(100).Equals(ElectricApparentPower.FromVoltamperes(120), 0.3, ComparisonType.Relative)); - Assert.False(ElectricApparentPower.FromVoltamperes(100).Equals(ElectricApparentPower.FromVoltamperes(120), 0.1, ComparisonType.Relative)); + ElectricApparentPower voltampere = ElectricApparentPower.FromVoltamperes(1); + Assert.False(voltampere.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = ElectricApparentPower.FromVoltamperes(1); - Assert.Throws(() => v.Equals(ElectricApparentPower.FromVoltamperes(1), -1, ComparisonType.Relative)); + ElectricApparentPower voltampere = ElectricApparentPower.FromVoltamperes(1); + Assert.False(voltampere.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - ElectricApparentPower voltampere = ElectricApparentPower.FromVoltamperes(1); - Assert.False(voltampere.Equals(new object())); + var quantity = ElectricApparentPower.FromVoltamperes(firstValue); + var otherQuantity = ElectricApparentPower.FromVoltamperes(secondValue); + ElectricApparentPower maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, ElectricApparentPower.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - ElectricApparentPower voltampere = ElectricApparentPower.FromVoltamperes(1); - Assert.False(voltampere.Equals(null)); + var quantity = ElectricApparentPower.FromVoltamperes(1); + var negativeTolerance = ElectricApparentPower.FromVoltamperes(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCapacitanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCapacitanceTestsBase.g.cs index 6ff5944fad..d7d1a1f7ce 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCapacitanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCapacitanceTestsBase.g.cs @@ -707,34 +707,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = ElectricCapacitance.FromFarads(1); - Assert.True(v.Equals(ElectricCapacitance.FromFarads(1), FaradsTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(ElectricCapacitance.Zero, FaradsTolerance, ComparisonType.Relative)); - Assert.True(ElectricCapacitance.FromFarads(100).Equals(ElectricCapacitance.FromFarads(120), 0.3, ComparisonType.Relative)); - Assert.False(ElectricCapacitance.FromFarads(100).Equals(ElectricCapacitance.FromFarads(120), 0.1, ComparisonType.Relative)); + ElectricCapacitance farad = ElectricCapacitance.FromFarads(1); + Assert.False(farad.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = ElectricCapacitance.FromFarads(1); - Assert.Throws(() => v.Equals(ElectricCapacitance.FromFarads(1), -1, ComparisonType.Relative)); + ElectricCapacitance farad = ElectricCapacitance.FromFarads(1); + Assert.False(farad.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - ElectricCapacitance farad = ElectricCapacitance.FromFarads(1); - Assert.False(farad.Equals(new object())); + var quantity = ElectricCapacitance.FromFarads(firstValue); + var otherQuantity = ElectricCapacitance.FromFarads(secondValue); + ElectricCapacitance maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, ElectricCapacitance.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - ElectricCapacitance farad = ElectricCapacitance.FromFarads(1); - Assert.False(farad.Equals(null)); + var quantity = ElectricCapacitance.FromFarads(1); + var negativeTolerance = ElectricCapacitance.FromFarads(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeDensityTestsBase.g.cs index 4c4432814b..c5ca052a05 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeDensityTestsBase.g.cs @@ -526,34 +526,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = ElectricChargeDensity.FromCoulombsPerCubicMeter(1); - Assert.True(v.Equals(ElectricChargeDensity.FromCoulombsPerCubicMeter(1), CoulombsPerCubicMeterTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(ElectricChargeDensity.Zero, CoulombsPerCubicMeterTolerance, ComparisonType.Relative)); - Assert.True(ElectricChargeDensity.FromCoulombsPerCubicMeter(100).Equals(ElectricChargeDensity.FromCoulombsPerCubicMeter(120), 0.3, ComparisonType.Relative)); - Assert.False(ElectricChargeDensity.FromCoulombsPerCubicMeter(100).Equals(ElectricChargeDensity.FromCoulombsPerCubicMeter(120), 0.1, ComparisonType.Relative)); + ElectricChargeDensity coulombpercubicmeter = ElectricChargeDensity.FromCoulombsPerCubicMeter(1); + Assert.False(coulombpercubicmeter.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = ElectricChargeDensity.FromCoulombsPerCubicMeter(1); - Assert.Throws(() => v.Equals(ElectricChargeDensity.FromCoulombsPerCubicMeter(1), -1, ComparisonType.Relative)); + ElectricChargeDensity coulombpercubicmeter = ElectricChargeDensity.FromCoulombsPerCubicMeter(1); + Assert.False(coulombpercubicmeter.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - ElectricChargeDensity coulombpercubicmeter = ElectricChargeDensity.FromCoulombsPerCubicMeter(1); - Assert.False(coulombpercubicmeter.Equals(new object())); + var quantity = ElectricChargeDensity.FromCoulombsPerCubicMeter(firstValue); + var otherQuantity = ElectricChargeDensity.FromCoulombsPerCubicMeter(secondValue); + ElectricChargeDensity maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, ElectricChargeDensity.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - ElectricChargeDensity coulombpercubicmeter = ElectricChargeDensity.FromCoulombsPerCubicMeter(1); - Assert.False(coulombpercubicmeter.Equals(null)); + var quantity = ElectricChargeDensity.FromCoulombsPerCubicMeter(1); + var negativeTolerance = ElectricChargeDensity.FromCoulombsPerCubicMeter(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeTestsBase.g.cs index 38196445cf..a230db093b 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeTestsBase.g.cs @@ -895,34 +895,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = ElectricCharge.FromCoulombs(1); - Assert.True(v.Equals(ElectricCharge.FromCoulombs(1), CoulombsTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(ElectricCharge.Zero, CoulombsTolerance, ComparisonType.Relative)); - Assert.True(ElectricCharge.FromCoulombs(100).Equals(ElectricCharge.FromCoulombs(120), 0.3, ComparisonType.Relative)); - Assert.False(ElectricCharge.FromCoulombs(100).Equals(ElectricCharge.FromCoulombs(120), 0.1, ComparisonType.Relative)); + ElectricCharge coulomb = ElectricCharge.FromCoulombs(1); + Assert.False(coulomb.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = ElectricCharge.FromCoulombs(1); - Assert.Throws(() => v.Equals(ElectricCharge.FromCoulombs(1), -1, ComparisonType.Relative)); + ElectricCharge coulomb = ElectricCharge.FromCoulombs(1); + Assert.False(coulomb.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - ElectricCharge coulomb = ElectricCharge.FromCoulombs(1); - Assert.False(coulomb.Equals(new object())); + var quantity = ElectricCharge.FromCoulombs(firstValue); + var otherQuantity = ElectricCharge.FromCoulombs(secondValue); + ElectricCharge maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, ElectricCharge.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - ElectricCharge coulomb = ElectricCharge.FromCoulombs(1); - Assert.False(coulomb.Equals(null)); + var quantity = ElectricCharge.FromCoulombs(1); + var negativeTolerance = ElectricCharge.FromCoulombs(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductanceTestsBase.g.cs index 61813c6aae..5d2940a3f5 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductanceTestsBase.g.cs @@ -983,34 +983,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = ElectricConductance.FromSiemens(1); - Assert.True(v.Equals(ElectricConductance.FromSiemens(1), SiemensTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(ElectricConductance.Zero, SiemensTolerance, ComparisonType.Relative)); - Assert.True(ElectricConductance.FromSiemens(100).Equals(ElectricConductance.FromSiemens(120), 0.3, ComparisonType.Relative)); - Assert.False(ElectricConductance.FromSiemens(100).Equals(ElectricConductance.FromSiemens(120), 0.1, ComparisonType.Relative)); + ElectricConductance siemens = ElectricConductance.FromSiemens(1); + Assert.False(siemens.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = ElectricConductance.FromSiemens(1); - Assert.Throws(() => v.Equals(ElectricConductance.FromSiemens(1), -1, ComparisonType.Relative)); + ElectricConductance siemens = ElectricConductance.FromSiemens(1); + Assert.False(siemens.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - ElectricConductance siemens = ElectricConductance.FromSiemens(1); - Assert.False(siemens.Equals(new object())); + var quantity = ElectricConductance.FromSiemens(firstValue); + var otherQuantity = ElectricConductance.FromSiemens(secondValue); + ElectricConductance maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, ElectricConductance.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - ElectricConductance siemens = ElectricConductance.FromSiemens(1); - Assert.False(siemens.Equals(null)); + var quantity = ElectricConductance.FromSiemens(1); + var negativeTolerance = ElectricConductance.FromSiemens(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductivityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductivityTestsBase.g.cs index 3f0c9a3225..ce63ef0041 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductivityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductivityTestsBase.g.cs @@ -687,34 +687,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = ElectricConductivity.FromSiemensPerMeter(1); - Assert.True(v.Equals(ElectricConductivity.FromSiemensPerMeter(1), SiemensPerMeterTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(ElectricConductivity.Zero, SiemensPerMeterTolerance, ComparisonType.Relative)); - Assert.True(ElectricConductivity.FromSiemensPerMeter(100).Equals(ElectricConductivity.FromSiemensPerMeter(120), 0.3, ComparisonType.Relative)); - Assert.False(ElectricConductivity.FromSiemensPerMeter(100).Equals(ElectricConductivity.FromSiemensPerMeter(120), 0.1, ComparisonType.Relative)); + ElectricConductivity siemenspermeter = ElectricConductivity.FromSiemensPerMeter(1); + Assert.False(siemenspermeter.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = ElectricConductivity.FromSiemensPerMeter(1); - Assert.Throws(() => v.Equals(ElectricConductivity.FromSiemensPerMeter(1), -1, ComparisonType.Relative)); + ElectricConductivity siemenspermeter = ElectricConductivity.FromSiemensPerMeter(1); + Assert.False(siemenspermeter.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - ElectricConductivity siemenspermeter = ElectricConductivity.FromSiemensPerMeter(1); - Assert.False(siemenspermeter.Equals(new object())); + var quantity = ElectricConductivity.FromSiemensPerMeter(firstValue); + var otherQuantity = ElectricConductivity.FromSiemensPerMeter(secondValue); + ElectricConductivity maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, ElectricConductivity.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - ElectricConductivity siemenspermeter = ElectricConductivity.FromSiemensPerMeter(1); - Assert.False(siemenspermeter.Equals(null)); + var quantity = ElectricConductivity.FromSiemensPerMeter(1); + var negativeTolerance = ElectricConductivity.FromSiemensPerMeter(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentDensityTestsBase.g.cs index 8a1bc11461..88276f17d5 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentDensityTestsBase.g.cs @@ -591,34 +591,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = ElectricCurrentDensity.FromAmperesPerSquareMeter(1); - Assert.True(v.Equals(ElectricCurrentDensity.FromAmperesPerSquareMeter(1), AmperesPerSquareMeterTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(ElectricCurrentDensity.Zero, AmperesPerSquareMeterTolerance, ComparisonType.Relative)); - Assert.True(ElectricCurrentDensity.FromAmperesPerSquareMeter(100).Equals(ElectricCurrentDensity.FromAmperesPerSquareMeter(120), 0.3, ComparisonType.Relative)); - Assert.False(ElectricCurrentDensity.FromAmperesPerSquareMeter(100).Equals(ElectricCurrentDensity.FromAmperesPerSquareMeter(120), 0.1, ComparisonType.Relative)); + ElectricCurrentDensity amperepersquaremeter = ElectricCurrentDensity.FromAmperesPerSquareMeter(1); + Assert.False(amperepersquaremeter.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = ElectricCurrentDensity.FromAmperesPerSquareMeter(1); - Assert.Throws(() => v.Equals(ElectricCurrentDensity.FromAmperesPerSquareMeter(1), -1, ComparisonType.Relative)); + ElectricCurrentDensity amperepersquaremeter = ElectricCurrentDensity.FromAmperesPerSquareMeter(1); + Assert.False(amperepersquaremeter.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - ElectricCurrentDensity amperepersquaremeter = ElectricCurrentDensity.FromAmperesPerSquareMeter(1); - Assert.False(amperepersquaremeter.Equals(new object())); + var quantity = ElectricCurrentDensity.FromAmperesPerSquareMeter(firstValue); + var otherQuantity = ElectricCurrentDensity.FromAmperesPerSquareMeter(secondValue); + ElectricCurrentDensity maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, ElectricCurrentDensity.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - ElectricCurrentDensity amperepersquaremeter = ElectricCurrentDensity.FromAmperesPerSquareMeter(1); - Assert.False(amperepersquaremeter.Equals(null)); + var quantity = ElectricCurrentDensity.FromAmperesPerSquareMeter(1); + var negativeTolerance = ElectricCurrentDensity.FromAmperesPerSquareMeter(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentGradientTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentGradientTestsBase.g.cs index d4c84273a2..22bbae351a 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentGradientTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentGradientTestsBase.g.cs @@ -719,34 +719,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = ElectricCurrentGradient.FromAmperesPerSecond(1); - Assert.True(v.Equals(ElectricCurrentGradient.FromAmperesPerSecond(1), AmperesPerSecondTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(ElectricCurrentGradient.Zero, AmperesPerSecondTolerance, ComparisonType.Relative)); - Assert.True(ElectricCurrentGradient.FromAmperesPerSecond(100).Equals(ElectricCurrentGradient.FromAmperesPerSecond(120), 0.3, ComparisonType.Relative)); - Assert.False(ElectricCurrentGradient.FromAmperesPerSecond(100).Equals(ElectricCurrentGradient.FromAmperesPerSecond(120), 0.1, ComparisonType.Relative)); + ElectricCurrentGradient amperepersecond = ElectricCurrentGradient.FromAmperesPerSecond(1); + Assert.False(amperepersecond.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = ElectricCurrentGradient.FromAmperesPerSecond(1); - Assert.Throws(() => v.Equals(ElectricCurrentGradient.FromAmperesPerSecond(1), -1, ComparisonType.Relative)); + ElectricCurrentGradient amperepersecond = ElectricCurrentGradient.FromAmperesPerSecond(1); + Assert.False(amperepersecond.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - ElectricCurrentGradient amperepersecond = ElectricCurrentGradient.FromAmperesPerSecond(1); - Assert.False(amperepersecond.Equals(new object())); + var quantity = ElectricCurrentGradient.FromAmperesPerSecond(firstValue); + var otherQuantity = ElectricCurrentGradient.FromAmperesPerSecond(secondValue); + ElectricCurrentGradient maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, ElectricCurrentGradient.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - ElectricCurrentGradient amperepersecond = ElectricCurrentGradient.FromAmperesPerSecond(1); - Assert.False(amperepersecond.Equals(null)); + var quantity = ElectricCurrentGradient.FromAmperesPerSecond(1); + var negativeTolerance = ElectricCurrentGradient.FromAmperesPerSecond(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentTestsBase.g.cs index a629f4f7ba..fdf1051a4d 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentTestsBase.g.cs @@ -771,34 +771,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = ElectricCurrent.FromAmperes(1); - Assert.True(v.Equals(ElectricCurrent.FromAmperes(1), AmperesTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(ElectricCurrent.Zero, AmperesTolerance, ComparisonType.Relative)); - Assert.True(ElectricCurrent.FromAmperes(100).Equals(ElectricCurrent.FromAmperes(120), 0.3, ComparisonType.Relative)); - Assert.False(ElectricCurrent.FromAmperes(100).Equals(ElectricCurrent.FromAmperes(120), 0.1, ComparisonType.Relative)); + ElectricCurrent ampere = ElectricCurrent.FromAmperes(1); + Assert.False(ampere.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = ElectricCurrent.FromAmperes(1); - Assert.Throws(() => v.Equals(ElectricCurrent.FromAmperes(1), -1, ComparisonType.Relative)); + ElectricCurrent ampere = ElectricCurrent.FromAmperes(1); + Assert.False(ampere.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - ElectricCurrent ampere = ElectricCurrent.FromAmperes(1); - Assert.False(ampere.Equals(new object())); + var quantity = ElectricCurrent.FromAmperes(firstValue); + var otherQuantity = ElectricCurrent.FromAmperes(secondValue); + ElectricCurrent maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, ElectricCurrent.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - ElectricCurrent ampere = ElectricCurrent.FromAmperes(1); - Assert.False(ampere.Equals(null)); + var quantity = ElectricCurrent.FromAmperes(1); + var negativeTolerance = ElectricCurrent.FromAmperes(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricFieldTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricFieldTestsBase.g.cs index 557537b9a6..8dfefedb0c 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricFieldTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricFieldTestsBase.g.cs @@ -526,34 +526,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = ElectricField.FromVoltsPerMeter(1); - Assert.True(v.Equals(ElectricField.FromVoltsPerMeter(1), VoltsPerMeterTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(ElectricField.Zero, VoltsPerMeterTolerance, ComparisonType.Relative)); - Assert.True(ElectricField.FromVoltsPerMeter(100).Equals(ElectricField.FromVoltsPerMeter(120), 0.3, ComparisonType.Relative)); - Assert.False(ElectricField.FromVoltsPerMeter(100).Equals(ElectricField.FromVoltsPerMeter(120), 0.1, ComparisonType.Relative)); + ElectricField voltpermeter = ElectricField.FromVoltsPerMeter(1); + Assert.False(voltpermeter.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = ElectricField.FromVoltsPerMeter(1); - Assert.Throws(() => v.Equals(ElectricField.FromVoltsPerMeter(1), -1, ComparisonType.Relative)); + ElectricField voltpermeter = ElectricField.FromVoltsPerMeter(1); + Assert.False(voltpermeter.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - ElectricField voltpermeter = ElectricField.FromVoltsPerMeter(1); - Assert.False(voltpermeter.Equals(new object())); + var quantity = ElectricField.FromVoltsPerMeter(firstValue); + var otherQuantity = ElectricField.FromVoltsPerMeter(secondValue); + ElectricField maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, ElectricField.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - ElectricField voltpermeter = ElectricField.FromVoltsPerMeter(1); - Assert.False(voltpermeter.Equals(null)); + var quantity = ElectricField.FromVoltsPerMeter(1); + var negativeTolerance = ElectricField.FromVoltsPerMeter(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricImpedanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricImpedanceTestsBase.g.cs index 44ff64bd41..993fa6dee3 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricImpedanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricImpedanceTestsBase.g.cs @@ -739,34 +739,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = ElectricImpedance.FromOhms(1); - Assert.True(v.Equals(ElectricImpedance.FromOhms(1), OhmsTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(ElectricImpedance.Zero, OhmsTolerance, ComparisonType.Relative)); - Assert.True(ElectricImpedance.FromOhms(100).Equals(ElectricImpedance.FromOhms(120), 0.3, ComparisonType.Relative)); - Assert.False(ElectricImpedance.FromOhms(100).Equals(ElectricImpedance.FromOhms(120), 0.1, ComparisonType.Relative)); + ElectricImpedance ohm = ElectricImpedance.FromOhms(1); + Assert.False(ohm.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = ElectricImpedance.FromOhms(1); - Assert.Throws(() => v.Equals(ElectricImpedance.FromOhms(1), -1, ComparisonType.Relative)); + ElectricImpedance ohm = ElectricImpedance.FromOhms(1); + Assert.False(ohm.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - ElectricImpedance ohm = ElectricImpedance.FromOhms(1); - Assert.False(ohm.Equals(new object())); + var quantity = ElectricImpedance.FromOhms(firstValue); + var otherQuantity = ElectricImpedance.FromOhms(secondValue); + ElectricImpedance maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, ElectricImpedance.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - ElectricImpedance ohm = ElectricImpedance.FromOhms(1); - Assert.False(ohm.Equals(null)); + var quantity = ElectricImpedance.FromOhms(1); + var negativeTolerance = ElectricImpedance.FromOhms(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricInductanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricInductanceTestsBase.g.cs index 022a221992..b7889cf3c3 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricInductanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricInductanceTestsBase.g.cs @@ -655,34 +655,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = ElectricInductance.FromHenries(1); - Assert.True(v.Equals(ElectricInductance.FromHenries(1), HenriesTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(ElectricInductance.Zero, HenriesTolerance, ComparisonType.Relative)); - Assert.True(ElectricInductance.FromHenries(100).Equals(ElectricInductance.FromHenries(120), 0.3, ComparisonType.Relative)); - Assert.False(ElectricInductance.FromHenries(100).Equals(ElectricInductance.FromHenries(120), 0.1, ComparisonType.Relative)); + ElectricInductance henry = ElectricInductance.FromHenries(1); + Assert.False(henry.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = ElectricInductance.FromHenries(1); - Assert.Throws(() => v.Equals(ElectricInductance.FromHenries(1), -1, ComparisonType.Relative)); + ElectricInductance henry = ElectricInductance.FromHenries(1); + Assert.False(henry.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - ElectricInductance henry = ElectricInductance.FromHenries(1); - Assert.False(henry.Equals(new object())); + var quantity = ElectricInductance.FromHenries(firstValue); + var otherQuantity = ElectricInductance.FromHenries(secondValue); + ElectricInductance maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, ElectricInductance.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - ElectricInductance henry = ElectricInductance.FromHenries(1); - Assert.False(henry.Equals(null)); + var quantity = ElectricInductance.FromHenries(1); + var negativeTolerance = ElectricInductance.FromHenries(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialChangeRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialChangeRateTestsBase.g.cs index 2133015c69..c7ff162b51 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialChangeRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialChangeRateTestsBase.g.cs @@ -1087,34 +1087,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = ElectricPotentialChangeRate.FromVoltsPerSecond(1); - Assert.True(v.Equals(ElectricPotentialChangeRate.FromVoltsPerSecond(1), VoltsPerSecondTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(ElectricPotentialChangeRate.Zero, VoltsPerSecondTolerance, ComparisonType.Relative)); - Assert.True(ElectricPotentialChangeRate.FromVoltsPerSecond(100).Equals(ElectricPotentialChangeRate.FromVoltsPerSecond(120), 0.3, ComparisonType.Relative)); - Assert.False(ElectricPotentialChangeRate.FromVoltsPerSecond(100).Equals(ElectricPotentialChangeRate.FromVoltsPerSecond(120), 0.1, ComparisonType.Relative)); + ElectricPotentialChangeRate voltpersecond = ElectricPotentialChangeRate.FromVoltsPerSecond(1); + Assert.False(voltpersecond.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = ElectricPotentialChangeRate.FromVoltsPerSecond(1); - Assert.Throws(() => v.Equals(ElectricPotentialChangeRate.FromVoltsPerSecond(1), -1, ComparisonType.Relative)); + ElectricPotentialChangeRate voltpersecond = ElectricPotentialChangeRate.FromVoltsPerSecond(1); + Assert.False(voltpersecond.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - ElectricPotentialChangeRate voltpersecond = ElectricPotentialChangeRate.FromVoltsPerSecond(1); - Assert.False(voltpersecond.Equals(new object())); + var quantity = ElectricPotentialChangeRate.FromVoltsPerSecond(firstValue); + var otherQuantity = ElectricPotentialChangeRate.FromVoltsPerSecond(secondValue); + ElectricPotentialChangeRate maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, ElectricPotentialChangeRate.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - ElectricPotentialChangeRate voltpersecond = ElectricPotentialChangeRate.FromVoltsPerSecond(1); - Assert.False(voltpersecond.Equals(null)); + var quantity = ElectricPotentialChangeRate.FromVoltsPerSecond(1); + var negativeTolerance = ElectricPotentialChangeRate.FromVoltsPerSecond(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialTestsBase.g.cs index 4c4ccfa1ad..6ca4aa9a8c 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialTestsBase.g.cs @@ -765,34 +765,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = ElectricPotential.FromVolts(1); - Assert.True(v.Equals(ElectricPotential.FromVolts(1), VoltsTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(ElectricPotential.Zero, VoltsTolerance, ComparisonType.Relative)); - Assert.True(ElectricPotential.FromVolts(100).Equals(ElectricPotential.FromVolts(120), 0.3, ComparisonType.Relative)); - Assert.False(ElectricPotential.FromVolts(100).Equals(ElectricPotential.FromVolts(120), 0.1, ComparisonType.Relative)); + ElectricPotential volt = ElectricPotential.FromVolts(1); + Assert.False(volt.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = ElectricPotential.FromVolts(1); - Assert.Throws(() => v.Equals(ElectricPotential.FromVolts(1), -1, ComparisonType.Relative)); + ElectricPotential volt = ElectricPotential.FromVolts(1); + Assert.False(volt.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - ElectricPotential volt = ElectricPotential.FromVolts(1); - Assert.False(volt.Equals(new object())); + var quantity = ElectricPotential.FromVolts(firstValue); + var otherQuantity = ElectricPotential.FromVolts(secondValue); + ElectricPotential maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, ElectricPotential.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - ElectricPotential volt = ElectricPotential.FromVolts(1); - Assert.False(volt.Equals(null)); + var quantity = ElectricPotential.FromVolts(1); + var negativeTolerance = ElectricPotential.FromVolts(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricReactanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricReactanceTestsBase.g.cs index 0a8dc81039..9e24b6efe3 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricReactanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricReactanceTestsBase.g.cs @@ -739,34 +739,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = ElectricReactance.FromOhms(1); - Assert.True(v.Equals(ElectricReactance.FromOhms(1), OhmsTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(ElectricReactance.Zero, OhmsTolerance, ComparisonType.Relative)); - Assert.True(ElectricReactance.FromOhms(100).Equals(ElectricReactance.FromOhms(120), 0.3, ComparisonType.Relative)); - Assert.False(ElectricReactance.FromOhms(100).Equals(ElectricReactance.FromOhms(120), 0.1, ComparisonType.Relative)); + ElectricReactance ohm = ElectricReactance.FromOhms(1); + Assert.False(ohm.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = ElectricReactance.FromOhms(1); - Assert.Throws(() => v.Equals(ElectricReactance.FromOhms(1), -1, ComparisonType.Relative)); + ElectricReactance ohm = ElectricReactance.FromOhms(1); + Assert.False(ohm.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - ElectricReactance ohm = ElectricReactance.FromOhms(1); - Assert.False(ohm.Equals(new object())); + var quantity = ElectricReactance.FromOhms(firstValue); + var otherQuantity = ElectricReactance.FromOhms(secondValue); + ElectricReactance maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, ElectricReactance.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - ElectricReactance ohm = ElectricReactance.FromOhms(1); - Assert.False(ohm.Equals(null)); + var quantity = ElectricReactance.FromOhms(1); + var negativeTolerance = ElectricReactance.FromOhms(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricReactiveEnergyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricReactiveEnergyTestsBase.g.cs index 2bdbbc17c2..9e3d00362e 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricReactiveEnergyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricReactiveEnergyTestsBase.g.cs @@ -591,34 +591,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = ElectricReactiveEnergy.FromVoltampereReactiveHours(1); - Assert.True(v.Equals(ElectricReactiveEnergy.FromVoltampereReactiveHours(1), VoltampereReactiveHoursTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(ElectricReactiveEnergy.Zero, VoltampereReactiveHoursTolerance, ComparisonType.Relative)); - Assert.True(ElectricReactiveEnergy.FromVoltampereReactiveHours(100).Equals(ElectricReactiveEnergy.FromVoltampereReactiveHours(120), 0.3, ComparisonType.Relative)); - Assert.False(ElectricReactiveEnergy.FromVoltampereReactiveHours(100).Equals(ElectricReactiveEnergy.FromVoltampereReactiveHours(120), 0.1, ComparisonType.Relative)); + ElectricReactiveEnergy voltamperereactivehour = ElectricReactiveEnergy.FromVoltampereReactiveHours(1); + Assert.False(voltamperereactivehour.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = ElectricReactiveEnergy.FromVoltampereReactiveHours(1); - Assert.Throws(() => v.Equals(ElectricReactiveEnergy.FromVoltampereReactiveHours(1), -1, ComparisonType.Relative)); + ElectricReactiveEnergy voltamperereactivehour = ElectricReactiveEnergy.FromVoltampereReactiveHours(1); + Assert.False(voltamperereactivehour.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - ElectricReactiveEnergy voltamperereactivehour = ElectricReactiveEnergy.FromVoltampereReactiveHours(1); - Assert.False(voltamperereactivehour.Equals(new object())); + var quantity = ElectricReactiveEnergy.FromVoltampereReactiveHours(firstValue); + var otherQuantity = ElectricReactiveEnergy.FromVoltampereReactiveHours(secondValue); + ElectricReactiveEnergy maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, ElectricReactiveEnergy.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - ElectricReactiveEnergy voltamperereactivehour = ElectricReactiveEnergy.FromVoltampereReactiveHours(1); - Assert.False(voltamperereactivehour.Equals(null)); + var quantity = ElectricReactiveEnergy.FromVoltampereReactiveHours(1); + var negativeTolerance = ElectricReactiveEnergy.FromVoltampereReactiveHours(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricReactivePowerTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricReactivePowerTestsBase.g.cs index 1217ecf674..02aa73c09f 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricReactivePowerTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricReactivePowerTestsBase.g.cs @@ -623,34 +623,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = ElectricReactivePower.FromVoltamperesReactive(1); - Assert.True(v.Equals(ElectricReactivePower.FromVoltamperesReactive(1), VoltamperesReactiveTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(ElectricReactivePower.Zero, VoltamperesReactiveTolerance, ComparisonType.Relative)); - Assert.True(ElectricReactivePower.FromVoltamperesReactive(100).Equals(ElectricReactivePower.FromVoltamperesReactive(120), 0.3, ComparisonType.Relative)); - Assert.False(ElectricReactivePower.FromVoltamperesReactive(100).Equals(ElectricReactivePower.FromVoltamperesReactive(120), 0.1, ComparisonType.Relative)); + ElectricReactivePower voltamperereactive = ElectricReactivePower.FromVoltamperesReactive(1); + Assert.False(voltamperereactive.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = ElectricReactivePower.FromVoltamperesReactive(1); - Assert.Throws(() => v.Equals(ElectricReactivePower.FromVoltamperesReactive(1), -1, ComparisonType.Relative)); + ElectricReactivePower voltamperereactive = ElectricReactivePower.FromVoltamperesReactive(1); + Assert.False(voltamperereactive.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - ElectricReactivePower voltamperereactive = ElectricReactivePower.FromVoltamperesReactive(1); - Assert.False(voltamperereactive.Equals(new object())); + var quantity = ElectricReactivePower.FromVoltamperesReactive(firstValue); + var otherQuantity = ElectricReactivePower.FromVoltamperesReactive(secondValue); + ElectricReactivePower maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, ElectricReactivePower.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - ElectricReactivePower voltamperereactive = ElectricReactivePower.FromVoltamperesReactive(1); - Assert.False(voltamperereactive.Equals(null)); + var quantity = ElectricReactivePower.FromVoltamperesReactive(1); + var negativeTolerance = ElectricReactivePower.FromVoltamperesReactive(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistanceTestsBase.g.cs index 52aeab3c26..408555f9cb 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistanceTestsBase.g.cs @@ -739,34 +739,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = ElectricResistance.FromOhms(1); - Assert.True(v.Equals(ElectricResistance.FromOhms(1), OhmsTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(ElectricResistance.Zero, OhmsTolerance, ComparisonType.Relative)); - Assert.True(ElectricResistance.FromOhms(100).Equals(ElectricResistance.FromOhms(120), 0.3, ComparisonType.Relative)); - Assert.False(ElectricResistance.FromOhms(100).Equals(ElectricResistance.FromOhms(120), 0.1, ComparisonType.Relative)); + ElectricResistance ohm = ElectricResistance.FromOhms(1); + Assert.False(ohm.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = ElectricResistance.FromOhms(1); - Assert.Throws(() => v.Equals(ElectricResistance.FromOhms(1), -1, ComparisonType.Relative)); + ElectricResistance ohm = ElectricResistance.FromOhms(1); + Assert.False(ohm.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - ElectricResistance ohm = ElectricResistance.FromOhms(1); - Assert.False(ohm.Equals(new object())); + var quantity = ElectricResistance.FromOhms(firstValue); + var otherQuantity = ElectricResistance.FromOhms(secondValue); + ElectricResistance maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, ElectricResistance.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - ElectricResistance ohm = ElectricResistance.FromOhms(1); - Assert.False(ohm.Equals(null)); + var quantity = ElectricResistance.FromOhms(1); + var negativeTolerance = ElectricResistance.FromOhms(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistivityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistivityTestsBase.g.cs index ce35d0b79f..c5086b7fda 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistivityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistivityTestsBase.g.cs @@ -919,34 +919,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = ElectricResistivity.FromOhmMeters(1); - Assert.True(v.Equals(ElectricResistivity.FromOhmMeters(1), OhmMetersTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(ElectricResistivity.Zero, OhmMetersTolerance, ComparisonType.Relative)); - Assert.True(ElectricResistivity.FromOhmMeters(100).Equals(ElectricResistivity.FromOhmMeters(120), 0.3, ComparisonType.Relative)); - Assert.False(ElectricResistivity.FromOhmMeters(100).Equals(ElectricResistivity.FromOhmMeters(120), 0.1, ComparisonType.Relative)); + ElectricResistivity ohmmeter = ElectricResistivity.FromOhmMeters(1); + Assert.False(ohmmeter.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = ElectricResistivity.FromOhmMeters(1); - Assert.Throws(() => v.Equals(ElectricResistivity.FromOhmMeters(1), -1, ComparisonType.Relative)); + ElectricResistivity ohmmeter = ElectricResistivity.FromOhmMeters(1); + Assert.False(ohmmeter.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - ElectricResistivity ohmmeter = ElectricResistivity.FromOhmMeters(1); - Assert.False(ohmmeter.Equals(new object())); + var quantity = ElectricResistivity.FromOhmMeters(firstValue); + var otherQuantity = ElectricResistivity.FromOhmMeters(secondValue); + ElectricResistivity maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, ElectricResistivity.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - ElectricResistivity ohmmeter = ElectricResistivity.FromOhmMeters(1); - Assert.False(ohmmeter.Equals(null)); + var quantity = ElectricResistivity.FromOhmMeters(1); + var negativeTolerance = ElectricResistivity.FromOhmMeters(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricSurfaceChargeDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricSurfaceChargeDensityTestsBase.g.cs index 42f1c2654a..1962e6b00f 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricSurfaceChargeDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricSurfaceChargeDensityTestsBase.g.cs @@ -591,34 +591,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1); - Assert.True(v.Equals(ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1), CoulombsPerSquareMeterTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(ElectricSurfaceChargeDensity.Zero, CoulombsPerSquareMeterTolerance, ComparisonType.Relative)); - Assert.True(ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(100).Equals(ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(120), 0.3, ComparisonType.Relative)); - Assert.False(ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(100).Equals(ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(120), 0.1, ComparisonType.Relative)); + ElectricSurfaceChargeDensity coulombpersquaremeter = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1); + Assert.False(coulombpersquaremeter.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1); - Assert.Throws(() => v.Equals(ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1), -1, ComparisonType.Relative)); + ElectricSurfaceChargeDensity coulombpersquaremeter = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1); + Assert.False(coulombpersquaremeter.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - ElectricSurfaceChargeDensity coulombpersquaremeter = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1); - Assert.False(coulombpersquaremeter.Equals(new object())); + var quantity = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(firstValue); + var otherQuantity = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(secondValue); + ElectricSurfaceChargeDensity maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, ElectricSurfaceChargeDensity.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - ElectricSurfaceChargeDensity coulombpersquaremeter = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1); - Assert.False(coulombpersquaremeter.Equals(null)); + var quantity = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1); + var negativeTolerance = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricSusceptanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricSusceptanceTestsBase.g.cs index 9b7f4e7d94..542de39a01 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricSusceptanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricSusceptanceTestsBase.g.cs @@ -983,34 +983,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = ElectricSusceptance.FromSiemens(1); - Assert.True(v.Equals(ElectricSusceptance.FromSiemens(1), SiemensTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(ElectricSusceptance.Zero, SiemensTolerance, ComparisonType.Relative)); - Assert.True(ElectricSusceptance.FromSiemens(100).Equals(ElectricSusceptance.FromSiemens(120), 0.3, ComparisonType.Relative)); - Assert.False(ElectricSusceptance.FromSiemens(100).Equals(ElectricSusceptance.FromSiemens(120), 0.1, ComparisonType.Relative)); + ElectricSusceptance siemens = ElectricSusceptance.FromSiemens(1); + Assert.False(siemens.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = ElectricSusceptance.FromSiemens(1); - Assert.Throws(() => v.Equals(ElectricSusceptance.FromSiemens(1), -1, ComparisonType.Relative)); + ElectricSusceptance siemens = ElectricSusceptance.FromSiemens(1); + Assert.False(siemens.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - ElectricSusceptance siemens = ElectricSusceptance.FromSiemens(1); - Assert.False(siemens.Equals(new object())); + var quantity = ElectricSusceptance.FromSiemens(firstValue); + var otherQuantity = ElectricSusceptance.FromSiemens(secondValue); + ElectricSusceptance maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, ElectricSusceptance.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - ElectricSusceptance siemens = ElectricSusceptance.FromSiemens(1); - Assert.False(siemens.Equals(null)); + var quantity = ElectricSusceptance.FromSiemens(1); + var negativeTolerance = ElectricSusceptance.FromSiemens(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/EnergyDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/EnergyDensityTestsBase.g.cs index d1170ac3ad..9bf463ecdd 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/EnergyDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/EnergyDensityTestsBase.g.cs @@ -879,34 +879,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = EnergyDensity.FromJoulesPerCubicMeter(1); - Assert.True(v.Equals(EnergyDensity.FromJoulesPerCubicMeter(1), JoulesPerCubicMeterTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(EnergyDensity.Zero, JoulesPerCubicMeterTolerance, ComparisonType.Relative)); - Assert.True(EnergyDensity.FromJoulesPerCubicMeter(100).Equals(EnergyDensity.FromJoulesPerCubicMeter(120), 0.3, ComparisonType.Relative)); - Assert.False(EnergyDensity.FromJoulesPerCubicMeter(100).Equals(EnergyDensity.FromJoulesPerCubicMeter(120), 0.1, ComparisonType.Relative)); + EnergyDensity joulepercubicmeter = EnergyDensity.FromJoulesPerCubicMeter(1); + Assert.False(joulepercubicmeter.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = EnergyDensity.FromJoulesPerCubicMeter(1); - Assert.Throws(() => v.Equals(EnergyDensity.FromJoulesPerCubicMeter(1), -1, ComparisonType.Relative)); + EnergyDensity joulepercubicmeter = EnergyDensity.FromJoulesPerCubicMeter(1); + Assert.False(joulepercubicmeter.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - EnergyDensity joulepercubicmeter = EnergyDensity.FromJoulesPerCubicMeter(1); - Assert.False(joulepercubicmeter.Equals(new object())); + var quantity = EnergyDensity.FromJoulesPerCubicMeter(firstValue); + var otherQuantity = EnergyDensity.FromJoulesPerCubicMeter(secondValue); + EnergyDensity maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, EnergyDensity.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - EnergyDensity joulepercubicmeter = EnergyDensity.FromJoulesPerCubicMeter(1); - Assert.False(joulepercubicmeter.Equals(null)); + var quantity = EnergyDensity.FromJoulesPerCubicMeter(1); + var negativeTolerance = EnergyDensity.FromJoulesPerCubicMeter(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/EnergyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/EnergyTestsBase.g.cs index deac0da13e..e8735945b6 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/EnergyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/EnergyTestsBase.g.cs @@ -2120,34 +2120,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = Energy.FromJoules(1); - Assert.True(v.Equals(Energy.FromJoules(1), JoulesTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(Energy.Zero, JoulesTolerance, ComparisonType.Relative)); - Assert.True(Energy.FromJoules(100).Equals(Energy.FromJoules(120), 0.3, ComparisonType.Relative)); - Assert.False(Energy.FromJoules(100).Equals(Energy.FromJoules(120), 0.1, ComparisonType.Relative)); + Energy joule = Energy.FromJoules(1); + Assert.False(joule.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = Energy.FromJoules(1); - Assert.Throws(() => v.Equals(Energy.FromJoules(1), -1, ComparisonType.Relative)); + Energy joule = Energy.FromJoules(1); + Assert.False(joule.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - Energy joule = Energy.FromJoules(1); - Assert.False(joule.Equals(new object())); + var quantity = Energy.FromJoules(firstValue); + var otherQuantity = Energy.FromJoules(secondValue); + Energy maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, Energy.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - Energy joule = Energy.FromJoules(1); - Assert.False(joule.Equals(null)); + var quantity = Energy.FromJoules(1); + var negativeTolerance = Energy.FromJoules(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/EntropyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/EntropyTestsBase.g.cs index 59ea0ad87f..a467238862 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/EntropyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/EntropyTestsBase.g.cs @@ -719,34 +719,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = Entropy.FromJoulesPerKelvin(1); - Assert.True(v.Equals(Entropy.FromJoulesPerKelvin(1), JoulesPerKelvinTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(Entropy.Zero, JoulesPerKelvinTolerance, ComparisonType.Relative)); - Assert.True(Entropy.FromJoulesPerKelvin(100).Equals(Entropy.FromJoulesPerKelvin(120), 0.3, ComparisonType.Relative)); - Assert.False(Entropy.FromJoulesPerKelvin(100).Equals(Entropy.FromJoulesPerKelvin(120), 0.1, ComparisonType.Relative)); + Entropy jouleperkelvin = Entropy.FromJoulesPerKelvin(1); + Assert.False(jouleperkelvin.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = Entropy.FromJoulesPerKelvin(1); - Assert.Throws(() => v.Equals(Entropy.FromJoulesPerKelvin(1), -1, ComparisonType.Relative)); + Entropy jouleperkelvin = Entropy.FromJoulesPerKelvin(1); + Assert.False(jouleperkelvin.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - Entropy jouleperkelvin = Entropy.FromJoulesPerKelvin(1); - Assert.False(jouleperkelvin.Equals(new object())); + var quantity = Entropy.FromJoulesPerKelvin(firstValue); + var otherQuantity = Entropy.FromJoulesPerKelvin(secondValue); + Entropy maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, Entropy.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - Entropy jouleperkelvin = Entropy.FromJoulesPerKelvin(1); - Assert.False(jouleperkelvin.Equals(null)); + var quantity = Entropy.FromJoulesPerKelvin(1); + var negativeTolerance = Entropy.FromJoulesPerKelvin(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/FluidResistanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/FluidResistanceTestsBase.g.cs index e5fce9111f..a6db98697c 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/FluidResistanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/FluidResistanceTestsBase.g.cs @@ -1502,34 +1502,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = FluidResistance.FromPascalSecondsPerCubicMeter(1); - Assert.True(v.Equals(FluidResistance.FromPascalSecondsPerCubicMeter(1), PascalSecondsPerCubicMeterTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(FluidResistance.Zero, PascalSecondsPerCubicMeterTolerance, ComparisonType.Relative)); - Assert.True(FluidResistance.FromPascalSecondsPerCubicMeter(100).Equals(FluidResistance.FromPascalSecondsPerCubicMeter(120), 0.3, ComparisonType.Relative)); - Assert.False(FluidResistance.FromPascalSecondsPerCubicMeter(100).Equals(FluidResistance.FromPascalSecondsPerCubicMeter(120), 0.1, ComparisonType.Relative)); + FluidResistance pascalsecondpercubicmeter = FluidResistance.FromPascalSecondsPerCubicMeter(1); + Assert.False(pascalsecondpercubicmeter.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = FluidResistance.FromPascalSecondsPerCubicMeter(1); - Assert.Throws(() => v.Equals(FluidResistance.FromPascalSecondsPerCubicMeter(1), -1, ComparisonType.Relative)); + FluidResistance pascalsecondpercubicmeter = FluidResistance.FromPascalSecondsPerCubicMeter(1); + Assert.False(pascalsecondpercubicmeter.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - FluidResistance pascalsecondpercubicmeter = FluidResistance.FromPascalSecondsPerCubicMeter(1); - Assert.False(pascalsecondpercubicmeter.Equals(new object())); + var quantity = FluidResistance.FromPascalSecondsPerCubicMeter(firstValue); + var otherQuantity = FluidResistance.FromPascalSecondsPerCubicMeter(secondValue); + FluidResistance maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, FluidResistance.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - FluidResistance pascalsecondpercubicmeter = FluidResistance.FromPascalSecondsPerCubicMeter(1); - Assert.False(pascalsecondpercubicmeter.Equals(null)); + var quantity = FluidResistance.FromPascalSecondsPerCubicMeter(1); + var negativeTolerance = FluidResistance.FromPascalSecondsPerCubicMeter(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ForceChangeRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ForceChangeRateTestsBase.g.cs index 71f7e85020..a7907ea8d8 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ForceChangeRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ForceChangeRateTestsBase.g.cs @@ -1059,34 +1059,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = ForceChangeRate.FromNewtonsPerSecond(1); - Assert.True(v.Equals(ForceChangeRate.FromNewtonsPerSecond(1), NewtonsPerSecondTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(ForceChangeRate.Zero, NewtonsPerSecondTolerance, ComparisonType.Relative)); - Assert.True(ForceChangeRate.FromNewtonsPerSecond(100).Equals(ForceChangeRate.FromNewtonsPerSecond(120), 0.3, ComparisonType.Relative)); - Assert.False(ForceChangeRate.FromNewtonsPerSecond(100).Equals(ForceChangeRate.FromNewtonsPerSecond(120), 0.1, ComparisonType.Relative)); + ForceChangeRate newtonpersecond = ForceChangeRate.FromNewtonsPerSecond(1); + Assert.False(newtonpersecond.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = ForceChangeRate.FromNewtonsPerSecond(1); - Assert.Throws(() => v.Equals(ForceChangeRate.FromNewtonsPerSecond(1), -1, ComparisonType.Relative)); + ForceChangeRate newtonpersecond = ForceChangeRate.FromNewtonsPerSecond(1); + Assert.False(newtonpersecond.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - ForceChangeRate newtonpersecond = ForceChangeRate.FromNewtonsPerSecond(1); - Assert.False(newtonpersecond.Equals(new object())); + var quantity = ForceChangeRate.FromNewtonsPerSecond(firstValue); + var otherQuantity = ForceChangeRate.FromNewtonsPerSecond(secondValue); + ForceChangeRate maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, ForceChangeRate.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - ForceChangeRate newtonpersecond = ForceChangeRate.FromNewtonsPerSecond(1); - Assert.False(newtonpersecond.Equals(null)); + var quantity = ForceChangeRate.FromNewtonsPerSecond(1); + var negativeTolerance = ForceChangeRate.FromNewtonsPerSecond(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ForcePerLengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ForcePerLengthTestsBase.g.cs index 009824af70..6be0f104a1 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ForcePerLengthTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ForcePerLengthTestsBase.g.cs @@ -1861,34 +1861,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = ForcePerLength.FromNewtonsPerMeter(1); - Assert.True(v.Equals(ForcePerLength.FromNewtonsPerMeter(1), NewtonsPerMeterTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(ForcePerLength.Zero, NewtonsPerMeterTolerance, ComparisonType.Relative)); - Assert.True(ForcePerLength.FromNewtonsPerMeter(100).Equals(ForcePerLength.FromNewtonsPerMeter(120), 0.3, ComparisonType.Relative)); - Assert.False(ForcePerLength.FromNewtonsPerMeter(100).Equals(ForcePerLength.FromNewtonsPerMeter(120), 0.1, ComparisonType.Relative)); + ForcePerLength newtonpermeter = ForcePerLength.FromNewtonsPerMeter(1); + Assert.False(newtonpermeter.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = ForcePerLength.FromNewtonsPerMeter(1); - Assert.Throws(() => v.Equals(ForcePerLength.FromNewtonsPerMeter(1), -1, ComparisonType.Relative)); + ForcePerLength newtonpermeter = ForcePerLength.FromNewtonsPerMeter(1); + Assert.False(newtonpermeter.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - ForcePerLength newtonpermeter = ForcePerLength.FromNewtonsPerMeter(1); - Assert.False(newtonpermeter.Equals(new object())); + var quantity = ForcePerLength.FromNewtonsPerMeter(firstValue); + var otherQuantity = ForcePerLength.FromNewtonsPerMeter(secondValue); + ForcePerLength maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, ForcePerLength.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - ForcePerLength newtonpermeter = ForcePerLength.FromNewtonsPerMeter(1); - Assert.False(newtonpermeter.Equals(null)); + var quantity = ForcePerLength.FromNewtonsPerMeter(1); + var negativeTolerance = ForcePerLength.FromNewtonsPerMeter(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ForceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ForceTestsBase.g.cs index 596f6baf4e..078d781861 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ForceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ForceTestsBase.g.cs @@ -1305,34 +1305,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = Force.FromNewtons(1); - Assert.True(v.Equals(Force.FromNewtons(1), NewtonsTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(Force.Zero, NewtonsTolerance, ComparisonType.Relative)); - Assert.True(Force.FromNewtons(100).Equals(Force.FromNewtons(120), 0.3, ComparisonType.Relative)); - Assert.False(Force.FromNewtons(100).Equals(Force.FromNewtons(120), 0.1, ComparisonType.Relative)); + Force newton = Force.FromNewtons(1); + Assert.False(newton.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = Force.FromNewtons(1); - Assert.Throws(() => v.Equals(Force.FromNewtons(1), -1, ComparisonType.Relative)); + Force newton = Force.FromNewtons(1); + Assert.False(newton.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - Force newton = Force.FromNewtons(1); - Assert.False(newton.Equals(new object())); + var quantity = Force.FromNewtons(firstValue); + var otherQuantity = Force.FromNewtons(secondValue); + Force maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, Force.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - Force newton = Force.FromNewtons(1); - Assert.False(newton.Equals(null)); + var quantity = Force.FromNewtons(1); + var negativeTolerance = Force.FromNewtons(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/FrequencyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/FrequencyTestsBase.g.cs index 0f21f9f0eb..15ec9aef68 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/FrequencyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/FrequencyTestsBase.g.cs @@ -1008,34 +1008,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = Frequency.FromHertz(1); - Assert.True(v.Equals(Frequency.FromHertz(1), HertzTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(Frequency.Zero, HertzTolerance, ComparisonType.Relative)); - Assert.True(Frequency.FromHertz(100).Equals(Frequency.FromHertz(120), 0.3, ComparisonType.Relative)); - Assert.False(Frequency.FromHertz(100).Equals(Frequency.FromHertz(120), 0.1, ComparisonType.Relative)); + Frequency hertz = Frequency.FromHertz(1); + Assert.False(hertz.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = Frequency.FromHertz(1); - Assert.Throws(() => v.Equals(Frequency.FromHertz(1), -1, ComparisonType.Relative)); + Frequency hertz = Frequency.FromHertz(1); + Assert.False(hertz.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - Frequency hertz = Frequency.FromHertz(1); - Assert.False(hertz.Equals(new object())); + var quantity = Frequency.FromHertz(firstValue); + var otherQuantity = Frequency.FromHertz(secondValue); + Frequency maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, Frequency.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - Frequency hertz = Frequency.FromHertz(1); - Assert.False(hertz.Equals(null)); + var quantity = Frequency.FromHertz(1); + var negativeTolerance = Frequency.FromHertz(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/FuelEfficiencyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/FuelEfficiencyTestsBase.g.cs index 3fee48c253..e0a49af9b6 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/FuelEfficiencyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/FuelEfficiencyTestsBase.g.cs @@ -623,34 +623,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = FuelEfficiency.FromKilometersPerLiter(1); - Assert.True(v.Equals(FuelEfficiency.FromKilometersPerLiter(1), KilometersPerLiterTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(FuelEfficiency.Zero, KilometersPerLiterTolerance, ComparisonType.Relative)); - Assert.True(FuelEfficiency.FromKilometersPerLiter(100).Equals(FuelEfficiency.FromKilometersPerLiter(120), 0.3, ComparisonType.Relative)); - Assert.False(FuelEfficiency.FromKilometersPerLiter(100).Equals(FuelEfficiency.FromKilometersPerLiter(120), 0.1, ComparisonType.Relative)); + FuelEfficiency kilometerperliter = FuelEfficiency.FromKilometersPerLiter(1); + Assert.False(kilometerperliter.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = FuelEfficiency.FromKilometersPerLiter(1); - Assert.Throws(() => v.Equals(FuelEfficiency.FromKilometersPerLiter(1), -1, ComparisonType.Relative)); + FuelEfficiency kilometerperliter = FuelEfficiency.FromKilometersPerLiter(1); + Assert.False(kilometerperliter.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - FuelEfficiency kilometerperliter = FuelEfficiency.FromKilometersPerLiter(1); - Assert.False(kilometerperliter.Equals(new object())); + var quantity = FuelEfficiency.FromKilometersPerLiter(firstValue); + var otherQuantity = FuelEfficiency.FromKilometersPerLiter(secondValue); + FuelEfficiency maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, FuelEfficiency.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - FuelEfficiency kilometerperliter = FuelEfficiency.FromKilometersPerLiter(1); - Assert.False(kilometerperliter.Equals(null)); + var quantity = FuelEfficiency.FromKilometersPerLiter(1); + var negativeTolerance = FuelEfficiency.FromKilometersPerLiter(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/HeatFluxTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/HeatFluxTestsBase.g.cs index c9342f9574..4ae644c6b0 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/HeatFluxTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/HeatFluxTestsBase.g.cs @@ -1092,34 +1092,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = HeatFlux.FromWattsPerSquareMeter(1); - Assert.True(v.Equals(HeatFlux.FromWattsPerSquareMeter(1), WattsPerSquareMeterTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(HeatFlux.Zero, WattsPerSquareMeterTolerance, ComparisonType.Relative)); - Assert.True(HeatFlux.FromWattsPerSquareMeter(100).Equals(HeatFlux.FromWattsPerSquareMeter(120), 0.3, ComparisonType.Relative)); - Assert.False(HeatFlux.FromWattsPerSquareMeter(100).Equals(HeatFlux.FromWattsPerSquareMeter(120), 0.1, ComparisonType.Relative)); + HeatFlux wattpersquaremeter = HeatFlux.FromWattsPerSquareMeter(1); + Assert.False(wattpersquaremeter.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = HeatFlux.FromWattsPerSquareMeter(1); - Assert.Throws(() => v.Equals(HeatFlux.FromWattsPerSquareMeter(1), -1, ComparisonType.Relative)); + HeatFlux wattpersquaremeter = HeatFlux.FromWattsPerSquareMeter(1); + Assert.False(wattpersquaremeter.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - HeatFlux wattpersquaremeter = HeatFlux.FromWattsPerSquareMeter(1); - Assert.False(wattpersquaremeter.Equals(new object())); + var quantity = HeatFlux.FromWattsPerSquareMeter(firstValue); + var otherQuantity = HeatFlux.FromWattsPerSquareMeter(secondValue); + HeatFlux maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, HeatFlux.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - HeatFlux wattpersquaremeter = HeatFlux.FromWattsPerSquareMeter(1); - Assert.False(wattpersquaremeter.Equals(null)); + var quantity = HeatFlux.FromWattsPerSquareMeter(1); + var negativeTolerance = HeatFlux.FromWattsPerSquareMeter(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/HeatTransferCoefficientTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/HeatTransferCoefficientTestsBase.g.cs index eeb73465cf..04f8e48266 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/HeatTransferCoefficientTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/HeatTransferCoefficientTestsBase.g.cs @@ -844,34 +844,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(1); - Assert.True(v.Equals(HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(1), WattsPerSquareMeterKelvinTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(HeatTransferCoefficient.Zero, WattsPerSquareMeterKelvinTolerance, ComparisonType.Relative)); - Assert.True(HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(100).Equals(HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(120), 0.3, ComparisonType.Relative)); - Assert.False(HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(100).Equals(HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(120), 0.1, ComparisonType.Relative)); + HeatTransferCoefficient wattpersquaremeterkelvin = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(1); + Assert.False(wattpersquaremeterkelvin.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(1); - Assert.Throws(() => v.Equals(HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(1), -1, ComparisonType.Relative)); + HeatTransferCoefficient wattpersquaremeterkelvin = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(1); + Assert.False(wattpersquaremeterkelvin.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - HeatTransferCoefficient wattpersquaremeterkelvin = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(1); - Assert.False(wattpersquaremeterkelvin.Equals(new object())); + var quantity = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(firstValue); + var otherQuantity = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(secondValue); + HeatTransferCoefficient maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, HeatTransferCoefficient.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - HeatTransferCoefficient wattpersquaremeterkelvin = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(1); - Assert.False(wattpersquaremeterkelvin.Equals(null)); + var quantity = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(1); + var negativeTolerance = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/IlluminanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/IlluminanceTestsBase.g.cs index 4cd667e085..dd3045fcc8 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/IlluminanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/IlluminanceTestsBase.g.cs @@ -611,34 +611,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = Illuminance.FromLux(1); - Assert.True(v.Equals(Illuminance.FromLux(1), LuxTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(Illuminance.Zero, LuxTolerance, ComparisonType.Relative)); - Assert.True(Illuminance.FromLux(100).Equals(Illuminance.FromLux(120), 0.3, ComparisonType.Relative)); - Assert.False(Illuminance.FromLux(100).Equals(Illuminance.FromLux(120), 0.1, ComparisonType.Relative)); + Illuminance lux = Illuminance.FromLux(1); + Assert.False(lux.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = Illuminance.FromLux(1); - Assert.Throws(() => v.Equals(Illuminance.FromLux(1), -1, ComparisonType.Relative)); + Illuminance lux = Illuminance.FromLux(1); + Assert.False(lux.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - Illuminance lux = Illuminance.FromLux(1); - Assert.False(lux.Equals(new object())); + var quantity = Illuminance.FromLux(firstValue); + var otherQuantity = Illuminance.FromLux(secondValue); + Illuminance maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, Illuminance.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - Illuminance lux = Illuminance.FromLux(1); - Assert.False(lux.Equals(null)); + var quantity = Illuminance.FromLux(1); + var negativeTolerance = Illuminance.FromLux(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ImpulseTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ImpulseTestsBase.g.cs index 77a8908ca5..1fc469f050 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ImpulseTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ImpulseTestsBase.g.cs @@ -899,34 +899,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = Impulse.FromNewtonSeconds(1); - Assert.True(v.Equals(Impulse.FromNewtonSeconds(1), NewtonSecondsTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(Impulse.Zero, NewtonSecondsTolerance, ComparisonType.Relative)); - Assert.True(Impulse.FromNewtonSeconds(100).Equals(Impulse.FromNewtonSeconds(120), 0.3, ComparisonType.Relative)); - Assert.False(Impulse.FromNewtonSeconds(100).Equals(Impulse.FromNewtonSeconds(120), 0.1, ComparisonType.Relative)); + Impulse newtonsecond = Impulse.FromNewtonSeconds(1); + Assert.False(newtonsecond.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = Impulse.FromNewtonSeconds(1); - Assert.Throws(() => v.Equals(Impulse.FromNewtonSeconds(1), -1, ComparisonType.Relative)); + Impulse newtonsecond = Impulse.FromNewtonSeconds(1); + Assert.False(newtonsecond.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - Impulse newtonsecond = Impulse.FromNewtonSeconds(1); - Assert.False(newtonsecond.Equals(new object())); + var quantity = Impulse.FromNewtonSeconds(firstValue); + var otherQuantity = Impulse.FromNewtonSeconds(secondValue); + Impulse maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, Impulse.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - Impulse newtonsecond = Impulse.FromNewtonSeconds(1); - Assert.False(newtonsecond.Equals(null)); + var quantity = Impulse.FromNewtonSeconds(1); + var negativeTolerance = Impulse.FromNewtonSeconds(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/InformationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/InformationTestsBase.g.cs index 1089205005..f53661ad89 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/InformationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/InformationTestsBase.g.cs @@ -1527,34 +1527,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = Information.FromBits(1); - Assert.True(v.Equals(Information.FromBits(1), BitsTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(Information.Zero, BitsTolerance, ComparisonType.Relative)); - Assert.True(Information.FromBits(100).Equals(Information.FromBits(120), 0.3, ComparisonType.Relative)); - Assert.False(Information.FromBits(100).Equals(Information.FromBits(120), 0.1, ComparisonType.Relative)); + Information bit = Information.FromBits(1); + Assert.False(bit.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = Information.FromBits(1); - Assert.Throws(() => v.Equals(Information.FromBits(1), -1, ComparisonType.Relative)); + Information bit = Information.FromBits(1); + Assert.False(bit.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - Information bit = Information.FromBits(1); - Assert.False(bit.Equals(new object())); + var quantity = Information.FromBits(firstValue); + var otherQuantity = Information.FromBits(secondValue); + Information maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, Information.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - Information bit = Information.FromBits(1); - Assert.False(bit.Equals(null)); + var quantity = Information.FromBits(1); + var negativeTolerance = Information.FromBits(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/IrradianceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/IrradianceTestsBase.g.cs index baecb5d8ed..64649485e0 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/IrradianceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/IrradianceTestsBase.g.cs @@ -919,34 +919,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = Irradiance.FromWattsPerSquareMeter(1); - Assert.True(v.Equals(Irradiance.FromWattsPerSquareMeter(1), WattsPerSquareMeterTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(Irradiance.Zero, WattsPerSquareMeterTolerance, ComparisonType.Relative)); - Assert.True(Irradiance.FromWattsPerSquareMeter(100).Equals(Irradiance.FromWattsPerSquareMeter(120), 0.3, ComparisonType.Relative)); - Assert.False(Irradiance.FromWattsPerSquareMeter(100).Equals(Irradiance.FromWattsPerSquareMeter(120), 0.1, ComparisonType.Relative)); + Irradiance wattpersquaremeter = Irradiance.FromWattsPerSquareMeter(1); + Assert.False(wattpersquaremeter.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = Irradiance.FromWattsPerSquareMeter(1); - Assert.Throws(() => v.Equals(Irradiance.FromWattsPerSquareMeter(1), -1, ComparisonType.Relative)); + Irradiance wattpersquaremeter = Irradiance.FromWattsPerSquareMeter(1); + Assert.False(wattpersquaremeter.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - Irradiance wattpersquaremeter = Irradiance.FromWattsPerSquareMeter(1); - Assert.False(wattpersquaremeter.Equals(new object())); + var quantity = Irradiance.FromWattsPerSquareMeter(firstValue); + var otherQuantity = Irradiance.FromWattsPerSquareMeter(secondValue); + Irradiance maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, Irradiance.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - Irradiance wattpersquaremeter = Irradiance.FromWattsPerSquareMeter(1); - Assert.False(wattpersquaremeter.Equals(null)); + var quantity = Irradiance.FromWattsPerSquareMeter(1); + var negativeTolerance = Irradiance.FromWattsPerSquareMeter(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/IrradiationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/IrradiationTestsBase.g.cs index 52edc6447c..7bcb25e38d 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/IrradiationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/IrradiationTestsBase.g.cs @@ -783,34 +783,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = Irradiation.FromJoulesPerSquareMeter(1); - Assert.True(v.Equals(Irradiation.FromJoulesPerSquareMeter(1), JoulesPerSquareMeterTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(Irradiation.Zero, JoulesPerSquareMeterTolerance, ComparisonType.Relative)); - Assert.True(Irradiation.FromJoulesPerSquareMeter(100).Equals(Irradiation.FromJoulesPerSquareMeter(120), 0.3, ComparisonType.Relative)); - Assert.False(Irradiation.FromJoulesPerSquareMeter(100).Equals(Irradiation.FromJoulesPerSquareMeter(120), 0.1, ComparisonType.Relative)); + Irradiation joulepersquaremeter = Irradiation.FromJoulesPerSquareMeter(1); + Assert.False(joulepersquaremeter.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = Irradiation.FromJoulesPerSquareMeter(1); - Assert.Throws(() => v.Equals(Irradiation.FromJoulesPerSquareMeter(1), -1, ComparisonType.Relative)); + Irradiation joulepersquaremeter = Irradiation.FromJoulesPerSquareMeter(1); + Assert.False(joulepersquaremeter.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - Irradiation joulepersquaremeter = Irradiation.FromJoulesPerSquareMeter(1); - Assert.False(joulepersquaremeter.Equals(new object())); + var quantity = Irradiation.FromJoulesPerSquareMeter(firstValue); + var otherQuantity = Irradiation.FromJoulesPerSquareMeter(secondValue); + Irradiation maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, Irradiation.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - Irradiation joulepersquaremeter = Irradiation.FromJoulesPerSquareMeter(1); - Assert.False(joulepersquaremeter.Equals(null)); + var quantity = Irradiation.FromJoulesPerSquareMeter(1); + var negativeTolerance = Irradiation.FromJoulesPerSquareMeter(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/JerkTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/JerkTestsBase.g.cs index 65c5d79c7f..536de9d86d 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/JerkTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/JerkTestsBase.g.cs @@ -1034,34 +1034,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = Jerk.FromMetersPerSecondCubed(1); - Assert.True(v.Equals(Jerk.FromMetersPerSecondCubed(1), MetersPerSecondCubedTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(Jerk.Zero, MetersPerSecondCubedTolerance, ComparisonType.Relative)); - Assert.True(Jerk.FromMetersPerSecondCubed(100).Equals(Jerk.FromMetersPerSecondCubed(120), 0.3, ComparisonType.Relative)); - Assert.False(Jerk.FromMetersPerSecondCubed(100).Equals(Jerk.FromMetersPerSecondCubed(120), 0.1, ComparisonType.Relative)); + Jerk meterpersecondcubed = Jerk.FromMetersPerSecondCubed(1); + Assert.False(meterpersecondcubed.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = Jerk.FromMetersPerSecondCubed(1); - Assert.Throws(() => v.Equals(Jerk.FromMetersPerSecondCubed(1), -1, ComparisonType.Relative)); + Jerk meterpersecondcubed = Jerk.FromMetersPerSecondCubed(1); + Assert.False(meterpersecondcubed.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - Jerk meterpersecondcubed = Jerk.FromMetersPerSecondCubed(1); - Assert.False(meterpersecondcubed.Equals(new object())); + var quantity = Jerk.FromMetersPerSecondCubed(firstValue); + var otherQuantity = Jerk.FromMetersPerSecondCubed(secondValue); + Jerk maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, Jerk.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - Jerk meterpersecondcubed = Jerk.FromMetersPerSecondCubed(1); - Assert.False(meterpersecondcubed.Equals(null)); + var quantity = Jerk.FromMetersPerSecondCubed(1); + var negativeTolerance = Jerk.FromMetersPerSecondCubed(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/KinematicViscosityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/KinematicViscosityTestsBase.g.cs index 925f9934b8..5745d607dc 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/KinematicViscosityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/KinematicViscosityTestsBase.g.cs @@ -919,34 +919,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = KinematicViscosity.FromSquareMetersPerSecond(1); - Assert.True(v.Equals(KinematicViscosity.FromSquareMetersPerSecond(1), SquareMetersPerSecondTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(KinematicViscosity.Zero, SquareMetersPerSecondTolerance, ComparisonType.Relative)); - Assert.True(KinematicViscosity.FromSquareMetersPerSecond(100).Equals(KinematicViscosity.FromSquareMetersPerSecond(120), 0.3, ComparisonType.Relative)); - Assert.False(KinematicViscosity.FromSquareMetersPerSecond(100).Equals(KinematicViscosity.FromSquareMetersPerSecond(120), 0.1, ComparisonType.Relative)); + KinematicViscosity squaremeterpersecond = KinematicViscosity.FromSquareMetersPerSecond(1); + Assert.False(squaremeterpersecond.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = KinematicViscosity.FromSquareMetersPerSecond(1); - Assert.Throws(() => v.Equals(KinematicViscosity.FromSquareMetersPerSecond(1), -1, ComparisonType.Relative)); + KinematicViscosity squaremeterpersecond = KinematicViscosity.FromSquareMetersPerSecond(1); + Assert.False(squaremeterpersecond.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - KinematicViscosity squaremeterpersecond = KinematicViscosity.FromSquareMetersPerSecond(1); - Assert.False(squaremeterpersecond.Equals(new object())); + var quantity = KinematicViscosity.FromSquareMetersPerSecond(firstValue); + var otherQuantity = KinematicViscosity.FromSquareMetersPerSecond(secondValue); + KinematicViscosity maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, KinematicViscosity.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - KinematicViscosity squaremeterpersecond = KinematicViscosity.FromSquareMetersPerSecond(1); - Assert.False(squaremeterpersecond.Equals(null)); + var quantity = KinematicViscosity.FromSquareMetersPerSecond(1); + var negativeTolerance = KinematicViscosity.FromSquareMetersPerSecond(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LeakRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LeakRateTestsBase.g.cs index 27496a473a..ee5fbe2c9c 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LeakRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LeakRateTestsBase.g.cs @@ -591,34 +591,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = LeakRate.FromPascalCubicMetersPerSecond(1); - Assert.True(v.Equals(LeakRate.FromPascalCubicMetersPerSecond(1), PascalCubicMetersPerSecondTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(LeakRate.Zero, PascalCubicMetersPerSecondTolerance, ComparisonType.Relative)); - Assert.True(LeakRate.FromPascalCubicMetersPerSecond(100).Equals(LeakRate.FromPascalCubicMetersPerSecond(120), 0.3, ComparisonType.Relative)); - Assert.False(LeakRate.FromPascalCubicMetersPerSecond(100).Equals(LeakRate.FromPascalCubicMetersPerSecond(120), 0.1, ComparisonType.Relative)); + LeakRate pascalcubicmeterpersecond = LeakRate.FromPascalCubicMetersPerSecond(1); + Assert.False(pascalcubicmeterpersecond.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = LeakRate.FromPascalCubicMetersPerSecond(1); - Assert.Throws(() => v.Equals(LeakRate.FromPascalCubicMetersPerSecond(1), -1, ComparisonType.Relative)); + LeakRate pascalcubicmeterpersecond = LeakRate.FromPascalCubicMetersPerSecond(1); + Assert.False(pascalcubicmeterpersecond.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - LeakRate pascalcubicmeterpersecond = LeakRate.FromPascalCubicMetersPerSecond(1); - Assert.False(pascalcubicmeterpersecond.Equals(new object())); + var quantity = LeakRate.FromPascalCubicMetersPerSecond(firstValue); + var otherQuantity = LeakRate.FromPascalCubicMetersPerSecond(secondValue); + LeakRate maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, LeakRate.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - LeakRate pascalcubicmeterpersecond = LeakRate.FromPascalCubicMetersPerSecond(1); - Assert.False(pascalcubicmeterpersecond.Equals(null)); + var quantity = LeakRate.FromPascalCubicMetersPerSecond(1); + var negativeTolerance = LeakRate.FromPascalCubicMetersPerSecond(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LengthTestsBase.g.cs index 19d718d8f5..1cd46b6ab4 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LengthTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LengthTestsBase.g.cs @@ -2661,34 +2661,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = Length.FromMeters(1); - Assert.True(v.Equals(Length.FromMeters(1), MetersTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(Length.Zero, MetersTolerance, ComparisonType.Relative)); - Assert.True(Length.FromMeters(100).Equals(Length.FromMeters(120), 0.3, ComparisonType.Relative)); - Assert.False(Length.FromMeters(100).Equals(Length.FromMeters(120), 0.1, ComparisonType.Relative)); + Length meter = Length.FromMeters(1); + Assert.False(meter.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = Length.FromMeters(1); - Assert.Throws(() => v.Equals(Length.FromMeters(1), -1, ComparisonType.Relative)); + Length meter = Length.FromMeters(1); + Assert.False(meter.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - Length meter = Length.FromMeters(1); - Assert.False(meter.Equals(new object())); + var quantity = Length.FromMeters(firstValue); + var otherQuantity = Length.FromMeters(secondValue); + Length maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, Length.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - Length meter = Length.FromMeters(1); - Assert.False(meter.Equals(null)); + var quantity = Length.FromMeters(1); + var negativeTolerance = Length.FromMeters(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LevelTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LevelTestsBase.g.cs index 5305ef8a58..bf429a014a 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LevelTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LevelTestsBase.g.cs @@ -502,23 +502,6 @@ public void Equals_Null_ReturnsFalse() #pragma warning restore CS8073 } - [Fact] - public void Equals_RelativeTolerance_IsImplemented() - { - var v = Level.FromDecibels(1); - Assert.True(v.Equals(Level.FromDecibels(1), DecibelsTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(Level.Zero, DecibelsTolerance, ComparisonType.Relative)); - Assert.True(Level.FromDecibels(100).Equals(Level.FromDecibels(120), 0.3, ComparisonType.Relative)); - Assert.False(Level.FromDecibels(100).Equals(Level.FromDecibels(120), 0.1, ComparisonType.Relative)); - } - - [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() - { - var v = Level.FromDecibels(1); - Assert.Throws(() => v.Equals(Level.FromDecibels(1), -1, ComparisonType.Relative)); - } - [Fact] public void EqualsReturnsFalseOnTypeMismatch() { @@ -533,6 +516,34 @@ public void EqualsReturnsFalseOnNull() Assert.False(decibel.Equals(null)); } + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + { + var quantity = Level.FromDecibels(firstValue); + var otherQuantity = Level.FromDecibels(secondValue); + Level maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, Level.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); + // note: it's currently not possible to test this due to the rounding error from (quantity - otherQuantity) + // Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + } + + [Fact] + public void Equals_WithNegativeTolerance_DoesNotThrowArgumentOutOfRangeException() + { + // note: unlike with vector quantities- a small tolerance maybe positive in one unit and negative in another + var quantity = Level.FromDecibels(1); + var negativeTolerance = Level.FromDecibels(-1); + Assert.True(quantity.Equals(quantity, negativeTolerance)); + } + [Fact] public void HasAtLeastOneAbbreviationSpecified() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LinearDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LinearDensityTestsBase.g.cs index c3b8bcbd16..1b60488d3d 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LinearDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LinearDensityTestsBase.g.cs @@ -1071,34 +1071,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = LinearDensity.FromKilogramsPerMeter(1); - Assert.True(v.Equals(LinearDensity.FromKilogramsPerMeter(1), KilogramsPerMeterTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(LinearDensity.Zero, KilogramsPerMeterTolerance, ComparisonType.Relative)); - Assert.True(LinearDensity.FromKilogramsPerMeter(100).Equals(LinearDensity.FromKilogramsPerMeter(120), 0.3, ComparisonType.Relative)); - Assert.False(LinearDensity.FromKilogramsPerMeter(100).Equals(LinearDensity.FromKilogramsPerMeter(120), 0.1, ComparisonType.Relative)); + LinearDensity kilogrampermeter = LinearDensity.FromKilogramsPerMeter(1); + Assert.False(kilogrampermeter.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = LinearDensity.FromKilogramsPerMeter(1); - Assert.Throws(() => v.Equals(LinearDensity.FromKilogramsPerMeter(1), -1, ComparisonType.Relative)); + LinearDensity kilogrampermeter = LinearDensity.FromKilogramsPerMeter(1); + Assert.False(kilogrampermeter.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - LinearDensity kilogrampermeter = LinearDensity.FromKilogramsPerMeter(1); - Assert.False(kilogrampermeter.Equals(new object())); + var quantity = LinearDensity.FromKilogramsPerMeter(firstValue); + var otherQuantity = LinearDensity.FromKilogramsPerMeter(secondValue); + LinearDensity maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, LinearDensity.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - LinearDensity kilogrampermeter = LinearDensity.FromKilogramsPerMeter(1); - Assert.False(kilogrampermeter.Equals(null)); + var quantity = LinearDensity.FromKilogramsPerMeter(1); + var negativeTolerance = LinearDensity.FromKilogramsPerMeter(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LinearPowerDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LinearPowerDensityTestsBase.g.cs index 448934fb7a..955f9566fd 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LinearPowerDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LinearPowerDensityTestsBase.g.cs @@ -1235,34 +1235,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = LinearPowerDensity.FromWattsPerMeter(1); - Assert.True(v.Equals(LinearPowerDensity.FromWattsPerMeter(1), WattsPerMeterTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(LinearPowerDensity.Zero, WattsPerMeterTolerance, ComparisonType.Relative)); - Assert.True(LinearPowerDensity.FromWattsPerMeter(100).Equals(LinearPowerDensity.FromWattsPerMeter(120), 0.3, ComparisonType.Relative)); - Assert.False(LinearPowerDensity.FromWattsPerMeter(100).Equals(LinearPowerDensity.FromWattsPerMeter(120), 0.1, ComparisonType.Relative)); + LinearPowerDensity wattpermeter = LinearPowerDensity.FromWattsPerMeter(1); + Assert.False(wattpermeter.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = LinearPowerDensity.FromWattsPerMeter(1); - Assert.Throws(() => v.Equals(LinearPowerDensity.FromWattsPerMeter(1), -1, ComparisonType.Relative)); + LinearPowerDensity wattpermeter = LinearPowerDensity.FromWattsPerMeter(1); + Assert.False(wattpermeter.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - LinearPowerDensity wattpermeter = LinearPowerDensity.FromWattsPerMeter(1); - Assert.False(wattpermeter.Equals(new object())); + var quantity = LinearPowerDensity.FromWattsPerMeter(firstValue); + var otherQuantity = LinearPowerDensity.FromWattsPerMeter(secondValue); + LinearPowerDensity maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, LinearPowerDensity.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - LinearPowerDensity wattpermeter = LinearPowerDensity.FromWattsPerMeter(1); - Assert.False(wattpermeter.Equals(null)); + var quantity = LinearPowerDensity.FromWattsPerMeter(1); + var negativeTolerance = LinearPowerDensity.FromWattsPerMeter(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminanceTestsBase.g.cs index 697d5f6627..e02d8489ae 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminanceTestsBase.g.cs @@ -815,34 +815,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = Luminance.FromCandelasPerSquareMeter(1); - Assert.True(v.Equals(Luminance.FromCandelasPerSquareMeter(1), CandelasPerSquareMeterTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(Luminance.Zero, CandelasPerSquareMeterTolerance, ComparisonType.Relative)); - Assert.True(Luminance.FromCandelasPerSquareMeter(100).Equals(Luminance.FromCandelasPerSquareMeter(120), 0.3, ComparisonType.Relative)); - Assert.False(Luminance.FromCandelasPerSquareMeter(100).Equals(Luminance.FromCandelasPerSquareMeter(120), 0.1, ComparisonType.Relative)); + Luminance candelapersquaremeter = Luminance.FromCandelasPerSquareMeter(1); + Assert.False(candelapersquaremeter.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = Luminance.FromCandelasPerSquareMeter(1); - Assert.Throws(() => v.Equals(Luminance.FromCandelasPerSquareMeter(1), -1, ComparisonType.Relative)); + Luminance candelapersquaremeter = Luminance.FromCandelasPerSquareMeter(1); + Assert.False(candelapersquaremeter.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - Luminance candelapersquaremeter = Luminance.FromCandelasPerSquareMeter(1); - Assert.False(candelapersquaremeter.Equals(new object())); + var quantity = Luminance.FromCandelasPerSquareMeter(firstValue); + var otherQuantity = Luminance.FromCandelasPerSquareMeter(secondValue); + Luminance maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, Luminance.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - Luminance candelapersquaremeter = Luminance.FromCandelasPerSquareMeter(1); - Assert.False(candelapersquaremeter.Equals(null)); + var quantity = Luminance.FromCandelasPerSquareMeter(1); + var negativeTolerance = Luminance.FromCandelasPerSquareMeter(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminosityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminosityTestsBase.g.cs index c3d5f23bc7..a86d408057 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminosityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminosityTestsBase.g.cs @@ -919,34 +919,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = Luminosity.FromWatts(1); - Assert.True(v.Equals(Luminosity.FromWatts(1), WattsTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(Luminosity.Zero, WattsTolerance, ComparisonType.Relative)); - Assert.True(Luminosity.FromWatts(100).Equals(Luminosity.FromWatts(120), 0.3, ComparisonType.Relative)); - Assert.False(Luminosity.FromWatts(100).Equals(Luminosity.FromWatts(120), 0.1, ComparisonType.Relative)); + Luminosity watt = Luminosity.FromWatts(1); + Assert.False(watt.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = Luminosity.FromWatts(1); - Assert.Throws(() => v.Equals(Luminosity.FromWatts(1), -1, ComparisonType.Relative)); + Luminosity watt = Luminosity.FromWatts(1); + Assert.False(watt.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - Luminosity watt = Luminosity.FromWatts(1); - Assert.False(watt.Equals(new object())); + var quantity = Luminosity.FromWatts(firstValue); + var otherQuantity = Luminosity.FromWatts(secondValue); + Luminosity maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, Luminosity.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - Luminosity watt = Luminosity.FromWatts(1); - Assert.False(watt.Equals(null)); + var quantity = Luminosity.FromWatts(1); + var negativeTolerance = Luminosity.FromWatts(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousFluxTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousFluxTestsBase.g.cs index 6bb7cdbd0d..87b0b13626 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousFluxTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousFluxTestsBase.g.cs @@ -526,34 +526,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = LuminousFlux.FromLumens(1); - Assert.True(v.Equals(LuminousFlux.FromLumens(1), LumensTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(LuminousFlux.Zero, LumensTolerance, ComparisonType.Relative)); - Assert.True(LuminousFlux.FromLumens(100).Equals(LuminousFlux.FromLumens(120), 0.3, ComparisonType.Relative)); - Assert.False(LuminousFlux.FromLumens(100).Equals(LuminousFlux.FromLumens(120), 0.1, ComparisonType.Relative)); + LuminousFlux lumen = LuminousFlux.FromLumens(1); + Assert.False(lumen.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = LuminousFlux.FromLumens(1); - Assert.Throws(() => v.Equals(LuminousFlux.FromLumens(1), -1, ComparisonType.Relative)); + LuminousFlux lumen = LuminousFlux.FromLumens(1); + Assert.False(lumen.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - LuminousFlux lumen = LuminousFlux.FromLumens(1); - Assert.False(lumen.Equals(new object())); + var quantity = LuminousFlux.FromLumens(firstValue); + var otherQuantity = LuminousFlux.FromLumens(secondValue); + LuminousFlux maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, LuminousFlux.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - LuminousFlux lumen = LuminousFlux.FromLumens(1); - Assert.False(lumen.Equals(null)); + var quantity = LuminousFlux.FromLumens(1); + var negativeTolerance = LuminousFlux.FromLumens(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousIntensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousIntensityTestsBase.g.cs index 41d1623280..83fa504238 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousIntensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousIntensityTestsBase.g.cs @@ -526,34 +526,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = LuminousIntensity.FromCandela(1); - Assert.True(v.Equals(LuminousIntensity.FromCandela(1), CandelaTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(LuminousIntensity.Zero, CandelaTolerance, ComparisonType.Relative)); - Assert.True(LuminousIntensity.FromCandela(100).Equals(LuminousIntensity.FromCandela(120), 0.3, ComparisonType.Relative)); - Assert.False(LuminousIntensity.FromCandela(100).Equals(LuminousIntensity.FromCandela(120), 0.1, ComparisonType.Relative)); + LuminousIntensity candela = LuminousIntensity.FromCandela(1); + Assert.False(candela.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = LuminousIntensity.FromCandela(1); - Assert.Throws(() => v.Equals(LuminousIntensity.FromCandela(1), -1, ComparisonType.Relative)); + LuminousIntensity candela = LuminousIntensity.FromCandela(1); + Assert.False(candela.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - LuminousIntensity candela = LuminousIntensity.FromCandela(1); - Assert.False(candela.Equals(new object())); + var quantity = LuminousIntensity.FromCandela(firstValue); + var otherQuantity = LuminousIntensity.FromCandela(secondValue); + LuminousIntensity maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, LuminousIntensity.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - LuminousIntensity candela = LuminousIntensity.FromCandela(1); - Assert.False(candela.Equals(null)); + var quantity = LuminousIntensity.FromCandela(1); + var negativeTolerance = LuminousIntensity.FromCandela(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFieldTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFieldTestsBase.g.cs index 48e5f94d6d..ba52810f02 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFieldTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFieldTestsBase.g.cs @@ -687,34 +687,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = MagneticField.FromTeslas(1); - Assert.True(v.Equals(MagneticField.FromTeslas(1), TeslasTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(MagneticField.Zero, TeslasTolerance, ComparisonType.Relative)); - Assert.True(MagneticField.FromTeslas(100).Equals(MagneticField.FromTeslas(120), 0.3, ComparisonType.Relative)); - Assert.False(MagneticField.FromTeslas(100).Equals(MagneticField.FromTeslas(120), 0.1, ComparisonType.Relative)); + MagneticField tesla = MagneticField.FromTeslas(1); + Assert.False(tesla.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = MagneticField.FromTeslas(1); - Assert.Throws(() => v.Equals(MagneticField.FromTeslas(1), -1, ComparisonType.Relative)); + MagneticField tesla = MagneticField.FromTeslas(1); + Assert.False(tesla.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - MagneticField tesla = MagneticField.FromTeslas(1); - Assert.False(tesla.Equals(new object())); + var quantity = MagneticField.FromTeslas(firstValue); + var otherQuantity = MagneticField.FromTeslas(secondValue); + MagneticField maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, MagneticField.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - MagneticField tesla = MagneticField.FromTeslas(1); - Assert.False(tesla.Equals(null)); + var quantity = MagneticField.FromTeslas(1); + var negativeTolerance = MagneticField.FromTeslas(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFluxTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFluxTestsBase.g.cs index efedfe224d..b512b1596c 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFluxTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFluxTestsBase.g.cs @@ -526,34 +526,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = MagneticFlux.FromWebers(1); - Assert.True(v.Equals(MagneticFlux.FromWebers(1), WebersTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(MagneticFlux.Zero, WebersTolerance, ComparisonType.Relative)); - Assert.True(MagneticFlux.FromWebers(100).Equals(MagneticFlux.FromWebers(120), 0.3, ComparisonType.Relative)); - Assert.False(MagneticFlux.FromWebers(100).Equals(MagneticFlux.FromWebers(120), 0.1, ComparisonType.Relative)); + MagneticFlux weber = MagneticFlux.FromWebers(1); + Assert.False(weber.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = MagneticFlux.FromWebers(1); - Assert.Throws(() => v.Equals(MagneticFlux.FromWebers(1), -1, ComparisonType.Relative)); + MagneticFlux weber = MagneticFlux.FromWebers(1); + Assert.False(weber.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - MagneticFlux weber = MagneticFlux.FromWebers(1); - Assert.False(weber.Equals(new object())); + var quantity = MagneticFlux.FromWebers(firstValue); + var otherQuantity = MagneticFlux.FromWebers(secondValue); + MagneticFlux maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, MagneticFlux.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - MagneticFlux weber = MagneticFlux.FromWebers(1); - Assert.False(weber.Equals(null)); + var quantity = MagneticFlux.FromWebers(1); + var negativeTolerance = MagneticFlux.FromWebers(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MagnetizationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MagnetizationTestsBase.g.cs index 4ffda490eb..1299b3c87c 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MagnetizationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MagnetizationTestsBase.g.cs @@ -526,34 +526,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = Magnetization.FromAmperesPerMeter(1); - Assert.True(v.Equals(Magnetization.FromAmperesPerMeter(1), AmperesPerMeterTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(Magnetization.Zero, AmperesPerMeterTolerance, ComparisonType.Relative)); - Assert.True(Magnetization.FromAmperesPerMeter(100).Equals(Magnetization.FromAmperesPerMeter(120), 0.3, ComparisonType.Relative)); - Assert.False(Magnetization.FromAmperesPerMeter(100).Equals(Magnetization.FromAmperesPerMeter(120), 0.1, ComparisonType.Relative)); + Magnetization amperepermeter = Magnetization.FromAmperesPerMeter(1); + Assert.False(amperepermeter.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = Magnetization.FromAmperesPerMeter(1); - Assert.Throws(() => v.Equals(Magnetization.FromAmperesPerMeter(1), -1, ComparisonType.Relative)); + Magnetization amperepermeter = Magnetization.FromAmperesPerMeter(1); + Assert.False(amperepermeter.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - Magnetization amperepermeter = Magnetization.FromAmperesPerMeter(1); - Assert.False(amperepermeter.Equals(new object())); + var quantity = Magnetization.FromAmperesPerMeter(firstValue); + var otherQuantity = Magnetization.FromAmperesPerMeter(secondValue); + Magnetization maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, Magnetization.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - Magnetization amperepermeter = Magnetization.FromAmperesPerMeter(1); - Assert.False(amperepermeter.Equals(null)); + var quantity = Magnetization.FromAmperesPerMeter(1); + var negativeTolerance = Magnetization.FromAmperesPerMeter(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassConcentrationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassConcentrationTestsBase.g.cs index f4452e2d44..b8b5389b3c 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassConcentrationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassConcentrationTestsBase.g.cs @@ -2131,34 +2131,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = MassConcentration.FromKilogramsPerCubicMeter(1); - Assert.True(v.Equals(MassConcentration.FromKilogramsPerCubicMeter(1), KilogramsPerCubicMeterTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(MassConcentration.Zero, KilogramsPerCubicMeterTolerance, ComparisonType.Relative)); - Assert.True(MassConcentration.FromKilogramsPerCubicMeter(100).Equals(MassConcentration.FromKilogramsPerCubicMeter(120), 0.3, ComparisonType.Relative)); - Assert.False(MassConcentration.FromKilogramsPerCubicMeter(100).Equals(MassConcentration.FromKilogramsPerCubicMeter(120), 0.1, ComparisonType.Relative)); + MassConcentration kilogrampercubicmeter = MassConcentration.FromKilogramsPerCubicMeter(1); + Assert.False(kilogrampercubicmeter.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = MassConcentration.FromKilogramsPerCubicMeter(1); - Assert.Throws(() => v.Equals(MassConcentration.FromKilogramsPerCubicMeter(1), -1, ComparisonType.Relative)); + MassConcentration kilogrampercubicmeter = MassConcentration.FromKilogramsPerCubicMeter(1); + Assert.False(kilogrampercubicmeter.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - MassConcentration kilogrampercubicmeter = MassConcentration.FromKilogramsPerCubicMeter(1); - Assert.False(kilogrampercubicmeter.Equals(new object())); + var quantity = MassConcentration.FromKilogramsPerCubicMeter(firstValue); + var otherQuantity = MassConcentration.FromKilogramsPerCubicMeter(secondValue); + MassConcentration maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, MassConcentration.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - MassConcentration kilogrampercubicmeter = MassConcentration.FromKilogramsPerCubicMeter(1); - Assert.False(kilogrampercubicmeter.Equals(null)); + var quantity = MassConcentration.FromKilogramsPerCubicMeter(1); + var negativeTolerance = MassConcentration.FromKilogramsPerCubicMeter(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFlowTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFlowTestsBase.g.cs index 3b39e35ead..7dfeedcde7 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFlowTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFlowTestsBase.g.cs @@ -1762,34 +1762,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = MassFlow.FromGramsPerSecond(1); - Assert.True(v.Equals(MassFlow.FromGramsPerSecond(1), GramsPerSecondTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(MassFlow.Zero, GramsPerSecondTolerance, ComparisonType.Relative)); - Assert.True(MassFlow.FromGramsPerSecond(100).Equals(MassFlow.FromGramsPerSecond(120), 0.3, ComparisonType.Relative)); - Assert.False(MassFlow.FromGramsPerSecond(100).Equals(MassFlow.FromGramsPerSecond(120), 0.1, ComparisonType.Relative)); + MassFlow grampersecond = MassFlow.FromGramsPerSecond(1); + Assert.False(grampersecond.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = MassFlow.FromGramsPerSecond(1); - Assert.Throws(() => v.Equals(MassFlow.FromGramsPerSecond(1), -1, ComparisonType.Relative)); + MassFlow grampersecond = MassFlow.FromGramsPerSecond(1); + Assert.False(grampersecond.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - MassFlow grampersecond = MassFlow.FromGramsPerSecond(1); - Assert.False(grampersecond.Equals(new object())); + var quantity = MassFlow.FromGramsPerSecond(firstValue); + var otherQuantity = MassFlow.FromGramsPerSecond(secondValue); + MassFlow maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, MassFlow.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - MassFlow grampersecond = MassFlow.FromGramsPerSecond(1); - Assert.False(grampersecond.Equals(null)); + var quantity = MassFlow.FromGramsPerSecond(1); + var negativeTolerance = MassFlow.FromGramsPerSecond(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFluxTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFluxTestsBase.g.cs index 91807c4675..4c8aa41cf6 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFluxTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFluxTestsBase.g.cs @@ -879,34 +879,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = MassFlux.FromKilogramsPerSecondPerSquareMeter(1); - Assert.True(v.Equals(MassFlux.FromKilogramsPerSecondPerSquareMeter(1), KilogramsPerSecondPerSquareMeterTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(MassFlux.Zero, KilogramsPerSecondPerSquareMeterTolerance, ComparisonType.Relative)); - Assert.True(MassFlux.FromKilogramsPerSecondPerSquareMeter(100).Equals(MassFlux.FromKilogramsPerSecondPerSquareMeter(120), 0.3, ComparisonType.Relative)); - Assert.False(MassFlux.FromKilogramsPerSecondPerSquareMeter(100).Equals(MassFlux.FromKilogramsPerSecondPerSquareMeter(120), 0.1, ComparisonType.Relative)); + MassFlux kilogrampersecondpersquaremeter = MassFlux.FromKilogramsPerSecondPerSquareMeter(1); + Assert.False(kilogrampersecondpersquaremeter.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = MassFlux.FromKilogramsPerSecondPerSquareMeter(1); - Assert.Throws(() => v.Equals(MassFlux.FromKilogramsPerSecondPerSquareMeter(1), -1, ComparisonType.Relative)); + MassFlux kilogrampersecondpersquaremeter = MassFlux.FromKilogramsPerSecondPerSquareMeter(1); + Assert.False(kilogrampersecondpersquaremeter.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - MassFlux kilogrampersecondpersquaremeter = MassFlux.FromKilogramsPerSecondPerSquareMeter(1); - Assert.False(kilogrampersecondpersquaremeter.Equals(new object())); + var quantity = MassFlux.FromKilogramsPerSecondPerSquareMeter(firstValue); + var otherQuantity = MassFlux.FromKilogramsPerSecondPerSquareMeter(secondValue); + MassFlux maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, MassFlux.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - MassFlux kilogrampersecondpersquaremeter = MassFlux.FromKilogramsPerSecondPerSquareMeter(1); - Assert.False(kilogrampersecondpersquaremeter.Equals(null)); + var quantity = MassFlux.FromKilogramsPerSecondPerSquareMeter(1); + var negativeTolerance = MassFlux.FromKilogramsPerSecondPerSquareMeter(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFractionTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFractionTestsBase.g.cs index d8ea83e2f5..a193c68d56 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFractionTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFractionTestsBase.g.cs @@ -1224,34 +1224,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = MassFraction.FromDecimalFractions(1); - Assert.True(v.Equals(MassFraction.FromDecimalFractions(1), DecimalFractionsTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(MassFraction.Zero, DecimalFractionsTolerance, ComparisonType.Relative)); - Assert.True(MassFraction.FromDecimalFractions(100).Equals(MassFraction.FromDecimalFractions(120), 0.3, ComparisonType.Relative)); - Assert.False(MassFraction.FromDecimalFractions(100).Equals(MassFraction.FromDecimalFractions(120), 0.1, ComparisonType.Relative)); + MassFraction decimalfraction = MassFraction.FromDecimalFractions(1); + Assert.False(decimalfraction.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = MassFraction.FromDecimalFractions(1); - Assert.Throws(() => v.Equals(MassFraction.FromDecimalFractions(1), -1, ComparisonType.Relative)); + MassFraction decimalfraction = MassFraction.FromDecimalFractions(1); + Assert.False(decimalfraction.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - MassFraction decimalfraction = MassFraction.FromDecimalFractions(1); - Assert.False(decimalfraction.Equals(new object())); + var quantity = MassFraction.FromDecimalFractions(firstValue); + var otherQuantity = MassFraction.FromDecimalFractions(secondValue); + MassFraction maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, MassFraction.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - MassFraction decimalfraction = MassFraction.FromDecimalFractions(1); - Assert.False(decimalfraction.Equals(null)); + var quantity = MassFraction.FromDecimalFractions(1); + var negativeTolerance = MassFraction.FromDecimalFractions(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassMomentOfInertiaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassMomentOfInertiaTestsBase.g.cs index f4e0e09f33..d9dccc3b91 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassMomentOfInertiaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassMomentOfInertiaTestsBase.g.cs @@ -1391,34 +1391,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = MassMomentOfInertia.FromKilogramSquareMeters(1); - Assert.True(v.Equals(MassMomentOfInertia.FromKilogramSquareMeters(1), KilogramSquareMetersTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(MassMomentOfInertia.Zero, KilogramSquareMetersTolerance, ComparisonType.Relative)); - Assert.True(MassMomentOfInertia.FromKilogramSquareMeters(100).Equals(MassMomentOfInertia.FromKilogramSquareMeters(120), 0.3, ComparisonType.Relative)); - Assert.False(MassMomentOfInertia.FromKilogramSquareMeters(100).Equals(MassMomentOfInertia.FromKilogramSquareMeters(120), 0.1, ComparisonType.Relative)); + MassMomentOfInertia kilogramsquaremeter = MassMomentOfInertia.FromKilogramSquareMeters(1); + Assert.False(kilogramsquaremeter.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = MassMomentOfInertia.FromKilogramSquareMeters(1); - Assert.Throws(() => v.Equals(MassMomentOfInertia.FromKilogramSquareMeters(1), -1, ComparisonType.Relative)); + MassMomentOfInertia kilogramsquaremeter = MassMomentOfInertia.FromKilogramSquareMeters(1); + Assert.False(kilogramsquaremeter.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - MassMomentOfInertia kilogramsquaremeter = MassMomentOfInertia.FromKilogramSquareMeters(1); - Assert.False(kilogramsquaremeter.Equals(new object())); + var quantity = MassMomentOfInertia.FromKilogramSquareMeters(firstValue); + var otherQuantity = MassMomentOfInertia.FromKilogramSquareMeters(secondValue); + MassMomentOfInertia maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, MassMomentOfInertia.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - MassMomentOfInertia kilogramsquaremeter = MassMomentOfInertia.FromKilogramSquareMeters(1); - Assert.False(kilogramsquaremeter.Equals(null)); + var quantity = MassMomentOfInertia.FromKilogramSquareMeters(1); + var negativeTolerance = MassMomentOfInertia.FromKilogramSquareMeters(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassTestsBase.g.cs index 99787d81b5..4fcd256ce4 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassTestsBase.g.cs @@ -2185,34 +2185,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = Mass.FromKilograms(1); - Assert.True(v.Equals(Mass.FromKilograms(1), KilogramsTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(Mass.Zero, KilogramsTolerance, ComparisonType.Relative)); - Assert.True(Mass.FromKilograms(100).Equals(Mass.FromKilograms(120), 0.3, ComparisonType.Relative)); - Assert.False(Mass.FromKilograms(100).Equals(Mass.FromKilograms(120), 0.1, ComparisonType.Relative)); + Mass kilogram = Mass.FromKilograms(1); + Assert.False(kilogram.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = Mass.FromKilograms(1); - Assert.Throws(() => v.Equals(Mass.FromKilograms(1), -1, ComparisonType.Relative)); + Mass kilogram = Mass.FromKilograms(1); + Assert.False(kilogram.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - Mass kilogram = Mass.FromKilograms(1); - Assert.False(kilogram.Equals(new object())); + var quantity = Mass.FromKilograms(firstValue); + var otherQuantity = Mass.FromKilograms(secondValue); + Mass maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, Mass.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - Mass kilogram = Mass.FromKilograms(1); - Assert.False(kilogram.Equals(null)); + var quantity = Mass.FromKilograms(1); + var negativeTolerance = Mass.FromKilograms(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MolalityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MolalityTestsBase.g.cs index 66dc43e33c..46f1f77af4 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MolalityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MolalityTestsBase.g.cs @@ -591,34 +591,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = Molality.FromMolesPerKilogram(1); - Assert.True(v.Equals(Molality.FromMolesPerKilogram(1), MolesPerKilogramTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(Molality.Zero, MolesPerKilogramTolerance, ComparisonType.Relative)); - Assert.True(Molality.FromMolesPerKilogram(100).Equals(Molality.FromMolesPerKilogram(120), 0.3, ComparisonType.Relative)); - Assert.False(Molality.FromMolesPerKilogram(100).Equals(Molality.FromMolesPerKilogram(120), 0.1, ComparisonType.Relative)); + Molality moleperkilogram = Molality.FromMolesPerKilogram(1); + Assert.False(moleperkilogram.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = Molality.FromMolesPerKilogram(1); - Assert.Throws(() => v.Equals(Molality.FromMolesPerKilogram(1), -1, ComparisonType.Relative)); + Molality moleperkilogram = Molality.FromMolesPerKilogram(1); + Assert.False(moleperkilogram.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - Molality moleperkilogram = Molality.FromMolesPerKilogram(1); - Assert.False(moleperkilogram.Equals(new object())); + var quantity = Molality.FromMolesPerKilogram(firstValue); + var otherQuantity = Molality.FromMolesPerKilogram(secondValue); + Molality maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, Molality.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - Molality moleperkilogram = Molality.FromMolesPerKilogram(1); - Assert.False(moleperkilogram.Equals(null)); + var quantity = Molality.FromMolesPerKilogram(1); + var negativeTolerance = Molality.FromMolesPerKilogram(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEnergyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEnergyTestsBase.g.cs index 38499ca4df..ee3bde5c94 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEnergyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEnergyTestsBase.g.cs @@ -591,34 +591,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = MolarEnergy.FromJoulesPerMole(1); - Assert.True(v.Equals(MolarEnergy.FromJoulesPerMole(1), JoulesPerMoleTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(MolarEnergy.Zero, JoulesPerMoleTolerance, ComparisonType.Relative)); - Assert.True(MolarEnergy.FromJoulesPerMole(100).Equals(MolarEnergy.FromJoulesPerMole(120), 0.3, ComparisonType.Relative)); - Assert.False(MolarEnergy.FromJoulesPerMole(100).Equals(MolarEnergy.FromJoulesPerMole(120), 0.1, ComparisonType.Relative)); + MolarEnergy joulepermole = MolarEnergy.FromJoulesPerMole(1); + Assert.False(joulepermole.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = MolarEnergy.FromJoulesPerMole(1); - Assert.Throws(() => v.Equals(MolarEnergy.FromJoulesPerMole(1), -1, ComparisonType.Relative)); + MolarEnergy joulepermole = MolarEnergy.FromJoulesPerMole(1); + Assert.False(joulepermole.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - MolarEnergy joulepermole = MolarEnergy.FromJoulesPerMole(1); - Assert.False(joulepermole.Equals(new object())); + var quantity = MolarEnergy.FromJoulesPerMole(firstValue); + var otherQuantity = MolarEnergy.FromJoulesPerMole(secondValue); + MolarEnergy maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, MolarEnergy.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - MolarEnergy joulepermole = MolarEnergy.FromJoulesPerMole(1); - Assert.False(joulepermole.Equals(null)); + var quantity = MolarEnergy.FromJoulesPerMole(1); + var negativeTolerance = MolarEnergy.FromJoulesPerMole(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEntropyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEntropyTestsBase.g.cs index bc0e21b3ee..2bfd7c8f4c 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEntropyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEntropyTestsBase.g.cs @@ -591,34 +591,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = MolarEntropy.FromJoulesPerMoleKelvin(1); - Assert.True(v.Equals(MolarEntropy.FromJoulesPerMoleKelvin(1), JoulesPerMoleKelvinTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(MolarEntropy.Zero, JoulesPerMoleKelvinTolerance, ComparisonType.Relative)); - Assert.True(MolarEntropy.FromJoulesPerMoleKelvin(100).Equals(MolarEntropy.FromJoulesPerMoleKelvin(120), 0.3, ComparisonType.Relative)); - Assert.False(MolarEntropy.FromJoulesPerMoleKelvin(100).Equals(MolarEntropy.FromJoulesPerMoleKelvin(120), 0.1, ComparisonType.Relative)); + MolarEntropy joulepermolekelvin = MolarEntropy.FromJoulesPerMoleKelvin(1); + Assert.False(joulepermolekelvin.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = MolarEntropy.FromJoulesPerMoleKelvin(1); - Assert.Throws(() => v.Equals(MolarEntropy.FromJoulesPerMoleKelvin(1), -1, ComparisonType.Relative)); + MolarEntropy joulepermolekelvin = MolarEntropy.FromJoulesPerMoleKelvin(1); + Assert.False(joulepermolekelvin.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - MolarEntropy joulepermolekelvin = MolarEntropy.FromJoulesPerMoleKelvin(1); - Assert.False(joulepermolekelvin.Equals(new object())); + var quantity = MolarEntropy.FromJoulesPerMoleKelvin(firstValue); + var otherQuantity = MolarEntropy.FromJoulesPerMoleKelvin(secondValue); + MolarEntropy maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, MolarEntropy.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - MolarEntropy joulepermolekelvin = MolarEntropy.FromJoulesPerMoleKelvin(1); - Assert.False(joulepermolekelvin.Equals(null)); + var quantity = MolarEntropy.FromJoulesPerMoleKelvin(1); + var negativeTolerance = MolarEntropy.FromJoulesPerMoleKelvin(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarFlowTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarFlowTestsBase.g.cs index bd6eb60f16..fa1bd670ab 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarFlowTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarFlowTestsBase.g.cs @@ -783,34 +783,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = MolarFlow.FromMolesPerSecond(1); - Assert.True(v.Equals(MolarFlow.FromMolesPerSecond(1), MolesPerSecondTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(MolarFlow.Zero, MolesPerSecondTolerance, ComparisonType.Relative)); - Assert.True(MolarFlow.FromMolesPerSecond(100).Equals(MolarFlow.FromMolesPerSecond(120), 0.3, ComparisonType.Relative)); - Assert.False(MolarFlow.FromMolesPerSecond(100).Equals(MolarFlow.FromMolesPerSecond(120), 0.1, ComparisonType.Relative)); + MolarFlow molepersecond = MolarFlow.FromMolesPerSecond(1); + Assert.False(molepersecond.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = MolarFlow.FromMolesPerSecond(1); - Assert.Throws(() => v.Equals(MolarFlow.FromMolesPerSecond(1), -1, ComparisonType.Relative)); + MolarFlow molepersecond = MolarFlow.FromMolesPerSecond(1); + Assert.False(molepersecond.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - MolarFlow molepersecond = MolarFlow.FromMolesPerSecond(1); - Assert.False(molepersecond.Equals(new object())); + var quantity = MolarFlow.FromMolesPerSecond(firstValue); + var otherQuantity = MolarFlow.FromMolesPerSecond(secondValue); + MolarFlow maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, MolarFlow.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - MolarFlow molepersecond = MolarFlow.FromMolesPerSecond(1); - Assert.False(molepersecond.Equals(null)); + var quantity = MolarFlow.FromMolesPerSecond(1); + var negativeTolerance = MolarFlow.FromMolesPerSecond(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarMassTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarMassTestsBase.g.cs index d2d864a7f9..352d3d1f71 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarMassTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarMassTestsBase.g.cs @@ -1115,34 +1115,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = MolarMass.FromKilogramsPerMole(1); - Assert.True(v.Equals(MolarMass.FromKilogramsPerMole(1), KilogramsPerMoleTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(MolarMass.Zero, KilogramsPerMoleTolerance, ComparisonType.Relative)); - Assert.True(MolarMass.FromKilogramsPerMole(100).Equals(MolarMass.FromKilogramsPerMole(120), 0.3, ComparisonType.Relative)); - Assert.False(MolarMass.FromKilogramsPerMole(100).Equals(MolarMass.FromKilogramsPerMole(120), 0.1, ComparisonType.Relative)); + MolarMass kilogrampermole = MolarMass.FromKilogramsPerMole(1); + Assert.False(kilogrampermole.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = MolarMass.FromKilogramsPerMole(1); - Assert.Throws(() => v.Equals(MolarMass.FromKilogramsPerMole(1), -1, ComparisonType.Relative)); + MolarMass kilogrampermole = MolarMass.FromKilogramsPerMole(1); + Assert.False(kilogrampermole.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - MolarMass kilogrampermole = MolarMass.FromKilogramsPerMole(1); - Assert.False(kilogrampermole.Equals(new object())); + var quantity = MolarMass.FromKilogramsPerMole(firstValue); + var otherQuantity = MolarMass.FromKilogramsPerMole(secondValue); + MolarMass maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, MolarMass.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - MolarMass kilogrampermole = MolarMass.FromKilogramsPerMole(1); - Assert.False(kilogrampermole.Equals(null)); + var quantity = MolarMass.FromKilogramsPerMole(1); + var negativeTolerance = MolarMass.FromKilogramsPerMole(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarityTestsBase.g.cs index 7f61722283..2afa67a0c2 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarityTestsBase.g.cs @@ -1015,34 +1015,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = Molarity.FromMolesPerCubicMeter(1); - Assert.True(v.Equals(Molarity.FromMolesPerCubicMeter(1), MolesPerCubicMeterTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(Molarity.Zero, MolesPerCubicMeterTolerance, ComparisonType.Relative)); - Assert.True(Molarity.FromMolesPerCubicMeter(100).Equals(Molarity.FromMolesPerCubicMeter(120), 0.3, ComparisonType.Relative)); - Assert.False(Molarity.FromMolesPerCubicMeter(100).Equals(Molarity.FromMolesPerCubicMeter(120), 0.1, ComparisonType.Relative)); + Molarity molepercubicmeter = Molarity.FromMolesPerCubicMeter(1); + Assert.False(molepercubicmeter.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = Molarity.FromMolesPerCubicMeter(1); - Assert.Throws(() => v.Equals(Molarity.FromMolesPerCubicMeter(1), -1, ComparisonType.Relative)); + Molarity molepercubicmeter = Molarity.FromMolesPerCubicMeter(1); + Assert.False(molepercubicmeter.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - Molarity molepercubicmeter = Molarity.FromMolesPerCubicMeter(1); - Assert.False(molepercubicmeter.Equals(new object())); + var quantity = Molarity.FromMolesPerCubicMeter(firstValue); + var otherQuantity = Molarity.FromMolesPerCubicMeter(secondValue); + Molarity maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, Molarity.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - Molarity molepercubicmeter = Molarity.FromMolesPerCubicMeter(1); - Assert.False(molepercubicmeter.Equals(null)); + var quantity = Molarity.FromMolesPerCubicMeter(1); + var negativeTolerance = Molarity.FromMolesPerCubicMeter(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PermeabilityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PermeabilityTestsBase.g.cs index ed298f48c3..52ac867bb1 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PermeabilityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PermeabilityTestsBase.g.cs @@ -526,34 +526,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = Permeability.FromHenriesPerMeter(1); - Assert.True(v.Equals(Permeability.FromHenriesPerMeter(1), HenriesPerMeterTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(Permeability.Zero, HenriesPerMeterTolerance, ComparisonType.Relative)); - Assert.True(Permeability.FromHenriesPerMeter(100).Equals(Permeability.FromHenriesPerMeter(120), 0.3, ComparisonType.Relative)); - Assert.False(Permeability.FromHenriesPerMeter(100).Equals(Permeability.FromHenriesPerMeter(120), 0.1, ComparisonType.Relative)); + Permeability henrypermeter = Permeability.FromHenriesPerMeter(1); + Assert.False(henrypermeter.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = Permeability.FromHenriesPerMeter(1); - Assert.Throws(() => v.Equals(Permeability.FromHenriesPerMeter(1), -1, ComparisonType.Relative)); + Permeability henrypermeter = Permeability.FromHenriesPerMeter(1); + Assert.False(henrypermeter.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - Permeability henrypermeter = Permeability.FromHenriesPerMeter(1); - Assert.False(henrypermeter.Equals(new object())); + var quantity = Permeability.FromHenriesPerMeter(firstValue); + var otherQuantity = Permeability.FromHenriesPerMeter(secondValue); + Permeability maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, Permeability.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - Permeability henrypermeter = Permeability.FromHenriesPerMeter(1); - Assert.False(henrypermeter.Equals(null)); + var quantity = Permeability.FromHenriesPerMeter(1); + var negativeTolerance = Permeability.FromHenriesPerMeter(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PermittivityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PermittivityTestsBase.g.cs index 59e39aa62d..3a80e3e997 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PermittivityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PermittivityTestsBase.g.cs @@ -526,34 +526,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = Permittivity.FromFaradsPerMeter(1); - Assert.True(v.Equals(Permittivity.FromFaradsPerMeter(1), FaradsPerMeterTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(Permittivity.Zero, FaradsPerMeterTolerance, ComparisonType.Relative)); - Assert.True(Permittivity.FromFaradsPerMeter(100).Equals(Permittivity.FromFaradsPerMeter(120), 0.3, ComparisonType.Relative)); - Assert.False(Permittivity.FromFaradsPerMeter(100).Equals(Permittivity.FromFaradsPerMeter(120), 0.1, ComparisonType.Relative)); + Permittivity faradpermeter = Permittivity.FromFaradsPerMeter(1); + Assert.False(faradpermeter.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = Permittivity.FromFaradsPerMeter(1); - Assert.Throws(() => v.Equals(Permittivity.FromFaradsPerMeter(1), -1, ComparisonType.Relative)); + Permittivity faradpermeter = Permittivity.FromFaradsPerMeter(1); + Assert.False(faradpermeter.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - Permittivity faradpermeter = Permittivity.FromFaradsPerMeter(1); - Assert.False(faradpermeter.Equals(new object())); + var quantity = Permittivity.FromFaradsPerMeter(firstValue); + var otherQuantity = Permittivity.FromFaradsPerMeter(secondValue); + Permittivity maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, Permittivity.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - Permittivity faradpermeter = Permittivity.FromFaradsPerMeter(1); - Assert.False(faradpermeter.Equals(null)); + var quantity = Permittivity.FromFaradsPerMeter(1); + var negativeTolerance = Permittivity.FromFaradsPerMeter(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PorousMediumPermeabilityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PorousMediumPermeabilityTestsBase.g.cs index e033ef8f1a..1b245ff09a 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PorousMediumPermeabilityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PorousMediumPermeabilityTestsBase.g.cs @@ -655,34 +655,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = PorousMediumPermeability.FromSquareMeters(1); - Assert.True(v.Equals(PorousMediumPermeability.FromSquareMeters(1), SquareMetersTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(PorousMediumPermeability.Zero, SquareMetersTolerance, ComparisonType.Relative)); - Assert.True(PorousMediumPermeability.FromSquareMeters(100).Equals(PorousMediumPermeability.FromSquareMeters(120), 0.3, ComparisonType.Relative)); - Assert.False(PorousMediumPermeability.FromSquareMeters(100).Equals(PorousMediumPermeability.FromSquareMeters(120), 0.1, ComparisonType.Relative)); + PorousMediumPermeability squaremeter = PorousMediumPermeability.FromSquareMeters(1); + Assert.False(squaremeter.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = PorousMediumPermeability.FromSquareMeters(1); - Assert.Throws(() => v.Equals(PorousMediumPermeability.FromSquareMeters(1), -1, ComparisonType.Relative)); + PorousMediumPermeability squaremeter = PorousMediumPermeability.FromSquareMeters(1); + Assert.False(squaremeter.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - PorousMediumPermeability squaremeter = PorousMediumPermeability.FromSquareMeters(1); - Assert.False(squaremeter.Equals(new object())); + var quantity = PorousMediumPermeability.FromSquareMeters(firstValue); + var otherQuantity = PorousMediumPermeability.FromSquareMeters(secondValue); + PorousMediumPermeability maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, PorousMediumPermeability.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - PorousMediumPermeability squaremeter = PorousMediumPermeability.FromSquareMeters(1); - Assert.False(squaremeter.Equals(null)); + var quantity = PorousMediumPermeability.FromSquareMeters(1); + var negativeTolerance = PorousMediumPermeability.FromSquareMeters(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerDensityTestsBase.g.cs index dadc40c4ef..b64437df26 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerDensityTestsBase.g.cs @@ -1855,34 +1855,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = PowerDensity.FromWattsPerCubicMeter(1); - Assert.True(v.Equals(PowerDensity.FromWattsPerCubicMeter(1), WattsPerCubicMeterTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(PowerDensity.Zero, WattsPerCubicMeterTolerance, ComparisonType.Relative)); - Assert.True(PowerDensity.FromWattsPerCubicMeter(100).Equals(PowerDensity.FromWattsPerCubicMeter(120), 0.3, ComparisonType.Relative)); - Assert.False(PowerDensity.FromWattsPerCubicMeter(100).Equals(PowerDensity.FromWattsPerCubicMeter(120), 0.1, ComparisonType.Relative)); + PowerDensity wattpercubicmeter = PowerDensity.FromWattsPerCubicMeter(1); + Assert.False(wattpercubicmeter.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = PowerDensity.FromWattsPerCubicMeter(1); - Assert.Throws(() => v.Equals(PowerDensity.FromWattsPerCubicMeter(1), -1, ComparisonType.Relative)); + PowerDensity wattpercubicmeter = PowerDensity.FromWattsPerCubicMeter(1); + Assert.False(wattpercubicmeter.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - PowerDensity wattpercubicmeter = PowerDensity.FromWattsPerCubicMeter(1); - Assert.False(wattpercubicmeter.Equals(new object())); + var quantity = PowerDensity.FromWattsPerCubicMeter(firstValue); + var otherQuantity = PowerDensity.FromWattsPerCubicMeter(secondValue); + PowerDensity maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, PowerDensity.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - PowerDensity wattpercubicmeter = PowerDensity.FromWattsPerCubicMeter(1); - Assert.False(wattpercubicmeter.Equals(null)); + var quantity = PowerDensity.FromWattsPerCubicMeter(1); + var negativeTolerance = PowerDensity.FromWattsPerCubicMeter(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerRatioTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerRatioTestsBase.g.cs index da25e594c9..62c90725f7 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerRatioTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerRatioTestsBase.g.cs @@ -523,23 +523,6 @@ public void Equals_Null_ReturnsFalse() #pragma warning restore CS8073 } - [Fact] - public void Equals_RelativeTolerance_IsImplemented() - { - var v = PowerRatio.FromDecibelWatts(1); - Assert.True(v.Equals(PowerRatio.FromDecibelWatts(1), DecibelWattsTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(PowerRatio.Zero, DecibelWattsTolerance, ComparisonType.Relative)); - Assert.True(PowerRatio.FromDecibelWatts(100).Equals(PowerRatio.FromDecibelWatts(120), 0.3, ComparisonType.Relative)); - Assert.False(PowerRatio.FromDecibelWatts(100).Equals(PowerRatio.FromDecibelWatts(120), 0.1, ComparisonType.Relative)); - } - - [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() - { - var v = PowerRatio.FromDecibelWatts(1); - Assert.Throws(() => v.Equals(PowerRatio.FromDecibelWatts(1), -1, ComparisonType.Relative)); - } - [Fact] public void EqualsReturnsFalseOnTypeMismatch() { @@ -554,6 +537,34 @@ public void EqualsReturnsFalseOnNull() Assert.False(decibelwatt.Equals(null)); } + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + { + var quantity = PowerRatio.FromDecibelWatts(firstValue); + var otherQuantity = PowerRatio.FromDecibelWatts(secondValue); + PowerRatio maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, PowerRatio.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); + // note: it's currently not possible to test this due to the rounding error from (quantity - otherQuantity) + // Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + } + + [Fact] + public void Equals_WithNegativeTolerance_DoesNotThrowArgumentOutOfRangeException() + { + // note: unlike with vector quantities- a small tolerance maybe positive in one unit and negative in another + var quantity = PowerRatio.FromDecibelWatts(1); + var negativeTolerance = PowerRatio.FromDecibelWatts(-1); + Assert.True(quantity.Equals(quantity, negativeTolerance)); + } + [Fact] public void HasAtLeastOneAbbreviationSpecified() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerTestsBase.g.cs index 4eb21688af..3132574950 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerTestsBase.g.cs @@ -1386,34 +1386,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = Power.FromWatts(1); - Assert.True(v.Equals(Power.FromWatts(1), WattsTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(Power.Zero, WattsTolerance, ComparisonType.Relative)); - Assert.True(Power.FromWatts(100).Equals(Power.FromWatts(120), 0.3, ComparisonType.Relative)); - Assert.False(Power.FromWatts(100).Equals(Power.FromWatts(120), 0.1, ComparisonType.Relative)); + Power watt = Power.FromWatts(1); + Assert.False(watt.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = Power.FromWatts(1); - Assert.Throws(() => v.Equals(Power.FromWatts(1), -1, ComparisonType.Relative)); + Power watt = Power.FromWatts(1); + Assert.False(watt.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - Power watt = Power.FromWatts(1); - Assert.False(watt.Equals(new object())); + var quantity = Power.FromWatts(firstValue); + var otherQuantity = Power.FromWatts(secondValue); + Power maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, Power.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - Power watt = Power.FromWatts(1); - Assert.False(watt.Equals(null)); + var quantity = Power.FromWatts(1); + var negativeTolerance = Power.FromWatts(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PressureChangeRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PressureChangeRateTestsBase.g.cs index 8881ab41ae..c6551c372d 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PressureChangeRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PressureChangeRateTestsBase.g.cs @@ -1605,34 +1605,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = PressureChangeRate.FromPascalsPerSecond(1); - Assert.True(v.Equals(PressureChangeRate.FromPascalsPerSecond(1), PascalsPerSecondTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(PressureChangeRate.Zero, PascalsPerSecondTolerance, ComparisonType.Relative)); - Assert.True(PressureChangeRate.FromPascalsPerSecond(100).Equals(PressureChangeRate.FromPascalsPerSecond(120), 0.3, ComparisonType.Relative)); - Assert.False(PressureChangeRate.FromPascalsPerSecond(100).Equals(PressureChangeRate.FromPascalsPerSecond(120), 0.1, ComparisonType.Relative)); + PressureChangeRate pascalpersecond = PressureChangeRate.FromPascalsPerSecond(1); + Assert.False(pascalpersecond.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = PressureChangeRate.FromPascalsPerSecond(1); - Assert.Throws(() => v.Equals(PressureChangeRate.FromPascalsPerSecond(1), -1, ComparisonType.Relative)); + PressureChangeRate pascalpersecond = PressureChangeRate.FromPascalsPerSecond(1); + Assert.False(pascalpersecond.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - PressureChangeRate pascalpersecond = PressureChangeRate.FromPascalsPerSecond(1); - Assert.False(pascalpersecond.Equals(new object())); + var quantity = PressureChangeRate.FromPascalsPerSecond(firstValue); + var otherQuantity = PressureChangeRate.FromPascalsPerSecond(secondValue); + PressureChangeRate maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, PressureChangeRate.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - PressureChangeRate pascalpersecond = PressureChangeRate.FromPascalsPerSecond(1); - Assert.False(pascalpersecond.Equals(null)); + var quantity = PressureChangeRate.FromPascalsPerSecond(1); + var negativeTolerance = PressureChangeRate.FromPascalsPerSecond(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PressureTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PressureTestsBase.g.cs index d0815e9271..007eb4777d 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PressureTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PressureTestsBase.g.cs @@ -2815,34 +2815,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = Pressure.FromPascals(1); - Assert.True(v.Equals(Pressure.FromPascals(1), PascalsTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(Pressure.Zero, PascalsTolerance, ComparisonType.Relative)); - Assert.True(Pressure.FromPascals(100).Equals(Pressure.FromPascals(120), 0.3, ComparisonType.Relative)); - Assert.False(Pressure.FromPascals(100).Equals(Pressure.FromPascals(120), 0.1, ComparisonType.Relative)); + Pressure pascal = Pressure.FromPascals(1); + Assert.False(pascal.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = Pressure.FromPascals(1); - Assert.Throws(() => v.Equals(Pressure.FromPascals(1), -1, ComparisonType.Relative)); + Pressure pascal = Pressure.FromPascals(1); + Assert.False(pascal.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - Pressure pascal = Pressure.FromPascals(1); - Assert.False(pascal.Equals(new object())); + var quantity = Pressure.FromPascals(firstValue); + var otherQuantity = Pressure.FromPascals(secondValue); + Pressure maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, Pressure.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - Pressure pascal = Pressure.FromPascals(1); - Assert.False(pascal.Equals(null)); + var quantity = Pressure.FromPascals(1); + var negativeTolerance = Pressure.FromPascals(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RadiationEquivalentDoseRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RadiationEquivalentDoseRateTestsBase.g.cs index ad98696554..768c34fea8 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RadiationEquivalentDoseRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RadiationEquivalentDoseRateTestsBase.g.cs @@ -951,34 +951,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = RadiationEquivalentDoseRate.FromSievertsPerSecond(1); - Assert.True(v.Equals(RadiationEquivalentDoseRate.FromSievertsPerSecond(1), SievertsPerSecondTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(RadiationEquivalentDoseRate.Zero, SievertsPerSecondTolerance, ComparisonType.Relative)); - Assert.True(RadiationEquivalentDoseRate.FromSievertsPerSecond(100).Equals(RadiationEquivalentDoseRate.FromSievertsPerSecond(120), 0.3, ComparisonType.Relative)); - Assert.False(RadiationEquivalentDoseRate.FromSievertsPerSecond(100).Equals(RadiationEquivalentDoseRate.FromSievertsPerSecond(120), 0.1, ComparisonType.Relative)); + RadiationEquivalentDoseRate sievertpersecond = RadiationEquivalentDoseRate.FromSievertsPerSecond(1); + Assert.False(sievertpersecond.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = RadiationEquivalentDoseRate.FromSievertsPerSecond(1); - Assert.Throws(() => v.Equals(RadiationEquivalentDoseRate.FromSievertsPerSecond(1), -1, ComparisonType.Relative)); + RadiationEquivalentDoseRate sievertpersecond = RadiationEquivalentDoseRate.FromSievertsPerSecond(1); + Assert.False(sievertpersecond.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - RadiationEquivalentDoseRate sievertpersecond = RadiationEquivalentDoseRate.FromSievertsPerSecond(1); - Assert.False(sievertpersecond.Equals(new object())); + var quantity = RadiationEquivalentDoseRate.FromSievertsPerSecond(firstValue); + var otherQuantity = RadiationEquivalentDoseRate.FromSievertsPerSecond(secondValue); + RadiationEquivalentDoseRate maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, RadiationEquivalentDoseRate.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - RadiationEquivalentDoseRate sievertpersecond = RadiationEquivalentDoseRate.FromSievertsPerSecond(1); - Assert.False(sievertpersecond.Equals(null)); + var quantity = RadiationEquivalentDoseRate.FromSievertsPerSecond(1); + var negativeTolerance = RadiationEquivalentDoseRate.FromSievertsPerSecond(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RadiationEquivalentDoseTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RadiationEquivalentDoseTestsBase.g.cs index 7c6fd0e6ec..08e4636d0c 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RadiationEquivalentDoseTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RadiationEquivalentDoseTestsBase.g.cs @@ -755,34 +755,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = RadiationEquivalentDose.FromSieverts(1); - Assert.True(v.Equals(RadiationEquivalentDose.FromSieverts(1), SievertsTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(RadiationEquivalentDose.Zero, SievertsTolerance, ComparisonType.Relative)); - Assert.True(RadiationEquivalentDose.FromSieverts(100).Equals(RadiationEquivalentDose.FromSieverts(120), 0.3, ComparisonType.Relative)); - Assert.False(RadiationEquivalentDose.FromSieverts(100).Equals(RadiationEquivalentDose.FromSieverts(120), 0.1, ComparisonType.Relative)); + RadiationEquivalentDose sievert = RadiationEquivalentDose.FromSieverts(1); + Assert.False(sievert.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = RadiationEquivalentDose.FromSieverts(1); - Assert.Throws(() => v.Equals(RadiationEquivalentDose.FromSieverts(1), -1, ComparisonType.Relative)); + RadiationEquivalentDose sievert = RadiationEquivalentDose.FromSieverts(1); + Assert.False(sievert.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - RadiationEquivalentDose sievert = RadiationEquivalentDose.FromSieverts(1); - Assert.False(sievert.Equals(new object())); + var quantity = RadiationEquivalentDose.FromSieverts(firstValue); + var otherQuantity = RadiationEquivalentDose.FromSieverts(secondValue); + RadiationEquivalentDose maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, RadiationEquivalentDose.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - RadiationEquivalentDose sievert = RadiationEquivalentDose.FromSieverts(1); - Assert.False(sievert.Equals(null)); + var quantity = RadiationEquivalentDose.FromSieverts(1); + var negativeTolerance = RadiationEquivalentDose.FromSieverts(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RadiationExposureTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RadiationExposureTestsBase.g.cs index a1870c720e..706a7547be 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RadiationExposureTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RadiationExposureTestsBase.g.cs @@ -751,34 +751,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = RadiationExposure.FromCoulombsPerKilogram(1); - Assert.True(v.Equals(RadiationExposure.FromCoulombsPerKilogram(1), CoulombsPerKilogramTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(RadiationExposure.Zero, CoulombsPerKilogramTolerance, ComparisonType.Relative)); - Assert.True(RadiationExposure.FromCoulombsPerKilogram(100).Equals(RadiationExposure.FromCoulombsPerKilogram(120), 0.3, ComparisonType.Relative)); - Assert.False(RadiationExposure.FromCoulombsPerKilogram(100).Equals(RadiationExposure.FromCoulombsPerKilogram(120), 0.1, ComparisonType.Relative)); + RadiationExposure coulombperkilogram = RadiationExposure.FromCoulombsPerKilogram(1); + Assert.False(coulombperkilogram.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = RadiationExposure.FromCoulombsPerKilogram(1); - Assert.Throws(() => v.Equals(RadiationExposure.FromCoulombsPerKilogram(1), -1, ComparisonType.Relative)); + RadiationExposure coulombperkilogram = RadiationExposure.FromCoulombsPerKilogram(1); + Assert.False(coulombperkilogram.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - RadiationExposure coulombperkilogram = RadiationExposure.FromCoulombsPerKilogram(1); - Assert.False(coulombperkilogram.Equals(new object())); + var quantity = RadiationExposure.FromCoulombsPerKilogram(firstValue); + var otherQuantity = RadiationExposure.FromCoulombsPerKilogram(secondValue); + RadiationExposure maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, RadiationExposure.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - RadiationExposure coulombperkilogram = RadiationExposure.FromCoulombsPerKilogram(1); - Assert.False(coulombperkilogram.Equals(null)); + var quantity = RadiationExposure.FromCoulombsPerKilogram(1); + var negativeTolerance = RadiationExposure.FromCoulombsPerKilogram(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RadioactivityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RadioactivityTestsBase.g.cs index 9ff100c470..252b9371ef 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RadioactivityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RadioactivityTestsBase.g.cs @@ -1820,34 +1820,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = Radioactivity.FromBecquerels(1); - Assert.True(v.Equals(Radioactivity.FromBecquerels(1), BecquerelsTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(Radioactivity.Zero, BecquerelsTolerance, ComparisonType.Relative)); - Assert.True(Radioactivity.FromBecquerels(100).Equals(Radioactivity.FromBecquerels(120), 0.3, ComparisonType.Relative)); - Assert.False(Radioactivity.FromBecquerels(100).Equals(Radioactivity.FromBecquerels(120), 0.1, ComparisonType.Relative)); + Radioactivity becquerel = Radioactivity.FromBecquerels(1); + Assert.False(becquerel.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = Radioactivity.FromBecquerels(1); - Assert.Throws(() => v.Equals(Radioactivity.FromBecquerels(1), -1, ComparisonType.Relative)); + Radioactivity becquerel = Radioactivity.FromBecquerels(1); + Assert.False(becquerel.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - Radioactivity becquerel = Radioactivity.FromBecquerels(1); - Assert.False(becquerel.Equals(new object())); + var quantity = Radioactivity.FromBecquerels(firstValue); + var otherQuantity = Radioactivity.FromBecquerels(secondValue); + Radioactivity maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, Radioactivity.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - Radioactivity becquerel = Radioactivity.FromBecquerels(1); - Assert.False(becquerel.Equals(null)); + var quantity = Radioactivity.FromBecquerels(1); + var negativeTolerance = Radioactivity.FromBecquerels(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RatioChangeRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RatioChangeRateTestsBase.g.cs index d31df12b20..201653a03b 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RatioChangeRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RatioChangeRateTestsBase.g.cs @@ -559,34 +559,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = RatioChangeRate.FromDecimalFractionsPerSecond(1); - Assert.True(v.Equals(RatioChangeRate.FromDecimalFractionsPerSecond(1), DecimalFractionsPerSecondTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(RatioChangeRate.Zero, DecimalFractionsPerSecondTolerance, ComparisonType.Relative)); - Assert.True(RatioChangeRate.FromDecimalFractionsPerSecond(100).Equals(RatioChangeRate.FromDecimalFractionsPerSecond(120), 0.3, ComparisonType.Relative)); - Assert.False(RatioChangeRate.FromDecimalFractionsPerSecond(100).Equals(RatioChangeRate.FromDecimalFractionsPerSecond(120), 0.1, ComparisonType.Relative)); + RatioChangeRate decimalfractionpersecond = RatioChangeRate.FromDecimalFractionsPerSecond(1); + Assert.False(decimalfractionpersecond.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = RatioChangeRate.FromDecimalFractionsPerSecond(1); - Assert.Throws(() => v.Equals(RatioChangeRate.FromDecimalFractionsPerSecond(1), -1, ComparisonType.Relative)); + RatioChangeRate decimalfractionpersecond = RatioChangeRate.FromDecimalFractionsPerSecond(1); + Assert.False(decimalfractionpersecond.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - RatioChangeRate decimalfractionpersecond = RatioChangeRate.FromDecimalFractionsPerSecond(1); - Assert.False(decimalfractionpersecond.Equals(new object())); + var quantity = RatioChangeRate.FromDecimalFractionsPerSecond(firstValue); + var otherQuantity = RatioChangeRate.FromDecimalFractionsPerSecond(secondValue); + RatioChangeRate maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, RatioChangeRate.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - RatioChangeRate decimalfractionpersecond = RatioChangeRate.FromDecimalFractionsPerSecond(1); - Assert.False(decimalfractionpersecond.Equals(null)); + var quantity = RatioChangeRate.FromDecimalFractionsPerSecond(1); + var negativeTolerance = RatioChangeRate.FromDecimalFractionsPerSecond(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RatioTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RatioTestsBase.g.cs index 1708796b9e..252448f697 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RatioTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RatioTestsBase.g.cs @@ -627,34 +627,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = Ratio.FromDecimalFractions(1); - Assert.True(v.Equals(Ratio.FromDecimalFractions(1), DecimalFractionsTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(Ratio.Zero, DecimalFractionsTolerance, ComparisonType.Relative)); - Assert.True(Ratio.FromDecimalFractions(100).Equals(Ratio.FromDecimalFractions(120), 0.3, ComparisonType.Relative)); - Assert.False(Ratio.FromDecimalFractions(100).Equals(Ratio.FromDecimalFractions(120), 0.1, ComparisonType.Relative)); + Ratio decimalfraction = Ratio.FromDecimalFractions(1); + Assert.False(decimalfraction.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = Ratio.FromDecimalFractions(1); - Assert.Throws(() => v.Equals(Ratio.FromDecimalFractions(1), -1, ComparisonType.Relative)); + Ratio decimalfraction = Ratio.FromDecimalFractions(1); + Assert.False(decimalfraction.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - Ratio decimalfraction = Ratio.FromDecimalFractions(1); - Assert.False(decimalfraction.Equals(new object())); + var quantity = Ratio.FromDecimalFractions(firstValue); + var otherQuantity = Ratio.FromDecimalFractions(secondValue); + Ratio maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, Ratio.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - Ratio decimalfraction = Ratio.FromDecimalFractions(1); - Assert.False(decimalfraction.Equals(null)); + var quantity = Ratio.FromDecimalFractions(1); + var negativeTolerance = Ratio.FromDecimalFractions(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalAreaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalAreaTestsBase.g.cs index 85afe81976..b6488b71ad 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalAreaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalAreaTestsBase.g.cs @@ -847,34 +847,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = ReciprocalArea.FromInverseSquareMeters(1); - Assert.True(v.Equals(ReciprocalArea.FromInverseSquareMeters(1), InverseSquareMetersTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(ReciprocalArea.Zero, InverseSquareMetersTolerance, ComparisonType.Relative)); - Assert.True(ReciprocalArea.FromInverseSquareMeters(100).Equals(ReciprocalArea.FromInverseSquareMeters(120), 0.3, ComparisonType.Relative)); - Assert.False(ReciprocalArea.FromInverseSquareMeters(100).Equals(ReciprocalArea.FromInverseSquareMeters(120), 0.1, ComparisonType.Relative)); + ReciprocalArea inversesquaremeter = ReciprocalArea.FromInverseSquareMeters(1); + Assert.False(inversesquaremeter.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = ReciprocalArea.FromInverseSquareMeters(1); - Assert.Throws(() => v.Equals(ReciprocalArea.FromInverseSquareMeters(1), -1, ComparisonType.Relative)); + ReciprocalArea inversesquaremeter = ReciprocalArea.FromInverseSquareMeters(1); + Assert.False(inversesquaremeter.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - ReciprocalArea inversesquaremeter = ReciprocalArea.FromInverseSquareMeters(1); - Assert.False(inversesquaremeter.Equals(new object())); + var quantity = ReciprocalArea.FromInverseSquareMeters(firstValue); + var otherQuantity = ReciprocalArea.FromInverseSquareMeters(secondValue); + ReciprocalArea maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, ReciprocalArea.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - ReciprocalArea inversesquaremeter = ReciprocalArea.FromInverseSquareMeters(1); - Assert.False(inversesquaremeter.Equals(null)); + var quantity = ReciprocalArea.FromInverseSquareMeters(1); + var negativeTolerance = ReciprocalArea.FromInverseSquareMeters(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalLengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalLengthTestsBase.g.cs index cd93811dd3..a1787eb848 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalLengthTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalLengthTestsBase.g.cs @@ -1025,34 +1025,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = ReciprocalLength.FromInverseMeters(1); - Assert.True(v.Equals(ReciprocalLength.FromInverseMeters(1), InverseMetersTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(ReciprocalLength.Zero, InverseMetersTolerance, ComparisonType.Relative)); - Assert.True(ReciprocalLength.FromInverseMeters(100).Equals(ReciprocalLength.FromInverseMeters(120), 0.3, ComparisonType.Relative)); - Assert.False(ReciprocalLength.FromInverseMeters(100).Equals(ReciprocalLength.FromInverseMeters(120), 0.1, ComparisonType.Relative)); + ReciprocalLength inversemeter = ReciprocalLength.FromInverseMeters(1); + Assert.False(inversemeter.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = ReciprocalLength.FromInverseMeters(1); - Assert.Throws(() => v.Equals(ReciprocalLength.FromInverseMeters(1), -1, ComparisonType.Relative)); + ReciprocalLength inversemeter = ReciprocalLength.FromInverseMeters(1); + Assert.False(inversemeter.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - ReciprocalLength inversemeter = ReciprocalLength.FromInverseMeters(1); - Assert.False(inversemeter.Equals(new object())); + var quantity = ReciprocalLength.FromInverseMeters(firstValue); + var otherQuantity = ReciprocalLength.FromInverseMeters(secondValue); + ReciprocalLength maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, ReciprocalLength.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - ReciprocalLength inversemeter = ReciprocalLength.FromInverseMeters(1); - Assert.False(inversemeter.Equals(null)); + var quantity = ReciprocalLength.FromInverseMeters(1); + var negativeTolerance = ReciprocalLength.FromInverseMeters(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RelativeHumidityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RelativeHumidityTestsBase.g.cs index 3837ed73fe..23d78769a9 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RelativeHumidityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RelativeHumidityTestsBase.g.cs @@ -466,34 +466,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = RelativeHumidity.FromPercent(1); - Assert.True(v.Equals(RelativeHumidity.FromPercent(1), PercentTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(RelativeHumidity.Zero, PercentTolerance, ComparisonType.Relative)); - Assert.True(RelativeHumidity.FromPercent(100).Equals(RelativeHumidity.FromPercent(120), 0.3, ComparisonType.Relative)); - Assert.False(RelativeHumidity.FromPercent(100).Equals(RelativeHumidity.FromPercent(120), 0.1, ComparisonType.Relative)); + RelativeHumidity percent = RelativeHumidity.FromPercent(1); + Assert.False(percent.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = RelativeHumidity.FromPercent(1); - Assert.Throws(() => v.Equals(RelativeHumidity.FromPercent(1), -1, ComparisonType.Relative)); + RelativeHumidity percent = RelativeHumidity.FromPercent(1); + Assert.False(percent.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - RelativeHumidity percent = RelativeHumidity.FromPercent(1); - Assert.False(percent.Equals(new object())); + var quantity = RelativeHumidity.FromPercent(firstValue); + var otherQuantity = RelativeHumidity.FromPercent(secondValue); + RelativeHumidity maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, RelativeHumidity.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - RelativeHumidity percent = RelativeHumidity.FromPercent(1); - Assert.False(percent.Equals(null)); + var quantity = RelativeHumidity.FromPercent(1); + var negativeTolerance = RelativeHumidity.FromPercent(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalAccelerationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalAccelerationTestsBase.g.cs index 9f282aae78..12f85b5b77 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalAccelerationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalAccelerationTestsBase.g.cs @@ -644,34 +644,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = RotationalAcceleration.FromRadiansPerSecondSquared(1); - Assert.True(v.Equals(RotationalAcceleration.FromRadiansPerSecondSquared(1), RadiansPerSecondSquaredTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(RotationalAcceleration.Zero, RadiansPerSecondSquaredTolerance, ComparisonType.Relative)); - Assert.True(RotationalAcceleration.FromRadiansPerSecondSquared(100).Equals(RotationalAcceleration.FromRadiansPerSecondSquared(120), 0.3, ComparisonType.Relative)); - Assert.False(RotationalAcceleration.FromRadiansPerSecondSquared(100).Equals(RotationalAcceleration.FromRadiansPerSecondSquared(120), 0.1, ComparisonType.Relative)); + RotationalAcceleration radianpersecondsquared = RotationalAcceleration.FromRadiansPerSecondSquared(1); + Assert.False(radianpersecondsquared.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = RotationalAcceleration.FromRadiansPerSecondSquared(1); - Assert.Throws(() => v.Equals(RotationalAcceleration.FromRadiansPerSecondSquared(1), -1, ComparisonType.Relative)); + RotationalAcceleration radianpersecondsquared = RotationalAcceleration.FromRadiansPerSecondSquared(1); + Assert.False(radianpersecondsquared.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - RotationalAcceleration radianpersecondsquared = RotationalAcceleration.FromRadiansPerSecondSquared(1); - Assert.False(radianpersecondsquared.Equals(new object())); + var quantity = RotationalAcceleration.FromRadiansPerSecondSquared(firstValue); + var otherQuantity = RotationalAcceleration.FromRadiansPerSecondSquared(secondValue); + RotationalAcceleration maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, RotationalAcceleration.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - RotationalAcceleration radianpersecondsquared = RotationalAcceleration.FromRadiansPerSecondSquared(1); - Assert.False(radianpersecondsquared.Equals(null)); + var quantity = RotationalAcceleration.FromRadiansPerSecondSquared(1); + var negativeTolerance = RotationalAcceleration.FromRadiansPerSecondSquared(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalSpeedTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalSpeedTestsBase.g.cs index 26828b6d84..e595a61724 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalSpeedTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalSpeedTestsBase.g.cs @@ -1241,34 +1241,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = RotationalSpeed.FromRadiansPerSecond(1); - Assert.True(v.Equals(RotationalSpeed.FromRadiansPerSecond(1), RadiansPerSecondTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(RotationalSpeed.Zero, RadiansPerSecondTolerance, ComparisonType.Relative)); - Assert.True(RotationalSpeed.FromRadiansPerSecond(100).Equals(RotationalSpeed.FromRadiansPerSecond(120), 0.3, ComparisonType.Relative)); - Assert.False(RotationalSpeed.FromRadiansPerSecond(100).Equals(RotationalSpeed.FromRadiansPerSecond(120), 0.1, ComparisonType.Relative)); + RotationalSpeed radianpersecond = RotationalSpeed.FromRadiansPerSecond(1); + Assert.False(radianpersecond.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = RotationalSpeed.FromRadiansPerSecond(1); - Assert.Throws(() => v.Equals(RotationalSpeed.FromRadiansPerSecond(1), -1, ComparisonType.Relative)); + RotationalSpeed radianpersecond = RotationalSpeed.FromRadiansPerSecond(1); + Assert.False(radianpersecond.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - RotationalSpeed radianpersecond = RotationalSpeed.FromRadiansPerSecond(1); - Assert.False(radianpersecond.Equals(new object())); + var quantity = RotationalSpeed.FromRadiansPerSecond(firstValue); + var otherQuantity = RotationalSpeed.FromRadiansPerSecond(secondValue); + RotationalSpeed maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, RotationalSpeed.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - RotationalSpeed radianpersecond = RotationalSpeed.FromRadiansPerSecond(1); - Assert.False(radianpersecond.Equals(null)); + var quantity = RotationalSpeed.FromRadiansPerSecond(1); + var negativeTolerance = RotationalSpeed.FromRadiansPerSecond(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessPerLengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessPerLengthTestsBase.g.cs index c44f3f0299..6b4c69d5ae 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessPerLengthTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessPerLengthTestsBase.g.cs @@ -823,34 +823,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(1); - Assert.True(v.Equals(RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(1), NewtonMetersPerRadianPerMeterTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(RotationalStiffnessPerLength.Zero, NewtonMetersPerRadianPerMeterTolerance, ComparisonType.Relative)); - Assert.True(RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(100).Equals(RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(120), 0.3, ComparisonType.Relative)); - Assert.False(RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(100).Equals(RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(120), 0.1, ComparisonType.Relative)); + RotationalStiffnessPerLength newtonmeterperradianpermeter = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(1); + Assert.False(newtonmeterperradianpermeter.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(1); - Assert.Throws(() => v.Equals(RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(1), -1, ComparisonType.Relative)); + RotationalStiffnessPerLength newtonmeterperradianpermeter = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(1); + Assert.False(newtonmeterperradianpermeter.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - RotationalStiffnessPerLength newtonmeterperradianpermeter = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(1); - Assert.False(newtonmeterperradianpermeter.Equals(new object())); + var quantity = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(firstValue); + var otherQuantity = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(secondValue); + RotationalStiffnessPerLength maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, RotationalStiffnessPerLength.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - RotationalStiffnessPerLength newtonmeterperradianpermeter = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(1); - Assert.False(newtonmeterperradianpermeter.Equals(null)); + var quantity = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(1); + var negativeTolerance = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessTestsBase.g.cs index 508614dbae..2975af62e7 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessTestsBase.g.cs @@ -2922,34 +2922,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = RotationalStiffness.FromNewtonMetersPerRadian(1); - Assert.True(v.Equals(RotationalStiffness.FromNewtonMetersPerRadian(1), NewtonMetersPerRadianTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(RotationalStiffness.Zero, NewtonMetersPerRadianTolerance, ComparisonType.Relative)); - Assert.True(RotationalStiffness.FromNewtonMetersPerRadian(100).Equals(RotationalStiffness.FromNewtonMetersPerRadian(120), 0.3, ComparisonType.Relative)); - Assert.False(RotationalStiffness.FromNewtonMetersPerRadian(100).Equals(RotationalStiffness.FromNewtonMetersPerRadian(120), 0.1, ComparisonType.Relative)); + RotationalStiffness newtonmeterperradian = RotationalStiffness.FromNewtonMetersPerRadian(1); + Assert.False(newtonmeterperradian.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = RotationalStiffness.FromNewtonMetersPerRadian(1); - Assert.Throws(() => v.Equals(RotationalStiffness.FromNewtonMetersPerRadian(1), -1, ComparisonType.Relative)); + RotationalStiffness newtonmeterperradian = RotationalStiffness.FromNewtonMetersPerRadian(1); + Assert.False(newtonmeterperradian.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - RotationalStiffness newtonmeterperradian = RotationalStiffness.FromNewtonMetersPerRadian(1); - Assert.False(newtonmeterperradian.Equals(new object())); + var quantity = RotationalStiffness.FromNewtonMetersPerRadian(firstValue); + var otherQuantity = RotationalStiffness.FromNewtonMetersPerRadian(secondValue); + RotationalStiffness maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, RotationalStiffness.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - RotationalStiffness newtonmeterperradian = RotationalStiffness.FromNewtonMetersPerRadian(1); - Assert.False(newtonmeterperradian.Equals(null)); + var quantity = RotationalStiffness.FromNewtonMetersPerRadian(1); + var negativeTolerance = RotationalStiffness.FromNewtonMetersPerRadian(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ScalarTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ScalarTestsBase.g.cs index 195818496c..f4cc851e6e 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ScalarTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ScalarTestsBase.g.cs @@ -466,34 +466,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = Scalar.FromAmount(1); - Assert.True(v.Equals(Scalar.FromAmount(1), AmountTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(Scalar.Zero, AmountTolerance, ComparisonType.Relative)); - Assert.True(Scalar.FromAmount(100).Equals(Scalar.FromAmount(120), 0.3, ComparisonType.Relative)); - Assert.False(Scalar.FromAmount(100).Equals(Scalar.FromAmount(120), 0.1, ComparisonType.Relative)); + Scalar amount = Scalar.FromAmount(1); + Assert.False(amount.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = Scalar.FromAmount(1); - Assert.Throws(() => v.Equals(Scalar.FromAmount(1), -1, ComparisonType.Relative)); + Scalar amount = Scalar.FromAmount(1); + Assert.False(amount.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - Scalar amount = Scalar.FromAmount(1); - Assert.False(amount.Equals(new object())); + var quantity = Scalar.FromAmount(firstValue); + var otherQuantity = Scalar.FromAmount(secondValue); + Scalar maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, Scalar.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - Scalar amount = Scalar.FromAmount(1); - Assert.False(amount.Equals(null)); + var quantity = Scalar.FromAmount(1); + var negativeTolerance = Scalar.FromAmount(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SolidAngleTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SolidAngleTestsBase.g.cs index 7537c62bbf..615b63f972 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SolidAngleTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SolidAngleTestsBase.g.cs @@ -466,34 +466,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = SolidAngle.FromSteradians(1); - Assert.True(v.Equals(SolidAngle.FromSteradians(1), SteradiansTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(SolidAngle.Zero, SteradiansTolerance, ComparisonType.Relative)); - Assert.True(SolidAngle.FromSteradians(100).Equals(SolidAngle.FromSteradians(120), 0.3, ComparisonType.Relative)); - Assert.False(SolidAngle.FromSteradians(100).Equals(SolidAngle.FromSteradians(120), 0.1, ComparisonType.Relative)); + SolidAngle steradian = SolidAngle.FromSteradians(1); + Assert.False(steradian.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = SolidAngle.FromSteradians(1); - Assert.Throws(() => v.Equals(SolidAngle.FromSteradians(1), -1, ComparisonType.Relative)); + SolidAngle steradian = SolidAngle.FromSteradians(1); + Assert.False(steradian.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - SolidAngle steradian = SolidAngle.FromSteradians(1); - Assert.False(steradian.Equals(new object())); + var quantity = SolidAngle.FromSteradians(firstValue); + var otherQuantity = SolidAngle.FromSteradians(secondValue); + SolidAngle maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, SolidAngle.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - SolidAngle steradian = SolidAngle.FromSteradians(1); - Assert.False(steradian.Equals(null)); + var quantity = SolidAngle.FromSteradians(1); + var negativeTolerance = SolidAngle.FromSteradians(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEnergyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEnergyTestsBase.g.cs index 91b3e5ef87..073dcb5177 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEnergyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEnergyTestsBase.g.cs @@ -1455,34 +1455,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = SpecificEnergy.FromJoulesPerKilogram(1); - Assert.True(v.Equals(SpecificEnergy.FromJoulesPerKilogram(1), JoulesPerKilogramTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(SpecificEnergy.Zero, JoulesPerKilogramTolerance, ComparisonType.Relative)); - Assert.True(SpecificEnergy.FromJoulesPerKilogram(100).Equals(SpecificEnergy.FromJoulesPerKilogram(120), 0.3, ComparisonType.Relative)); - Assert.False(SpecificEnergy.FromJoulesPerKilogram(100).Equals(SpecificEnergy.FromJoulesPerKilogram(120), 0.1, ComparisonType.Relative)); + SpecificEnergy jouleperkilogram = SpecificEnergy.FromJoulesPerKilogram(1); + Assert.False(jouleperkilogram.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = SpecificEnergy.FromJoulesPerKilogram(1); - Assert.Throws(() => v.Equals(SpecificEnergy.FromJoulesPerKilogram(1), -1, ComparisonType.Relative)); + SpecificEnergy jouleperkilogram = SpecificEnergy.FromJoulesPerKilogram(1); + Assert.False(jouleperkilogram.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - SpecificEnergy jouleperkilogram = SpecificEnergy.FromJoulesPerKilogram(1); - Assert.False(jouleperkilogram.Equals(new object())); + var quantity = SpecificEnergy.FromJoulesPerKilogram(firstValue); + var otherQuantity = SpecificEnergy.FromJoulesPerKilogram(secondValue); + SpecificEnergy maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, SpecificEnergy.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - SpecificEnergy jouleperkilogram = SpecificEnergy.FromJoulesPerKilogram(1); - Assert.False(jouleperkilogram.Equals(null)); + var quantity = SpecificEnergy.FromJoulesPerKilogram(1); + var negativeTolerance = SpecificEnergy.FromJoulesPerKilogram(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEntropyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEntropyTestsBase.g.cs index fffd2ae534..4a6c3dd94a 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEntropyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEntropyTestsBase.g.cs @@ -804,34 +804,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = SpecificEntropy.FromJoulesPerKilogramKelvin(1); - Assert.True(v.Equals(SpecificEntropy.FromJoulesPerKilogramKelvin(1), JoulesPerKilogramKelvinTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(SpecificEntropy.Zero, JoulesPerKilogramKelvinTolerance, ComparisonType.Relative)); - Assert.True(SpecificEntropy.FromJoulesPerKilogramKelvin(100).Equals(SpecificEntropy.FromJoulesPerKilogramKelvin(120), 0.3, ComparisonType.Relative)); - Assert.False(SpecificEntropy.FromJoulesPerKilogramKelvin(100).Equals(SpecificEntropy.FromJoulesPerKilogramKelvin(120), 0.1, ComparisonType.Relative)); + SpecificEntropy jouleperkilogramkelvin = SpecificEntropy.FromJoulesPerKilogramKelvin(1); + Assert.False(jouleperkilogramkelvin.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = SpecificEntropy.FromJoulesPerKilogramKelvin(1); - Assert.Throws(() => v.Equals(SpecificEntropy.FromJoulesPerKilogramKelvin(1), -1, ComparisonType.Relative)); + SpecificEntropy jouleperkilogramkelvin = SpecificEntropy.FromJoulesPerKilogramKelvin(1); + Assert.False(jouleperkilogramkelvin.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - SpecificEntropy jouleperkilogramkelvin = SpecificEntropy.FromJoulesPerKilogramKelvin(1); - Assert.False(jouleperkilogramkelvin.Equals(new object())); + var quantity = SpecificEntropy.FromJoulesPerKilogramKelvin(firstValue); + var otherQuantity = SpecificEntropy.FromJoulesPerKilogramKelvin(secondValue); + SpecificEntropy maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, SpecificEntropy.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - SpecificEntropy jouleperkilogramkelvin = SpecificEntropy.FromJoulesPerKilogramKelvin(1); - Assert.False(jouleperkilogramkelvin.Equals(null)); + var quantity = SpecificEntropy.FromJoulesPerKilogramKelvin(1); + var negativeTolerance = SpecificEntropy.FromJoulesPerKilogramKelvin(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificFuelConsumptionTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificFuelConsumptionTestsBase.g.cs index 5b7731fe77..ae24b2d820 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificFuelConsumptionTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificFuelConsumptionTestsBase.g.cs @@ -623,34 +623,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = SpecificFuelConsumption.FromGramsPerKilonewtonSecond(1); - Assert.True(v.Equals(SpecificFuelConsumption.FromGramsPerKilonewtonSecond(1), GramsPerKilonewtonSecondTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(SpecificFuelConsumption.Zero, GramsPerKilonewtonSecondTolerance, ComparisonType.Relative)); - Assert.True(SpecificFuelConsumption.FromGramsPerKilonewtonSecond(100).Equals(SpecificFuelConsumption.FromGramsPerKilonewtonSecond(120), 0.3, ComparisonType.Relative)); - Assert.False(SpecificFuelConsumption.FromGramsPerKilonewtonSecond(100).Equals(SpecificFuelConsumption.FromGramsPerKilonewtonSecond(120), 0.1, ComparisonType.Relative)); + SpecificFuelConsumption gramperkilonewtonsecond = SpecificFuelConsumption.FromGramsPerKilonewtonSecond(1); + Assert.False(gramperkilonewtonsecond.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = SpecificFuelConsumption.FromGramsPerKilonewtonSecond(1); - Assert.Throws(() => v.Equals(SpecificFuelConsumption.FromGramsPerKilonewtonSecond(1), -1, ComparisonType.Relative)); + SpecificFuelConsumption gramperkilonewtonsecond = SpecificFuelConsumption.FromGramsPerKilonewtonSecond(1); + Assert.False(gramperkilonewtonsecond.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - SpecificFuelConsumption gramperkilonewtonsecond = SpecificFuelConsumption.FromGramsPerKilonewtonSecond(1); - Assert.False(gramperkilonewtonsecond.Equals(new object())); + var quantity = SpecificFuelConsumption.FromGramsPerKilonewtonSecond(firstValue); + var otherQuantity = SpecificFuelConsumption.FromGramsPerKilonewtonSecond(secondValue); + SpecificFuelConsumption maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, SpecificFuelConsumption.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - SpecificFuelConsumption gramperkilonewtonsecond = SpecificFuelConsumption.FromGramsPerKilonewtonSecond(1); - Assert.False(gramperkilonewtonsecond.Equals(null)); + var quantity = SpecificFuelConsumption.FromGramsPerKilonewtonSecond(1); + var negativeTolerance = SpecificFuelConsumption.FromGramsPerKilonewtonSecond(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificVolumeTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificVolumeTestsBase.g.cs index 7580f7a71b..d84d1055d3 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificVolumeTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificVolumeTestsBase.g.cs @@ -591,34 +591,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = SpecificVolume.FromCubicMetersPerKilogram(1); - Assert.True(v.Equals(SpecificVolume.FromCubicMetersPerKilogram(1), CubicMetersPerKilogramTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(SpecificVolume.Zero, CubicMetersPerKilogramTolerance, ComparisonType.Relative)); - Assert.True(SpecificVolume.FromCubicMetersPerKilogram(100).Equals(SpecificVolume.FromCubicMetersPerKilogram(120), 0.3, ComparisonType.Relative)); - Assert.False(SpecificVolume.FromCubicMetersPerKilogram(100).Equals(SpecificVolume.FromCubicMetersPerKilogram(120), 0.1, ComparisonType.Relative)); + SpecificVolume cubicmeterperkilogram = SpecificVolume.FromCubicMetersPerKilogram(1); + Assert.False(cubicmeterperkilogram.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = SpecificVolume.FromCubicMetersPerKilogram(1); - Assert.Throws(() => v.Equals(SpecificVolume.FromCubicMetersPerKilogram(1), -1, ComparisonType.Relative)); + SpecificVolume cubicmeterperkilogram = SpecificVolume.FromCubicMetersPerKilogram(1); + Assert.False(cubicmeterperkilogram.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - SpecificVolume cubicmeterperkilogram = SpecificVolume.FromCubicMetersPerKilogram(1); - Assert.False(cubicmeterperkilogram.Equals(new object())); + var quantity = SpecificVolume.FromCubicMetersPerKilogram(firstValue); + var otherQuantity = SpecificVolume.FromCubicMetersPerKilogram(secondValue); + SpecificVolume maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, SpecificVolume.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - SpecificVolume cubicmeterperkilogram = SpecificVolume.FromCubicMetersPerKilogram(1); - Assert.False(cubicmeterperkilogram.Equals(null)); + var quantity = SpecificVolume.FromCubicMetersPerKilogram(1); + var negativeTolerance = SpecificVolume.FromCubicMetersPerKilogram(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificWeightTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificWeightTestsBase.g.cs index ef46d3c56d..4bdb9d9db4 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificWeightTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificWeightTestsBase.g.cs @@ -1039,34 +1039,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = SpecificWeight.FromNewtonsPerCubicMeter(1); - Assert.True(v.Equals(SpecificWeight.FromNewtonsPerCubicMeter(1), NewtonsPerCubicMeterTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(SpecificWeight.Zero, NewtonsPerCubicMeterTolerance, ComparisonType.Relative)); - Assert.True(SpecificWeight.FromNewtonsPerCubicMeter(100).Equals(SpecificWeight.FromNewtonsPerCubicMeter(120), 0.3, ComparisonType.Relative)); - Assert.False(SpecificWeight.FromNewtonsPerCubicMeter(100).Equals(SpecificWeight.FromNewtonsPerCubicMeter(120), 0.1, ComparisonType.Relative)); + SpecificWeight newtonpercubicmeter = SpecificWeight.FromNewtonsPerCubicMeter(1); + Assert.False(newtonpercubicmeter.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = SpecificWeight.FromNewtonsPerCubicMeter(1); - Assert.Throws(() => v.Equals(SpecificWeight.FromNewtonsPerCubicMeter(1), -1, ComparisonType.Relative)); + SpecificWeight newtonpercubicmeter = SpecificWeight.FromNewtonsPerCubicMeter(1); + Assert.False(newtonpercubicmeter.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - SpecificWeight newtonpercubicmeter = SpecificWeight.FromNewtonsPerCubicMeter(1); - Assert.False(newtonpercubicmeter.Equals(new object())); + var quantity = SpecificWeight.FromNewtonsPerCubicMeter(firstValue); + var otherQuantity = SpecificWeight.FromNewtonsPerCubicMeter(secondValue); + SpecificWeight maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, SpecificWeight.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - SpecificWeight newtonpercubicmeter = SpecificWeight.FromNewtonsPerCubicMeter(1); - Assert.False(newtonpercubicmeter.Equals(null)); + var quantity = SpecificWeight.FromNewtonsPerCubicMeter(1); + var negativeTolerance = SpecificWeight.FromNewtonsPerCubicMeter(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SpeedTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SpeedTestsBase.g.cs index 186a2d8e99..d4a4320a20 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SpeedTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SpeedTestsBase.g.cs @@ -2085,34 +2085,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = Speed.FromMetersPerSecond(1); - Assert.True(v.Equals(Speed.FromMetersPerSecond(1), MetersPerSecondTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(Speed.Zero, MetersPerSecondTolerance, ComparisonType.Relative)); - Assert.True(Speed.FromMetersPerSecond(100).Equals(Speed.FromMetersPerSecond(120), 0.3, ComparisonType.Relative)); - Assert.False(Speed.FromMetersPerSecond(100).Equals(Speed.FromMetersPerSecond(120), 0.1, ComparisonType.Relative)); + Speed meterpersecond = Speed.FromMetersPerSecond(1); + Assert.False(meterpersecond.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = Speed.FromMetersPerSecond(1); - Assert.Throws(() => v.Equals(Speed.FromMetersPerSecond(1), -1, ComparisonType.Relative)); + Speed meterpersecond = Speed.FromMetersPerSecond(1); + Assert.False(meterpersecond.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - Speed meterpersecond = Speed.FromMetersPerSecond(1); - Assert.False(meterpersecond.Equals(new object())); + var quantity = Speed.FromMetersPerSecond(firstValue); + var otherQuantity = Speed.FromMetersPerSecond(secondValue); + Speed maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, Speed.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - Speed meterpersecond = Speed.FromMetersPerSecond(1); - Assert.False(meterpersecond.Equals(null)); + var quantity = Speed.FromMetersPerSecond(1); + var negativeTolerance = Speed.FromMetersPerSecond(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/StandardVolumeFlowTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/StandardVolumeFlowTestsBase.g.cs index 3cfb825ab8..5afa97b3a1 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/StandardVolumeFlowTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/StandardVolumeFlowTestsBase.g.cs @@ -783,34 +783,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = StandardVolumeFlow.FromStandardCubicMetersPerSecond(1); - Assert.True(v.Equals(StandardVolumeFlow.FromStandardCubicMetersPerSecond(1), StandardCubicMetersPerSecondTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(StandardVolumeFlow.Zero, StandardCubicMetersPerSecondTolerance, ComparisonType.Relative)); - Assert.True(StandardVolumeFlow.FromStandardCubicMetersPerSecond(100).Equals(StandardVolumeFlow.FromStandardCubicMetersPerSecond(120), 0.3, ComparisonType.Relative)); - Assert.False(StandardVolumeFlow.FromStandardCubicMetersPerSecond(100).Equals(StandardVolumeFlow.FromStandardCubicMetersPerSecond(120), 0.1, ComparisonType.Relative)); + StandardVolumeFlow standardcubicmeterpersecond = StandardVolumeFlow.FromStandardCubicMetersPerSecond(1); + Assert.False(standardcubicmeterpersecond.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = StandardVolumeFlow.FromStandardCubicMetersPerSecond(1); - Assert.Throws(() => v.Equals(StandardVolumeFlow.FromStandardCubicMetersPerSecond(1), -1, ComparisonType.Relative)); + StandardVolumeFlow standardcubicmeterpersecond = StandardVolumeFlow.FromStandardCubicMetersPerSecond(1); + Assert.False(standardcubicmeterpersecond.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - StandardVolumeFlow standardcubicmeterpersecond = StandardVolumeFlow.FromStandardCubicMetersPerSecond(1); - Assert.False(standardcubicmeterpersecond.Equals(new object())); + var quantity = StandardVolumeFlow.FromStandardCubicMetersPerSecond(firstValue); + var otherQuantity = StandardVolumeFlow.FromStandardCubicMetersPerSecond(secondValue); + StandardVolumeFlow maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, StandardVolumeFlow.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - StandardVolumeFlow standardcubicmeterpersecond = StandardVolumeFlow.FromStandardCubicMetersPerSecond(1); - Assert.False(standardcubicmeterpersecond.Equals(null)); + var quantity = StandardVolumeFlow.FromStandardCubicMetersPerSecond(1); + var negativeTolerance = StandardVolumeFlow.FromStandardCubicMetersPerSecond(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureChangeRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureChangeRateTestsBase.g.cs index 3f93f54c57..c9124c12d1 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureChangeRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureChangeRateTestsBase.g.cs @@ -1039,34 +1039,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = TemperatureChangeRate.FromDegreesCelsiusPerSecond(1); - Assert.True(v.Equals(TemperatureChangeRate.FromDegreesCelsiusPerSecond(1), DegreesCelsiusPerSecondTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(TemperatureChangeRate.Zero, DegreesCelsiusPerSecondTolerance, ComparisonType.Relative)); - Assert.True(TemperatureChangeRate.FromDegreesCelsiusPerSecond(100).Equals(TemperatureChangeRate.FromDegreesCelsiusPerSecond(120), 0.3, ComparisonType.Relative)); - Assert.False(TemperatureChangeRate.FromDegreesCelsiusPerSecond(100).Equals(TemperatureChangeRate.FromDegreesCelsiusPerSecond(120), 0.1, ComparisonType.Relative)); + TemperatureChangeRate degreecelsiuspersecond = TemperatureChangeRate.FromDegreesCelsiusPerSecond(1); + Assert.False(degreecelsiuspersecond.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = TemperatureChangeRate.FromDegreesCelsiusPerSecond(1); - Assert.Throws(() => v.Equals(TemperatureChangeRate.FromDegreesCelsiusPerSecond(1), -1, ComparisonType.Relative)); + TemperatureChangeRate degreecelsiuspersecond = TemperatureChangeRate.FromDegreesCelsiusPerSecond(1); + Assert.False(degreecelsiuspersecond.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - TemperatureChangeRate degreecelsiuspersecond = TemperatureChangeRate.FromDegreesCelsiusPerSecond(1); - Assert.False(degreecelsiuspersecond.Equals(new object())); + var quantity = TemperatureChangeRate.FromDegreesCelsiusPerSecond(firstValue); + var otherQuantity = TemperatureChangeRate.FromDegreesCelsiusPerSecond(secondValue); + TemperatureChangeRate maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, TemperatureChangeRate.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - TemperatureChangeRate degreecelsiuspersecond = TemperatureChangeRate.FromDegreesCelsiusPerSecond(1); - Assert.False(degreecelsiuspersecond.Equals(null)); + var quantity = TemperatureChangeRate.FromDegreesCelsiusPerSecond(1); + var negativeTolerance = TemperatureChangeRate.FromDegreesCelsiusPerSecond(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureDeltaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureDeltaTestsBase.g.cs index eb7acaf065..1451a1e1c5 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureDeltaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureDeltaTestsBase.g.cs @@ -783,34 +783,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = TemperatureDelta.FromKelvins(1); - Assert.True(v.Equals(TemperatureDelta.FromKelvins(1), KelvinsTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(TemperatureDelta.Zero, KelvinsTolerance, ComparisonType.Relative)); - Assert.True(TemperatureDelta.FromKelvins(100).Equals(TemperatureDelta.FromKelvins(120), 0.3, ComparisonType.Relative)); - Assert.False(TemperatureDelta.FromKelvins(100).Equals(TemperatureDelta.FromKelvins(120), 0.1, ComparisonType.Relative)); + TemperatureDelta kelvin = TemperatureDelta.FromKelvins(1); + Assert.False(kelvin.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = TemperatureDelta.FromKelvins(1); - Assert.Throws(() => v.Equals(TemperatureDelta.FromKelvins(1), -1, ComparisonType.Relative)); + TemperatureDelta kelvin = TemperatureDelta.FromKelvins(1); + Assert.False(kelvin.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - TemperatureDelta kelvin = TemperatureDelta.FromKelvins(1); - Assert.False(kelvin.Equals(new object())); + var quantity = TemperatureDelta.FromKelvins(firstValue); + var otherQuantity = TemperatureDelta.FromKelvins(secondValue); + TemperatureDelta maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, TemperatureDelta.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - TemperatureDelta kelvin = TemperatureDelta.FromKelvins(1); - Assert.False(kelvin.Equals(null)); + var quantity = TemperatureDelta.FromKelvins(1); + var negativeTolerance = TemperatureDelta.FromKelvins(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureGradientTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureGradientTestsBase.g.cs index feb6d435cc..b80f4e9fb1 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureGradientTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureGradientTestsBase.g.cs @@ -623,34 +623,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = TemperatureGradient.FromKelvinsPerMeter(1); - Assert.True(v.Equals(TemperatureGradient.FromKelvinsPerMeter(1), KelvinsPerMeterTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(TemperatureGradient.Zero, KelvinsPerMeterTolerance, ComparisonType.Relative)); - Assert.True(TemperatureGradient.FromKelvinsPerMeter(100).Equals(TemperatureGradient.FromKelvinsPerMeter(120), 0.3, ComparisonType.Relative)); - Assert.False(TemperatureGradient.FromKelvinsPerMeter(100).Equals(TemperatureGradient.FromKelvinsPerMeter(120), 0.1, ComparisonType.Relative)); + TemperatureGradient kelvinpermeter = TemperatureGradient.FromKelvinsPerMeter(1); + Assert.False(kelvinpermeter.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = TemperatureGradient.FromKelvinsPerMeter(1); - Assert.Throws(() => v.Equals(TemperatureGradient.FromKelvinsPerMeter(1), -1, ComparisonType.Relative)); + TemperatureGradient kelvinpermeter = TemperatureGradient.FromKelvinsPerMeter(1); + Assert.False(kelvinpermeter.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - TemperatureGradient kelvinpermeter = TemperatureGradient.FromKelvinsPerMeter(1); - Assert.False(kelvinpermeter.Equals(new object())); + var quantity = TemperatureGradient.FromKelvinsPerMeter(firstValue); + var otherQuantity = TemperatureGradient.FromKelvinsPerMeter(secondValue); + TemperatureGradient maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, TemperatureGradient.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - TemperatureGradient kelvinpermeter = TemperatureGradient.FromKelvinsPerMeter(1); - Assert.False(kelvinpermeter.Equals(null)); + var quantity = TemperatureGradient.FromKelvinsPerMeter(1); + var negativeTolerance = TemperatureGradient.FromKelvinsPerMeter(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureTestsBase.g.cs index 49be974927..dd136cc364 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureTestsBase.g.cs @@ -803,34 +803,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = Temperature.FromKelvins(1); - Assert.True(v.Equals(Temperature.FromKelvins(1), KelvinsTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(Temperature.Zero, KelvinsTolerance, ComparisonType.Relative)); - Assert.True(Temperature.FromKelvins(100).Equals(Temperature.FromKelvins(120), 0.3, ComparisonType.Relative)); - Assert.False(Temperature.FromKelvins(100).Equals(Temperature.FromKelvins(120), 0.1, ComparisonType.Relative)); + Temperature kelvin = Temperature.FromKelvins(1); + Assert.False(kelvin.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = Temperature.FromKelvins(1); - Assert.Throws(() => v.Equals(Temperature.FromKelvins(1), -1, ComparisonType.Relative)); + Temperature kelvin = Temperature.FromKelvins(1); + Assert.False(kelvin.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - Temperature kelvin = Temperature.FromKelvins(1); - Assert.False(kelvin.Equals(new object())); + var quantity = Temperature.FromKelvins(firstValue); + var otherQuantity = Temperature.FromKelvins(secondValue); + TemperatureDelta maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, TemperatureDelta.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - Temperature kelvin = Temperature.FromKelvins(1); - Assert.False(kelvin.Equals(null)); + var quantity = Temperature.FromKelvins(1); + TemperatureDelta negativeTolerance = quantity - Temperature.FromKelvins(2); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalConductivityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalConductivityTestsBase.g.cs index bcc4cd973e..f7ea4e76b2 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalConductivityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalConductivityTestsBase.g.cs @@ -559,34 +559,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = ThermalConductivity.FromWattsPerMeterKelvin(1); - Assert.True(v.Equals(ThermalConductivity.FromWattsPerMeterKelvin(1), WattsPerMeterKelvinTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(ThermalConductivity.Zero, WattsPerMeterKelvinTolerance, ComparisonType.Relative)); - Assert.True(ThermalConductivity.FromWattsPerMeterKelvin(100).Equals(ThermalConductivity.FromWattsPerMeterKelvin(120), 0.3, ComparisonType.Relative)); - Assert.False(ThermalConductivity.FromWattsPerMeterKelvin(100).Equals(ThermalConductivity.FromWattsPerMeterKelvin(120), 0.1, ComparisonType.Relative)); + ThermalConductivity wattpermeterkelvin = ThermalConductivity.FromWattsPerMeterKelvin(1); + Assert.False(wattpermeterkelvin.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = ThermalConductivity.FromWattsPerMeterKelvin(1); - Assert.Throws(() => v.Equals(ThermalConductivity.FromWattsPerMeterKelvin(1), -1, ComparisonType.Relative)); + ThermalConductivity wattpermeterkelvin = ThermalConductivity.FromWattsPerMeterKelvin(1); + Assert.False(wattpermeterkelvin.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - ThermalConductivity wattpermeterkelvin = ThermalConductivity.FromWattsPerMeterKelvin(1); - Assert.False(wattpermeterkelvin.Equals(new object())); + var quantity = ThermalConductivity.FromWattsPerMeterKelvin(firstValue); + var otherQuantity = ThermalConductivity.FromWattsPerMeterKelvin(secondValue); + ThermalConductivity maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, ThermalConductivity.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - ThermalConductivity wattpermeterkelvin = ThermalConductivity.FromWattsPerMeterKelvin(1); - Assert.False(wattpermeterkelvin.Equals(null)); + var quantity = ThermalConductivity.FromWattsPerMeterKelvin(1); + var negativeTolerance = ThermalConductivity.FromWattsPerMeterKelvin(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalInsulanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalInsulanceTestsBase.g.cs index c0bfead86e..db92152e20 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalInsulanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalInsulanceTestsBase.g.cs @@ -719,34 +719,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = ThermalInsulance.FromSquareMeterKelvinsPerKilowatt(1); - Assert.True(v.Equals(ThermalInsulance.FromSquareMeterKelvinsPerKilowatt(1), SquareMeterKelvinsPerKilowattTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(ThermalInsulance.Zero, SquareMeterKelvinsPerKilowattTolerance, ComparisonType.Relative)); - Assert.True(ThermalInsulance.FromSquareMeterKelvinsPerKilowatt(100).Equals(ThermalInsulance.FromSquareMeterKelvinsPerKilowatt(120), 0.3, ComparisonType.Relative)); - Assert.False(ThermalInsulance.FromSquareMeterKelvinsPerKilowatt(100).Equals(ThermalInsulance.FromSquareMeterKelvinsPerKilowatt(120), 0.1, ComparisonType.Relative)); + ThermalInsulance squaremeterkelvinperkilowatt = ThermalInsulance.FromSquareMeterKelvinsPerKilowatt(1); + Assert.False(squaremeterkelvinperkilowatt.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = ThermalInsulance.FromSquareMeterKelvinsPerKilowatt(1); - Assert.Throws(() => v.Equals(ThermalInsulance.FromSquareMeterKelvinsPerKilowatt(1), -1, ComparisonType.Relative)); + ThermalInsulance squaremeterkelvinperkilowatt = ThermalInsulance.FromSquareMeterKelvinsPerKilowatt(1); + Assert.False(squaremeterkelvinperkilowatt.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - ThermalInsulance squaremeterkelvinperkilowatt = ThermalInsulance.FromSquareMeterKelvinsPerKilowatt(1); - Assert.False(squaremeterkelvinperkilowatt.Equals(new object())); + var quantity = ThermalInsulance.FromSquareMeterKelvinsPerKilowatt(firstValue); + var otherQuantity = ThermalInsulance.FromSquareMeterKelvinsPerKilowatt(secondValue); + ThermalInsulance maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, ThermalInsulance.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - ThermalInsulance squaremeterkelvinperkilowatt = ThermalInsulance.FromSquareMeterKelvinsPerKilowatt(1); - Assert.False(squaremeterkelvinperkilowatt.Equals(null)); + var quantity = ThermalInsulance.FromSquareMeterKelvinsPerKilowatt(1); + var negativeTolerance = ThermalInsulance.FromSquareMeterKelvinsPerKilowatt(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalResistanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalResistanceTestsBase.g.cs index 4c51dfc264..dad96683d0 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalResistanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalResistanceTestsBase.g.cs @@ -559,34 +559,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = ThermalResistance.FromKelvinsPerWatt(1); - Assert.True(v.Equals(ThermalResistance.FromKelvinsPerWatt(1), KelvinsPerWattTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(ThermalResistance.Zero, KelvinsPerWattTolerance, ComparisonType.Relative)); - Assert.True(ThermalResistance.FromKelvinsPerWatt(100).Equals(ThermalResistance.FromKelvinsPerWatt(120), 0.3, ComparisonType.Relative)); - Assert.False(ThermalResistance.FromKelvinsPerWatt(100).Equals(ThermalResistance.FromKelvinsPerWatt(120), 0.1, ComparisonType.Relative)); + ThermalResistance kelvinperwatt = ThermalResistance.FromKelvinsPerWatt(1); + Assert.False(kelvinperwatt.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = ThermalResistance.FromKelvinsPerWatt(1); - Assert.Throws(() => v.Equals(ThermalResistance.FromKelvinsPerWatt(1), -1, ComparisonType.Relative)); + ThermalResistance kelvinperwatt = ThermalResistance.FromKelvinsPerWatt(1); + Assert.False(kelvinperwatt.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - ThermalResistance kelvinperwatt = ThermalResistance.FromKelvinsPerWatt(1); - Assert.False(kelvinperwatt.Equals(new object())); + var quantity = ThermalResistance.FromKelvinsPerWatt(firstValue); + var otherQuantity = ThermalResistance.FromKelvinsPerWatt(secondValue); + ThermalResistance maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, ThermalResistance.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - ThermalResistance kelvinperwatt = ThermalResistance.FromKelvinsPerWatt(1); - Assert.False(kelvinperwatt.Equals(null)); + var quantity = ThermalResistance.FromKelvinsPerWatt(1); + var negativeTolerance = ThermalResistance.FromKelvinsPerWatt(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TorqueTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TorqueTestsBase.g.cs index 024286685b..f9d792a450 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TorqueTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TorqueTestsBase.g.cs @@ -1346,34 +1346,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = Torque.FromNewtonMeters(1); - Assert.True(v.Equals(Torque.FromNewtonMeters(1), NewtonMetersTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(Torque.Zero, NewtonMetersTolerance, ComparisonType.Relative)); - Assert.True(Torque.FromNewtonMeters(100).Equals(Torque.FromNewtonMeters(120), 0.3, ComparisonType.Relative)); - Assert.False(Torque.FromNewtonMeters(100).Equals(Torque.FromNewtonMeters(120), 0.1, ComparisonType.Relative)); + Torque newtonmeter = Torque.FromNewtonMeters(1); + Assert.False(newtonmeter.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = Torque.FromNewtonMeters(1); - Assert.Throws(() => v.Equals(Torque.FromNewtonMeters(1), -1, ComparisonType.Relative)); + Torque newtonmeter = Torque.FromNewtonMeters(1); + Assert.False(newtonmeter.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - Torque newtonmeter = Torque.FromNewtonMeters(1); - Assert.False(newtonmeter.Equals(new object())); + var quantity = Torque.FromNewtonMeters(firstValue); + var otherQuantity = Torque.FromNewtonMeters(secondValue); + Torque maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, Torque.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - Torque newtonmeter = Torque.FromNewtonMeters(1); - Assert.False(newtonmeter.Equals(null)); + var quantity = Torque.FromNewtonMeters(1); + var negativeTolerance = Torque.FromNewtonMeters(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TurbidityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TurbidityTestsBase.g.cs index 20892c55df..083f8e0465 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TurbidityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TurbidityTestsBase.g.cs @@ -466,34 +466,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = Turbidity.FromNTU(1); - Assert.True(v.Equals(Turbidity.FromNTU(1), NTUTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(Turbidity.Zero, NTUTolerance, ComparisonType.Relative)); - Assert.True(Turbidity.FromNTU(100).Equals(Turbidity.FromNTU(120), 0.3, ComparisonType.Relative)); - Assert.False(Turbidity.FromNTU(100).Equals(Turbidity.FromNTU(120), 0.1, ComparisonType.Relative)); + Turbidity ntu = Turbidity.FromNTU(1); + Assert.False(ntu.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = Turbidity.FromNTU(1); - Assert.Throws(() => v.Equals(Turbidity.FromNTU(1), -1, ComparisonType.Relative)); + Turbidity ntu = Turbidity.FromNTU(1); + Assert.False(ntu.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - Turbidity ntu = Turbidity.FromNTU(1); - Assert.False(ntu.Equals(new object())); + var quantity = Turbidity.FromNTU(firstValue); + var otherQuantity = Turbidity.FromNTU(secondValue); + Turbidity maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, Turbidity.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - Turbidity ntu = Turbidity.FromNTU(1); - Assert.False(ntu.Equals(null)); + var quantity = Turbidity.FromNTU(1); + var negativeTolerance = Turbidity.FromNTU(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VitaminATestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VitaminATestsBase.g.cs index 9e63f64d15..087400f798 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VitaminATestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VitaminATestsBase.g.cs @@ -466,34 +466,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = VitaminA.FromInternationalUnits(1); - Assert.True(v.Equals(VitaminA.FromInternationalUnits(1), InternationalUnitsTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(VitaminA.Zero, InternationalUnitsTolerance, ComparisonType.Relative)); - Assert.True(VitaminA.FromInternationalUnits(100).Equals(VitaminA.FromInternationalUnits(120), 0.3, ComparisonType.Relative)); - Assert.False(VitaminA.FromInternationalUnits(100).Equals(VitaminA.FromInternationalUnits(120), 0.1, ComparisonType.Relative)); + VitaminA internationalunit = VitaminA.FromInternationalUnits(1); + Assert.False(internationalunit.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = VitaminA.FromInternationalUnits(1); - Assert.Throws(() => v.Equals(VitaminA.FromInternationalUnits(1), -1, ComparisonType.Relative)); + VitaminA internationalunit = VitaminA.FromInternationalUnits(1); + Assert.False(internationalunit.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - VitaminA internationalunit = VitaminA.FromInternationalUnits(1); - Assert.False(internationalunit.Equals(new object())); + var quantity = VitaminA.FromInternationalUnits(firstValue); + var otherQuantity = VitaminA.FromInternationalUnits(secondValue); + VitaminA maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, VitaminA.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - VitaminA internationalunit = VitaminA.FromInternationalUnits(1); - Assert.False(internationalunit.Equals(null)); + var quantity = VitaminA.FromInternationalUnits(1); + var negativeTolerance = VitaminA.FromInternationalUnits(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeConcentrationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeConcentrationTestsBase.g.cs index bd01c8516d..bfdb3ce196 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeConcentrationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeConcentrationTestsBase.g.cs @@ -1096,34 +1096,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = VolumeConcentration.FromDecimalFractions(1); - Assert.True(v.Equals(VolumeConcentration.FromDecimalFractions(1), DecimalFractionsTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(VolumeConcentration.Zero, DecimalFractionsTolerance, ComparisonType.Relative)); - Assert.True(VolumeConcentration.FromDecimalFractions(100).Equals(VolumeConcentration.FromDecimalFractions(120), 0.3, ComparisonType.Relative)); - Assert.False(VolumeConcentration.FromDecimalFractions(100).Equals(VolumeConcentration.FromDecimalFractions(120), 0.1, ComparisonType.Relative)); + VolumeConcentration decimalfraction = VolumeConcentration.FromDecimalFractions(1); + Assert.False(decimalfraction.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = VolumeConcentration.FromDecimalFractions(1); - Assert.Throws(() => v.Equals(VolumeConcentration.FromDecimalFractions(1), -1, ComparisonType.Relative)); + VolumeConcentration decimalfraction = VolumeConcentration.FromDecimalFractions(1); + Assert.False(decimalfraction.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - VolumeConcentration decimalfraction = VolumeConcentration.FromDecimalFractions(1); - Assert.False(decimalfraction.Equals(new object())); + var quantity = VolumeConcentration.FromDecimalFractions(firstValue); + var otherQuantity = VolumeConcentration.FromDecimalFractions(secondValue); + VolumeConcentration maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, VolumeConcentration.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - VolumeConcentration decimalfraction = VolumeConcentration.FromDecimalFractions(1); - Assert.False(decimalfraction.Equals(null)); + var quantity = VolumeConcentration.FromDecimalFractions(1); + var negativeTolerance = VolumeConcentration.FromDecimalFractions(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowPerAreaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowPerAreaTestsBase.g.cs index 8608810b3c..90041ee2a7 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowPerAreaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowPerAreaTestsBase.g.cs @@ -559,34 +559,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = VolumeFlowPerArea.FromCubicMetersPerSecondPerSquareMeter(1); - Assert.True(v.Equals(VolumeFlowPerArea.FromCubicMetersPerSecondPerSquareMeter(1), CubicMetersPerSecondPerSquareMeterTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(VolumeFlowPerArea.Zero, CubicMetersPerSecondPerSquareMeterTolerance, ComparisonType.Relative)); - Assert.True(VolumeFlowPerArea.FromCubicMetersPerSecondPerSquareMeter(100).Equals(VolumeFlowPerArea.FromCubicMetersPerSecondPerSquareMeter(120), 0.3, ComparisonType.Relative)); - Assert.False(VolumeFlowPerArea.FromCubicMetersPerSecondPerSquareMeter(100).Equals(VolumeFlowPerArea.FromCubicMetersPerSecondPerSquareMeter(120), 0.1, ComparisonType.Relative)); + VolumeFlowPerArea cubicmeterpersecondpersquaremeter = VolumeFlowPerArea.FromCubicMetersPerSecondPerSquareMeter(1); + Assert.False(cubicmeterpersecondpersquaremeter.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = VolumeFlowPerArea.FromCubicMetersPerSecondPerSquareMeter(1); - Assert.Throws(() => v.Equals(VolumeFlowPerArea.FromCubicMetersPerSecondPerSquareMeter(1), -1, ComparisonType.Relative)); + VolumeFlowPerArea cubicmeterpersecondpersquaremeter = VolumeFlowPerArea.FromCubicMetersPerSecondPerSquareMeter(1); + Assert.False(cubicmeterpersecondpersquaremeter.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - VolumeFlowPerArea cubicmeterpersecondpersquaremeter = VolumeFlowPerArea.FromCubicMetersPerSecondPerSquareMeter(1); - Assert.False(cubicmeterpersecondpersquaremeter.Equals(new object())); + var quantity = VolumeFlowPerArea.FromCubicMetersPerSecondPerSquareMeter(firstValue); + var otherQuantity = VolumeFlowPerArea.FromCubicMetersPerSecondPerSquareMeter(secondValue); + VolumeFlowPerArea maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, VolumeFlowPerArea.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - VolumeFlowPerArea cubicmeterpersecondpersquaremeter = VolumeFlowPerArea.FromCubicMetersPerSecondPerSquareMeter(1); - Assert.False(cubicmeterpersecondpersquaremeter.Equals(null)); + var quantity = VolumeFlowPerArea.FromCubicMetersPerSecondPerSquareMeter(1); + var negativeTolerance = VolumeFlowPerArea.FromCubicMetersPerSecondPerSquareMeter(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowTestsBase.g.cs index b44ad00ce2..73c2401b5f 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowTestsBase.g.cs @@ -4602,34 +4602,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = VolumeFlow.FromCubicMetersPerSecond(1); - Assert.True(v.Equals(VolumeFlow.FromCubicMetersPerSecond(1), CubicMetersPerSecondTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(VolumeFlow.Zero, CubicMetersPerSecondTolerance, ComparisonType.Relative)); - Assert.True(VolumeFlow.FromCubicMetersPerSecond(100).Equals(VolumeFlow.FromCubicMetersPerSecond(120), 0.3, ComparisonType.Relative)); - Assert.False(VolumeFlow.FromCubicMetersPerSecond(100).Equals(VolumeFlow.FromCubicMetersPerSecond(120), 0.1, ComparisonType.Relative)); + VolumeFlow cubicmeterpersecond = VolumeFlow.FromCubicMetersPerSecond(1); + Assert.False(cubicmeterpersecond.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = VolumeFlow.FromCubicMetersPerSecond(1); - Assert.Throws(() => v.Equals(VolumeFlow.FromCubicMetersPerSecond(1), -1, ComparisonType.Relative)); + VolumeFlow cubicmeterpersecond = VolumeFlow.FromCubicMetersPerSecond(1); + Assert.False(cubicmeterpersecond.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - VolumeFlow cubicmeterpersecond = VolumeFlow.FromCubicMetersPerSecond(1); - Assert.False(cubicmeterpersecond.Equals(new object())); + var quantity = VolumeFlow.FromCubicMetersPerSecond(firstValue); + var otherQuantity = VolumeFlow.FromCubicMetersPerSecond(secondValue); + VolumeFlow maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, VolumeFlow.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - VolumeFlow cubicmeterpersecond = VolumeFlow.FromCubicMetersPerSecond(1); - Assert.False(cubicmeterpersecond.Equals(null)); + var quantity = VolumeFlow.FromCubicMetersPerSecond(1); + var negativeTolerance = VolumeFlow.FromCubicMetersPerSecond(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumePerLengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumePerLengthTestsBase.g.cs index 2802a1e72f..b95c6ab159 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumePerLengthTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumePerLengthTestsBase.g.cs @@ -783,34 +783,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = VolumePerLength.FromCubicMetersPerMeter(1); - Assert.True(v.Equals(VolumePerLength.FromCubicMetersPerMeter(1), CubicMetersPerMeterTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(VolumePerLength.Zero, CubicMetersPerMeterTolerance, ComparisonType.Relative)); - Assert.True(VolumePerLength.FromCubicMetersPerMeter(100).Equals(VolumePerLength.FromCubicMetersPerMeter(120), 0.3, ComparisonType.Relative)); - Assert.False(VolumePerLength.FromCubicMetersPerMeter(100).Equals(VolumePerLength.FromCubicMetersPerMeter(120), 0.1, ComparisonType.Relative)); + VolumePerLength cubicmeterpermeter = VolumePerLength.FromCubicMetersPerMeter(1); + Assert.False(cubicmeterpermeter.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = VolumePerLength.FromCubicMetersPerMeter(1); - Assert.Throws(() => v.Equals(VolumePerLength.FromCubicMetersPerMeter(1), -1, ComparisonType.Relative)); + VolumePerLength cubicmeterpermeter = VolumePerLength.FromCubicMetersPerMeter(1); + Assert.False(cubicmeterpermeter.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - VolumePerLength cubicmeterpermeter = VolumePerLength.FromCubicMetersPerMeter(1); - Assert.False(cubicmeterpermeter.Equals(new object())); + var quantity = VolumePerLength.FromCubicMetersPerMeter(firstValue); + var otherQuantity = VolumePerLength.FromCubicMetersPerMeter(secondValue); + VolumePerLength maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, VolumePerLength.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - VolumePerLength cubicmeterpermeter = VolumePerLength.FromCubicMetersPerMeter(1); - Assert.False(cubicmeterpermeter.Equals(null)); + var quantity = VolumePerLength.FromCubicMetersPerMeter(1); + var negativeTolerance = VolumePerLength.FromCubicMetersPerMeter(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeTestsBase.g.cs index bb7f1dabf7..a70847bebd 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeTestsBase.g.cs @@ -3118,34 +3118,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = Volume.FromCubicMeters(1); - Assert.True(v.Equals(Volume.FromCubicMeters(1), CubicMetersTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(Volume.Zero, CubicMetersTolerance, ComparisonType.Relative)); - Assert.True(Volume.FromCubicMeters(100).Equals(Volume.FromCubicMeters(120), 0.3, ComparisonType.Relative)); - Assert.False(Volume.FromCubicMeters(100).Equals(Volume.FromCubicMeters(120), 0.1, ComparisonType.Relative)); + Volume cubicmeter = Volume.FromCubicMeters(1); + Assert.False(cubicmeter.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = Volume.FromCubicMeters(1); - Assert.Throws(() => v.Equals(Volume.FromCubicMeters(1), -1, ComparisonType.Relative)); + Volume cubicmeter = Volume.FromCubicMeters(1); + Assert.False(cubicmeter.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - Volume cubicmeter = Volume.FromCubicMeters(1); - Assert.False(cubicmeter.Equals(new object())); + var quantity = Volume.FromCubicMeters(firstValue); + var otherQuantity = Volume.FromCubicMeters(secondValue); + Volume maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, Volume.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - Volume cubicmeter = Volume.FromCubicMeters(1); - Assert.False(cubicmeter.Equals(null)); + var quantity = Volume.FromCubicMeters(1); + var negativeTolerance = Volume.FromCubicMeters(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumetricHeatCapacityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumetricHeatCapacityTestsBase.g.cs index f6edd591f4..6b733d5655 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumetricHeatCapacityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumetricHeatCapacityTestsBase.g.cs @@ -783,34 +783,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = VolumetricHeatCapacity.FromJoulesPerCubicMeterKelvin(1); - Assert.True(v.Equals(VolumetricHeatCapacity.FromJoulesPerCubicMeterKelvin(1), JoulesPerCubicMeterKelvinTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(VolumetricHeatCapacity.Zero, JoulesPerCubicMeterKelvinTolerance, ComparisonType.Relative)); - Assert.True(VolumetricHeatCapacity.FromJoulesPerCubicMeterKelvin(100).Equals(VolumetricHeatCapacity.FromJoulesPerCubicMeterKelvin(120), 0.3, ComparisonType.Relative)); - Assert.False(VolumetricHeatCapacity.FromJoulesPerCubicMeterKelvin(100).Equals(VolumetricHeatCapacity.FromJoulesPerCubicMeterKelvin(120), 0.1, ComparisonType.Relative)); + VolumetricHeatCapacity joulepercubicmeterkelvin = VolumetricHeatCapacity.FromJoulesPerCubicMeterKelvin(1); + Assert.False(joulepercubicmeterkelvin.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = VolumetricHeatCapacity.FromJoulesPerCubicMeterKelvin(1); - Assert.Throws(() => v.Equals(VolumetricHeatCapacity.FromJoulesPerCubicMeterKelvin(1), -1, ComparisonType.Relative)); + VolumetricHeatCapacity joulepercubicmeterkelvin = VolumetricHeatCapacity.FromJoulesPerCubicMeterKelvin(1); + Assert.False(joulepercubicmeterkelvin.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - VolumetricHeatCapacity joulepercubicmeterkelvin = VolumetricHeatCapacity.FromJoulesPerCubicMeterKelvin(1); - Assert.False(joulepercubicmeterkelvin.Equals(new object())); + var quantity = VolumetricHeatCapacity.FromJoulesPerCubicMeterKelvin(firstValue); + var otherQuantity = VolumetricHeatCapacity.FromJoulesPerCubicMeterKelvin(secondValue); + VolumetricHeatCapacity maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, VolumetricHeatCapacity.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - VolumetricHeatCapacity joulepercubicmeterkelvin = VolumetricHeatCapacity.FromJoulesPerCubicMeterKelvin(1); - Assert.False(joulepercubicmeterkelvin.Equals(null)); + var quantity = VolumetricHeatCapacity.FromJoulesPerCubicMeterKelvin(1); + var negativeTolerance = VolumetricHeatCapacity.FromJoulesPerCubicMeterKelvin(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/WarpingMomentOfInertiaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/WarpingMomentOfInertiaTestsBase.g.cs index f90fada63b..8e49634c81 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/WarpingMomentOfInertiaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/WarpingMomentOfInertiaTestsBase.g.cs @@ -687,34 +687,43 @@ public void Equals_Null_ReturnsFalse() } [Fact] - public void Equals_RelativeTolerance_IsImplemented() + public void EqualsReturnsFalseOnTypeMismatch() { - var v = WarpingMomentOfInertia.FromMetersToTheSixth(1); - Assert.True(v.Equals(WarpingMomentOfInertia.FromMetersToTheSixth(1), MetersToTheSixthTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(WarpingMomentOfInertia.Zero, MetersToTheSixthTolerance, ComparisonType.Relative)); - Assert.True(WarpingMomentOfInertia.FromMetersToTheSixth(100).Equals(WarpingMomentOfInertia.FromMetersToTheSixth(120), 0.3, ComparisonType.Relative)); - Assert.False(WarpingMomentOfInertia.FromMetersToTheSixth(100).Equals(WarpingMomentOfInertia.FromMetersToTheSixth(120), 0.1, ComparisonType.Relative)); + WarpingMomentOfInertia metertothesixth = WarpingMomentOfInertia.FromMetersToTheSixth(1); + Assert.False(metertothesixth.Equals(new object())); } [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + public void EqualsReturnsFalseOnNull() { - var v = WarpingMomentOfInertia.FromMetersToTheSixth(1); - Assert.Throws(() => v.Equals(WarpingMomentOfInertia.FromMetersToTheSixth(1), -1, ComparisonType.Relative)); + WarpingMomentOfInertia metertothesixth = WarpingMomentOfInertia.FromMetersToTheSixth(1); + Assert.False(metertothesixth.Equals(null)); } - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) { - WarpingMomentOfInertia metertothesixth = WarpingMomentOfInertia.FromMetersToTheSixth(1); - Assert.False(metertothesixth.Equals(new object())); + var quantity = WarpingMomentOfInertia.FromMetersToTheSixth(firstValue); + var otherQuantity = WarpingMomentOfInertia.FromMetersToTheSixth(secondValue); + WarpingMomentOfInertia maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + var largerTolerance = maxTolerance * 1.1; + var smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, WarpingMomentOfInertia.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); } [Fact] - public void EqualsReturnsFalseOnNull() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { - WarpingMomentOfInertia metertothesixth = WarpingMomentOfInertia.FromMetersToTheSixth(1); - Assert.False(metertothesixth.Equals(null)); + var quantity = WarpingMomentOfInertia.FromMetersToTheSixth(1); + var negativeTolerance = WarpingMomentOfInertia.FromMetersToTheSixth(-1); + Assert.Throws(() => quantity.Equals(quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedQuantityCodeTests.cs b/UnitsNet.Tests/GeneratedQuantityCodeTests.cs index 02da53de1f..19b0af3ebe 100644 --- a/UnitsNet.Tests/GeneratedQuantityCodeTests.cs +++ b/UnitsNet.Tests/GeneratedQuantityCodeTests.cs @@ -21,14 +21,12 @@ public class QuantitiesWithDouble [Fact] public void LengthEquals_GivenMaxError_ReturnsTrueIfWithinError() { - var smallError = 1e-5; + Assert.True(Length.FromMeters(1).Equals(Length.FromMeters(1), Length.Zero), "Equal values have zero difference."); + Assert.True(Length.FromMeters(1).Equals(Length.FromMeters(1), Length.FromMillimeters(1e-5)), "Using a max difference value should not change that fact."); - Assert.True(Length.FromMeters(1).Equals(Length.FromMeters(1), 0, ComparisonType.Relative), "Integer values have zero difference."); - Assert.True(Length.FromMeters(1).Equals(Length.FromMeters(1), smallError, ComparisonType.Relative), "Using a max difference value should not change that fact."); - - Assert.False(Length.FromMeters(1 + 0.39).Equals(Length.FromMeters(1.39), 0, ComparisonType.Relative), + Assert.False(Length.FromMeters(1 + 0.39).Equals(Length.FromMeters(1.39), Length.Zero), "Example of floating precision arithmetic that produces slightly different results."); - Assert.True(Length.FromMeters(1 + 0.39).Equals(Length.FromMeters(1.39), smallError, ComparisonType.Relative), "But the difference is very small"); + Assert.True(Length.FromMeters(1 + 0.39).Equals(Length.FromMeters(1.39), Length.FromMillimeters(1e-5)), "But the difference is very small"); } [Fact] diff --git a/UnitsNet.Tests/QuantityTests.cs b/UnitsNet.Tests/QuantityTests.cs index 26e61b917c..c3ad83bd97 100644 --- a/UnitsNet.Tests/QuantityTests.cs +++ b/UnitsNet.Tests/QuantityTests.cs @@ -18,80 +18,6 @@ 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)); - } - [Fact] public void TryFrom_ValidQuantityNameAndUnitName_ReturnsTrueAndQuantity() { diff --git a/UnitsNet/CustomCode/Quantities/Temperature.extra.cs b/UnitsNet/CustomCode/Quantities/Temperature.extra.cs index 4556009fc6..aa5434819b 100644 --- a/UnitsNet/CustomCode/Quantities/Temperature.extra.cs +++ b/UnitsNet/CustomCode/Quantities/Temperature.extra.cs @@ -58,6 +58,7 @@ public partial struct Temperature /// Factor to multiply by. /// Unit to perform multiplication in. /// The resulting . + [Obsolete("Affine quantities, such as the Temperate, cannot be multiplied directly: consider using the TemperatureDelta type instead.")] public Temperature Multiply(double factor, TemperatureUnit unit) { double resultInUnit = As(unit) * factor; @@ -75,10 +76,24 @@ public Temperature Multiply(double factor, TemperatureUnit unit) /// Factor to multiply by. /// Unit to perform multiplication in. /// The resulting . + [Obsolete("Affine quantities, such as the Temperate, cannot be divided directly: consider using the TemperatureDelta type instead.")] public Temperature Divide(double divisor, TemperatureUnit unit) { double resultInUnit = As(unit) / divisor; return From(resultInUnit, unit); } + + /// /> + [Obsolete("Affine quantities, such as the Temperate, should use an offset-based tolerance: consider using the TemperatureDelta type instead.")] + public bool Equals(Temperature other, Temperature tolerance) + { + if (tolerance.Value < 0) + { + throw ExceptionHelper.CreateArgumentOutOfRangeExceptionForNegativeTolerance(nameof(tolerance)); + } + + var unitKey = UnitKey.ForUnit(tolerance.Unit); + return Comparison.EqualsAbsolute(this.GetValue(unitKey), other.GetValue(unitKey), tolerance.Value); + } } } diff --git a/UnitsNet/ExceptionHelper.cs b/UnitsNet/ExceptionHelper.cs new file mode 100644 index 0000000000..8e8969e0f6 --- /dev/null +++ b/UnitsNet/ExceptionHelper.cs @@ -0,0 +1,32 @@ +using System; + +namespace UnitsNet; + +internal static class ExceptionHelper +{ + internal static ArgumentException CreateArgumentException(object obj, string argumentName) + where TQuantity : IQuantity + { + return new ArgumentException($"The given object is of type {obj.GetType()}. The expected type is {typeof(TQuantity)}.", argumentName); + } + + internal static ArgumentException CreateArgumentOutOfRangeExceptionForNegativeTolerance(string argumentName) + { + return new ArgumentOutOfRangeException(argumentName, "The tolerance must be greater than or equal to 0."); + } + + internal static InvalidOperationException CreateInvalidOperationOnEmptyCollectionException() + { + return new InvalidOperationException("Sequence contains no elements."); + } + + internal static InvalidCastException CreateInvalidCastException() + { + return CreateInvalidCastException(typeof(TOther)); + } + + internal static InvalidCastException CreateInvalidCastException(Type targetType) + { + return new InvalidCastException($"Converting {typeof(TSource)} to {targetType} is not supported."); + } +} diff --git a/UnitsNet/Extensions/AffineQuantityExtensions.cs b/UnitsNet/Extensions/AffineQuantityExtensions.cs new file mode 100644 index 0000000000..196a5588f6 --- /dev/null +++ b/UnitsNet/Extensions/AffineQuantityExtensions.cs @@ -0,0 +1,187 @@ +// 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.Collections.Generic; +using UnitsNet.Units; +using UnitsNet; +#if NET +using System.Numerics; +#endif + +namespace UnitsNet; + +/// +/// Provides extension methods for affine quantities, such as the , enabling comparison and +/// averaging operations. +/// +public static class AffineQuantityExtensions +{ +#if NET + /// + public static bool Equals(this TQuantity quantity, TQuantity? other, TOffset tolerance) + where TQuantity : IAffineQuantity, ISubtractionOperators + where TOffset : IQuantityInstance, IAdditiveIdentity + { + return other != null && quantity.EqualsAbsolute(other, tolerance); + } + + /// + /// + /// Thrown when the is not of the same type as the + /// . + /// + public static bool Equals(this TQuantity quantity, IQuantity? other, TOffset tolerance) + where TQuantity : IAffineQuantity, ISubtractionOperators + where TOffset : IQuantityInstance, IAdditiveIdentity + { + if (other is not TQuantity otherInstance) + { + return false; + } + + // // TODO see about this (I think the exception should take precedence to the null check, but the QuantityTests disagree) + // if (tolerance is not TOffset toleranceQuantity) + // { + // throw ExceptionHelper.CreateArgumentException(tolerance, nameof(tolerance)); + // } + + return quantity.EqualsAbsolute(otherInstance, tolerance); + } + + /// + /// + /// 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 + /// + /// + /// + /// The type of the quantity being compared. + /// The type of the tolerance quantity. + /// The quantity to compare. + /// 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. + /// Thrown when the is negative. + /// Thrown when no unit information is found for one of the specified enum value. + /// + /// It is generally advised against specifying "zero" tolerance, preferring the use of the default equality + /// comparer, which is significantly more performant. + /// + public static bool EqualsAbsolute(this TQuantity quantity, TQuantity other, TOffset tolerance) + where TQuantity : IAffineQuantity, ISubtractionOperators + where TOffset : IQuantityInstance, IAdditiveIdentity + { + if (double.IsNegative(tolerance.Value)) + { + throw ExceptionHelper.CreateArgumentOutOfRangeExceptionForNegativeTolerance(nameof(tolerance)); + } + + TOffset difference = quantity - other; + return double.Abs(difference.Value) <= tolerance.GetValue(difference.UnitKey); + } +#else + /// + public static bool Equals(this Temperature quantity, Temperature other, TemperatureDelta tolerance) + { + return quantity.EqualsAbsolute(other, tolerance); + // return other.HasValue && quantity.EqualsAbsolute(other.Value, tolerance); + } + + /// + /// + /// Thrown when the is not of the same type as the + /// . + /// + public static bool Equals(this Temperature quantity, IQuantity? other, TemperatureDelta tolerance) + { + if (other is not Temperature otherInstance) + { + return false; + } + + // TODO see about this (I think the exception should take precedence to the null check, but the QuantityTests disagree) + // if (tolerance is not TemperatureDelta toleranceQuantity) + // { + // throw ExceptionHelper.CreateArgumentException(tolerance, nameof(tolerance)); + // } + + return quantity.EqualsAbsolute(otherInstance, tolerance); + } + + /// + /// + /// Compare equality to given a for the maximum allowed +/- + /// difference. + /// + /// + /// In this example, the two temperatures will be considered equal if the value of b is within 0.5 degrees Celsius + /// of a. + /// + /// var a = Temperature.FromDegreesCelsius(25); + /// var b = Temperature.FromDegreesCelsius(25.4); + /// var tolerance = TemperatureDelta.FromDegreesCelsius(0.5); + /// a.Equals(b, tolerance); // true, 25°C equals 25.4°C +/- 0.5°C + /// + /// + /// + /// The quantity to compare. + /// 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. + /// Thrown when the is negative. + /// Thrown when no unit information is found for one of the specified enum value. + /// + /// It is generally advised against specifying "zero" tolerance, preferring the use of the default equality + /// comparer, which is significantly more performant. + /// + public static bool EqualsAbsolute(this Temperature quantity, Temperature other, TemperatureDelta tolerance) + { + if (tolerance.Value < 0) + { + throw ExceptionHelper.CreateArgumentOutOfRangeExceptionForNegativeTolerance(nameof(tolerance)); + } + + TemperatureDelta difference = quantity - other; + return Math.Abs(difference.Value) <= tolerance.GetValue(UnitKey.ForUnit(difference.Unit)); + } +#endif + + /// + /// Calculates the average of a collection of values. + /// + /// The collection of values to average. + /// The average , in the unit of the first element in the sequence. + /// Thrown if the collection is null. + /// Thrown if the collection is empty. + public static Temperature Average(this IEnumerable temperatures) + { + return temperatures.ArithmeticMean(); + } + + /// + /// Calculates the average of a collection of values. + /// + /// The collection of values to average. + /// The unit in which to express the average. + /// The average , in the specified unit. + /// Thrown if the collection is null. + /// Thrown if the collection is empty. + /// + /// This method is slightly more performant than the alternative + /// + /// when most of the quantities in the collection are expected to be in the target unit. + /// + public static Temperature Average(this IEnumerable temperatures, TemperatureUnit unit) + { + return temperatures.ArithmeticMean(unit); + } +} diff --git a/UnitsNet/Extensions/LinearQuantityExtensions.cs b/UnitsNet/Extensions/LinearQuantityExtensions.cs new file mode 100644 index 0000000000..a8b8cf88e8 --- /dev/null +++ b/UnitsNet/Extensions/LinearQuantityExtensions.cs @@ -0,0 +1,274 @@ +// 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.Collections.Generic; +using System.Linq; + +namespace UnitsNet; + +/// +/// Provides extension methods for linear quantities, such as Mass and Length, enabling operations such as equality +/// checks, summation, and averaging. +/// +public static class LinearQuantityExtensions +{ + /// + public static bool Equals(this TQuantity quantity, TOther? other, TTolerance tolerance) + where TQuantity : ILinearQuantity + where TOther : IQuantityInstance + where TTolerance : IQuantityInstance + { + return other != null && quantity.EqualsAbsolute(other, tolerance); + } + + /// + /// + /// Thrown when the is not of the same type as the + /// . + /// + public static bool Equals(this TQuantity quantity, IQuantity? other, IQuantity tolerance) + where TQuantity : ILinearQuantity + { + if (other is not TQuantity otherInstance) + { + return false; + } + + // TODO see about this (I think the exception should take precedence to the null check, but the QuantityTests disagree) + if (tolerance is not TQuantity toleranceQuantity) + { + throw ExceptionHelper.CreateArgumentException(tolerance, nameof(tolerance)); + } + + return quantity.EqualsAbsolute(otherInstance, toleranceQuantity); + } + + /// + /// + /// 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 + /// + /// + /// + /// The type of the quantity being compared. + /// The type of the other quantity being compared. + /// The type of the tolerance quantity. + /// The quantity to compare. + /// 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. + /// Thrown when the is negative. + /// Thrown when no unit information is found for one of the specified enum value. + /// + /// It is generally advised against specifying "zero" tolerance, preferring the use of the default equality + /// comparer, which is significantly more performant. + /// + public static bool EqualsAbsolute(this TQuantity quantity, TOther other, TTolerance tolerance) + where TQuantity : ILinearQuantity + where TOther : IQuantityInstance + where TTolerance : IQuantityInstance + { + UnitKey quantityUnit = quantity.UnitKey; + return Comparison.EqualsAbsolute(quantity.Value, other.GetValue(quantityUnit), tolerance.GetValue(quantityUnit)); + } + + /// + /// Sums a sequence of linear quantities, such as Mass and Length. + /// + /// The type of the linear quantity. + /// The collection of linear quantities to sum. + /// + /// The sum of the linear quantities. If the sequence is empty, returns zero in the base unit. + /// In all other cases, the result will have the unit of the first element in the collection. + /// + public static TQuantity Sum(this IEnumerable quantities) + where TQuantity : ILinearQuantity + { + using IEnumerator enumerator = quantities.GetEnumerator(); + if (!enumerator.MoveNext()) + { +#if NET + return TQuantity.Zero; +#else + // for a struct-constrained TQuantity we could simply return default here + if (typeof(TQuantity).IsValueType) + { + return default!; + } + + return (TQuantity)UnitsNetSetup.Default.QuantityInfoLookup.GetQuantityInfo(typeof(TQuantity)).Zero; +#endif + } + + TQuantity firstQuantity = enumerator.Current!; + UnitKey resultUnit = firstQuantity.UnitKey; + var sumOfValues = firstQuantity.Value; + while (enumerator.MoveNext()) + { + sumOfValues += enumerator.Current!.GetValue(resultUnit); + } + +#if NET + return TQuantity.Create(sumOfValues, resultUnit); +#else + return firstQuantity.QuantityInfo.Create(sumOfValues, resultUnit); +#endif + } + + /// + /// Computes the sum of a sequence of quantities by applying a specified selector function to each element of the + /// sequence. + /// + /// The type of the elements of the source sequence. + /// The type of the quantity elements in the source sequence. + /// A sequence of quantities to calculate the sum of. + /// A function to transform each element of the source sequence into a quantity. + /// + /// The sum of the projected quantities. If the sequence is empty, returns zero in the base unit; otherwise, + /// returns the sum in the unit of the first element. + /// + /// Thrown if the source or selector is null. + public static TQuantity Sum(this IEnumerable source, Func selector) + where TQuantity : ILinearQuantity + { + return source.Select(selector).Sum(); + } + + /// + /// Sums a sequence of linear quantities, such as Mass and Length. + /// + /// The type of the linear quantity. + /// The unit type of the linear quantity. + /// The collection of linear quantities to sum. + /// The unit in which to express the sum. + /// The sum of the linear quantities in the specified unit. + /// Thrown when the sequence is null. + /// + /// This method is slightly more performant than the alternative + /// when most of the quantities in the sequence are expected to be in the target unit. + /// + public static TQuantity Sum(this IEnumerable quantities, TUnit unit) + where TQuantity : ILinearQuantity, IQuantity + where TUnit : struct, Enum + { + using IEnumerator enumerator = quantities.GetEnumerator(); + if (!enumerator.MoveNext()) + { +#if NET + return TQuantity.From(0, unit); +#else + return (TQuantity)Quantity.From(0, UnitKey.ForUnit(unit)); +#endif + } + + var unitKey = UnitKey.ForUnit(unit); + TQuantity firstQuantity = enumerator.Current!; + var resultValue = firstQuantity.GetValue(unitKey); + while (enumerator.MoveNext()) + { + resultValue += enumerator.Current!.GetValue(unitKey); + } + + return firstQuantity.QuantityInfo.From(resultValue, unit); + } + + /// + /// Computes the sum of the sequence of values that are obtained by invoking a + /// transform function on each element of the input sequence. + /// + /// The type of the elements of the source sequence. + /// The type of the quantity elements in the source sequence. + /// The type of the unit of the quantities. + /// A sequence of quantities to calculate the sum of. + /// A function to transform each element of the source sequence into a quantity. + /// The desired unit type for the resulting quantity + /// The sum of the projected quantities in the specified unit. + /// Thrown if the source or selector is null. + public static TQuantity Sum(this IEnumerable source, Func selector, TUnit targetUnit) + where TQuantity : ILinearQuantity, IQuantity + where TUnit : struct, Enum + { + return source.Select(selector).Sum(targetUnit); + } + + /// + /// Calculates the arithmetic average of a sequence of linear quantities, such as Mass and Length. + /// + /// The type of the linear quantity. + /// The sequence of linear quantities to average. + /// The average of the linear quantities, using the unit of the first element in the sequence. + /// Thrown when the sequence is null. + /// Thrown when the sequence is empty. + public static TQuantity Average(this IEnumerable quantities) + where TQuantity : ILinearQuantity + { + return quantities.ArithmeticMean(); + } + + /// + /// Computes the arithmetic average of a sequence of quantities, such as Mass and Length, by applying a specified + /// selector + /// function to each element of the elements in the sequence. + /// + /// The type of the elements of the source sequence. + /// The type of the quantity elements in the source sequence. + /// A sequence of quantities to calculate the average of. + /// A function to transform each element of the source sequence into a quantity. + /// The average of the projected quantities in the unit of the first element in the sequence. + /// Thrown when the sequence is null. + /// Thrown when the sequence is empty. + public static TQuantity Average(this IEnumerable source, Func selector) + where TQuantity : ILinearQuantity + { + return source.Select(selector).Average(); + } + + /// + /// Calculates the average of a sequence of linear quantities, such as Mass and Length. + /// + /// The type of the linear quantity. + /// The unit type of the linear quantity. + /// The sequence of linear quantities to average. + /// The unit in which to express the average. + /// The average of the linear quantities in the specified unit. + /// Thrown when the sequence is empty. + /// + /// This method is slightly more performant than the alternative + /// + /// when most of the quantities in the sequence are expected to be in the target unit. + /// + public static TQuantity Average(this IEnumerable quantities, TUnit targetUnit) + where TQuantity : ILinearQuantity, IQuantity + where TUnit : struct, Enum + { + return quantities.ArithmeticMean(targetUnit); + } + + /// + /// Computes the average of the sequence of values, such as Mass and Length, that are + /// obtained by invoking a transform function on each element of the input sequence. + /// + /// The type of the elements of the source sequence. + /// The type of the quantity elements in the source sequence. + /// The type of the unit of the quantities. + /// A sequence of quantities to calculate the average of. + /// A function to transform each element of the source sequence into a quantity. + /// The desired unit type for the resulting quantity. + /// The average of the projected quantities in the specified unit. + /// Thrown when the sequence is empty. + public static TQuantity Average(this IEnumerable source, Func selector, TUnit targetUnit) + where TQuantity : ILinearQuantity, IQuantity + where TUnit : struct, Enum + { + return source.Select(selector).Average(targetUnit); + } +} diff --git a/UnitsNet/Extensions/LogarithmicQuantityExtensions.cs b/UnitsNet/Extensions/LogarithmicQuantityExtensions.cs new file mode 100644 index 0000000000..14f22cc983 --- /dev/null +++ b/UnitsNet/Extensions/LogarithmicQuantityExtensions.cs @@ -0,0 +1,516 @@ +// 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.Linq; + +namespace UnitsNet; + +/// +/// Provides extension methods for logarithmic quantities, enabling operations such as equality checks, +/// summation, arithmetic mean, and geometric mean calculations. +/// +public static class LogarithmicQuantityExtensions +{ + private static double ToLinearSpace(this double logValue, double scalingFactor) + { + return Math.Pow(10, logValue / scalingFactor); + } + + private static double ToLogSpace(this double value, double scalingFactor) + { + return scalingFactor * Math.Log10(value); + } + + private static double RootN(double number, int n) + { +#if NET + return double.RootN(number, n); +#else + return Math.Pow(number, 1.0 / n); +#endif + } + + /// + public static bool Equals(this TQuantity quantity, TOther? other, TTolerance tolerance) + where TQuantity : ILogarithmicQuantity + where TOther : IQuantityInstance + where TTolerance : IQuantityInstance + { + return other is not null && quantity.EqualsAbsolute(other, tolerance); + } + + /// + /// + /// Thrown when the is not of the same type as the + /// . + /// + public static bool Equals(this TQuantity quantity, IQuantity? other, IQuantity tolerance) + where TQuantity : ILogarithmicQuantity + { + if (other is not TQuantity otherInstance) + { + return false; + } + + // TODO see about this (I think the exception should take precedence to the null check, but the QuantityTests disagree) + if (tolerance is not TQuantity toleranceQuantity) + { + throw ExceptionHelper.CreateArgumentException(tolerance, nameof(tolerance)); + } + + return quantity.EqualsAbsolute(otherInstance, toleranceQuantity); + } + + /// + /// Compares the logarithmic equality of the current quantity to another quantity, given a specified tolerance. + /// + /// In this example, the two power ratios will be considered equal if the value of `b` is within 0.5 decibels of + /// `a`. + /// + /// var a = PowerRatio.FromDecibelMilliwatts(30); // Reference power of 1 mW + /// var b = PowerRatio.FromDecibelMilliwatts(29.8); // Slightly less than `a` + /// var tolerance = PowerRatio.FromDecibelMilliwatts(0.5); // 0.5 dBm tolerance + /// a.Equals(b, tolerance); // true, as 30 dBm equals 29.8 dBm +/- 0.5 dBm + /// + /// + /// + /// The type of the quantity being compared. + /// The type of the other quantity being compared. + /// The type of the tolerance value. + /// The logarithmic quantity to compare. + /// The other quantity to compare to. + /// The tolerance value for the maximum allowed difference. + /// + /// True if the absolute difference between the two quantities, when converted to linear space, is not greater + /// than the specified tolerance. + /// + /// Thrown when no unit information is found for one of the specified enum value. + /// + /// This method converts the quantities and the tolerance to linear space before performing the comparison, an + /// operation which doesn't produce an exact value. + /// + /// It is generally advised against specifying "zero" tolerance, preferring the use of the default equality + /// comparer, which is significantly more performant. + /// + /// + public static bool EqualsAbsolute(this TQuantity quantity, TOther other, TTolerance tolerance) + where TQuantity : ILogarithmicQuantity + where TOther : IQuantityInstance + where TTolerance : IQuantityInstance + { + UnitKey quantityUnit = quantity.UnitKey; +#if NET + var scalingFactor = TQuantity.LogarithmicScalingFactor; +#else + var scalingFactor = quantity.LogarithmicScalingFactor; +#endif + var valueInLinearSpace = quantity.Value.ToLinearSpace(scalingFactor); + var otherValueInLinearSpace = other.GetValue(quantityUnit).ToLinearSpace(scalingFactor); + var toleranceInLinearSpace = Math.Abs(tolerance.GetValue(quantityUnit).ToLinearSpace(scalingFactor)); + return Math.Abs(valueInLinearSpace - otherValueInLinearSpace) <= toleranceInLinearSpace; + } + + /// + /// Sums a sequence of logarithmic quantities, such as PowerRatio and AmplitudeRatio. + /// + /// The type of the logarithmic quantity. + /// The sequence of logarithmic quantities to sum. + /// The sum of the logarithmic quantities in the unit of the first element in the sequence. + /// Thrown when the sequence is empty. + /// + /// When the sequence is not empty, each quantity is converted to linear space (in the unit of the first element), + /// summed, and then the result is converted back to logarithmic space using the same unit. + /// + public static TQuantity Sum(this IEnumerable quantities) + where TQuantity : ILogarithmicQuantity + { + if (quantities is null) + { + throw new ArgumentNullException(nameof(quantities)); + } + + using IEnumerator enumerator = quantities.GetEnumerator(); + if (!enumerator.MoveNext()) + { + throw ExceptionHelper.CreateInvalidOperationOnEmptyCollectionException(); + } + + TQuantity firstQuantity = enumerator.Current!; +#if NET + var logarithmicScalingFactor = TQuantity.LogarithmicScalingFactor; +#else + var logarithmicScalingFactor = firstQuantity.LogarithmicScalingFactor; +#endif + UnitKey resultUnit = firstQuantity.UnitKey; + var resultValue = firstQuantity.Value.ToLinearSpace(logarithmicScalingFactor); + while (enumerator.MoveNext()) + { + resultValue += enumerator.Current!.GetValue(resultUnit).ToLinearSpace(logarithmicScalingFactor); + } +#if NET + return TQuantity.Create(resultValue.ToLogSpace(logarithmicScalingFactor), resultUnit); +#else + return firstQuantity.QuantityInfo.Create(resultValue.ToLogSpace(logarithmicScalingFactor), resultUnit); +#endif + } + + /// + /// Computes the sum of a sequence of logarithmic quantities, such as PowerRatio and AmplitudeRatio, by applying a + /// specified selector function to each element of the + /// sequence. + /// + /// The type of the elements of the source sequence. + /// The type of the quantity elements in the source sequence. + /// A sequence of quantities to calculate the sum of. + /// A function to transform each element of the source sequence into a quantity. + /// The sum of the logarithmic quantities in the unit of the first element in the sequence. + /// Thrown when the sequence is empty. + /// + /// When the sequence is not empty, each quantity is converted to linear space (in the unit of the first element), + /// summed, and then the result is converted back to logarithmic space using the same unit. + /// + public static TQuantity Sum(this IEnumerable source, Func selector) + where TQuantity : ILogarithmicQuantity + { + return source.Select(selector).Sum(); + } + + /// + /// Sums a sequence of logarithmic quantities, such as PowerRatio and AmplitudeRatio, converting them to the + /// specified unit. + /// + /// The type of the logarithmic quantity. + /// The unit type of the logarithmic quantity. + /// The sequence of logarithmic quantities to sum. + /// The unit in which to express the sum. + /// The sum of the logarithmic quantities in the specified unit. + /// Thrown when the sequence is empty. + /// + /// This method converts each logarithmic quantity to linear space, sums them, and then converts the result back to + /// logarithmic space. + /// + public static TQuantity Sum(this IEnumerable quantities, TUnit targetUnit) + where TQuantity : ILogarithmicQuantity + where TUnit : struct, Enum + { + if (quantities is null) + { + throw new ArgumentNullException(nameof(quantities)); + } + + using IEnumerator enumerator = quantities.GetEnumerator(); + if (!enumerator.MoveNext()) + { + throw ExceptionHelper.CreateInvalidOperationOnEmptyCollectionException(); + } + + var unitKey = UnitKey.ForUnit(targetUnit); + TQuantity firstQuantity = enumerator.Current!; +#if NET + var logarithmicScalingFactor = TQuantity.LogarithmicScalingFactor; +#else + var logarithmicScalingFactor = firstQuantity.LogarithmicScalingFactor; +#endif + var sumInLinearSpace = firstQuantity.GetValue(unitKey).ToLinearSpace(logarithmicScalingFactor); + while (enumerator.MoveNext()) + { + sumInLinearSpace += enumerator.Current!.GetValue(unitKey).ToLinearSpace(logarithmicScalingFactor); + } + + return firstQuantity.QuantityInfo.From(sumInLinearSpace.ToLogSpace(logarithmicScalingFactor), targetUnit); + } + + /// + /// Computes the sum of the sequence of values, such as PowerRatio and + /// AmplitudeRatio, that is obtained by invoking a + /// transform function on each element of the input sequence. + /// + /// The type of the elements of the source sequence. + /// The type of the quantity elements in the source sequence. + /// The type of the unit of the quantities. + /// A sequence of quantities to calculate the sum of. + /// A function to transform each element of the source sequence into a quantity. + /// The desired unit type for the resulting quantity + /// The sum of the projected quantities in the specified unit. + /// Thrown if the source or selector is null. + /// + /// This method converts each logarithmic quantity to linear space, sums them, and then converts the result back to + /// logarithmic space. + /// + public static TQuantity Sum(this IEnumerable source, Func selector, TUnit targetUnit) + where TQuantity : ILogarithmicQuantity + where TUnit : struct, Enum + { + return source.Select(selector).Sum(targetUnit); + } + + /// + /// Computes the arithmetic mean of a sequence of logarithmic quantities, such as PowerRatio and AmplitudeRatio. + /// + /// The type of the logarithmic quantity. + /// The sequence of logarithmic quantities to average. + /// The average of the logarithmic quantities in the unit of the first element in the sequence. + /// Thrown when the sequence is empty. + /// + /// When the sequence is not empty, each quantity is converted to linear space (in the unit of the first element), + /// averaged, and then the result is converted back to logarithmic space using the same unit. + /// + public static TQuantity ArithmeticMean(this IEnumerable quantities) + where TQuantity : ILogarithmicQuantity + { + if (quantities is null) + { + throw new ArgumentNullException(nameof(quantities)); + } + + using IEnumerator enumerator = quantities.GetEnumerator(); + if (!enumerator.MoveNext()) + { + throw ExceptionHelper.CreateInvalidOperationOnEmptyCollectionException(); + } + + TQuantity firstQuantity = enumerator.Current!; +#if NET + var logarithmicScalingFactor = TQuantity.LogarithmicScalingFactor; +#else + var logarithmicScalingFactor = firstQuantity.LogarithmicScalingFactor; +#endif + UnitKey resultUnit = firstQuantity.UnitKey; + var sumInLinearSpace = firstQuantity.Value.ToLinearSpace(logarithmicScalingFactor); + var nbQuantities = 1; + while (enumerator.MoveNext()) + { + sumInLinearSpace += enumerator.Current!.GetValue(resultUnit).ToLinearSpace(logarithmicScalingFactor); + nbQuantities++; + } + + var avgInLinearSpace = sumInLinearSpace / nbQuantities; +#if NET + return TQuantity.Create(avgInLinearSpace.ToLogSpace(logarithmicScalingFactor), resultUnit); +#else + return firstQuantity.QuantityInfo.Create(avgInLinearSpace.ToLogSpace(logarithmicScalingFactor), resultUnit); +#endif + } + + /// + /// Computes the average of a sequence of quantities by applying a specified selector function to each element of the + /// sequence. + /// + /// The type of the elements of the source sequence. + /// The type of the quantity elements in the source sequence. + /// A sequence of quantities to calculate the sum of. + /// A function to transform each element of the source sequence into a quantity. + /// The average of the logarithmic quantities in the unit of the first element in the sequence. + /// Thrown when the sequence is empty. + /// + /// When the sequence is not empty, each quantity is converted to linear space (in the unit of the first element), + /// averaged, and then the result is converted back to logarithmic space using the same unit. + /// + public static TQuantity ArithmeticMean(this IEnumerable source, Func selector) + where TQuantity : ILogarithmicQuantity + { + return ArithmeticMean(source.Select(selector)); + } + + /// + /// Computes the arithmetic mean of a sequence of logarithmic quantities, such as PowerRatio and AmplitudeRatio. + /// + /// The type of the logarithmic quantity. + /// The unit type of the logarithmic quantity. + /// The sequence of logarithmic quantities to sum. + /// The unit in which to express the sum. + /// The arithmetic mean of the logarithmic quantities in the specified unit. + /// Thrown when the sequence is empty. + /// + /// When the sequence is not empty, each quantity is converted to linear space (in the specified unit), + /// averaged, and then the result is converted back to logarithmic space using the same unit. + /// + public static TQuantity ArithmeticMean(this IEnumerable quantities, TUnit unit) + where TQuantity : ILogarithmicQuantity + where TUnit : struct, Enum + { + if (quantities is null) + { + throw new ArgumentNullException(nameof(quantities)); + } + + using IEnumerator enumerator = quantities.GetEnumerator(); + if (!enumerator.MoveNext()) + { + throw ExceptionHelper.CreateInvalidOperationOnEmptyCollectionException(); + } + + var unitKey = UnitKey.ForUnit(unit); + TQuantity firstQuantity = enumerator.Current!; +#if NET + var logarithmicScalingFactor = TQuantity.LogarithmicScalingFactor; +#else + var logarithmicScalingFactor = firstQuantity.LogarithmicScalingFactor; +#endif + var sumInLinearSpace = firstQuantity.GetValue(unitKey).ToLinearSpace(logarithmicScalingFactor); + var nbQuantities = 1; + while (enumerator.MoveNext()) + { + sumInLinearSpace += enumerator.Current!.GetValue(unitKey).ToLinearSpace(logarithmicScalingFactor); + nbQuantities++; + } + + var avgInLinearSpace = sumInLinearSpace / nbQuantities; + return firstQuantity.QuantityInfo.From(avgInLinearSpace.ToLogSpace(logarithmicScalingFactor), unit); + } + + /// + /// Computes the arithmetic mean of the sequence of values that are obtained by + /// invoking a + /// transform function on each element of the input sequence. + /// + /// The type of the elements of the source sequence. + /// The type of the quantity elements in the source sequence. + /// The type of the unit of the quantities. + /// A sequence of quantities to calculate the sum of. + /// A function to transform each element of the source sequence into a quantity. + /// The desired unit type for the resulting quantity. + /// The arithmetic mean of the logarithmic quantities in the specified unit. + /// Thrown when the sequence is empty. + /// + /// When the sequence is not empty, each quantity is converted to linear space (in the specified unit), + /// averaged, and then the result is converted back to logarithmic space using the same unit. + /// + public static TQuantity ArithmeticMean(this IEnumerable source, Func selector, TUnit targetUnit) + where TQuantity : ILogarithmicQuantity + where TUnit : struct, Enum + { + return ArithmeticMean(source.Select(selector), targetUnit); + } + + /// + /// Computes the geometric mean of a sequence of logarithmic quantities, such as PowerRatio and AmplitudeRatio. + /// + /// The type of the logarithmic quantity. + /// The sequence of logarithmic quantities to average. + /// The geometric mean of the logarithmic quantities in the unit of the first element in the sequence. + /// Thrown when the sequence is empty. + /// + /// When the sequence is not empty, calculates the n-th root of the product of the quantities, which for the + /// logarithmic quantities is equal to the sum the values, converted in unit of the first element. + /// + public static TQuantity GeometricMean(this IEnumerable quantities) + where TQuantity : ILogarithmicQuantity + { + if (quantities is null) + { + throw new ArgumentNullException(nameof(quantities)); + } + + using IEnumerator enumerator = quantities.GetEnumerator(); + if (!enumerator.MoveNext()) + { + throw ExceptionHelper.CreateInvalidOperationOnEmptyCollectionException(); + } + + TQuantity firstQuantity = enumerator.Current!; + UnitKey resultUnit = firstQuantity.UnitKey; + var sumInLogSpace = firstQuantity.Value; + var nbQuantities = 1; + while (enumerator.MoveNext()) + { + sumInLogSpace += enumerator.Current!.GetValue(resultUnit); + nbQuantities++; + } + + var geometricMean = RootN(sumInLogSpace, nbQuantities); +#if NET + return TQuantity.Create(geometricMean, resultUnit); +#else + return firstQuantity.QuantityInfo.Create(geometricMean, resultUnit); +#endif + } + + /// + /// Computes the geometric mean of a sequence of quantities by applying a specified selector function to each element + /// of the + /// sequence. + /// + /// The type of the elements of the source sequence. + /// The type of the quantity elements in the source sequence. + /// A sequence of quantities to calculate the sum of. + /// A function to transform each element of the source sequence into a quantity. + /// The geometric mean of the logarithmic quantities in the unit of the first element in the sequence. + /// Thrown when the sequence is empty. + /// + /// When the sequence is not empty, calculates the n-th root of the product of the quantities, which for the + /// logarithmic quantities is equal to the sum the values, converted in unit of the first element. + /// + public static TQuantity GeometricMean(this IEnumerable source, Func selector) + where TQuantity : ILogarithmicQuantity + { + return source.Select(selector).GeometricMean(); + } + + /// + /// Computes the geometric mean of a sequence of logarithmic quantities, such as PowerRatio and AmplitudeRatio, using + /// the specified unit. + /// + /// The type of the logarithmic quantity. + /// The type of the unit of the quantities. + /// The sequence of logarithmic quantities to average. + /// The desired unit type for the resulting quantity. + /// The geometric mean of the logarithmic quantities in the unit of the first element in the sequence. + /// Thrown when the sequence is empty. + /// + /// When the sequence is not empty, calculates the n-th root of the product of the quantities, which for the + /// logarithmic quantities is equal to the sum the values, converted in unit of the first element. + /// + public static TQuantity GeometricMean(this IEnumerable quantities, TUnit targetUnit) + where TQuantity : ILogarithmicQuantity + where TUnit : struct, Enum + { + if (quantities is null) + { + throw new ArgumentNullException(nameof(quantities)); + } + + using IEnumerator enumerator = quantities.GetEnumerator(); + if (!enumerator.MoveNext()) + { + throw ExceptionHelper.CreateInvalidOperationOnEmptyCollectionException(); + } + + var unitKey = UnitKey.ForUnit(targetUnit); + TQuantity firstQuantity = enumerator.Current!; + var sumInLogSpace = firstQuantity.GetValue(unitKey); + var nbQuantities = 1; + while (enumerator.MoveNext()) + { + sumInLogSpace += enumerator.Current!.GetValue(unitKey); + nbQuantities++; + } + + var geometricMean = RootN(sumInLogSpace, nbQuantities); + return firstQuantity.QuantityInfo.From(geometricMean, unitKey.ToUnit()); + } + + /// + /// Computes the geometric mean of the sequence of values that are obtained by + /// invoking a + /// transform function on each element of the input sequence. + /// + /// The type of the elements of the source sequence. + /// The type of the quantity elements in the source sequence. + /// The type of the unit of the quantities. + /// A sequence of quantities to calculate the sum of. + /// A function to transform each element of the source sequence into a quantity. + /// The desired unit type for the resulting quantity. + /// The arithmetic mean of the logarithmic quantities in the specified unit. + /// Thrown when the sequence is empty. + /// + /// When the sequence is not empty, calculates the n-th root of the product of the quantities, which for the + /// logarithmic quantities is equal to the sum the values, converted in unit of the first element. + /// + public static TQuantity GeometricMean(this IEnumerable source, Func selector, TUnit targetUnit) + where TQuantity : ILogarithmicQuantity + where TUnit : struct, Enum + { + return source.Select(selector).GeometricMean(targetUnit); + } +} diff --git a/UnitsNet/Extensions/QuantityExtensions.cs b/UnitsNet/Extensions/QuantityExtensions.cs new file mode 100644 index 0000000000..8bb9e03cdd --- /dev/null +++ b/UnitsNet/Extensions/QuantityExtensions.cs @@ -0,0 +1,139 @@ +// 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.Globalization; + +namespace UnitsNet; + +/// +/// Provides extension methods applicable to all quantities in the UnitsNet library. +/// +public static class QuantityExtensions +{ + /// + /// This should be using UnitConverter.Default.ConvertValue(quantity, toUnit) + internal static double GetValue(this TQuantity quantity, UnitKey toUnit) + where TQuantity : IQuantity + { + return quantity.As(toUnit); + } + + /// + /// Returns the string representation of the specified quantity using the provided format provider. + /// + /// + /// The type of the quantity, which must implement and + /// . + /// + /// The quantity to convert to a string. + /// + /// The format provider to use for localization and number formatting. + /// If null, the default is . + /// + /// A string representation of the quantity. + public static string ToString(this TQuantity quantity, IFormatProvider? formatProvider) + where TQuantity : IQuantity, IFormattable + { + return quantity.ToString(null, formatProvider); + } + + /// + /// Returns the string representation of the specified quantity using the provided format string. + /// + /// + /// The type of the quantity, which must implement and + /// . + /// + /// The quantity to convert to a string. + /// + /// The format string to use for formatting the quantity. + /// If null or empty, the default format is used. + /// + /// A string representation of the quantity. + public static string ToString(this TQuantity quantity, string? format) + where TQuantity : IQuantity, IFormattable + { + return quantity.ToString(format, null); + } + + /// + /// Calculates the arithmetic mean of a sequence of quantities. + /// + /// The type of the quantity. + /// The collection of quantities to average. + /// The average of the quantities, using the unit of the first element in the sequence. + /// Thrown when the collection is null. + /// Thrown when the collection is empty. + internal static TQuantity ArithmeticMean(this IEnumerable quantities) + where TQuantity : IQuantityInstance + { + if (quantities is null) + { + throw new ArgumentNullException(nameof(quantities)); + } + + using IEnumerator enumerator = quantities.GetEnumerator(); + if (!enumerator.MoveNext()) + { + throw ExceptionHelper.CreateInvalidOperationOnEmptyCollectionException(); + } + + TQuantity firstQuantity = enumerator.Current!; + UnitKey resultUnit = firstQuantity.UnitKey; + var sumOfValues = firstQuantity.Value; + var nbValues = 1; + while (enumerator.MoveNext()) + { + sumOfValues += enumerator.Current!.GetValue(resultUnit); + nbValues++; + } + +#if NET + return TQuantity.Create(sumOfValues / nbValues, resultUnit); +#else + return firstQuantity.QuantityInfo.Create(sumOfValues / nbValues, resultUnit); +#endif + } + + /// + /// Calculates the arithmetic mean of a sequence of quantities. + /// + /// The type of the quantity. + /// The unit type of the quantity. + /// The collection of quantities to average. + /// The unit in which to express the sum. + /// The average of the vector quantities in the specified unit. + /// Thrown when the collection is empty. + /// + /// This method is slightly more performant than the alternative + /// + /// when most of the quantities in the collection are expected to be in the target unit. + /// + internal static TQuantity ArithmeticMean(this IEnumerable quantities, TUnit unit) + where TQuantity : IQuantity + where TUnit: struct, Enum + { + if (quantities is null) + { + throw new ArgumentNullException(nameof(quantities)); + } + + using IEnumerator enumerator = quantities.GetEnumerator(); + if (!enumerator.MoveNext()) + { + throw ExceptionHelper.CreateInvalidOperationOnEmptyCollectionException(); + } + + TQuantity firstQuantity = enumerator.Current!; + var unitKey = UnitKey.ForUnit(unit); + var sumOfValues = firstQuantity.GetValue(unitKey); + var nbValues = 1; + while (enumerator.MoveNext()) + { + sumOfValues += enumerator.Current!.GetValue(unitKey); + nbValues++; + } + + return firstQuantity.QuantityInfo.From(sumOfValues / nbValues, unit); + } +} diff --git a/UnitsNet/GeneratedCode/Quantities/AbsorbedDoseOfIonizingRadiation.g.cs b/UnitsNet/GeneratedCode/Quantities/AbsorbedDoseOfIonizingRadiation.g.cs index 75653b7566..d56dfc09c4 100644 --- a/UnitsNet/GeneratedCode/Quantities/AbsorbedDoseOfIonizingRadiation.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AbsorbedDoseOfIonizingRadiation.g.cs @@ -201,9 +201,6 @@ public AbsorbedDoseOfIonizingRadiation(double value, UnitSystem unitSystem) /// public static AbsorbedDoseOfIonizingRadiation Zero => Info.Zero; - /// - public static AbsorbedDoseOfIonizingRadiation AdditiveIdentity => Zero; - #endregion #region Properties @@ -238,6 +235,11 @@ public AbsorbedDoseOfIonizingRadiation(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -808,6 +810,15 @@ public bool Equals(AbsorbedDoseOfIonizingRadiation other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current AbsorbedDoseOfIonizingRadiation. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -844,88 +855,6 @@ public int CompareTo(AbsorbedDoseOfIonizingRadiation other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another AbsorbedDoseOfIonizingRadiation within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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(AbsorbedDoseOfIonizingRadiation other, AbsorbedDoseOfIonizingRadiation tolerance) instead, 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(AbsorbedDoseOfIonizingRadiation other, double tolerance, ComparisonType comparisonType) - { - if (tolerance < 0) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: comparisonType); - } - - /// - public bool Equals(IQuantity? other, IQuantity tolerance) - { - return other is AbsorbedDoseOfIonizingRadiation otherTyped - && (tolerance is AbsorbedDoseOfIonizingRadiation toleranceTyped - ? true - : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'AbsorbedDoseOfIonizingRadiation'.", nameof(tolerance))) - && Equals(otherTyped, toleranceTyped); - } - - /// - public bool Equals(AbsorbedDoseOfIonizingRadiation other, AbsorbedDoseOfIonizingRadiation tolerance) - { - 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. - /// - /// A hash code for the current AbsorbedDoseOfIonizingRadiation. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -942,6 +871,12 @@ public double As(AbsorbedDoseOfIonizingRadiationUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -1103,27 +1038,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs b/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs index 7a592c91ba..595136ac7b 100644 --- a/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs @@ -202,9 +202,6 @@ public Acceleration(double value, UnitSystem unitSystem) /// public static Acceleration Zero => Info.Zero; - /// - public static Acceleration AdditiveIdentity => Zero; - #endregion #region Properties @@ -239,6 +236,11 @@ public Acceleration(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -798,6 +800,15 @@ public bool Equals(Acceleration other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current Acceleration. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -834,88 +845,6 @@ public int CompareTo(Acceleration other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another Acceleration within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: 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) - { - 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. - /// - /// A hash code for the current Acceleration. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -932,6 +861,12 @@ public double As(AccelerationUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -1087,27 +1022,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs b/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs index 8ed34cca7c..68d7835094 100644 --- a/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs @@ -206,9 +206,6 @@ public AmountOfSubstance(double value, UnitSystem unitSystem) /// public static AmountOfSubstance Zero => Info.Zero; - /// - public static AmountOfSubstance AdditiveIdentity => Zero; - #endregion #region Properties @@ -243,6 +240,11 @@ public AmountOfSubstance(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -853,6 +855,15 @@ public bool Equals(AmountOfSubstance other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current AmountOfSubstance. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -889,88 +900,6 @@ public int CompareTo(AmountOfSubstance other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another AmountOfSubstance within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: 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) - { - 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. - /// - /// A hash code for the current AmountOfSubstance. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -987,6 +916,12 @@ public double As(AmountOfSubstanceUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -1148,27 +1083,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.g.cs b/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.g.cs index 1806a17e9c..e291328a91 100644 --- a/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.g.cs @@ -37,7 +37,7 @@ namespace UnitsNet [DataContract] [DebuggerTypeProxy(typeof(QuantityDisplay))] public readonly partial struct AmplitudeRatio : - IArithmeticQuantity, + ILogarithmicQuantity, #if NET7_0_OR_GREATER IComparisonOperators, IParsable, @@ -171,8 +171,8 @@ public AmplitudeRatio(double value, AmplitudeRatioUnit unit) /// public static AmplitudeRatio Zero => Info.Zero; - /// - public static AmplitudeRatio AdditiveIdentity => Zero; + /// + public static double LogarithmicScalingFactor {get;} = 20; #endregion @@ -208,6 +208,15 @@ public AmplitudeRatio(double value, AmplitudeRatioUnit unit) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + +#if NETSTANDARD2_0 + double ILogarithmicQuantity.LogarithmicScalingFactor => LogarithmicScalingFactor; +#endif + #endregion #endregion @@ -591,6 +600,15 @@ public bool Equals(AmplitudeRatio other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current AmplitudeRatio. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -627,88 +645,6 @@ public int CompareTo(AmplitudeRatio other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another AmplitudeRatio within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: 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) - { - 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. - /// - /// A hash code for the current AmplitudeRatio. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -725,6 +661,12 @@ public double As(AmplitudeRatioUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -860,27 +802,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/Angle.g.cs b/UnitsNet/GeneratedCode/Quantities/Angle.g.cs index 0a0e51e199..05d06ab6df 100644 --- a/UnitsNet/GeneratedCode/Quantities/Angle.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Angle.g.cs @@ -187,9 +187,6 @@ public Angle(double value, AngleUnit unit) /// public static Angle Zero => Info.Zero; - /// - public static Angle AdditiveIdentity => Zero; - #endregion #region Properties @@ -224,6 +221,11 @@ public Angle(double value, AngleUnit unit) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -786,6 +788,15 @@ public bool Equals(Angle other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current Angle. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -822,88 +833,6 @@ public int CompareTo(Angle other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another Angle within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: 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) - { - 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. - /// - /// A hash code for the current Angle. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -920,6 +849,12 @@ public double As(AngleUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -1077,27 +1012,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/Area.g.cs b/UnitsNet/GeneratedCode/Quantities/Area.g.cs index a698fe395c..1bb1b69dc3 100644 --- a/UnitsNet/GeneratedCode/Quantities/Area.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Area.g.cs @@ -213,9 +213,6 @@ public Area(double value, UnitSystem unitSystem) /// public static Area Zero => Info.Zero; - /// - public static Area AdditiveIdentity => Zero; - #endregion #region Properties @@ -250,6 +247,11 @@ public Area(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -882,6 +884,15 @@ public bool Equals(Area other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current Area. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -918,88 +929,6 @@ public int CompareTo(Area other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another Area within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: 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) - { - 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. - /// - /// A hash code for the current Area. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -1016,6 +945,12 @@ public double As(AreaUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -1171,27 +1106,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs index 7246421b4e..fe9756dbce 100644 --- a/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs @@ -187,9 +187,6 @@ public AreaDensity(double value, UnitSystem unitSystem) /// public static AreaDensity Zero => Info.Zero; - /// - public static AreaDensity AdditiveIdentity => Zero; - #endregion #region Properties @@ -224,6 +221,11 @@ public AreaDensity(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -594,6 +596,15 @@ public bool Equals(AreaDensity other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current AreaDensity. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -630,88 +641,6 @@ public int CompareTo(AreaDensity other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another AreaDensity within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: 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) - { - 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. - /// - /// A hash code for the current AreaDensity. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -728,6 +657,12 @@ public double As(AreaDensityUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -861,27 +796,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs b/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs index 6508ef3ab6..6c4e0dba13 100644 --- a/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs @@ -191,9 +191,6 @@ public AreaMomentOfInertia(double value, UnitSystem unitSystem) /// public static AreaMomentOfInertia Zero => Info.Zero; - /// - public static AreaMomentOfInertia AdditiveIdentity => Zero; - #endregion #region Properties @@ -228,6 +225,11 @@ public AreaMomentOfInertia(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -649,6 +651,15 @@ public bool Equals(AreaMomentOfInertia other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current AreaMomentOfInertia. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -685,88 +696,6 @@ public int CompareTo(AreaMomentOfInertia other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another AreaMomentOfInertia within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: 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) - { - 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. - /// - /// A hash code for the current AreaMomentOfInertia. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -783,6 +712,12 @@ public double As(AreaMomentOfInertiaUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -922,27 +857,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs b/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs index 041a02fd3d..fc98e4a110 100644 --- a/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs @@ -223,9 +223,6 @@ public BitRate(double value, UnitSystem unitSystem) /// public static BitRate Zero => Info.Zero; - /// - public static BitRate AdditiveIdentity => Zero; - #endregion #region Properties @@ -260,6 +257,11 @@ public BitRate(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -1160,6 +1162,15 @@ public bool Equals(BitRate other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current BitRate. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -1196,88 +1207,6 @@ public int CompareTo(BitRate other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another BitRate within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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, double tolerance, ComparisonType comparisonType) - { - if (tolerance < 0) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: 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) - { - 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. - /// - /// A hash code for the current BitRate. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -1294,6 +1223,12 @@ public double As(BitRateUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -1499,27 +1434,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs b/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs index c70ac398cf..45c4649ef4 100644 --- a/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs @@ -188,9 +188,6 @@ public BrakeSpecificFuelConsumption(double value, UnitSystem unitSystem) /// public static BrakeSpecificFuelConsumption Zero => Info.Zero; - /// - public static BrakeSpecificFuelConsumption AdditiveIdentity => Zero; - #endregion #region Properties @@ -225,6 +222,11 @@ public BrakeSpecificFuelConsumption(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -607,6 +609,15 @@ public bool Equals(BrakeSpecificFuelConsumption other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current BrakeSpecificFuelConsumption. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -643,88 +654,6 @@ public int CompareTo(BrakeSpecificFuelConsumption other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another BrakeSpecificFuelConsumption within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: 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) - { - 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. - /// - /// A hash code for the current BrakeSpecificFuelConsumption. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -741,6 +670,12 @@ public double As(BrakeSpecificFuelConsumptionUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -874,27 +809,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs b/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs index 8384900aa3..c804336738 100644 --- a/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs @@ -190,9 +190,6 @@ public CoefficientOfThermalExpansion(double value, UnitSystem unitSystem) /// public static CoefficientOfThermalExpansion Zero => Info.Zero; - /// - public static CoefficientOfThermalExpansion AdditiveIdentity => Zero; - #endregion #region Properties @@ -227,6 +224,11 @@ public CoefficientOfThermalExpansion(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -642,6 +644,15 @@ public bool Equals(CoefficientOfThermalExpansion other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current CoefficientOfThermalExpansion. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -678,88 +689,6 @@ public int CompareTo(CoefficientOfThermalExpansion other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another CoefficientOfThermalExpansion within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: 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) - { - 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. - /// - /// A hash code for the current CoefficientOfThermalExpansion. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -776,6 +705,12 @@ public double As(CoefficientOfThermalExpansionUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -915,27 +850,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/Compressibility.g.cs b/UnitsNet/GeneratedCode/Quantities/Compressibility.g.cs index 4bbf914689..84984a7f30 100644 --- a/UnitsNet/GeneratedCode/Quantities/Compressibility.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Compressibility.g.cs @@ -188,9 +188,6 @@ public Compressibility(double value, UnitSystem unitSystem) /// public static Compressibility Zero => Info.Zero; - /// - public static Compressibility AdditiveIdentity => Zero; - #endregion #region Properties @@ -225,6 +222,11 @@ public Compressibility(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -645,6 +647,15 @@ public bool Equals(Compressibility other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current Compressibility. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -681,88 +692,6 @@ public int CompareTo(Compressibility other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another Compressibility within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: 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) - { - 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. - /// - /// A hash code for the current Compressibility. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -779,6 +708,12 @@ public double As(CompressibilityUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -920,27 +855,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/Density.g.cs b/UnitsNet/GeneratedCode/Quantities/Density.g.cs index 0172155c0b..4a928507dd 100644 --- a/UnitsNet/GeneratedCode/Quantities/Density.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Density.g.cs @@ -249,9 +249,6 @@ public Density(double value, UnitSystem unitSystem) /// public static Density Zero => Info.Zero; - /// - public static Density AdditiveIdentity => Zero; - #endregion #region Properties @@ -286,6 +283,11 @@ public Density(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -1494,6 +1496,15 @@ public bool Equals(Density other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current Density. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -1530,88 +1541,6 @@ public int CompareTo(Density other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another Density within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: 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) - { - 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. - /// - /// A hash code for the current Density. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -1628,6 +1557,12 @@ public double As(DensityUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -1867,27 +1802,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/DoseAreaProduct.g.cs b/UnitsNet/GeneratedCode/Quantities/DoseAreaProduct.g.cs index 758b789b4a..53aa54a5eb 100644 --- a/UnitsNet/GeneratedCode/Quantities/DoseAreaProduct.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/DoseAreaProduct.g.cs @@ -209,9 +209,6 @@ public DoseAreaProduct(double value, UnitSystem unitSystem) /// public static DoseAreaProduct Zero => Info.Zero; - /// - public static DoseAreaProduct AdditiveIdentity => Zero; - #endregion #region Properties @@ -246,6 +243,11 @@ public DoseAreaProduct(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -936,6 +938,15 @@ public bool Equals(DoseAreaProduct other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current DoseAreaProduct. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -972,88 +983,6 @@ public int CompareTo(DoseAreaProduct other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another DoseAreaProduct within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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(DoseAreaProduct other, DoseAreaProduct tolerance) instead, 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(DoseAreaProduct other, double tolerance, ComparisonType comparisonType) - { - if (tolerance < 0) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: comparisonType); - } - - /// - public bool Equals(IQuantity? other, IQuantity tolerance) - { - return other is DoseAreaProduct otherTyped - && (tolerance is DoseAreaProduct toleranceTyped - ? true - : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'DoseAreaProduct'.", nameof(tolerance))) - && Equals(otherTyped, toleranceTyped); - } - - /// - public bool Equals(DoseAreaProduct other, DoseAreaProduct tolerance) - { - 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. - /// - /// A hash code for the current DoseAreaProduct. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -1070,6 +999,12 @@ public double As(DoseAreaProductUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -1247,27 +1182,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/Duration.g.cs b/UnitsNet/GeneratedCode/Quantities/Duration.g.cs index bc69f1ec3e..e1d8f1e42d 100644 --- a/UnitsNet/GeneratedCode/Quantities/Duration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Duration.g.cs @@ -211,9 +211,6 @@ public Duration(double value, UnitSystem unitSystem) /// public static Duration Zero => Info.Zero; - /// - public static Duration AdditiveIdentity => Zero; - #endregion #region Properties @@ -248,6 +245,11 @@ public Duration(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -852,6 +854,15 @@ public bool Equals(Duration other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current Duration. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -888,88 +899,6 @@ public int CompareTo(Duration other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another Duration within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: 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) - { - 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. - /// - /// A hash code for the current Duration. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -986,6 +915,12 @@ public double As(DurationUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -1139,27 +1074,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs b/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs index 3634fb0af8..2300eda9bd 100644 --- a/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs @@ -198,9 +198,6 @@ public DynamicViscosity(double value, UnitSystem unitSystem) /// public static DynamicViscosity Zero => Info.Zero; - /// - public static DynamicViscosity AdditiveIdentity => Zero; - #endregion #region Properties @@ -235,6 +232,11 @@ public DynamicViscosity(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -716,6 +718,15 @@ public bool Equals(DynamicViscosity other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current DynamicViscosity. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -752,88 +763,6 @@ public int CompareTo(DynamicViscosity other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another DynamicViscosity within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: 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) - { - 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. - /// - /// A hash code for the current DynamicViscosity. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -850,6 +779,12 @@ public double As(DynamicViscosityUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -997,27 +932,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.g.cs index 457f23afa4..86bbd5ec5a 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.g.cs @@ -201,9 +201,6 @@ public ElectricAdmittance(double value, UnitSystem unitSystem) /// public static ElectricAdmittance Zero => Info.Zero; - /// - public static ElectricAdmittance AdditiveIdentity => Zero; - #endregion #region Properties @@ -238,6 +235,11 @@ public ElectricAdmittance(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -793,6 +795,15 @@ public bool Equals(ElectricAdmittance other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current ElectricAdmittance. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -829,88 +840,6 @@ public int CompareTo(ElectricAdmittance other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another ElectricAdmittance within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: 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) - { - 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. - /// - /// A hash code for the current ElectricAdmittance. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -927,6 +856,12 @@ public double As(ElectricAdmittanceUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -1086,27 +1021,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricApparentEnergy.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricApparentEnergy.g.cs index 54d8574e8d..5eb0d3fab8 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricApparentEnergy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricApparentEnergy.g.cs @@ -184,9 +184,6 @@ public ElectricApparentEnergy(double value, UnitSystem unitSystem) /// public static ElectricApparentEnergy Zero => Info.Zero; - /// - public static ElectricApparentEnergy AdditiveIdentity => Zero; - #endregion #region Properties @@ -221,6 +218,11 @@ public ElectricApparentEnergy(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -581,6 +583,15 @@ public bool Equals(ElectricApparentEnergy other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current ElectricApparentEnergy. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -617,88 +628,6 @@ public int CompareTo(ElectricApparentEnergy other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another ElectricApparentEnergy within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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(ElectricApparentEnergy other, ElectricApparentEnergy tolerance) instead, 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(ElectricApparentEnergy other, double tolerance, ComparisonType comparisonType) - { - if (tolerance < 0) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: comparisonType); - } - - /// - public bool Equals(IQuantity? other, IQuantity tolerance) - { - return other is ElectricApparentEnergy otherTyped - && (tolerance is ElectricApparentEnergy toleranceTyped - ? true - : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'ElectricApparentEnergy'.", nameof(tolerance))) - && Equals(otherTyped, toleranceTyped); - } - - /// - public bool Equals(ElectricApparentEnergy other, ElectricApparentEnergy tolerance) - { - 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. - /// - /// A hash code for the current ElectricApparentEnergy. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -715,6 +644,12 @@ public double As(ElectricApparentEnergyUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -848,27 +783,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricApparentPower.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricApparentPower.g.cs index 70c0f0f50c..45e093512b 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricApparentPower.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricApparentPower.g.cs @@ -190,9 +190,6 @@ public ElectricApparentPower(double value, UnitSystem unitSystem) /// public static ElectricApparentPower Zero => Info.Zero; - /// - public static ElectricApparentPower AdditiveIdentity => Zero; - #endregion #region Properties @@ -227,6 +224,11 @@ public ElectricApparentPower(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -632,6 +634,15 @@ public bool Equals(ElectricApparentPower other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current ElectricApparentPower. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -668,88 +679,6 @@ public int CompareTo(ElectricApparentPower other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another ElectricApparentPower within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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(ElectricApparentPower other, ElectricApparentPower tolerance) instead, 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(ElectricApparentPower other, double tolerance, ComparisonType comparisonType) - { - if (tolerance < 0) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: comparisonType); - } - - /// - public bool Equals(IQuantity? other, IQuantity tolerance) - { - return other is ElectricApparentPower otherTyped - && (tolerance is ElectricApparentPower toleranceTyped - ? true - : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'ElectricApparentPower'.", nameof(tolerance))) - && Equals(otherTyped, toleranceTyped); - } - - /// - public bool Equals(ElectricApparentPower other, ElectricApparentPower tolerance) - { - 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. - /// - /// A hash code for the current ElectricApparentPower. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -766,6 +695,12 @@ public double As(ElectricApparentPowerUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -905,27 +840,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCapacitance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCapacitance.g.cs index 1e85e79354..24bd261f78 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCapacitance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCapacitance.g.cs @@ -191,9 +191,6 @@ public ElectricCapacitance(double value, UnitSystem unitSystem) /// public static ElectricCapacitance Zero => Info.Zero; - /// - public static ElectricCapacitance AdditiveIdentity => Zero; - #endregion #region Properties @@ -228,6 +225,11 @@ public ElectricCapacitance(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -648,6 +650,15 @@ public bool Equals(ElectricCapacitance other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current ElectricCapacitance. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -684,88 +695,6 @@ public int CompareTo(ElectricCapacitance other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another ElectricCapacitance within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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(ElectricCapacitance other, ElectricCapacitance tolerance) instead, 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(ElectricCapacitance other, double tolerance, ComparisonType comparisonType) - { - if (tolerance < 0) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: comparisonType); - } - - /// - public bool Equals(IQuantity? other, IQuantity tolerance) - { - return other is ElectricCapacitance otherTyped - && (tolerance is ElectricCapacitance toleranceTyped - ? true - : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'ElectricCapacitance'.", nameof(tolerance))) - && Equals(otherTyped, toleranceTyped); - } - - /// - public bool Equals(ElectricCapacitance other, ElectricCapacitance tolerance) - { - 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. - /// - /// A hash code for the current ElectricCapacitance. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -782,6 +711,12 @@ public double As(ElectricCapacitanceUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -923,27 +858,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs index ea6adb8192..18fde1fe69 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs @@ -200,9 +200,6 @@ public ElectricCharge(double value, UnitSystem unitSystem) /// public static ElectricCharge Zero => Info.Zero; - /// - public static ElectricCharge AdditiveIdentity => Zero; - #endregion #region Properties @@ -237,6 +234,11 @@ public ElectricCharge(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -739,6 +741,15 @@ public bool Equals(ElectricCharge other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current ElectricCharge. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -775,88 +786,6 @@ public int CompareTo(ElectricCharge other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another ElectricCharge within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: 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) - { - 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. - /// - /// A hash code for the current ElectricCharge. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -873,6 +802,12 @@ public double As(ElectricChargeUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -1022,27 +957,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.g.cs index ec5c8a459d..4d1083c921 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.g.cs @@ -185,9 +185,6 @@ public ElectricChargeDensity(double value, UnitSystem unitSystem) /// public static ElectricChargeDensity Zero => Info.Zero; - /// - public static ElectricChargeDensity AdditiveIdentity => Zero; - #endregion #region Properties @@ -222,6 +219,11 @@ public ElectricChargeDensity(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -552,6 +554,15 @@ public bool Equals(ElectricChargeDensity other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current ElectricChargeDensity. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -588,88 +599,6 @@ public int CompareTo(ElectricChargeDensity other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another ElectricChargeDensity within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: 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) - { - 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. - /// - /// A hash code for the current ElectricChargeDensity. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -686,6 +615,12 @@ public double As(ElectricChargeDensityUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -815,27 +750,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricConductance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricConductance.g.cs index b045c34f41..ebb5454f0e 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricConductance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricConductance.g.cs @@ -200,9 +200,6 @@ public ElectricConductance(double value, UnitSystem unitSystem) /// public static ElectricConductance Zero => Info.Zero; - /// - public static ElectricConductance AdditiveIdentity => Zero; - #endregion #region Properties @@ -237,6 +234,11 @@ public ElectricConductance(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -792,6 +794,15 @@ public bool Equals(ElectricConductance other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current ElectricConductance. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -828,88 +839,6 @@ public int CompareTo(ElectricConductance other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another ElectricConductance within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: 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) - { - 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. - /// - /// A hash code for the current ElectricConductance. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -926,6 +855,12 @@ public double As(ElectricConductanceUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -1085,27 +1020,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs index c6640f9ed8..59e69259ec 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs @@ -190,9 +190,6 @@ public ElectricConductivity(double value, UnitSystem unitSystem) /// public static ElectricConductivity Zero => Info.Zero; - /// - public static ElectricConductivity AdditiveIdentity => Zero; - #endregion #region Properties @@ -227,6 +224,11 @@ public ElectricConductivity(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -643,6 +645,15 @@ public bool Equals(ElectricConductivity other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current ElectricConductivity. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -679,88 +690,6 @@ public int CompareTo(ElectricConductivity other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another ElectricConductivity within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: 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) - { - 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. - /// - /// A hash code for the current ElectricConductivity. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -777,6 +706,12 @@ public double As(ElectricConductivityUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -916,27 +851,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs index 060dc3ac06..da3daf01d4 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs @@ -200,9 +200,6 @@ public ElectricCurrent(double value, UnitSystem unitSystem) /// public static ElectricCurrent Zero => Info.Zero; - /// - public static ElectricCurrent AdditiveIdentity => Zero; - #endregion #region Properties @@ -237,6 +234,11 @@ public ElectricCurrent(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -721,6 +723,15 @@ public bool Equals(ElectricCurrent other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current ElectricCurrent. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -757,88 +768,6 @@ public int CompareTo(ElectricCurrent other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another ElectricCurrent within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: 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) - { - 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. - /// - /// A hash code for the current ElectricCurrent. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -855,6 +784,12 @@ public double As(ElectricCurrentUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -1000,27 +935,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs index f40f779096..1f164f74be 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs @@ -187,9 +187,6 @@ public ElectricCurrentDensity(double value, UnitSystem unitSystem) /// public static ElectricCurrentDensity Zero => Info.Zero; - /// - public static ElectricCurrentDensity AdditiveIdentity => Zero; - #endregion #region Properties @@ -224,6 +221,11 @@ public ElectricCurrentDensity(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -584,6 +586,15 @@ public bool Equals(ElectricCurrentDensity other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current ElectricCurrentDensity. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -620,88 +631,6 @@ public int CompareTo(ElectricCurrentDensity other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another ElectricCurrentDensity within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: 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) - { - 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. - /// - /// A hash code for the current ElectricCurrentDensity. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -718,6 +647,12 @@ public double As(ElectricCurrentDensityUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -851,27 +786,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs index b35e6f2b27..8bcae0bedf 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs @@ -191,9 +191,6 @@ public ElectricCurrentGradient(double value, UnitSystem unitSystem) /// public static ElectricCurrentGradient Zero => Info.Zero; - /// - public static ElectricCurrentGradient AdditiveIdentity => Zero; - #endregion #region Properties @@ -228,6 +225,11 @@ public ElectricCurrentGradient(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -658,6 +660,15 @@ public bool Equals(ElectricCurrentGradient other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current ElectricCurrentGradient. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -694,88 +705,6 @@ public int CompareTo(ElectricCurrentGradient other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another ElectricCurrentGradient within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: 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) - { - 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. - /// - /// A hash code for the current ElectricCurrentGradient. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -792,6 +721,12 @@ public double As(ElectricCurrentGradientUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -933,27 +868,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricField.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricField.g.cs index d67f98cd85..928d371956 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricField.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricField.g.cs @@ -185,9 +185,6 @@ public ElectricField(double value, UnitSystem unitSystem) /// public static ElectricField Zero => Info.Zero; - /// - public static ElectricField AdditiveIdentity => Zero; - #endregion #region Properties @@ -222,6 +219,11 @@ public ElectricField(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -552,6 +554,15 @@ public bool Equals(ElectricField other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current ElectricField. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -588,88 +599,6 @@ public int CompareTo(ElectricField other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another ElectricField within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: 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) - { - 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. - /// - /// A hash code for the current ElectricField. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -686,6 +615,12 @@ public double As(ElectricFieldUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -815,27 +750,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricImpedance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricImpedance.g.cs index 58726afefe..50073bb733 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricImpedance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricImpedance.g.cs @@ -193,9 +193,6 @@ public ElectricImpedance(double value, UnitSystem unitSystem) /// public static ElectricImpedance Zero => Info.Zero; - /// - public static ElectricImpedance AdditiveIdentity => Zero; - #endregion #region Properties @@ -230,6 +227,11 @@ public ElectricImpedance(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -665,6 +667,15 @@ public bool Equals(ElectricImpedance other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current ElectricImpedance. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -701,88 +712,6 @@ public int CompareTo(ElectricImpedance other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another ElectricImpedance within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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(ElectricImpedance other, ElectricImpedance tolerance) instead, 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(ElectricImpedance other, double tolerance, ComparisonType comparisonType) - { - if (tolerance < 0) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: comparisonType); - } - - /// - public bool Equals(IQuantity? other, IQuantity tolerance) - { - return other is ElectricImpedance otherTyped - && (tolerance is ElectricImpedance toleranceTyped - ? true - : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'ElectricImpedance'.", nameof(tolerance))) - && Equals(otherTyped, toleranceTyped); - } - - /// - public bool Equals(ElectricImpedance other, ElectricImpedance tolerance) - { - 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. - /// - /// A hash code for the current ElectricImpedance. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -799,6 +728,12 @@ public double As(ElectricImpedanceUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -942,27 +877,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricInductance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricInductance.g.cs index 26a0aa991f..3cf1ff0b61 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricInductance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricInductance.g.cs @@ -189,9 +189,6 @@ public ElectricInductance(double value, UnitSystem unitSystem) /// public static ElectricInductance Zero => Info.Zero; - /// - public static ElectricInductance AdditiveIdentity => Zero; - #endregion #region Properties @@ -226,6 +223,11 @@ public ElectricInductance(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -616,6 +618,15 @@ public bool Equals(ElectricInductance other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current ElectricInductance. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -652,88 +663,6 @@ public int CompareTo(ElectricInductance other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another ElectricInductance within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: 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) - { - 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. - /// - /// A hash code for the current ElectricInductance. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -750,6 +679,12 @@ public double As(ElectricInductanceUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -887,27 +822,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs index 61efd8df1b..3febd51304 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs @@ -196,9 +196,6 @@ public ElectricPotential(double value, UnitSystem unitSystem) /// public static ElectricPotential Zero => Info.Zero; - /// - public static ElectricPotential AdditiveIdentity => Zero; - #endregion #region Properties @@ -233,6 +230,11 @@ public ElectricPotential(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -666,6 +668,15 @@ public bool Equals(ElectricPotential other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current ElectricPotential. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -702,88 +713,6 @@ public int CompareTo(ElectricPotential other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another ElectricPotential within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: 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) - { - 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. - /// - /// A hash code for the current ElectricPotential. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -800,6 +729,12 @@ public double As(ElectricPotentialUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -939,27 +874,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs index a8f692fdf3..73ff2247a4 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs @@ -201,9 +201,6 @@ public ElectricPotentialChangeRate(double value, UnitSystem unitSystem) /// public static ElectricPotentialChangeRate Zero => Info.Zero; - /// - public static ElectricPotentialChangeRate AdditiveIdentity => Zero; - #endregion #region Properties @@ -238,6 +235,11 @@ public ElectricPotentialChangeRate(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -853,6 +855,15 @@ public bool Equals(ElectricPotentialChangeRate other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current ElectricPotentialChangeRate. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -889,88 +900,6 @@ public int CompareTo(ElectricPotentialChangeRate other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another ElectricPotentialChangeRate within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: 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) - { - 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. - /// - /// A hash code for the current ElectricPotentialChangeRate. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -987,6 +916,12 @@ public double As(ElectricPotentialChangeRateUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -1154,27 +1089,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricReactance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricReactance.g.cs index e48eb8f62c..c3f0b483ff 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricReactance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricReactance.g.cs @@ -192,9 +192,6 @@ public ElectricReactance(double value, UnitSystem unitSystem) /// public static ElectricReactance Zero => Info.Zero; - /// - public static ElectricReactance AdditiveIdentity => Zero; - #endregion #region Properties @@ -229,6 +226,11 @@ public ElectricReactance(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -664,6 +666,15 @@ public bool Equals(ElectricReactance other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current ElectricReactance. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -700,88 +711,6 @@ public int CompareTo(ElectricReactance other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another ElectricReactance within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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(ElectricReactance other, ElectricReactance tolerance) instead, 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(ElectricReactance other, double tolerance, ComparisonType comparisonType) - { - if (tolerance < 0) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: comparisonType); - } - - /// - public bool Equals(IQuantity? other, IQuantity tolerance) - { - return other is ElectricReactance otherTyped - && (tolerance is ElectricReactance toleranceTyped - ? true - : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'ElectricReactance'.", nameof(tolerance))) - && Equals(otherTyped, toleranceTyped); - } - - /// - public bool Equals(ElectricReactance other, ElectricReactance tolerance) - { - 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. - /// - /// A hash code for the current ElectricReactance. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -798,6 +727,12 @@ public double As(ElectricReactanceUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -941,27 +876,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricReactiveEnergy.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricReactiveEnergy.g.cs index 606b448546..39965edd45 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricReactiveEnergy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricReactiveEnergy.g.cs @@ -184,9 +184,6 @@ public ElectricReactiveEnergy(double value, UnitSystem unitSystem) /// public static ElectricReactiveEnergy Zero => Info.Zero; - /// - public static ElectricReactiveEnergy AdditiveIdentity => Zero; - #endregion #region Properties @@ -221,6 +218,11 @@ public ElectricReactiveEnergy(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -581,6 +583,15 @@ public bool Equals(ElectricReactiveEnergy other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current ElectricReactiveEnergy. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -617,88 +628,6 @@ public int CompareTo(ElectricReactiveEnergy other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another ElectricReactiveEnergy within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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(ElectricReactiveEnergy other, ElectricReactiveEnergy tolerance) instead, 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(ElectricReactiveEnergy other, double tolerance, ComparisonType comparisonType) - { - if (tolerance < 0) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: comparisonType); - } - - /// - public bool Equals(IQuantity? other, IQuantity tolerance) - { - return other is ElectricReactiveEnergy otherTyped - && (tolerance is ElectricReactiveEnergy toleranceTyped - ? true - : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'ElectricReactiveEnergy'.", nameof(tolerance))) - && Equals(otherTyped, toleranceTyped); - } - - /// - public bool Equals(ElectricReactiveEnergy other, ElectricReactiveEnergy tolerance) - { - 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. - /// - /// A hash code for the current ElectricReactiveEnergy. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -715,6 +644,12 @@ public double As(ElectricReactiveEnergyUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -848,27 +783,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricReactivePower.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricReactivePower.g.cs index 712aa226fe..29d735bda3 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricReactivePower.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricReactivePower.g.cs @@ -188,9 +188,6 @@ public ElectricReactivePower(double value, UnitSystem unitSystem) /// public static ElectricReactivePower Zero => Info.Zero; - /// - public static ElectricReactivePower AdditiveIdentity => Zero; - #endregion #region Properties @@ -225,6 +222,11 @@ public ElectricReactivePower(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -600,6 +602,15 @@ public bool Equals(ElectricReactivePower other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current ElectricReactivePower. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -636,88 +647,6 @@ public int CompareTo(ElectricReactivePower other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another ElectricReactivePower within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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(ElectricReactivePower other, ElectricReactivePower tolerance) instead, 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(ElectricReactivePower other, double tolerance, ComparisonType comparisonType) - { - if (tolerance < 0) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: comparisonType); - } - - /// - public bool Equals(IQuantity? other, IQuantity tolerance) - { - return other is ElectricReactivePower otherTyped - && (tolerance is ElectricReactivePower toleranceTyped - ? true - : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'ElectricReactivePower'.", nameof(tolerance))) - && Equals(otherTyped, toleranceTyped); - } - - /// - public bool Equals(ElectricReactivePower other, ElectricReactivePower tolerance) - { - 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. - /// - /// A hash code for the current ElectricReactivePower. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -734,6 +663,12 @@ public double As(ElectricReactivePowerUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -869,27 +804,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs index d0f49e09e6..1750a38f29 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs @@ -195,9 +195,6 @@ public ElectricResistance(double value, UnitSystem unitSystem) /// public static ElectricResistance Zero => Info.Zero; - /// - public static ElectricResistance AdditiveIdentity => Zero; - #endregion #region Properties @@ -232,6 +229,11 @@ public ElectricResistance(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -677,6 +679,15 @@ public bool Equals(ElectricResistance other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current ElectricResistance. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -713,88 +724,6 @@ public int CompareTo(ElectricResistance other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another ElectricResistance within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: 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) - { - 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. - /// - /// A hash code for the current ElectricResistance. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -811,6 +740,12 @@ public double As(ElectricResistanceUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -954,27 +889,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs index 35408b639f..b612229a41 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs @@ -198,9 +198,6 @@ public ElectricResistivity(double value, UnitSystem unitSystem) /// public static ElectricResistivity Zero => Info.Zero; - /// - public static ElectricResistivity AdditiveIdentity => Zero; - #endregion #region Properties @@ -235,6 +232,11 @@ public ElectricResistivity(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -771,6 +773,15 @@ public bool Equals(ElectricResistivity other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current ElectricResistivity. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -807,88 +818,6 @@ public int CompareTo(ElectricResistivity other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another ElectricResistivity within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: 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) - { - 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. - /// - /// A hash code for the current ElectricResistivity. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -905,6 +834,12 @@ public double As(ElectricResistivityUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -1060,27 +995,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs index 5dcbb9131a..bb44f0c29e 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs @@ -187,9 +187,6 @@ public ElectricSurfaceChargeDensity(double value, UnitSystem unitSystem) /// public static ElectricSurfaceChargeDensity Zero => Info.Zero; - /// - public static ElectricSurfaceChargeDensity AdditiveIdentity => Zero; - #endregion #region Properties @@ -224,6 +221,11 @@ public ElectricSurfaceChargeDensity(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -584,6 +586,15 @@ public bool Equals(ElectricSurfaceChargeDensity other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current ElectricSurfaceChargeDensity. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -620,88 +631,6 @@ public int CompareTo(ElectricSurfaceChargeDensity other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another ElectricSurfaceChargeDensity within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: 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) - { - 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. - /// - /// A hash code for the current ElectricSurfaceChargeDensity. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -718,6 +647,12 @@ public double As(ElectricSurfaceChargeDensityUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -851,27 +786,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricSusceptance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricSusceptance.g.cs index e3280ad523..8adbf61f2e 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricSusceptance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricSusceptance.g.cs @@ -200,9 +200,6 @@ public ElectricSusceptance(double value, UnitSystem unitSystem) /// public static ElectricSusceptance Zero => Info.Zero; - /// - public static ElectricSusceptance AdditiveIdentity => Zero; - #endregion #region Properties @@ -237,6 +234,11 @@ public ElectricSusceptance(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -792,6 +794,15 @@ public bool Equals(ElectricSusceptance other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current ElectricSusceptance. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -828,88 +839,6 @@ public int CompareTo(ElectricSusceptance other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another ElectricSusceptance within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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(ElectricSusceptance other, ElectricSusceptance tolerance) instead, 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(ElectricSusceptance other, double tolerance, ComparisonType comparisonType) - { - if (tolerance < 0) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: comparisonType); - } - - /// - public bool Equals(IQuantity? other, IQuantity tolerance) - { - return other is ElectricSusceptance otherTyped - && (tolerance is ElectricSusceptance toleranceTyped - ? true - : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'ElectricSusceptance'.", nameof(tolerance))) - && Equals(otherTyped, toleranceTyped); - } - - /// - public bool Equals(ElectricSusceptance other, ElectricSusceptance tolerance) - { - 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. - /// - /// A hash code for the current ElectricSusceptance. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -926,6 +855,12 @@ public double As(ElectricSusceptanceUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -1085,27 +1020,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/Energy.g.cs b/UnitsNet/GeneratedCode/Quantities/Energy.g.cs index ab523addf3..ceb56502f2 100644 --- a/UnitsNet/GeneratedCode/Quantities/Energy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Energy.g.cs @@ -236,9 +236,6 @@ public Energy(double value, UnitSystem unitSystem) /// public static Energy Zero => Info.Zero; - /// - public static Energy AdditiveIdentity => Zero; - #endregion #region Properties @@ -273,6 +270,11 @@ public Energy(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -1270,6 +1272,15 @@ public bool Equals(Energy other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current Energy. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -1306,88 +1317,6 @@ public int CompareTo(Energy other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another Energy within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: 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) - { - 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. - /// - /// A hash code for the current Energy. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -1404,6 +1333,12 @@ public double As(EnergyUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -1611,27 +1546,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/EnergyDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/EnergyDensity.g.cs index 21c7492901..12ecd7d423 100644 --- a/UnitsNet/GeneratedCode/Quantities/EnergyDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/EnergyDensity.g.cs @@ -196,9 +196,6 @@ public EnergyDensity(double value, UnitSystem unitSystem) /// public static EnergyDensity Zero => Info.Zero; - /// - public static EnergyDensity AdditiveIdentity => Zero; - #endregion #region Properties @@ -233,6 +230,11 @@ public EnergyDensity(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -738,6 +740,15 @@ public bool Equals(EnergyDensity other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current EnergyDensity. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -774,88 +785,6 @@ public int CompareTo(EnergyDensity other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another EnergyDensity within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: 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) - { - 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. - /// - /// A hash code for the current EnergyDensity. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -872,6 +801,12 @@ public double As(EnergyDensityUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -1023,27 +958,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs b/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs index 12a78c5b9f..a4319be7e5 100644 --- a/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs @@ -193,9 +193,6 @@ public Entropy(double value, UnitSystem unitSystem) /// public static Entropy Zero => Info.Zero; - /// - public static Entropy AdditiveIdentity => Zero; - #endregion #region Properties @@ -230,6 +227,11 @@ public Entropy(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -672,6 +674,15 @@ public bool Equals(Entropy other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current Entropy. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -708,88 +719,6 @@ public int CompareTo(Entropy other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another Entropy within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: 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) - { - 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. - /// - /// A hash code for the current Entropy. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -806,6 +735,12 @@ public double As(EntropyUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -947,27 +882,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/FluidResistance.g.cs b/UnitsNet/GeneratedCode/Quantities/FluidResistance.g.cs index 8331a44a9c..dcce633bf0 100644 --- a/UnitsNet/GeneratedCode/Quantities/FluidResistance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/FluidResistance.g.cs @@ -203,9 +203,6 @@ public FluidResistance(double value, UnitSystem unitSystem) /// public static FluidResistance Zero => Info.Zero; - /// - public static FluidResistance AdditiveIdentity => Zero; - #endregion #region Properties @@ -240,6 +237,11 @@ public FluidResistance(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -840,6 +842,15 @@ public bool Equals(FluidResistance other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current FluidResistance. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -876,88 +887,6 @@ public int CompareTo(FluidResistance other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another FluidResistance within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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(FluidResistance other, FluidResistance tolerance) instead, 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(FluidResistance other, double tolerance, ComparisonType comparisonType) - { - if (tolerance < 0) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: comparisonType); - } - - /// - public bool Equals(IQuantity? other, IQuantity tolerance) - { - return other is FluidResistance otherTyped - && (tolerance is FluidResistance toleranceTyped - ? true - : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'FluidResistance'.", nameof(tolerance))) - && Equals(otherTyped, toleranceTyped); - } - - /// - public bool Equals(FluidResistance other, FluidResistance tolerance) - { - 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. - /// - /// A hash code for the current FluidResistance. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -974,6 +903,12 @@ public double As(FluidResistanceUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -1139,27 +1074,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/Force.g.cs b/UnitsNet/GeneratedCode/Quantities/Force.g.cs index 79fdcbf55e..bd65a4fa2d 100644 --- a/UnitsNet/GeneratedCode/Quantities/Force.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Force.g.cs @@ -210,9 +210,6 @@ public Force(double value, UnitSystem unitSystem) /// public static Force Zero => Info.Zero; - /// - public static Force AdditiveIdentity => Zero; - #endregion #region Properties @@ -247,6 +244,11 @@ public Force(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -863,6 +865,15 @@ public bool Equals(Force other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current Force. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -899,88 +910,6 @@ public int CompareTo(Force other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another Force within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: 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) - { - 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. - /// - /// A hash code for the current Force. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -997,6 +926,12 @@ public double As(ForceUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -1154,27 +1089,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs index 52fa8402a2..a91bc92d37 100644 --- a/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs @@ -199,9 +199,6 @@ public ForceChangeRate(double value, UnitSystem unitSystem) /// public static ForceChangeRate Zero => Info.Zero; - /// - public static ForceChangeRate AdditiveIdentity => Zero; - #endregion #region Properties @@ -236,6 +233,11 @@ public ForceChangeRate(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -786,6 +788,15 @@ public bool Equals(ForceChangeRate other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current ForceChangeRate. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -822,88 +833,6 @@ public int CompareTo(ForceChangeRate other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another ForceChangeRate within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: 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) - { - 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. - /// - /// A hash code for the current ForceChangeRate. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -920,6 +849,12 @@ public double As(ForceChangeRateUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -1077,27 +1012,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs b/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs index a7820ede8c..026376cd4b 100644 --- a/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs @@ -230,9 +230,6 @@ public ForcePerLength(double value, UnitSystem unitSystem) /// public static ForcePerLength Zero => Info.Zero; - /// - public static ForcePerLength AdditiveIdentity => Zero; - #endregion #region Properties @@ -267,6 +264,11 @@ public ForcePerLength(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -1210,6 +1212,15 @@ public bool Equals(ForcePerLength other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current ForcePerLength. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -1246,88 +1257,6 @@ public int CompareTo(ForcePerLength other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another ForcePerLength within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: 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) - { - 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. - /// - /// A hash code for the current ForcePerLength. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -1344,6 +1273,12 @@ public double As(ForcePerLengthUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -1547,27 +1482,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs b/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs index e015f473b8..753a06cfa9 100644 --- a/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs @@ -196,9 +196,6 @@ public Frequency(double value, UnitSystem unitSystem) /// public static Frequency Zero => Info.Zero; - /// - public static Frequency AdditiveIdentity => Zero; - #endregion #region Properties @@ -233,6 +230,11 @@ public Frequency(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -738,6 +740,15 @@ public bool Equals(Frequency other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current Frequency. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -774,88 +785,6 @@ public int CompareTo(Frequency other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another Frequency within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: 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) - { - 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. - /// - /// A hash code for the current Frequency. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -872,6 +801,12 @@ public double As(FrequencyUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -1023,27 +958,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/FuelEfficiency.g.cs b/UnitsNet/GeneratedCode/Quantities/FuelEfficiency.g.cs index 6d28751f01..643569172c 100644 --- a/UnitsNet/GeneratedCode/Quantities/FuelEfficiency.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/FuelEfficiency.g.cs @@ -188,9 +188,6 @@ public FuelEfficiency(double value, UnitSystem unitSystem) /// public static FuelEfficiency Zero => Info.Zero; - /// - public static FuelEfficiency AdditiveIdentity => Zero; - #endregion #region Properties @@ -225,6 +222,11 @@ public FuelEfficiency(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -600,6 +602,15 @@ public bool Equals(FuelEfficiency other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current FuelEfficiency. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -636,88 +647,6 @@ public int CompareTo(FuelEfficiency other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another FuelEfficiency within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: 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) - { - 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. - /// - /// A hash code for the current FuelEfficiency. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -734,6 +663,12 @@ public double As(FuelEfficiencyUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -869,27 +804,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs b/UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs index 283b7a0407..0b66ebc27a 100644 --- a/UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs @@ -202,9 +202,6 @@ public HeatFlux(double value, UnitSystem unitSystem) /// public static HeatFlux Zero => Info.Zero; - /// - public static HeatFlux AdditiveIdentity => Zero; - #endregion #region Properties @@ -239,6 +236,11 @@ public HeatFlux(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -834,6 +836,15 @@ public bool Equals(HeatFlux other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current HeatFlux. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -870,88 +881,6 @@ public int CompareTo(HeatFlux other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another HeatFlux within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: 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) - { - 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. - /// - /// A hash code for the current HeatFlux. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -968,6 +897,12 @@ public double As(HeatFluxUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -1131,27 +1066,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs b/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs index 981670c3e2..ce12dfb985 100644 --- a/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs @@ -186,9 +186,6 @@ public HeatTransferCoefficient(double value, UnitSystem unitSystem) /// public static HeatTransferCoefficient Zero => Info.Zero; - /// - public static HeatTransferCoefficient AdditiveIdentity => Zero; - #endregion #region Properties @@ -223,6 +220,11 @@ public HeatTransferCoefficient(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -613,6 +615,15 @@ public bool Equals(HeatTransferCoefficient other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current HeatTransferCoefficient. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -649,88 +660,6 @@ public int CompareTo(HeatTransferCoefficient other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another HeatTransferCoefficient within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: 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) - { - 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. - /// - /// A hash code for the current HeatTransferCoefficient. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -747,6 +676,12 @@ public double As(HeatTransferCoefficientUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -884,27 +819,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/Illuminance.g.cs b/UnitsNet/GeneratedCode/Quantities/Illuminance.g.cs index 26151b59bc..df428b789b 100644 --- a/UnitsNet/GeneratedCode/Quantities/Illuminance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Illuminance.g.cs @@ -191,9 +191,6 @@ public Illuminance(double value, UnitSystem unitSystem) /// public static Illuminance Zero => Info.Zero; - /// - public static Illuminance AdditiveIdentity => Zero; - #endregion #region Properties @@ -228,6 +225,11 @@ public Illuminance(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -613,6 +615,15 @@ public bool Equals(Illuminance other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current Illuminance. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -649,88 +660,6 @@ public int CompareTo(Illuminance other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another Illuminance within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: 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) - { - 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. - /// - /// A hash code for the current Illuminance. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -747,6 +676,12 @@ public double As(IlluminanceUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -882,27 +817,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/Impulse.g.cs b/UnitsNet/GeneratedCode/Quantities/Impulse.g.cs index 92765bafa6..4e3232afa3 100644 --- a/UnitsNet/GeneratedCode/Quantities/Impulse.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Impulse.g.cs @@ -194,9 +194,6 @@ public Impulse(double value, UnitSystem unitSystem) /// public static Impulse Zero => Info.Zero; - /// - public static Impulse AdditiveIdentity => Zero; - #endregion #region Properties @@ -231,6 +228,11 @@ public Impulse(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -741,6 +743,15 @@ public bool Equals(Impulse other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current Impulse. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -777,88 +788,6 @@ public int CompareTo(Impulse other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another Impulse within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: 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) - { - 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. - /// - /// A hash code for the current Impulse. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -875,6 +804,12 @@ public double As(ImpulseUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -1028,27 +963,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/Information.g.cs b/UnitsNet/GeneratedCode/Quantities/Information.g.cs index 5b866eab08..52c9cd1ed9 100644 --- a/UnitsNet/GeneratedCode/Quantities/Information.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Information.g.cs @@ -206,9 +206,6 @@ public Information(double value, InformationUnit unit) /// public static Information Zero => Info.Zero; - /// - public static Information AdditiveIdentity => Zero; - #endregion #region Properties @@ -243,6 +240,11 @@ public Information(double value, InformationUnit unit) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -1143,6 +1145,15 @@ public bool Equals(Information other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current Information. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -1179,88 +1190,6 @@ public int CompareTo(Information other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another Information within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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, double tolerance, ComparisonType comparisonType) - { - if (tolerance < 0) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: 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) - { - 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. - /// - /// A hash code for the current Information. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -1277,6 +1206,12 @@ public double As(InformationUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -1482,27 +1417,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/Irradiance.g.cs b/UnitsNet/GeneratedCode/Quantities/Irradiance.g.cs index b12546638e..6b5c8fd64f 100644 --- a/UnitsNet/GeneratedCode/Quantities/Irradiance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Irradiance.g.cs @@ -195,9 +195,6 @@ public Irradiance(double value, UnitSystem unitSystem) /// public static Irradiance Zero => Info.Zero; - /// - public static Irradiance AdditiveIdentity => Zero; - #endregion #region Properties @@ -232,6 +229,11 @@ public Irradiance(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -757,6 +759,15 @@ public bool Equals(Irradiance other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current Irradiance. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -793,88 +804,6 @@ public int CompareTo(Irradiance other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another Irradiance within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: 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) - { - 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. - /// - /// A hash code for the current Irradiance. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -891,6 +820,12 @@ public double As(IrradianceUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -1046,27 +981,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/Irradiation.g.cs b/UnitsNet/GeneratedCode/Quantities/Irradiation.g.cs index 5377fdff73..fabf415f5c 100644 --- a/UnitsNet/GeneratedCode/Quantities/Irradiation.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Irradiation.g.cs @@ -193,9 +193,6 @@ public Irradiation(double value, UnitSystem unitSystem) /// public static Irradiation Zero => Info.Zero; - /// - public static Irradiation AdditiveIdentity => Zero; - #endregion #region Properties @@ -230,6 +227,11 @@ public Irradiation(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -680,6 +682,15 @@ public bool Equals(Irradiation other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current Irradiation. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -716,88 +727,6 @@ public int CompareTo(Irradiation other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another Irradiation within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: 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) - { - 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. - /// - /// A hash code for the current Irradiation. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -814,6 +743,12 @@ public double As(IrradiationUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -959,27 +894,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/Jerk.g.cs b/UnitsNet/GeneratedCode/Quantities/Jerk.g.cs index 2c8c3d3a13..587a30b7d9 100644 --- a/UnitsNet/GeneratedCode/Quantities/Jerk.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Jerk.g.cs @@ -195,9 +195,6 @@ public Jerk(double value, UnitSystem unitSystem) /// public static Jerk Zero => Info.Zero; - /// - public static Jerk AdditiveIdentity => Zero; - #endregion #region Properties @@ -232,6 +229,11 @@ public Jerk(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -722,6 +724,15 @@ public bool Equals(Jerk other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current Jerk. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -758,88 +769,6 @@ public int CompareTo(Jerk other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another Jerk within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: 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) - { - 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. - /// - /// A hash code for the current Jerk. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -856,6 +785,12 @@ public double As(JerkUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -1005,27 +940,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs b/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs index 079dbcb587..997068d838 100644 --- a/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs @@ -199,9 +199,6 @@ public KinematicViscosity(double value, UnitSystem unitSystem) /// public static KinematicViscosity Zero => Info.Zero; - /// - public static KinematicViscosity AdditiveIdentity => Zero; - #endregion #region Properties @@ -236,6 +233,11 @@ public KinematicViscosity(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -714,6 +716,15 @@ public bool Equals(KinematicViscosity other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current KinematicViscosity. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -750,88 +761,6 @@ public int CompareTo(KinematicViscosity other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another KinematicViscosity within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: 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) - { - 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. - /// - /// A hash code for the current KinematicViscosity. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -848,6 +777,12 @@ public double As(KinematicViscosityUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -993,27 +928,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/LeakRate.g.cs b/UnitsNet/GeneratedCode/Quantities/LeakRate.g.cs index d407928b14..2508364f74 100644 --- a/UnitsNet/GeneratedCode/Quantities/LeakRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LeakRate.g.cs @@ -187,9 +187,6 @@ public LeakRate(double value, UnitSystem unitSystem) /// public static LeakRate Zero => Info.Zero; - /// - public static LeakRate AdditiveIdentity => Zero; - #endregion #region Properties @@ -224,6 +221,11 @@ public LeakRate(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -584,6 +586,15 @@ public bool Equals(LeakRate other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current LeakRate. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -620,88 +631,6 @@ public int CompareTo(LeakRate other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another LeakRate within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: 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) - { - 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. - /// - /// A hash code for the current LeakRate. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -718,6 +647,12 @@ public double As(LeakRateUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -851,27 +786,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/Length.g.cs b/UnitsNet/GeneratedCode/Quantities/Length.g.cs index c7b6885b1d..2bf95d97b2 100644 --- a/UnitsNet/GeneratedCode/Quantities/Length.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Length.g.cs @@ -243,9 +243,6 @@ public Length(double value, UnitSystem unitSystem) /// public static Length Zero => Info.Zero; - /// - public static Length AdditiveIdentity => Zero; - #endregion #region Properties @@ -280,6 +277,11 @@ public Length(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -1344,6 +1346,15 @@ public bool Equals(Length other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current Length. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -1380,88 +1391,6 @@ public int CompareTo(Length other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another Length within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: 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) - { - 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. - /// - /// A hash code for the current Length. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -1478,6 +1407,12 @@ public double As(LengthUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -1689,27 +1624,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/Level.g.cs b/UnitsNet/GeneratedCode/Quantities/Level.g.cs index 6febf1cdca..9ecf241a5e 100644 --- a/UnitsNet/GeneratedCode/Quantities/Level.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Level.g.cs @@ -37,7 +37,7 @@ namespace UnitsNet [DataContract] [DebuggerTypeProxy(typeof(QuantityDisplay))] public readonly partial struct Level : - IArithmeticQuantity, + ILogarithmicQuantity, #if NET7_0_OR_GREATER IComparisonOperators, IParsable, @@ -169,8 +169,8 @@ public Level(double value, LevelUnit unit) /// public static Level Zero => Info.Zero; - /// - public static Level AdditiveIdentity => Zero; + /// + public static double LogarithmicScalingFactor {get;} = 10; #endregion @@ -206,6 +206,15 @@ public Level(double value, LevelUnit unit) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + +#if NETSTANDARD2_0 + double ILogarithmicQuantity.LogarithmicScalingFactor => LogarithmicScalingFactor; +#endif + #endregion #endregion @@ -559,6 +568,15 @@ public bool Equals(Level other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current Level. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -595,88 +613,6 @@ public int CompareTo(Level other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another Level within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: 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) - { - 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. - /// - /// A hash code for the current Level. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -693,6 +629,12 @@ public double As(LevelUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -824,27 +766,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/LinearDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/LinearDensity.g.cs index 334dac8b05..5e73ea53d5 100644 --- a/UnitsNet/GeneratedCode/Quantities/LinearDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LinearDensity.g.cs @@ -207,9 +207,6 @@ public LinearDensity(double value, UnitSystem unitSystem) /// public static LinearDensity Zero => Info.Zero; - /// - public static LinearDensity AdditiveIdentity => Zero; - #endregion #region Properties @@ -244,6 +241,11 @@ public LinearDensity(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -851,6 +853,15 @@ public bool Equals(LinearDensity other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current LinearDensity. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -887,88 +898,6 @@ public int CompareTo(LinearDensity other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another LinearDensity within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: 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) - { - 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. - /// - /// A hash code for the current LinearDensity. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -985,6 +914,12 @@ public double As(LinearDensityUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -1148,27 +1083,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/LinearPowerDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/LinearPowerDensity.g.cs index f137c5532d..cec08e04aa 100644 --- a/UnitsNet/GeneratedCode/Quantities/LinearPowerDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LinearPowerDensity.g.cs @@ -209,9 +209,6 @@ public LinearPowerDensity(double value, UnitSystem unitSystem) /// public static LinearPowerDensity Zero => Info.Zero; - /// - public static LinearPowerDensity AdditiveIdentity => Zero; - #endregion #region Properties @@ -246,6 +243,11 @@ public LinearPowerDensity(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -936,6 +938,15 @@ public bool Equals(LinearPowerDensity other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current LinearPowerDensity. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -972,88 +983,6 @@ public int CompareTo(LinearPowerDensity other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another LinearPowerDensity within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: 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) - { - 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. - /// - /// A hash code for the current LinearPowerDensity. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -1070,6 +999,12 @@ public double As(LinearPowerDensityUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -1247,27 +1182,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/Luminance.g.cs b/UnitsNet/GeneratedCode/Quantities/Luminance.g.cs index d2f61862a2..2977781af1 100644 --- a/UnitsNet/GeneratedCode/Quantities/Luminance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Luminance.g.cs @@ -197,9 +197,6 @@ public Luminance(double value, UnitSystem unitSystem) /// public static Luminance Zero => Info.Zero; - /// - public static Luminance AdditiveIdentity => Zero; - #endregion #region Properties @@ -234,6 +231,11 @@ public Luminance(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -709,6 +711,15 @@ public bool Equals(Luminance other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current Luminance. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -745,88 +756,6 @@ public int CompareTo(Luminance other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another Luminance within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: 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) - { - 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. - /// - /// A hash code for the current Luminance. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -843,6 +772,12 @@ public double As(LuminanceUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -990,27 +925,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/Luminosity.g.cs b/UnitsNet/GeneratedCode/Quantities/Luminosity.g.cs index 1707babe0b..73d70755fe 100644 --- a/UnitsNet/GeneratedCode/Quantities/Luminosity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Luminosity.g.cs @@ -198,9 +198,6 @@ public Luminosity(double value, UnitSystem unitSystem) /// public static Luminosity Zero => Info.Zero; - /// - public static Luminosity AdditiveIdentity => Zero; - #endregion #region Properties @@ -235,6 +232,11 @@ public Luminosity(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -760,6 +762,15 @@ public bool Equals(Luminosity other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current Luminosity. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -796,88 +807,6 @@ public int CompareTo(Luminosity other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another Luminosity within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: 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) - { - 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. - /// - /// A hash code for the current Luminosity. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -894,6 +823,12 @@ public double As(LuminosityUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -1049,27 +984,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/LuminousFlux.g.cs b/UnitsNet/GeneratedCode/Quantities/LuminousFlux.g.cs index 5a0501eb02..e28603d44e 100644 --- a/UnitsNet/GeneratedCode/Quantities/LuminousFlux.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LuminousFlux.g.cs @@ -189,9 +189,6 @@ public LuminousFlux(double value, UnitSystem unitSystem) /// public static LuminousFlux Zero => Info.Zero; - /// - public static LuminousFlux AdditiveIdentity => Zero; - #endregion #region Properties @@ -226,6 +223,11 @@ public LuminousFlux(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -572,6 +574,15 @@ public bool Equals(LuminousFlux other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current LuminousFlux. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -608,88 +619,6 @@ public int CompareTo(LuminousFlux other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another LuminousFlux within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: 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) - { - 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. - /// - /// A hash code for the current LuminousFlux. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -706,6 +635,12 @@ public double As(LuminousFluxUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -835,27 +770,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.g.cs b/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.g.cs index ebb92e5e7a..71287d4141 100644 --- a/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.g.cs @@ -189,9 +189,6 @@ public LuminousIntensity(double value, UnitSystem unitSystem) /// public static LuminousIntensity Zero => Info.Zero; - /// - public static LuminousIntensity AdditiveIdentity => Zero; - #endregion #region Properties @@ -226,6 +223,11 @@ public LuminousIntensity(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -572,6 +574,15 @@ public bool Equals(LuminousIntensity other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current LuminousIntensity. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -608,88 +619,6 @@ public int CompareTo(LuminousIntensity other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another LuminousIntensity within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: 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) - { - 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. - /// - /// A hash code for the current LuminousIntensity. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -706,6 +635,12 @@ public double As(LuminousIntensityUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -835,27 +770,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/MagneticField.g.cs b/UnitsNet/GeneratedCode/Quantities/MagneticField.g.cs index 671e0e2954..3908d3cc70 100644 --- a/UnitsNet/GeneratedCode/Quantities/MagneticField.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MagneticField.g.cs @@ -190,9 +190,6 @@ public MagneticField(double value, UnitSystem unitSystem) /// public static MagneticField Zero => Info.Zero; - /// - public static MagneticField AdditiveIdentity => Zero; - #endregion #region Properties @@ -227,6 +224,11 @@ public MagneticField(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -632,6 +634,15 @@ public bool Equals(MagneticField other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current MagneticField. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -668,88 +679,6 @@ public int CompareTo(MagneticField other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another MagneticField within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: 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) - { - 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. - /// - /// A hash code for the current MagneticField. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -766,6 +695,12 @@ public double As(MagneticFieldUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -905,27 +840,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/MagneticFlux.g.cs b/UnitsNet/GeneratedCode/Quantities/MagneticFlux.g.cs index 3ef4d898fc..3538af7760 100644 --- a/UnitsNet/GeneratedCode/Quantities/MagneticFlux.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MagneticFlux.g.cs @@ -185,9 +185,6 @@ public MagneticFlux(double value, UnitSystem unitSystem) /// public static MagneticFlux Zero => Info.Zero; - /// - public static MagneticFlux AdditiveIdentity => Zero; - #endregion #region Properties @@ -222,6 +219,11 @@ public MagneticFlux(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -552,6 +554,15 @@ public bool Equals(MagneticFlux other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current MagneticFlux. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -588,88 +599,6 @@ public int CompareTo(MagneticFlux other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another MagneticFlux within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: 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) - { - 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. - /// - /// A hash code for the current MagneticFlux. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -686,6 +615,12 @@ public double As(MagneticFluxUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -815,27 +750,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/Magnetization.g.cs b/UnitsNet/GeneratedCode/Quantities/Magnetization.g.cs index 578de41b29..c0618365f4 100644 --- a/UnitsNet/GeneratedCode/Quantities/Magnetization.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Magnetization.g.cs @@ -185,9 +185,6 @@ public Magnetization(double value, UnitSystem unitSystem) /// public static Magnetization Zero => Info.Zero; - /// - public static Magnetization AdditiveIdentity => Zero; - #endregion #region Properties @@ -222,6 +219,11 @@ public Magnetization(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -552,6 +554,15 @@ public bool Equals(Magnetization other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current Magnetization. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -588,88 +599,6 @@ public int CompareTo(Magnetization other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another Magnetization within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: 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) - { - 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. - /// - /// A hash code for the current Magnetization. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -686,6 +615,12 @@ public double As(MagnetizationUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -815,27 +750,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/Mass.g.cs b/UnitsNet/GeneratedCode/Quantities/Mass.g.cs index c5e805a792..a82bdcce00 100644 --- a/UnitsNet/GeneratedCode/Quantities/Mass.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Mass.g.cs @@ -226,9 +226,6 @@ public Mass(double value, UnitSystem unitSystem) /// public static Mass Zero => Info.Zero; - /// - public static Mass AdditiveIdentity => Zero; - #endregion #region Properties @@ -263,6 +260,11 @@ public Mass(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -1083,6 +1085,15 @@ public bool Equals(Mass other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current Mass. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -1119,88 +1130,6 @@ public int CompareTo(Mass other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another Mass within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: 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) - { - 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. - /// - /// A hash code for the current Mass. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -1217,6 +1146,12 @@ public double As(MassUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -1398,27 +1333,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/MassConcentration.g.cs b/UnitsNet/GeneratedCode/Quantities/MassConcentration.g.cs index 57d1d1faa5..c60db148da 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassConcentration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassConcentration.g.cs @@ -240,9 +240,6 @@ public MassConcentration(double value, UnitSystem unitSystem) /// public static MassConcentration Zero => Info.Zero; - /// - public static MassConcentration AdditiveIdentity => Zero; - #endregion #region Properties @@ -277,6 +274,11 @@ public MassConcentration(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -1361,6 +1363,15 @@ public bool Equals(MassConcentration other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current MassConcentration. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -1397,88 +1408,6 @@ public int CompareTo(MassConcentration other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another MassConcentration within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: 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) - { - 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. - /// - /// A hash code for the current MassConcentration. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -1495,6 +1424,12 @@ public double As(MassConcentrationUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -1720,27 +1655,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs b/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs index 95b7045914..739a1c7592 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs @@ -226,9 +226,6 @@ public MassFlow(double value, UnitSystem unitSystem) /// public static MassFlow Zero => Info.Zero; - /// - public static MassFlow AdditiveIdentity => Zero; - #endregion #region Properties @@ -263,6 +260,11 @@ public MassFlow(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -1137,6 +1139,15 @@ public bool Equals(MassFlow other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current MassFlow. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -1173,88 +1184,6 @@ public int CompareTo(MassFlow other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another MassFlow within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: 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) - { - 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. - /// - /// A hash code for the current MassFlow. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -1271,6 +1200,12 @@ public double As(MassFlowUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -1464,27 +1399,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs b/UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs index e8f736a4a2..8f9b707a34 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs @@ -198,9 +198,6 @@ public MassFlux(double value, UnitSystem unitSystem) /// public static MassFlux Zero => Info.Zero; - /// - public static MassFlux AdditiveIdentity => Zero; - #endregion #region Properties @@ -235,6 +232,11 @@ public MassFlux(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -752,6 +754,15 @@ public bool Equals(MassFlux other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current MassFlux. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -788,88 +799,6 @@ public int CompareTo(MassFlux other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another MassFlux within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: 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) - { - 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. - /// - /// A hash code for the current MassFlux. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -886,6 +815,12 @@ public double As(MassFluxUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -1037,27 +972,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/MassFraction.g.cs b/UnitsNet/GeneratedCode/Quantities/MassFraction.g.cs index 0ba8c21471..07757ec170 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassFraction.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassFraction.g.cs @@ -197,9 +197,6 @@ public MassFraction(double value, MassFractionUnit unit) /// public static MassFraction Zero => Info.Zero; - /// - public static MassFraction AdditiveIdentity => Zero; - #endregion #region Properties @@ -234,6 +231,11 @@ public MassFraction(double value, MassFractionUnit unit) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -919,6 +921,15 @@ public bool Equals(MassFraction other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current MassFraction. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -955,88 +966,6 @@ public int CompareTo(MassFraction other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another MassFraction within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: 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) - { - 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. - /// - /// A hash code for the current MassFraction. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -1053,6 +982,12 @@ public double As(MassFractionUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -1228,27 +1163,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.g.cs b/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.g.cs index 76866ecf38..97668bdec0 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.g.cs @@ -209,9 +209,6 @@ public MassMomentOfInertia(double value, UnitSystem unitSystem) /// public static MassMomentOfInertia Zero => Info.Zero; - /// - public static MassMomentOfInertia AdditiveIdentity => Zero; - #endregion #region Properties @@ -246,6 +243,11 @@ public MassMomentOfInertia(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -981,6 +983,15 @@ public bool Equals(MassMomentOfInertia other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current MassMomentOfInertia. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -1017,88 +1028,6 @@ public int CompareTo(MassMomentOfInertia other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another MassMomentOfInertia within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: 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) - { - 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. - /// - /// A hash code for the current MassMomentOfInertia. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -1115,6 +1044,12 @@ public double As(MassMomentOfInertiaUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -1298,27 +1233,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/Molality.g.cs b/UnitsNet/GeneratedCode/Quantities/Molality.g.cs index 7d43cca5c5..72da45f445 100644 --- a/UnitsNet/GeneratedCode/Quantities/Molality.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Molality.g.cs @@ -187,9 +187,6 @@ public Molality(double value, UnitSystem unitSystem) /// public static Molality Zero => Info.Zero; - /// - public static Molality AdditiveIdentity => Zero; - #endregion #region Properties @@ -224,6 +221,11 @@ public Molality(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -584,6 +586,15 @@ public bool Equals(Molality other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current Molality. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -620,88 +631,6 @@ public int CompareTo(Molality other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another Molality within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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(Molality other, Molality tolerance) instead, 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(Molality other, double tolerance, ComparisonType comparisonType) - { - if (tolerance < 0) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: comparisonType); - } - - /// - public bool Equals(IQuantity? other, IQuantity tolerance) - { - return other is Molality otherTyped - && (tolerance is Molality toleranceTyped - ? true - : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'Molality'.", nameof(tolerance))) - && Equals(otherTyped, toleranceTyped); - } - - /// - public bool Equals(Molality other, Molality tolerance) - { - 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. - /// - /// A hash code for the current Molality. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -718,6 +647,12 @@ public double As(MolalityUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -851,27 +786,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/MolarEnergy.g.cs b/UnitsNet/GeneratedCode/Quantities/MolarEnergy.g.cs index aa06d4e447..de2260cdb5 100644 --- a/UnitsNet/GeneratedCode/Quantities/MolarEnergy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MolarEnergy.g.cs @@ -187,9 +187,6 @@ public MolarEnergy(double value, UnitSystem unitSystem) /// public static MolarEnergy Zero => Info.Zero; - /// - public static MolarEnergy AdditiveIdentity => Zero; - #endregion #region Properties @@ -224,6 +221,11 @@ public MolarEnergy(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -594,6 +596,15 @@ public bool Equals(MolarEnergy other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current MolarEnergy. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -630,88 +641,6 @@ public int CompareTo(MolarEnergy other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another MolarEnergy within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: 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) - { - 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. - /// - /// A hash code for the current MolarEnergy. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -728,6 +657,12 @@ public double As(MolarEnergyUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -861,27 +796,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs b/UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs index 43f6570199..7e43d6aa6a 100644 --- a/UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs @@ -184,9 +184,6 @@ public MolarEntropy(double value, UnitSystem unitSystem) /// public static MolarEntropy Zero => Info.Zero; - /// - public static MolarEntropy AdditiveIdentity => Zero; - #endregion #region Properties @@ -221,6 +218,11 @@ public MolarEntropy(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -581,6 +583,15 @@ public bool Equals(MolarEntropy other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current MolarEntropy. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -617,88 +628,6 @@ public int CompareTo(MolarEntropy other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another MolarEntropy within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: 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) - { - 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. - /// - /// A hash code for the current MolarEntropy. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -715,6 +644,12 @@ public double As(MolarEntropyUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -848,27 +783,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/MolarFlow.g.cs b/UnitsNet/GeneratedCode/Quantities/MolarFlow.g.cs index 391ee9f346..03d2f533d9 100644 --- a/UnitsNet/GeneratedCode/Quantities/MolarFlow.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MolarFlow.g.cs @@ -196,9 +196,6 @@ public MolarFlow(double value, UnitSystem unitSystem) /// public static MolarFlow Zero => Info.Zero; - /// - public static MolarFlow AdditiveIdentity => Zero; - #endregion #region Properties @@ -233,6 +230,11 @@ public MolarFlow(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -711,6 +713,15 @@ public bool Equals(MolarFlow other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current MolarFlow. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -747,88 +758,6 @@ public int CompareTo(MolarFlow other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another MolarFlow within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: 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) - { - 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. - /// - /// A hash code for the current MolarFlow. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -845,6 +774,12 @@ public double As(MolarFlowUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -990,27 +925,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs b/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs index 7612951a4d..231953d887 100644 --- a/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs @@ -199,9 +199,6 @@ public MolarMass(double value, UnitSystem unitSystem) /// public static MolarMass Zero => Info.Zero; - /// - public static MolarMass AdditiveIdentity => Zero; - #endregion #region Properties @@ -236,6 +233,11 @@ public MolarMass(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -768,6 +770,15 @@ public bool Equals(MolarMass other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current MolarMass. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -804,88 +815,6 @@ public int CompareTo(MolarMass other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another MolarMass within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: 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) - { - 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. - /// - /// A hash code for the current MolarMass. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -902,6 +831,12 @@ public double As(MolarMassUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -1055,27 +990,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs b/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs index c9c6c9e98b..90f88e2078 100644 --- a/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs @@ -202,9 +202,6 @@ public Molarity(double value, UnitSystem unitSystem) /// public static Molarity Zero => Info.Zero; - /// - public static Molarity AdditiveIdentity => Zero; - #endregion #region Properties @@ -239,6 +236,11 @@ public Molarity(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -753,6 +755,15 @@ public bool Equals(Molarity other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current Molarity. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -789,88 +800,6 @@ public int CompareTo(Molarity other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another Molarity within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: 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) - { - 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. - /// - /// A hash code for the current Molarity. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -887,6 +816,12 @@ public double As(MolarityUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -1036,27 +971,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/Permeability.g.cs b/UnitsNet/GeneratedCode/Quantities/Permeability.g.cs index 95ba8d862d..d141d3a044 100644 --- a/UnitsNet/GeneratedCode/Quantities/Permeability.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Permeability.g.cs @@ -185,9 +185,6 @@ public Permeability(double value, UnitSystem unitSystem) /// public static Permeability Zero => Info.Zero; - /// - public static Permeability AdditiveIdentity => Zero; - #endregion #region Properties @@ -222,6 +219,11 @@ public Permeability(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -552,6 +554,15 @@ public bool Equals(Permeability other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current Permeability. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -588,88 +599,6 @@ public int CompareTo(Permeability other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another Permeability within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: 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) - { - 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. - /// - /// A hash code for the current Permeability. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -686,6 +615,12 @@ public double As(PermeabilityUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -815,27 +750,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/Permittivity.g.cs b/UnitsNet/GeneratedCode/Quantities/Permittivity.g.cs index 325d333446..29191ab18d 100644 --- a/UnitsNet/GeneratedCode/Quantities/Permittivity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Permittivity.g.cs @@ -185,9 +185,6 @@ public Permittivity(double value, UnitSystem unitSystem) /// public static Permittivity Zero => Info.Zero; - /// - public static Permittivity AdditiveIdentity => Zero; - #endregion #region Properties @@ -222,6 +219,11 @@ public Permittivity(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -552,6 +554,15 @@ public bool Equals(Permittivity other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current Permittivity. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -588,88 +599,6 @@ public int CompareTo(Permittivity other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another Permittivity within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: 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) - { - 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. - /// - /// A hash code for the current Permittivity. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -686,6 +615,12 @@ public double As(PermittivityUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -815,27 +750,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/PorousMediumPermeability.g.cs b/UnitsNet/GeneratedCode/Quantities/PorousMediumPermeability.g.cs index b70e2b2300..af9ec2463c 100644 --- a/UnitsNet/GeneratedCode/Quantities/PorousMediumPermeability.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/PorousMediumPermeability.g.cs @@ -189,9 +189,6 @@ public PorousMediumPermeability(double value, UnitSystem unitSystem) /// public static PorousMediumPermeability Zero => Info.Zero; - /// - public static PorousMediumPermeability AdditiveIdentity => Zero; - #endregion #region Properties @@ -226,6 +223,11 @@ public PorousMediumPermeability(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -616,6 +618,15 @@ public bool Equals(PorousMediumPermeability other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current PorousMediumPermeability. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -652,88 +663,6 @@ public int CompareTo(PorousMediumPermeability other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another PorousMediumPermeability within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: 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) - { - 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. - /// - /// A hash code for the current PorousMediumPermeability. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -750,6 +679,12 @@ public double As(PorousMediumPermeabilityUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -887,27 +822,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/Power.g.cs b/UnitsNet/GeneratedCode/Quantities/Power.g.cs index 3e85d280de..53c4b85425 100644 --- a/UnitsNet/GeneratedCode/Quantities/Power.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Power.g.cs @@ -224,9 +224,6 @@ public Power(double value, UnitSystem unitSystem) /// public static Power Zero => Info.Zero; - /// - public static Power AdditiveIdentity => Zero; - #endregion #region Properties @@ -261,6 +258,11 @@ public Power(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -1069,6 +1071,15 @@ public bool Equals(Power other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current Power. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -1105,88 +1116,6 @@ public int CompareTo(Power other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another Power within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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, double tolerance, ComparisonType comparisonType) - { - if (tolerance < 0) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: 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) - { - 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. - /// - /// A hash code for the current Power. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -1203,6 +1132,12 @@ public double As(PowerUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -1384,27 +1319,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/PowerDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/PowerDensity.g.cs index 0917699725..11fe91bfa6 100644 --- a/UnitsNet/GeneratedCode/Quantities/PowerDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/PowerDensity.g.cs @@ -225,9 +225,6 @@ public PowerDensity(double value, UnitSystem unitSystem) /// public static PowerDensity Zero => Info.Zero; - /// - public static PowerDensity AdditiveIdentity => Zero; - #endregion #region Properties @@ -262,6 +259,11 @@ public PowerDensity(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -1237,6 +1239,15 @@ public bool Equals(PowerDensity other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current PowerDensity. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -1273,88 +1284,6 @@ public int CompareTo(PowerDensity other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another PowerDensity within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: 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) - { - 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. - /// - /// A hash code for the current PowerDensity. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -1371,6 +1300,12 @@ public double As(PowerDensityUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -1586,27 +1521,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/PowerRatio.g.cs b/UnitsNet/GeneratedCode/Quantities/PowerRatio.g.cs index fcd4e6c38e..96a9d66b9c 100644 --- a/UnitsNet/GeneratedCode/Quantities/PowerRatio.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/PowerRatio.g.cs @@ -37,7 +37,7 @@ namespace UnitsNet [DataContract] [DebuggerTypeProxy(typeof(QuantityDisplay))] public readonly partial struct PowerRatio : - IArithmeticQuantity, + ILogarithmicQuantity, #if NET7_0_OR_GREATER IComparisonOperators, IParsable, @@ -169,8 +169,8 @@ public PowerRatio(double value, PowerRatioUnit unit) /// public static PowerRatio Zero => Info.Zero; - /// - public static PowerRatio AdditiveIdentity => Zero; + /// + public static double LogarithmicScalingFactor {get;} = 10; #endregion @@ -206,6 +206,15 @@ public PowerRatio(double value, PowerRatioUnit unit) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + +#if NETSTANDARD2_0 + double ILogarithmicQuantity.LogarithmicScalingFactor => LogarithmicScalingFactor; +#endif + #endregion #endregion @@ -559,6 +568,15 @@ public bool Equals(PowerRatio other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current PowerRatio. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -595,88 +613,6 @@ public int CompareTo(PowerRatio other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another PowerRatio within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: 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) - { - 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. - /// - /// A hash code for the current PowerRatio. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -693,6 +629,12 @@ public double As(PowerRatioUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -824,27 +766,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/Pressure.g.cs b/UnitsNet/GeneratedCode/Quantities/Pressure.g.cs index 3b86ec054f..b30fd6938c 100644 --- a/UnitsNet/GeneratedCode/Quantities/Pressure.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Pressure.g.cs @@ -240,9 +240,6 @@ public Pressure(double value, UnitSystem unitSystem) /// public static Pressure Zero => Info.Zero; - /// - public static Pressure AdditiveIdentity => Zero; - #endregion #region Properties @@ -277,6 +274,11 @@ public Pressure(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -1361,6 +1363,15 @@ public bool Equals(Pressure other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current Pressure. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -1397,88 +1408,6 @@ public int CompareTo(Pressure other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another Pressure within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: 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) - { - 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. - /// - /// A hash code for the current Pressure. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -1495,6 +1424,12 @@ public double As(PressureUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -1716,27 +1651,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.g.cs index ae0d38a945..17a385eb99 100644 --- a/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.g.cs @@ -202,9 +202,6 @@ public PressureChangeRate(double value, UnitSystem unitSystem) /// public static PressureChangeRate Zero => Info.Zero; - /// - public static PressureChangeRate AdditiveIdentity => Zero; - #endregion #region Properties @@ -239,6 +236,11 @@ public PressureChangeRate(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -834,6 +836,15 @@ public bool Equals(PressureChangeRate other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current PressureChangeRate. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -870,88 +881,6 @@ public int CompareTo(PressureChangeRate other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another PressureChangeRate within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: 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) - { - 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. - /// - /// A hash code for the current PressureChangeRate. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -968,6 +897,12 @@ public double As(PressureChangeRateUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -1131,27 +1066,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/RadiationEquivalentDose.g.cs b/UnitsNet/GeneratedCode/Quantities/RadiationEquivalentDose.g.cs index f911a56ced..7d1beb68af 100644 --- a/UnitsNet/GeneratedCode/Quantities/RadiationEquivalentDose.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RadiationEquivalentDose.g.cs @@ -191,9 +191,6 @@ public RadiationEquivalentDose(double value, UnitSystem unitSystem) /// public static RadiationEquivalentDose Zero => Info.Zero; - /// - public static RadiationEquivalentDose AdditiveIdentity => Zero; - #endregion #region Properties @@ -228,6 +225,11 @@ public RadiationEquivalentDose(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -649,6 +651,15 @@ public bool Equals(RadiationEquivalentDose other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current RadiationEquivalentDose. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -685,88 +696,6 @@ public int CompareTo(RadiationEquivalentDose other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another RadiationEquivalentDose within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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(RadiationEquivalentDose other, RadiationEquivalentDose tolerance) instead, 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(RadiationEquivalentDose other, double tolerance, ComparisonType comparisonType) - { - if (tolerance < 0) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: comparisonType); - } - - /// - public bool Equals(IQuantity? other, IQuantity tolerance) - { - return other is RadiationEquivalentDose otherTyped - && (tolerance is RadiationEquivalentDose toleranceTyped - ? true - : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'RadiationEquivalentDose'.", nameof(tolerance))) - && Equals(otherTyped, toleranceTyped); - } - - /// - public bool Equals(RadiationEquivalentDose other, RadiationEquivalentDose tolerance) - { - 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. - /// - /// A hash code for the current RadiationEquivalentDose. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -783,6 +712,12 @@ public double As(RadiationEquivalentDoseUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -922,27 +857,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/RadiationEquivalentDoseRate.g.cs b/UnitsNet/GeneratedCode/Quantities/RadiationEquivalentDoseRate.g.cs index fec848f8e1..ed54bb9869 100644 --- a/UnitsNet/GeneratedCode/Quantities/RadiationEquivalentDoseRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RadiationEquivalentDoseRate.g.cs @@ -194,9 +194,6 @@ public RadiationEquivalentDoseRate(double value, UnitSystem unitSystem) /// public static RadiationEquivalentDoseRate Zero => Info.Zero; - /// - public static RadiationEquivalentDoseRate AdditiveIdentity => Zero; - #endregion #region Properties @@ -231,6 +228,11 @@ public RadiationEquivalentDoseRate(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -706,6 +708,15 @@ public bool Equals(RadiationEquivalentDoseRate other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current RadiationEquivalentDoseRate. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -742,88 +753,6 @@ public int CompareTo(RadiationEquivalentDoseRate other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another RadiationEquivalentDoseRate within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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(RadiationEquivalentDoseRate other, RadiationEquivalentDoseRate tolerance) instead, 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(RadiationEquivalentDoseRate other, double tolerance, ComparisonType comparisonType) - { - if (tolerance < 0) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: comparisonType); - } - - /// - public bool Equals(IQuantity? other, IQuantity tolerance) - { - return other is RadiationEquivalentDoseRate otherTyped - && (tolerance is RadiationEquivalentDoseRate toleranceTyped - ? true - : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'RadiationEquivalentDoseRate'.", nameof(tolerance))) - && Equals(otherTyped, toleranceTyped); - } - - /// - public bool Equals(RadiationEquivalentDoseRate other, RadiationEquivalentDoseRate tolerance) - { - 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. - /// - /// A hash code for the current RadiationEquivalentDoseRate. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -840,6 +769,12 @@ public double As(RadiationEquivalentDoseRateUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -987,27 +922,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/RadiationExposure.g.cs b/UnitsNet/GeneratedCode/Quantities/RadiationExposure.g.cs index 7e971768b2..feb0a03356 100644 --- a/UnitsNet/GeneratedCode/Quantities/RadiationExposure.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RadiationExposure.g.cs @@ -189,9 +189,6 @@ public RadiationExposure(double value, UnitSystem unitSystem) /// public static RadiationExposure Zero => Info.Zero; - /// - public static RadiationExposure AdditiveIdentity => Zero; - #endregion #region Properties @@ -226,6 +223,11 @@ public RadiationExposure(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -661,6 +663,15 @@ public bool Equals(RadiationExposure other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current RadiationExposure. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -697,88 +708,6 @@ public int CompareTo(RadiationExposure other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another RadiationExposure within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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(RadiationExposure other, RadiationExposure tolerance) instead, 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(RadiationExposure other, double tolerance, ComparisonType comparisonType) - { - if (tolerance < 0) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: comparisonType); - } - - /// - public bool Equals(IQuantity? other, IQuantity tolerance) - { - return other is RadiationExposure otherTyped - && (tolerance is RadiationExposure toleranceTyped - ? true - : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'RadiationExposure'.", nameof(tolerance))) - && Equals(otherTyped, toleranceTyped); - } - - /// - public bool Equals(RadiationExposure other, RadiationExposure tolerance) - { - 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. - /// - /// A hash code for the current RadiationExposure. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -795,6 +724,12 @@ public double As(RadiationExposureUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -938,27 +873,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/Radioactivity.g.cs b/UnitsNet/GeneratedCode/Quantities/Radioactivity.g.cs index 9757e6bb89..3bd5c96307 100644 --- a/UnitsNet/GeneratedCode/Quantities/Radioactivity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Radioactivity.g.cs @@ -210,9 +210,6 @@ public Radioactivity(double value, UnitSystem unitSystem) /// public static Radioactivity Zero => Info.Zero; - /// - public static Radioactivity AdditiveIdentity => Zero; - #endregion #region Properties @@ -247,6 +244,11 @@ public Radioactivity(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -997,6 +999,15 @@ public bool Equals(Radioactivity other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current Radioactivity. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -1033,88 +1044,6 @@ public int CompareTo(Radioactivity other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another Radioactivity within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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(Radioactivity other, Radioactivity tolerance) instead, 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(Radioactivity other, double tolerance, ComparisonType comparisonType) - { - if (tolerance < 0) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: comparisonType); - } - - /// - public bool Equals(IQuantity? other, IQuantity tolerance) - { - return other is Radioactivity otherTyped - && (tolerance is Radioactivity toleranceTyped - ? true - : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'Radioactivity'.", nameof(tolerance))) - && Equals(otherTyped, toleranceTyped); - } - - /// - public bool Equals(Radioactivity other, Radioactivity tolerance) - { - 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. - /// - /// A hash code for the current Radioactivity. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -1131,6 +1060,12 @@ public double As(RadioactivityUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -1316,27 +1251,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/Ratio.g.cs b/UnitsNet/GeneratedCode/Quantities/Ratio.g.cs index c4f44088bb..e3d516ac9e 100644 --- a/UnitsNet/GeneratedCode/Quantities/Ratio.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Ratio.g.cs @@ -173,9 +173,6 @@ public Ratio(double value, RatioUnit unit) /// public static Ratio Zero => Info.Zero; - /// - public static Ratio AdditiveIdentity => Zero; - #endregion #region Properties @@ -210,6 +207,11 @@ public Ratio(double value, RatioUnit unit) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -615,6 +617,15 @@ public bool Equals(Ratio other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current Ratio. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -651,88 +662,6 @@ public int CompareTo(Ratio other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another Ratio within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: 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) - { - 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. - /// - /// A hash code for the current Ratio. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -749,6 +678,12 @@ public double As(RatioUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -888,27 +823,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/RatioChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/RatioChangeRate.g.cs index b8a19daa18..f60298a01d 100644 --- a/UnitsNet/GeneratedCode/Quantities/RatioChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RatioChangeRate.g.cs @@ -183,9 +183,6 @@ public RatioChangeRate(double value, UnitSystem unitSystem) /// public static RatioChangeRate Zero => Info.Zero; - /// - public static RatioChangeRate AdditiveIdentity => Zero; - #endregion #region Properties @@ -220,6 +217,11 @@ public RatioChangeRate(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -565,6 +567,15 @@ public bool Equals(RatioChangeRate other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current RatioChangeRate. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -601,88 +612,6 @@ public int CompareTo(RatioChangeRate other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another RatioChangeRate within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: 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) - { - 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. - /// - /// A hash code for the current RatioChangeRate. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -699,6 +628,12 @@ public double As(RatioChangeRateUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -830,27 +765,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/ReciprocalArea.g.cs b/UnitsNet/GeneratedCode/Quantities/ReciprocalArea.g.cs index 48f5421847..648acae51f 100644 --- a/UnitsNet/GeneratedCode/Quantities/ReciprocalArea.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ReciprocalArea.g.cs @@ -202,9 +202,6 @@ public ReciprocalArea(double value, UnitSystem unitSystem) /// public static ReciprocalArea Zero => Info.Zero; - /// - public static ReciprocalArea AdditiveIdentity => Zero; - #endregion #region Properties @@ -239,6 +236,11 @@ public ReciprocalArea(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -760,6 +762,15 @@ public bool Equals(ReciprocalArea other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current ReciprocalArea. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -796,88 +807,6 @@ public int CompareTo(ReciprocalArea other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another ReciprocalArea within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: 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) - { - 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. - /// - /// A hash code for the current ReciprocalArea. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -894,6 +823,12 @@ public double As(ReciprocalAreaUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -1043,27 +978,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/ReciprocalLength.g.cs b/UnitsNet/GeneratedCode/Quantities/ReciprocalLength.g.cs index 8cd64726bf..90f97170d5 100644 --- a/UnitsNet/GeneratedCode/Quantities/ReciprocalLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ReciprocalLength.g.cs @@ -203,9 +203,6 @@ public ReciprocalLength(double value, UnitSystem unitSystem) /// public static ReciprocalLength Zero => Info.Zero; - /// - public static ReciprocalLength AdditiveIdentity => Zero; - #endregion #region Properties @@ -240,6 +237,11 @@ public ReciprocalLength(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -758,6 +760,15 @@ public bool Equals(ReciprocalLength other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current ReciprocalLength. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -794,88 +805,6 @@ public int CompareTo(ReciprocalLength other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another ReciprocalLength within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: 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) - { - 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. - /// - /// A hash code for the current ReciprocalLength. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -892,6 +821,12 @@ public double As(ReciprocalLengthUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -1039,27 +974,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/RelativeHumidity.g.cs b/UnitsNet/GeneratedCode/Quantities/RelativeHumidity.g.cs index 1fb75cf635..9db3c616df 100644 --- a/UnitsNet/GeneratedCode/Quantities/RelativeHumidity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RelativeHumidity.g.cs @@ -168,9 +168,6 @@ public RelativeHumidity(double value, RelativeHumidityUnit unit) /// public static RelativeHumidity Zero => Info.Zero; - /// - public static RelativeHumidity AdditiveIdentity => Zero; - #endregion #region Properties @@ -205,6 +202,11 @@ public RelativeHumidity(double value, RelativeHumidityUnit unit) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -535,6 +537,15 @@ public bool Equals(RelativeHumidity other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current RelativeHumidity. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -571,88 +582,6 @@ public int CompareTo(RelativeHumidity other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another RelativeHumidity within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: 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) - { - 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. - /// - /// A hash code for the current RelativeHumidity. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -669,6 +598,12 @@ public double As(RelativeHumidityUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -798,27 +733,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalAcceleration.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalAcceleration.g.cs index a0b08c42c7..7e8867c607 100644 --- a/UnitsNet/GeneratedCode/Quantities/RotationalAcceleration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RotationalAcceleration.g.cs @@ -185,9 +185,6 @@ public RotationalAcceleration(double value, UnitSystem unitSystem) /// public static RotationalAcceleration Zero => Info.Zero; - /// - public static RotationalAcceleration AdditiveIdentity => Zero; - #endregion #region Properties @@ -222,6 +219,11 @@ public RotationalAcceleration(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -597,6 +599,15 @@ public bool Equals(RotationalAcceleration other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current RotationalAcceleration. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -633,88 +644,6 @@ public int CompareTo(RotationalAcceleration other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another RotationalAcceleration within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: 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) - { - 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. - /// - /// A hash code for the current RotationalAcceleration. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -731,6 +660,12 @@ public double As(RotationalAccelerationUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -866,27 +801,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.g.cs index 50fbcd9d1b..726c1ed3df 100644 --- a/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.g.cs @@ -198,9 +198,6 @@ public RotationalSpeed(double value, UnitSystem unitSystem) /// public static RotationalSpeed Zero => Info.Zero; - /// - public static RotationalSpeed AdditiveIdentity => Zero; - #endregion #region Properties @@ -235,6 +232,11 @@ public RotationalSpeed(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -761,6 +763,15 @@ public bool Equals(RotationalSpeed other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current RotationalSpeed. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -797,88 +808,6 @@ public int CompareTo(RotationalSpeed other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another RotationalSpeed within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: 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) - { - 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. - /// - /// A hash code for the current RotationalSpeed. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -895,6 +824,12 @@ public double As(RotationalSpeedUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -1048,27 +983,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.g.cs index 11d7f0bd1f..27a9381aca 100644 --- a/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.g.cs @@ -219,9 +219,6 @@ public RotationalStiffness(double value, UnitSystem unitSystem) /// public static RotationalStiffness Zero => Info.Zero; - /// - public static RotationalStiffness AdditiveIdentity => Zero; - #endregion #region Properties @@ -256,6 +253,11 @@ public RotationalStiffness(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -1088,6 +1090,15 @@ public bool Equals(RotationalStiffness other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current RotationalStiffness. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -1124,88 +1135,6 @@ public int CompareTo(RotationalStiffness other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another RotationalStiffness within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: 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) - { - 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. - /// - /// A hash code for the current RotationalStiffness. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -1222,6 +1151,12 @@ public double As(RotationalStiffnessUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -1415,27 +1350,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs index c96323fef8..036faeba54 100644 --- a/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs @@ -189,9 +189,6 @@ public RotationalStiffnessPerLength(double value, UnitSystem unitSystem) /// public static RotationalStiffnessPerLength Zero => Info.Zero; - /// - public static RotationalStiffnessPerLength AdditiveIdentity => Zero; - #endregion #region Properties @@ -226,6 +223,11 @@ public RotationalStiffnessPerLength(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -626,6 +628,15 @@ public bool Equals(RotationalStiffnessPerLength other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current RotationalStiffnessPerLength. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -662,88 +673,6 @@ public int CompareTo(RotationalStiffnessPerLength other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another RotationalStiffnessPerLength within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: 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) - { - 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. - /// - /// A hash code for the current RotationalStiffnessPerLength. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -760,6 +689,12 @@ public double As(RotationalStiffnessPerLengthUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -897,27 +832,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/Scalar.g.cs b/UnitsNet/GeneratedCode/Quantities/Scalar.g.cs index 5deaa2984b..d8c79a77f8 100644 --- a/UnitsNet/GeneratedCode/Quantities/Scalar.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Scalar.g.cs @@ -168,9 +168,6 @@ public Scalar(double value, ScalarUnit unit) /// public static Scalar Zero => Info.Zero; - /// - public static Scalar AdditiveIdentity => Zero; - #endregion #region Properties @@ -205,6 +202,11 @@ public Scalar(double value, ScalarUnit unit) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -535,6 +537,15 @@ public bool Equals(Scalar other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current Scalar. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -571,88 +582,6 @@ public int CompareTo(Scalar other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another Scalar within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: 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) - { - 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. - /// - /// A hash code for the current Scalar. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -669,6 +598,12 @@ public double As(ScalarUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -798,27 +733,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/SolidAngle.g.cs b/UnitsNet/GeneratedCode/Quantities/SolidAngle.g.cs index 7068b95303..7f5f6e0ced 100644 --- a/UnitsNet/GeneratedCode/Quantities/SolidAngle.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SolidAngle.g.cs @@ -171,9 +171,6 @@ public SolidAngle(double value, SolidAngleUnit unit) /// public static SolidAngle Zero => Info.Zero; - /// - public static SolidAngle AdditiveIdentity => Zero; - #endregion #region Properties @@ -208,6 +205,11 @@ public SolidAngle(double value, SolidAngleUnit unit) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -538,6 +540,15 @@ public bool Equals(SolidAngle other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current SolidAngle. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -574,88 +585,6 @@ public int CompareTo(SolidAngle other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another SolidAngle within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: 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) - { - 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. - /// - /// A hash code for the current SolidAngle. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -672,6 +601,12 @@ public double As(SolidAngleUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -801,27 +736,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.g.cs index 05ed5a6004..4b6f1058db 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.g.cs @@ -222,9 +222,6 @@ public SpecificEnergy(double value, UnitSystem unitSystem) /// public static SpecificEnergy Zero => Info.Zero; - /// - public static SpecificEnergy AdditiveIdentity => Zero; - #endregion #region Properties @@ -259,6 +256,11 @@ public SpecificEnergy(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -1070,6 +1072,15 @@ public bool Equals(SpecificEnergy other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current SpecificEnergy. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -1106,88 +1117,6 @@ public int CompareTo(SpecificEnergy other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another SpecificEnergy within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: 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) - { - 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. - /// - /// A hash code for the current SpecificEnergy. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -1204,6 +1133,12 @@ public double As(SpecificEnergyUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -1391,27 +1326,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.g.cs index 04b4c83b10..0c61990840 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.g.cs @@ -194,9 +194,6 @@ public SpecificEntropy(double value, UnitSystem unitSystem) /// public static SpecificEntropy Zero => Info.Zero; - /// - public static SpecificEntropy AdditiveIdentity => Zero; - #endregion #region Properties @@ -231,6 +228,11 @@ public SpecificEntropy(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -697,6 +699,15 @@ public bool Equals(SpecificEntropy other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current SpecificEntropy. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -733,88 +744,6 @@ public int CompareTo(SpecificEntropy other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another SpecificEntropy within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: 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) - { - 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. - /// - /// A hash code for the current SpecificEntropy. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -831,6 +760,12 @@ public double As(SpecificEntropyUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -976,27 +911,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs index 2f6aed63bb..05f6bf02d9 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs @@ -188,9 +188,6 @@ public SpecificFuelConsumption(double value, UnitSystem unitSystem) /// public static SpecificFuelConsumption Zero => Info.Zero; - /// - public static SpecificFuelConsumption AdditiveIdentity => Zero; - #endregion #region Properties @@ -225,6 +222,11 @@ public SpecificFuelConsumption(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -600,6 +602,15 @@ public bool Equals(SpecificFuelConsumption other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current SpecificFuelConsumption. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -636,88 +647,6 @@ public int CompareTo(SpecificFuelConsumption other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another SpecificFuelConsumption within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: 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) - { - 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. - /// - /// A hash code for the current SpecificFuelConsumption. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -734,6 +663,12 @@ public double As(SpecificFuelConsumptionUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -869,27 +804,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs index fc38800fae..007359f236 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs @@ -187,9 +187,6 @@ public SpecificVolume(double value, UnitSystem unitSystem) /// public static SpecificVolume Zero => Info.Zero; - /// - public static SpecificVolume AdditiveIdentity => Zero; - #endregion #region Properties @@ -224,6 +221,11 @@ public SpecificVolume(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -601,6 +603,15 @@ public bool Equals(SpecificVolume other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current SpecificVolume. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -637,88 +648,6 @@ public int CompareTo(SpecificVolume other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another SpecificVolume within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: 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) - { - 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. - /// - /// A hash code for the current SpecificVolume. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -735,6 +664,12 @@ public double As(SpecificVolumeUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -868,27 +803,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificWeight.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificWeight.g.cs index cfbdb2525d..e6b5997a68 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificWeight.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificWeight.g.cs @@ -207,9 +207,6 @@ public SpecificWeight(double value, UnitSystem unitSystem) /// public static SpecificWeight Zero => Info.Zero; - /// - public static SpecificWeight AdditiveIdentity => Zero; - #endregion #region Properties @@ -244,6 +241,11 @@ public SpecificWeight(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -842,6 +844,15 @@ public bool Equals(SpecificWeight other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current SpecificWeight. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -878,88 +889,6 @@ public int CompareTo(SpecificWeight other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another SpecificWeight within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: 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) - { - 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. - /// - /// A hash code for the current SpecificWeight. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -976,6 +905,12 @@ public double As(SpecificWeightUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -1137,27 +1072,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/Speed.g.cs b/UnitsNet/GeneratedCode/Quantities/Speed.g.cs index d131274bf6..d239be94c2 100644 --- a/UnitsNet/GeneratedCode/Quantities/Speed.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Speed.g.cs @@ -224,9 +224,6 @@ public Speed(double value, UnitSystem unitSystem) /// public static Speed Zero => Info.Zero; - /// - public static Speed AdditiveIdentity => Zero; - #endregion #region Properties @@ -261,6 +258,11 @@ public Speed(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -1123,6 +1125,15 @@ public bool Equals(Speed other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current Speed. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -1159,88 +1170,6 @@ public int CompareTo(Speed other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another Speed within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: 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) - { - 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. - /// - /// A hash code for the current Speed. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -1257,6 +1186,12 @@ public double As(SpeedUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -1450,27 +1385,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/StandardVolumeFlow.g.cs b/UnitsNet/GeneratedCode/Quantities/StandardVolumeFlow.g.cs index 69b25724d1..a724bfcc7d 100644 --- a/UnitsNet/GeneratedCode/Quantities/StandardVolumeFlow.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/StandardVolumeFlow.g.cs @@ -190,9 +190,6 @@ public StandardVolumeFlow(double value, UnitSystem unitSystem) /// public static StandardVolumeFlow Zero => Info.Zero; - /// - public static StandardVolumeFlow AdditiveIdentity => Zero; - #endregion #region Properties @@ -227,6 +224,11 @@ public StandardVolumeFlow(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -677,6 +679,15 @@ public bool Equals(StandardVolumeFlow other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current StandardVolumeFlow. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -713,88 +724,6 @@ public int CompareTo(StandardVolumeFlow other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another StandardVolumeFlow within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: 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) - { - 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. - /// - /// A hash code for the current StandardVolumeFlow. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -811,6 +740,12 @@ public double As(StandardVolumeFlowUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -956,27 +891,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/Temperature.g.cs b/UnitsNet/GeneratedCode/Quantities/Temperature.g.cs index dacd7a803c..00e544ea4d 100644 --- a/UnitsNet/GeneratedCode/Quantities/Temperature.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Temperature.g.cs @@ -37,7 +37,7 @@ namespace UnitsNet [DataContract] [DebuggerTypeProxy(typeof(QuantityDisplay))] public readonly partial struct Temperature : - IQuantity, + IAffineQuantity, #if NET7_0_OR_GREATER IComparisonOperators, IParsable, @@ -225,6 +225,11 @@ public Temperature(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -644,6 +649,15 @@ public bool Equals(Temperature other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current Temperature. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -680,88 +694,6 @@ public int CompareTo(Temperature other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another Temperature within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: 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) - { - 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. - /// - /// A hash code for the current Temperature. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -778,6 +710,12 @@ public double As(TemperatureUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -925,27 +863,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.g.cs index 22a77ba5a9..260f7aaa18 100644 --- a/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.g.cs @@ -201,9 +201,6 @@ public TemperatureChangeRate(double value, UnitSystem unitSystem) /// public static TemperatureChangeRate Zero => Info.Zero; - /// - public static TemperatureChangeRate AdditiveIdentity => Zero; - #endregion #region Properties @@ -238,6 +235,11 @@ public TemperatureChangeRate(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -818,6 +820,15 @@ public bool Equals(TemperatureChangeRate other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current TemperatureChangeRate. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -854,88 +865,6 @@ public int CompareTo(TemperatureChangeRate other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another TemperatureChangeRate within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: 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) - { - 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. - /// - /// A hash code for the current TemperatureChangeRate. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -952,6 +881,12 @@ public double As(TemperatureChangeRateUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -1113,27 +1048,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs b/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs index e1b926a283..7a7a225532 100644 --- a/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs @@ -199,9 +199,6 @@ public TemperatureDelta(double value, UnitSystem unitSystem) /// public static TemperatureDelta Zero => Info.Zero; - /// - public static TemperatureDelta AdditiveIdentity => Zero; - #endregion #region Properties @@ -236,6 +233,11 @@ public TemperatureDelta(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -732,6 +734,15 @@ public bool Equals(TemperatureDelta other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current TemperatureDelta. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -768,88 +779,6 @@ public int CompareTo(TemperatureDelta other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another TemperatureDelta within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: 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) - { - 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. - /// - /// A hash code for the current TemperatureDelta. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -866,6 +795,12 @@ public double As(TemperatureDeltaUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -1011,27 +946,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/TemperatureGradient.g.cs b/UnitsNet/GeneratedCode/Quantities/TemperatureGradient.g.cs index 5ac707477b..4fa3d32e69 100644 --- a/UnitsNet/GeneratedCode/Quantities/TemperatureGradient.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/TemperatureGradient.g.cs @@ -188,9 +188,6 @@ public TemperatureGradient(double value, UnitSystem unitSystem) /// public static TemperatureGradient Zero => Info.Zero; - /// - public static TemperatureGradient AdditiveIdentity => Zero; - #endregion #region Properties @@ -225,6 +222,11 @@ public TemperatureGradient(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -610,6 +612,15 @@ public bool Equals(TemperatureGradient other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current TemperatureGradient. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -646,88 +657,6 @@ public int CompareTo(TemperatureGradient other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another TemperatureGradient within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: 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) - { - 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. - /// - /// A hash code for the current TemperatureGradient. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -744,6 +673,12 @@ public double As(TemperatureGradientUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -879,27 +814,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/ThermalConductivity.g.cs b/UnitsNet/GeneratedCode/Quantities/ThermalConductivity.g.cs index e847e024ec..28c8bf9809 100644 --- a/UnitsNet/GeneratedCode/Quantities/ThermalConductivity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ThermalConductivity.g.cs @@ -186,9 +186,6 @@ public ThermalConductivity(double value, UnitSystem unitSystem) /// public static ThermalConductivity Zero => Info.Zero; - /// - public static ThermalConductivity AdditiveIdentity => Zero; - #endregion #region Properties @@ -223,6 +220,11 @@ public ThermalConductivity(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -568,6 +570,15 @@ public bool Equals(ThermalConductivity other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current ThermalConductivity. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -604,88 +615,6 @@ public int CompareTo(ThermalConductivity other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another ThermalConductivity within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: 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) - { - 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. - /// - /// A hash code for the current ThermalConductivity. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -702,6 +631,12 @@ public double As(ThermalConductivityUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -833,27 +768,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/ThermalInsulance.g.cs b/UnitsNet/GeneratedCode/Quantities/ThermalInsulance.g.cs index 5e66daa43e..2df6ea38a1 100644 --- a/UnitsNet/GeneratedCode/Quantities/ThermalInsulance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ThermalInsulance.g.cs @@ -188,9 +188,6 @@ public ThermalInsulance(double value, UnitSystem unitSystem) /// public static ThermalInsulance Zero => Info.Zero; - /// - public static ThermalInsulance AdditiveIdentity => Zero; - #endregion #region Properties @@ -225,6 +222,11 @@ public ThermalInsulance(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -645,6 +647,15 @@ public bool Equals(ThermalInsulance other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current ThermalInsulance. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -681,88 +692,6 @@ public int CompareTo(ThermalInsulance other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another ThermalInsulance within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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(ThermalInsulance other, ThermalInsulance tolerance) instead, 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(ThermalInsulance other, double tolerance, ComparisonType comparisonType) - { - if (tolerance < 0) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: comparisonType); - } - - /// - public bool Equals(IQuantity? other, IQuantity tolerance) - { - return other is ThermalInsulance otherTyped - && (tolerance is ThermalInsulance toleranceTyped - ? true - : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'ThermalInsulance'.", nameof(tolerance))) - && Equals(otherTyped, toleranceTyped); - } - - /// - public bool Equals(ThermalInsulance other, ThermalInsulance tolerance) - { - 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. - /// - /// A hash code for the current ThermalInsulance. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -779,6 +708,12 @@ public double As(ThermalInsulanceUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -920,27 +855,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/ThermalResistance.g.cs b/UnitsNet/GeneratedCode/Quantities/ThermalResistance.g.cs index ffe4006c47..1257be0638 100644 --- a/UnitsNet/GeneratedCode/Quantities/ThermalResistance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ThermalResistance.g.cs @@ -183,9 +183,6 @@ public ThermalResistance(double value, UnitSystem unitSystem) /// public static ThermalResistance Zero => Info.Zero; - /// - public static ThermalResistance AdditiveIdentity => Zero; - #endregion #region Properties @@ -220,6 +217,11 @@ public ThermalResistance(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -565,6 +567,15 @@ public bool Equals(ThermalResistance other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current ThermalResistance. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -601,88 +612,6 @@ public int CompareTo(ThermalResistance other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another ThermalResistance within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: 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) - { - 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. - /// - /// A hash code for the current ThermalResistance. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -699,6 +628,12 @@ public double As(ThermalResistanceUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -830,27 +765,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/Torque.g.cs b/UnitsNet/GeneratedCode/Quantities/Torque.g.cs index d5ea323587..c1e4597788 100644 --- a/UnitsNet/GeneratedCode/Quantities/Torque.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Torque.g.cs @@ -215,9 +215,6 @@ public Torque(double value, UnitSystem unitSystem) /// public static Torque Zero => Info.Zero; - /// - public static Torque AdditiveIdentity => Zero; - #endregion #region Properties @@ -252,6 +249,11 @@ public Torque(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -988,6 +990,15 @@ public bool Equals(Torque other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current Torque. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -1024,88 +1035,6 @@ public int CompareTo(Torque other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another Torque within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: 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) - { - 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. - /// - /// A hash code for the current Torque. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -1122,6 +1051,12 @@ public double As(TorqueUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -1299,27 +1234,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/Turbidity.g.cs b/UnitsNet/GeneratedCode/Quantities/Turbidity.g.cs index 6472bef18c..a133506a51 100644 --- a/UnitsNet/GeneratedCode/Quantities/Turbidity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Turbidity.g.cs @@ -171,9 +171,6 @@ public Turbidity(double value, TurbidityUnit unit) /// public static Turbidity Zero => Info.Zero; - /// - public static Turbidity AdditiveIdentity => Zero; - #endregion #region Properties @@ -208,6 +205,11 @@ public Turbidity(double value, TurbidityUnit unit) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -538,6 +540,15 @@ public bool Equals(Turbidity other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current Turbidity. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -574,88 +585,6 @@ public int CompareTo(Turbidity other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another Turbidity within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: 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) - { - 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. - /// - /// A hash code for the current Turbidity. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -672,6 +601,12 @@ public double As(TurbidityUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -801,27 +736,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/VitaminA.g.cs b/UnitsNet/GeneratedCode/Quantities/VitaminA.g.cs index 3c59c1310e..09c4904e53 100644 --- a/UnitsNet/GeneratedCode/Quantities/VitaminA.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VitaminA.g.cs @@ -168,9 +168,6 @@ public VitaminA(double value, VitaminAUnit unit) /// public static VitaminA Zero => Info.Zero; - /// - public static VitaminA AdditiveIdentity => Zero; - #endregion #region Properties @@ -205,6 +202,11 @@ public VitaminA(double value, VitaminAUnit unit) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -535,6 +537,15 @@ public bool Equals(VitaminA other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current VitaminA. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -571,88 +582,6 @@ public int CompareTo(VitaminA other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another VitaminA within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: 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) - { - 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. - /// - /// A hash code for the current VitaminA. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -669,6 +598,12 @@ public double As(VitaminAUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -798,27 +733,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/Volume.g.cs b/UnitsNet/GeneratedCode/Quantities/Volume.g.cs index b4446c02b9..676672f58a 100644 --- a/UnitsNet/GeneratedCode/Quantities/Volume.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Volume.g.cs @@ -250,9 +250,6 @@ public Volume(double value, UnitSystem unitSystem) /// public static Volume Zero => Info.Zero; - /// - public static Volume AdditiveIdentity => Zero; - #endregion #region Properties @@ -287,6 +284,11 @@ public Volume(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -1494,6 +1496,15 @@ public bool Equals(Volume other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current Volume. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -1530,88 +1541,6 @@ public int CompareTo(Volume other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another Volume within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: 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) - { - 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. - /// - /// A hash code for the current Volume. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -1628,6 +1557,12 @@ public double As(VolumeUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -1863,27 +1798,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/VolumeConcentration.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumeConcentration.g.cs index 6ffc93ce8f..4a93f47b3c 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumeConcentration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumeConcentration.g.cs @@ -194,9 +194,6 @@ public VolumeConcentration(double value, VolumeConcentrationUnit unit) /// public static VolumeConcentration Zero => Info.Zero; - /// - public static VolumeConcentration AdditiveIdentity => Zero; - #endregion #region Properties @@ -231,6 +228,11 @@ public VolumeConcentration(double value, VolumeConcentrationUnit unit) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -862,6 +864,15 @@ public bool Equals(VolumeConcentration other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current VolumeConcentration. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -898,88 +909,6 @@ public int CompareTo(VolumeConcentration other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another VolumeConcentration within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: 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) - { - 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. - /// - /// A hash code for the current VolumeConcentration. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -996,6 +925,12 @@ public double As(VolumeConcentrationUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -1163,27 +1098,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs index 11adbe9845..f482c6a26f 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs @@ -263,9 +263,6 @@ public VolumeFlow(double value, UnitSystem unitSystem) /// public static VolumeFlow Zero => Info.Zero; - /// - public static VolumeFlow AdditiveIdentity => Zero; - #endregion #region Properties @@ -300,6 +297,11 @@ public VolumeFlow(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -1774,6 +1776,15 @@ public bool Equals(VolumeFlow other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current VolumeFlow. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -1810,88 +1821,6 @@ public int CompareTo(VolumeFlow other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another VolumeFlow within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: 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) - { - 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. - /// - /// A hash code for the current VolumeFlow. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -1908,6 +1837,12 @@ public double As(VolumeFlowUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -2185,27 +2120,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/VolumeFlowPerArea.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumeFlowPerArea.g.cs index 9eabd7a7a6..5aeb638a71 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumeFlowPerArea.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumeFlowPerArea.g.cs @@ -183,9 +183,6 @@ public VolumeFlowPerArea(double value, UnitSystem unitSystem) /// public static VolumeFlowPerArea Zero => Info.Zero; - /// - public static VolumeFlowPerArea AdditiveIdentity => Zero; - #endregion #region Properties @@ -220,6 +217,11 @@ public VolumeFlowPerArea(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -565,6 +567,15 @@ public bool Equals(VolumeFlowPerArea other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current VolumeFlowPerArea. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -601,88 +612,6 @@ public int CompareTo(VolumeFlowPerArea other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another VolumeFlowPerArea within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: 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) - { - 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. - /// - /// A hash code for the current VolumeFlowPerArea. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -699,6 +628,12 @@ public double As(VolumeFlowPerAreaUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -830,27 +765,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/VolumePerLength.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumePerLength.g.cs index d843c982c9..d5c295c893 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumePerLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumePerLength.g.cs @@ -190,9 +190,6 @@ public VolumePerLength(double value, UnitSystem unitSystem) /// public static VolumePerLength Zero => Info.Zero; - /// - public static VolumePerLength AdditiveIdentity => Zero; - #endregion #region Properties @@ -227,6 +224,11 @@ public VolumePerLength(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -677,6 +679,15 @@ public bool Equals(VolumePerLength other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current VolumePerLength. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -713,88 +724,6 @@ public int CompareTo(VolumePerLength other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another VolumePerLength within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: 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) - { - 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. - /// - /// A hash code for the current VolumePerLength. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -811,6 +740,12 @@ public double As(VolumePerLengthUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -956,27 +891,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs index 082c5e03c1..63e358667d 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs @@ -193,9 +193,6 @@ public VolumetricHeatCapacity(double value, UnitSystem unitSystem) /// public static VolumetricHeatCapacity Zero => Info.Zero; - /// - public static VolumetricHeatCapacity AdditiveIdentity => Zero; - #endregion #region Properties @@ -230,6 +227,11 @@ public VolumetricHeatCapacity(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -680,6 +682,15 @@ public bool Equals(VolumetricHeatCapacity other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current VolumetricHeatCapacity. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -716,88 +727,6 @@ public int CompareTo(VolumetricHeatCapacity other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another VolumetricHeatCapacity within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: 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) - { - 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. - /// - /// A hash code for the current VolumetricHeatCapacity. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -814,6 +743,12 @@ public double As(VolumetricHeatCapacityUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -959,27 +894,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs b/UnitsNet/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs index 9f977d6156..ce5f88386a 100644 --- a/UnitsNet/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs @@ -187,9 +187,6 @@ public WarpingMomentOfInertia(double value, UnitSystem unitSystem) /// public static WarpingMomentOfInertia Zero => Info.Zero; - /// - public static WarpingMomentOfInertia AdditiveIdentity => Zero; - #endregion #region Properties @@ -224,6 +221,11 @@ public WarpingMomentOfInertia(double value, UnitSystem unitSystem) [DebuggerBrowsable(DebuggerBrowsableState.Never)] QuantityInfo IQuantity.QuantityInfo => Info; +#if NETSTANDARD2_0 + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; +#endif + #endregion #endregion @@ -629,6 +631,15 @@ public bool Equals(WarpingMomentOfInertia other) #pragma warning restore CS0809 + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current WarpingMomentOfInertia. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. /// An object to compare with this instance. /// @@ -665,88 +676,6 @@ public int CompareTo(WarpingMomentOfInertia other) return _value.CompareTo(other.ToUnit(this.Unit).Value); } - /// - /// - /// Compare equality to another WarpingMomentOfInertia within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// 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.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using double internally. - /// - /// - /// The other quantity to compare to. - /// 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) - throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - - return UnitsNet.Comparison.Equals( - referenceValue: this.Value, - otherValue: other.As(this.Unit), - tolerance: tolerance, - comparisonType: 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) - { - 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. - /// - /// A hash code for the current WarpingMomentOfInertia. - public override int GetHashCode() - { - return new { Info.Name, Value, Unit }.GetHashCode(); - } - #endregion #region Conversion Methods @@ -763,6 +692,12 @@ public double As(WarpingMomentOfInertiaUnit unit) return ToUnit(unit).Value; } + /// + public double As(UnitKey unitKey) + { + return As(unitKey.ToUnit()); + } + /// public double As(UnitSystem unitSystem) { @@ -902,27 +837,6 @@ public override string ToString() return ToString(null, null); } - /// - /// Gets the default string representation of value and unit using the given format provider. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - public string ToString(IFormatProvider? provider) - { - return ToString(null, provider); - } - - /// - /// - /// Gets the string representation of this instance in the specified format string using . - /// - /// The format string. - /// The string representation. - public string ToString(string? format) - { - return ToString(format, null); - } - /// /// /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. diff --git a/UnitsNet/IArithmeticQuantity.cs b/UnitsNet/IArithmeticQuantity.cs index 7bb86eaa4e..6ecfc1adb4 100644 --- a/UnitsNet/IArithmeticQuantity.cs +++ b/UnitsNet/IArithmeticQuantity.cs @@ -1,20 +1,60 @@ -// Licensed under MIT No Attribution, see LICENSE file at the root. +// 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; +#if NET using System.Numerics; +#endif namespace UnitsNet; /// -/// An that (in .NET 7+) implements generic math interfaces for arithmetic operations. +/// Represents a quantity that has both magnitude and direction, supporting various arithmetic operations and +/// comparisons. +/// +/// +/// This interface defines standard linear arithmetic operations such as addition, subtraction, multiplication, and +/// division. +/// These types of quantities naturally support comparison operations with either absolute or relative tolerance, which +/// is useful for determining equality within a certain margin of error. +/// +/// For more information, see the Wikipedia page on +/// +/// Dimensional +/// Analysis +/// +/// . +/// +/// +/// The type that implements this interface. +public interface ILinearQuantity : IQuantityInstance +#if NET7_0_OR_GREATER + , IAdditiveIdentity +#endif + where TSelf : ILinearQuantity +{ +#if NET7_0_OR_GREATER + /// + /// The zero value of this quantity. + /// + static abstract TSelf Zero { get; } + + static TSelf IAdditiveIdentity.AdditiveIdentity + { + get => TSelf.Zero; + } + +#endif +} + +/// +/// An that (in .NET 7+) implements generic math interfaces for arithmetic +/// operations. /// /// The type itself, for the CRT pattern. /// The underlying unit enum type. -public interface IArithmeticQuantity : IQuantity +public interface IArithmeticQuantity : IQuantity, ILinearQuantity #if NET7_0_OR_GREATER , IAdditionOperators - , IAdditiveIdentity , ISubtractionOperators , IMultiplyOperators , IDivisionOperators @@ -23,10 +63,4 @@ public interface IArithmeticQuantity : IQuantity where TUnitType : struct, Enum { -#if NET7_0_OR_GREATER - /// - /// The zero value of this quantity. - /// - static abstract TSelf Zero { get; } -#endif } diff --git a/UnitsNet/IQuantity.cs b/UnitsNet/IQuantity.cs index cf254e0642..214368f272 100644 --- a/UnitsNet/IQuantity.cs +++ b/UnitsNet/IQuantity.cs @@ -1,7 +1,10 @@ // 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.Globalization; +#if NET7_0_OR_GREATER +using System.Numerics; + +#endif namespace UnitsNet { @@ -28,6 +31,14 @@ public interface IQuantity : IFormattable /// Wrong unit enum type was given. double As(Enum unit); + /// + /// Gets the value in the given unit key. + /// + /// The unit key. The unit type must be compatible, so for you should provide a value. + /// Value converted to the specified unit. + /// Wrong unit enum type was given. + double As(UnitKey unitKey); + /// /// Gets the value in the unit determined by the given . If multiple units were found for the given , /// the first match will be used. @@ -36,29 +47,6 @@ 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. /// @@ -81,20 +69,13 @@ public interface IQuantity : IFormattable IQuantity ToUnit(Enum unit); /// - /// Converts to a quantity with a unit determined by the given , which affects things like . + /// Converts to a quantity with a unit determined by the given . /// If multiple units were found for the given , the first match will be used. /// /// The to convert the quantity to. /// A new quantity with the determined unit. IQuantity ToUnit(UnitSystem unitSystem); - /// - /// Gets the string representation of value and unit. Uses two significant digits after radix. - /// - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - string ToString(IFormatProvider? provider); - /// /// Gets the unique key for the unit type and its corresponding value. /// @@ -136,13 +117,8 @@ public interface IQuantity : IQuantity /// Conversion was not possible from this to . /// A new in the given . IQuantity ToUnit(TUnitType unit); - - /// - /// Converts to a quantity with a unit determined by the given , which affects things like . - /// If multiple units were found for the given , the first match will be used. - /// - /// The to convert the quantity to. - /// A new quantity with the determined unit. + + /// new IQuantity ToUnit(UnitSystem unitSystem); #if NET @@ -164,41 +140,36 @@ Enum IQuantity.Unit #endif } + /// + /// + /// This is a specialization of that is used (internally) for constraining certain + /// methods, without having to include the unit type as additional generic parameter. + /// + /// + public interface IQuantityInstance : IQuantity + where TQuantity : IQuantity + { +#if NET + internal static abstract TQuantity Create(double value, UnitKey unit); +#else + /// + new IQuantityInstanceInfo QuantityInfo { get; } +#endif + } + /// /// An that supports generic equality comparison with tolerance. /// /// The type itself, for the CRT pattern. /// The underlying unit enum type. - public interface IQuantity : IQuantity + public interface IQuantity : IQuantityInstance, IQuantity where TSelf : IQuantity where TUnitType : struct, Enum { - /// - /// - /// 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); - /// new QuantityInfo QuantityInfo { get; } -#if NET7_0_OR_GREATER +#if NET /// /// Creates an instance of the quantity from a specified value and unit. /// @@ -207,6 +178,121 @@ public interface IQuantity : IQuantity /// An instance of the quantity with the specified value and unit. static abstract TSelf From(double value, TUnitType unit); + static TSelf IQuantityInstance.Create(double value, UnitKey unit) => TSelf.From(value, unit.ToUnit()); + + IQuantity IQuantity.ToUnit(TUnitType unit) + { + return TSelf.From(As(unit), unit); + } + + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) + { + TUnitType unit = QuantityInfo.GetDefaultUnit(unitSystem); + return ToUnit(unit); + } + #endif + + } + + /// + /// An that (in .NET 7+) implements generic math interfaces for arithmetic operations. + /// + /// The type itself, for the CRT pattern. + /// + public interface IAffineQuantity : IQuantityInstance + #if NET7_0_OR_GREATER + , IAdditiveIdentity + where TOffset : IAdditiveIdentity + #endif + where TSelf : IAffineQuantity + { + #if NET7_0_OR_GREATER + /// + /// The zero value of this quantity. + /// + static abstract TSelf Zero { get; } + + static TOffset IAdditiveIdentity.AdditiveIdentity => TOffset.AdditiveIdentity; + #endif + } + + /// + /// An that (in .NET 7+) implements generic math interfaces for arithmetic operations. + /// + /// The type itself, for the CRT pattern. + /// The underlying unit enum type. + /// + public interface IAffineQuantity : IQuantity, IAffineQuantity + #if NET7_0_OR_GREATER + , IAdditionOperators + , ISubtractionOperators + where TOffset : IAdditiveIdentity + #endif + where TSelf : IAffineQuantity + where TUnitType : struct, Enum + { + } + + + /// + /// Represents a logarithmic quantity that supports arithmetic operations and implements generic math interfaces + /// (in .NET 7+). This interface is designed for quantities that are logarithmic in nature, such as decibels. + /// + /// The type itself, for the CRT pattern. + /// + /// Logarithmic quantities are different from linear quantities in that they represent values on a logarithmic scale. + /// This interface extends and provides additional functionality specific + /// to logarithmic quantities, including arithmetic operations and a logarithmic scaling factor. + /// The logarithmic scale assumed here is base-10. + /// + public interface ILogarithmicQuantity : IQuantityInstance + #if NET7_0_OR_GREATER + , IMultiplicativeIdentity + #endif + where TSelf : ILogarithmicQuantity + { + #if NET7_0_OR_GREATER + /// + /// Gets the logarithmic scaling factor used to convert between linear and logarithmic units. + /// This factor is typically 10, but there are exceptions such as the PowerRatio, which uses 20. + /// + /// + /// The logarithmic scaling factor. + /// + static abstract double LogarithmicScalingFactor { get; } + + /// + /// The zero value of this quantity. + /// + static abstract TSelf Zero { get; } + + static TSelf IMultiplicativeIdentity.MultiplicativeIdentity => TSelf.Zero; + #else + /// + /// Gets the logarithmic scaling factor used to convert between linear and logarithmic units. + /// This factor is typically 10, but there are exceptions such as the PowerRatio, which uses 20. + /// + /// + /// The logarithmic scaling factor. + /// + double LogarithmicScalingFactor { get; } + #endif + } + + /// + /// The type itself, for the CRT pattern. + /// The underlying unit enum type. + public interface ILogarithmicQuantity : IQuantity, ILogarithmicQuantity + #if NET7_0_OR_GREATER + , IAdditionOperators + , ISubtractionOperators + , IMultiplyOperators + , IDivisionOperators + , IUnaryNegationOperators + #endif + where TSelf : ILogarithmicQuantity + where TUnitType : struct, Enum + { } } diff --git a/UnitsNet/QuantityTypeConverter.cs b/UnitsNet/QuantityTypeConverter.cs index eb98248e31..ad4350abef 100644 --- a/UnitsNet/QuantityTypeConverter.cs +++ b/UnitsNet/QuantityTypeConverter.cs @@ -59,7 +59,7 @@ public ConvertToUnitAttribute(object? unitType) : base(unitType) { } public class DisplayAsUnitAttribute : DefaultUnitAttribute { /// - /// The formatting used when the quantity is converted to string. See + /// The formatting used when the quantity is converted to string. See for more information about the supported formats. /// public string Format { get; set; } @@ -67,7 +67,7 @@ public class DisplayAsUnitAttribute : DefaultUnitAttribute /// Initializes a new instance of the class. /// /// The unit the quantity should be displayed in - /// Formatting string + /// Formatting string passed to the public DisplayAsUnitAttribute(object? unitType, string format = "G") : base(unitType) { Format = format; @@ -224,22 +224,22 @@ public override bool CanConvertTo(ITypeDescriptorContext? context, Type? destina { DisplayAsUnitAttribute? displayAsUnit = GetAttribute(context); - if (value is not IQuantity qvalue || destinationType != typeof(string)) + if (value is not IQuantity quantity || destinationType != typeof(string)) { return base.ConvertTo(context, culture, value, destinationType); } if (displayAsUnit == null) { - return qvalue.ToString(culture); + return quantity.ToString(culture); } if (displayAsUnit.UnitType == null) { - return qvalue.ToString(displayAsUnit.Format, culture); + return quantity.ToString(displayAsUnit.Format, culture); } - return qvalue.ToUnit(displayAsUnit.UnitType).ToString(displayAsUnit.Format, culture); + return quantity.ToUnit(displayAsUnit.UnitType).ToString(displayAsUnit.Format, culture); } } } diff --git a/UnitsNet/UnitMath.cs b/UnitsNet/UnitMath.cs index e68099184f..e9130bda08 100644 --- a/UnitsNet/UnitMath.cs +++ b/UnitsNet/UnitMath.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Numerics; namespace UnitsNet { @@ -9,56 +10,30 @@ namespace UnitsNet /// public static class UnitMath { - /// Returns the absolute value of a . - /// - /// A quantity with a value that is greater than or equal to , - /// but less than or equal to . - /// - /// A quantity with a value, such that 0 ≤ value ≤ . - public static TQuantity Abs(this TQuantity value) where TQuantity : IQuantity - { - return value.Value >= 0 ? value : (TQuantity) Quantity.From(-value.Value, value.Unit); - } - - /// Computes the sum of a sequence of values. - /// A sequence of values to calculate the sum of. - /// The desired unit type for the resulting quantity - /// The sum of the values in the sequence, represented in the specified unit type. - /// - /// source is null. - /// - /// - /// source contains quantity types different from . - /// - public static TQuantity Sum(this IEnumerable source, TUnitType unitType) - where TUnitType : struct, Enum - where TQuantity : IQuantity - { - return (TQuantity) Quantity.From(source.Sum(x => x.As(unitType)), unitType); - } - /// - /// Computes the sum of the sequence of values that are obtained by invoking a - /// transform function on each element of the input sequence. + /// Returns the absolute value of the specified quantity. /// - /// A sequence of values that are used to calculate a sum. - /// A transform function to apply to each element. - /// The desired unit type for the resulting quantity - /// The type of the elements of source. - /// The type of quantity that is produced by this operation. - /// The type of unit enum. - /// The sum of the projected values, represented in the specified unit type. - /// - /// source or selector is null. - /// - /// - /// source contains quantity types different from . + /// + /// The type of the quantity, which must implement . + /// + /// + /// The quantity whose absolute value is to be calculated. + /// + /// + /// A quantity of type representing the absolute value of the input quantity. + /// + /// + /// Thrown if the input is null. /// - public static TQuantity Sum(this IEnumerable source, Func selector, TUnitType unitType) - where TUnitType : struct, Enum - where TQuantity : IQuantity + public static TQuantity Abs(this TQuantity value) where TQuantity : IQuantity { - return source.Select(selector).Sum(unitType); + // TODO see about constraining to IQuantityInstance +// #if NET +// return TQuantity.Create(QuantityValue.Abs(value.Value), value.UnitKey); +// #else +// return value.QuantityInfo.Create(QuantityValue.Abs(value.Value), value.UnitKey); +// #endif + return (TQuantity)value.QuantityInfo.From(Math.Abs(value.Value), value.UnitKey); } /// Returns the smaller of two values. @@ -66,7 +41,8 @@ public static TQuantity Sum(this IEnumerableThe first of two values to compare. /// The second of two values to compare. /// Parameter or , whichever is smaller. - public static TQuantity Min(TQuantity val1, TQuantity val2) where TQuantity : IComparable, IQuantity + public static TQuantity Min(TQuantity val1, TQuantity val2) + where TQuantity : IQuantity, IComparable { return val1.CompareTo(val2) == 1 ? val2 : val1; } @@ -82,11 +58,12 @@ public static TQuantity Min(TQuantity val1, TQuantity val2) where TQu /// /// source contains quantity types different from . /// + [Obsolete("Duplicate of System.Linq.Min")] public static TQuantity Min(this IEnumerable source, TUnitType unitType) where TUnitType : struct, Enum where TQuantity : IQuantity { - return (TQuantity) Quantity.From(source.Min(x => x.As(unitType)), unitType); + return (TQuantity) Quantity.From(source.Min(x => x.As(unitType)), UnitKey.ForUnit(unitType)); } /// @@ -107,9 +84,10 @@ public static TQuantity Min(this IEnumerable so /// /// source contains quantity types different from . /// + [Obsolete("Duplicate of System.Linq.Min")] public static TQuantity Min(this IEnumerable source, Func selector, TUnitType unitType) - where TUnitType : struct, Enum where TQuantity : IQuantity + where TUnitType : struct, Enum { return source.Select(selector).Min(unitType); } @@ -119,7 +97,8 @@ public static TQuantity Min(this IEnumerableThe first of two values to compare. /// The second of two values to compare. /// Parameter or , whichever is larger. - public static TQuantity Max(TQuantity val1, TQuantity val2) where TQuantity : IComparable, IQuantity + public static TQuantity Max(TQuantity val1, TQuantity val2) + where TQuantity : IQuantity, IComparable { return val1.CompareTo(val2) == -1 ? val2 : val1; } @@ -135,11 +114,12 @@ public static TQuantity Max(TQuantity val1, TQuantity val2) where TQu /// /// source contains quantity types different from . /// + [Obsolete("Duplicate of System.Linq.Max")] public static TQuantity Max(this IEnumerable source, TUnitType unitType) - where TUnitType : struct, Enum where TQuantity : IQuantity + where TUnitType : struct, Enum { - return (TQuantity) Quantity.From(source.Max(x => x.As(unitType)), unitType); + return (TQuantity) Quantity.From(source.Max(x => x.As(unitType)), UnitKey.ForUnit(unitType)); } /// @@ -160,56 +140,14 @@ public static TQuantity Max(this IEnumerable so /// /// source contains quantity types different from . /// + [Obsolete("Duplicate of System.Linq.Max")] public static TQuantity Max(this IEnumerable source, Func selector, TUnitType unitType) - where TUnitType : struct, Enum where TQuantity : IQuantity - { - return source.Select(selector).Max(unitType); - } - - /// Computes the average of a sequence of values. - /// A sequence of values to calculate the average of. - /// The desired unit type for the resulting quantity - /// The average of the values in the sequence, represented in the specified unit type. - /// - /// source is null. - /// - /// source contains no elements. - /// - /// source contains quantity types different from . - /// - public static TQuantity Average(this IEnumerable source, TUnitType unitType) where TUnitType : struct, Enum - where TQuantity : IQuantity { - return (TQuantity) Quantity.From(source.Average(x => x.As(unitType)), unitType); - } - - /// - /// Computes the average of the sequence of values that are obtained by invoking - /// a transform function on each element of the input sequence. - /// - /// A sequence of values that are used to calculate an average. - /// A transform function to apply to each element. - /// The desired unit type for the resulting quantity - /// The type of the elements of source. - /// The type of quantity that is produced by this operation. - /// The type of unit enum. - /// The average of the projected values, represented in the specified unit type. - /// - /// source or selector is null. - /// - /// source contains no elements. - /// - /// source contains quantity types different from . - /// - public static TQuantity Average(this IEnumerable source, Func selector, TUnitType unitType) - where TUnitType : struct, Enum - where TQuantity : IQuantity - { - return source.Select(selector).Average(unitType); + return source.Select(selector).Max(unitType); } - + /// Returns clamped to the inclusive range of and . /// The value to be clamped. /// The lower bound of the result. From 00daab295b6279f47dc2e5622674d8df7daad1b3 Mon Sep 17 00:00:00 2001 From: lipchev Date: Sun, 27 Jul 2025 17:40:41 +0300 Subject: [PATCH 2/8] fixed the json-converter usage of Equals with (generic) tolerance --- .../UnitsNetBaseJsonConverterTest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UnitsNet.Serialization.JsonNet.Tests/UnitsNetBaseJsonConverterTest.cs b/UnitsNet.Serialization.JsonNet.Tests/UnitsNetBaseJsonConverterTest.cs index c438447b5f..b07bf62272 100644 --- a/UnitsNet.Serialization.JsonNet.Tests/UnitsNetBaseJsonConverterTest.cs +++ b/UnitsNet.Serialization.JsonNet.Tests/UnitsNetBaseJsonConverterTest.cs @@ -44,7 +44,7 @@ public void UnitsNetBaseJsonConverter_ConvertValueUnit_works_as_expected() Assert.NotNull(result); Assert.IsType(result); - Assert.True(Power.FromWatts(10.2365).Equals((Power)result, 1e-5, ComparisonType.Absolute)); + Assert.True(Power.FromWatts(10.2365).Equals((Power)result)); } [Fact] From 5a4b8b7c5f774347e2c469e80f1c875ef5295d5c Mon Sep 17 00:00:00 2001 From: Andreas Gullberg Larsen Date: Sun, 27 Jul 2025 19:41:14 +0200 Subject: [PATCH 3/8] Temperature.extra.cs: Typo --- UnitsNet/CustomCode/Quantities/Temperature.extra.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/UnitsNet/CustomCode/Quantities/Temperature.extra.cs b/UnitsNet/CustomCode/Quantities/Temperature.extra.cs index aa5434819b..4612e3a44d 100644 --- a/UnitsNet/CustomCode/Quantities/Temperature.extra.cs +++ b/UnitsNet/CustomCode/Quantities/Temperature.extra.cs @@ -58,7 +58,7 @@ public partial struct Temperature /// Factor to multiply by. /// Unit to perform multiplication in. /// The resulting . - [Obsolete("Affine quantities, such as the Temperate, cannot be multiplied directly: consider using the TemperatureDelta type instead.")] + [Obsolete("Affine quantities, such as Temperature, cannot be multiplied directly: consider using the TemperatureDelta type instead.")] public Temperature Multiply(double factor, TemperatureUnit unit) { double resultInUnit = As(unit) * factor; @@ -76,7 +76,7 @@ public Temperature Multiply(double factor, TemperatureUnit unit) /// Factor to multiply by. /// Unit to perform multiplication in. /// The resulting . - [Obsolete("Affine quantities, such as the Temperate, cannot be divided directly: consider using the TemperatureDelta type instead.")] + [Obsolete("Affine quantities, such as Temperature, cannot be divided directly: consider using the TemperatureDelta type instead.")] public Temperature Divide(double divisor, TemperatureUnit unit) { double resultInUnit = As(unit) / divisor; @@ -84,7 +84,7 @@ public Temperature Divide(double divisor, TemperatureUnit unit) } /// /> - [Obsolete("Affine quantities, such as the Temperate, should use an offset-based tolerance: consider using the TemperatureDelta type instead.")] + [Obsolete("Affine quantities, such as Temperature, should use an offset-based tolerance: consider using the TemperatureDelta type instead.")] public bool Equals(Temperature other, Temperature tolerance) { if (tolerance.Value < 0) From 2ea2f0bd57c30b7baeef31a5b35cce6569d14efc Mon Sep 17 00:00:00 2001 From: lipchev Date: Tue, 29 Jul 2025 03:23:28 +0300 Subject: [PATCH 4/8] - replaced the GetHashCode implementation with a helper from the Comparison class - Temperature: removed the [Obsolete] methods - added the missing tests for the Linear/Affine/Logarithmic extensions --- .../UnitsNetGen/QuantityGenerator.cs | 15 +- .../UnitsNetGen/UnitTestBaseClassGenerator.cs | 8 +- CodeGen/JsonTypes/Quantity.cs | 2 - ...peratureDeltasWithRandomUnitsBenchmarks.cs | 14 +- .../AffineQuantityExtensionsTest.cs | 225 +++++++ UnitsNet.Tests/CustomCode/TemperatureTests.cs | 64 +- ...orbedDoseOfIonizingRadiationTestsBase.g.cs | 4 +- .../TestsBase/AccelerationTestsBase.g.cs | 4 +- .../TestsBase/AmountOfSubstanceTestsBase.g.cs | 4 +- .../TestsBase/AmplitudeRatioTestsBase.g.cs | 6 +- .../TestsBase/AngleTestsBase.g.cs | 4 +- .../TestsBase/AreaDensityTestsBase.g.cs | 4 +- .../AreaMomentOfInertiaTestsBase.g.cs | 4 +- .../TestsBase/AreaTestsBase.g.cs | 4 +- .../TestsBase/BitRateTestsBase.g.cs | 4 +- ...BrakeSpecificFuelConsumptionTestsBase.g.cs | 4 +- ...oefficientOfThermalExpansionTestsBase.g.cs | 4 +- .../TestsBase/CompressibilityTestsBase.g.cs | 4 +- .../TestsBase/DensityTestsBase.g.cs | 4 +- .../TestsBase/DoseAreaProductTestsBase.g.cs | 4 +- .../TestsBase/DurationTestsBase.g.cs | 4 +- .../TestsBase/DynamicViscosityTestsBase.g.cs | 4 +- .../ElectricAdmittanceTestsBase.g.cs | 4 +- .../ElectricApparentEnergyTestsBase.g.cs | 4 +- .../ElectricApparentPowerTestsBase.g.cs | 4 +- .../ElectricCapacitanceTestsBase.g.cs | 4 +- .../ElectricChargeDensityTestsBase.g.cs | 4 +- .../TestsBase/ElectricChargeTestsBase.g.cs | 4 +- .../ElectricConductanceTestsBase.g.cs | 4 +- .../ElectricConductivityTestsBase.g.cs | 4 +- .../ElectricCurrentDensityTestsBase.g.cs | 4 +- .../ElectricCurrentGradientTestsBase.g.cs | 4 +- .../TestsBase/ElectricCurrentTestsBase.g.cs | 4 +- .../TestsBase/ElectricFieldTestsBase.g.cs | 4 +- .../TestsBase/ElectricImpedanceTestsBase.g.cs | 4 +- .../ElectricInductanceTestsBase.g.cs | 4 +- .../ElectricPotentialChangeRateTestsBase.g.cs | 4 +- .../TestsBase/ElectricPotentialTestsBase.g.cs | 4 +- .../TestsBase/ElectricReactanceTestsBase.g.cs | 4 +- .../ElectricReactiveEnergyTestsBase.g.cs | 4 +- .../ElectricReactivePowerTestsBase.g.cs | 4 +- .../ElectricResistanceTestsBase.g.cs | 4 +- .../ElectricResistivityTestsBase.g.cs | 4 +- ...ElectricSurfaceChargeDensityTestsBase.g.cs | 4 +- .../ElectricSusceptanceTestsBase.g.cs | 4 +- .../TestsBase/EnergyDensityTestsBase.g.cs | 4 +- .../TestsBase/EnergyTestsBase.g.cs | 4 +- .../TestsBase/EntropyTestsBase.g.cs | 4 +- .../TestsBase/FluidResistanceTestsBase.g.cs | 4 +- .../TestsBase/ForceChangeRateTestsBase.g.cs | 4 +- .../TestsBase/ForcePerLengthTestsBase.g.cs | 4 +- .../TestsBase/ForceTestsBase.g.cs | 4 +- .../TestsBase/FrequencyTestsBase.g.cs | 4 +- .../TestsBase/FuelEfficiencyTestsBase.g.cs | 4 +- .../TestsBase/HeatFluxTestsBase.g.cs | 4 +- .../HeatTransferCoefficientTestsBase.g.cs | 4 +- .../TestsBase/IlluminanceTestsBase.g.cs | 4 +- .../TestsBase/ImpulseTestsBase.g.cs | 4 +- .../TestsBase/InformationTestsBase.g.cs | 4 +- .../TestsBase/IrradianceTestsBase.g.cs | 4 +- .../TestsBase/IrradiationTestsBase.g.cs | 4 +- .../TestsBase/JerkTestsBase.g.cs | 4 +- .../KinematicViscosityTestsBase.g.cs | 4 +- .../TestsBase/LeakRateTestsBase.g.cs | 4 +- .../TestsBase/LengthTestsBase.g.cs | 4 +- .../TestsBase/LevelTestsBase.g.cs | 6 +- .../TestsBase/LinearDensityTestsBase.g.cs | 4 +- .../LinearPowerDensityTestsBase.g.cs | 4 +- .../TestsBase/LuminanceTestsBase.g.cs | 4 +- .../TestsBase/LuminosityTestsBase.g.cs | 4 +- .../TestsBase/LuminousFluxTestsBase.g.cs | 4 +- .../TestsBase/LuminousIntensityTestsBase.g.cs | 4 +- .../TestsBase/MagneticFieldTestsBase.g.cs | 4 +- .../TestsBase/MagneticFluxTestsBase.g.cs | 4 +- .../TestsBase/MagnetizationTestsBase.g.cs | 4 +- .../TestsBase/MassConcentrationTestsBase.g.cs | 4 +- .../TestsBase/MassFlowTestsBase.g.cs | 4 +- .../TestsBase/MassFluxTestsBase.g.cs | 4 +- .../TestsBase/MassFractionTestsBase.g.cs | 4 +- .../MassMomentOfInertiaTestsBase.g.cs | 4 +- .../TestsBase/MassTestsBase.g.cs | 4 +- .../TestsBase/MolalityTestsBase.g.cs | 4 +- .../TestsBase/MolarEnergyTestsBase.g.cs | 4 +- .../TestsBase/MolarEntropyTestsBase.g.cs | 4 +- .../TestsBase/MolarFlowTestsBase.g.cs | 4 +- .../TestsBase/MolarMassTestsBase.g.cs | 4 +- .../TestsBase/MolarityTestsBase.g.cs | 4 +- .../TestsBase/PermeabilityTestsBase.g.cs | 4 +- .../TestsBase/PermittivityTestsBase.g.cs | 4 +- .../PorousMediumPermeabilityTestsBase.g.cs | 4 +- .../TestsBase/PowerDensityTestsBase.g.cs | 4 +- .../TestsBase/PowerRatioTestsBase.g.cs | 6 +- .../TestsBase/PowerTestsBase.g.cs | 4 +- .../PressureChangeRateTestsBase.g.cs | 4 +- .../TestsBase/PressureTestsBase.g.cs | 4 +- .../RadiationEquivalentDoseRateTestsBase.g.cs | 4 +- .../RadiationEquivalentDoseTestsBase.g.cs | 4 +- .../TestsBase/RadiationExposureTestsBase.g.cs | 4 +- .../TestsBase/RadioactivityTestsBase.g.cs | 4 +- .../TestsBase/RatioChangeRateTestsBase.g.cs | 4 +- .../TestsBase/RatioTestsBase.g.cs | 4 +- .../TestsBase/ReciprocalAreaTestsBase.g.cs | 4 +- .../TestsBase/ReciprocalLengthTestsBase.g.cs | 4 +- .../TestsBase/RelativeHumidityTestsBase.g.cs | 4 +- .../RotationalAccelerationTestsBase.g.cs | 4 +- .../TestsBase/RotationalSpeedTestsBase.g.cs | 4 +- ...RotationalStiffnessPerLengthTestsBase.g.cs | 4 +- .../RotationalStiffnessTestsBase.g.cs | 4 +- .../TestsBase/ScalarTestsBase.g.cs | 4 +- .../TestsBase/SolidAngleTestsBase.g.cs | 4 +- .../TestsBase/SpecificEnergyTestsBase.g.cs | 4 +- .../TestsBase/SpecificEntropyTestsBase.g.cs | 4 +- .../SpecificFuelConsumptionTestsBase.g.cs | 4 +- .../TestsBase/SpecificVolumeTestsBase.g.cs | 4 +- .../TestsBase/SpecificWeightTestsBase.g.cs | 4 +- .../TestsBase/SpeedTestsBase.g.cs | 4 +- .../StandardVolumeFlowTestsBase.g.cs | 4 +- .../TemperatureChangeRateTestsBase.g.cs | 4 +- .../TestsBase/TemperatureDeltaTestsBase.g.cs | 4 +- .../TemperatureGradientTestsBase.g.cs | 4 +- .../TestsBase/TemperatureTestsBase.g.cs | 4 +- .../ThermalConductivityTestsBase.g.cs | 4 +- .../TestsBase/ThermalInsulanceTestsBase.g.cs | 4 +- .../TestsBase/ThermalResistanceTestsBase.g.cs | 4 +- .../TestsBase/TorqueTestsBase.g.cs | 4 +- .../TestsBase/TurbidityTestsBase.g.cs | 4 +- .../TestsBase/VitaminATestsBase.g.cs | 4 +- .../VolumeConcentrationTestsBase.g.cs | 4 +- .../TestsBase/VolumeFlowPerAreaTestsBase.g.cs | 4 +- .../TestsBase/VolumeFlowTestsBase.g.cs | 4 +- .../TestsBase/VolumePerLengthTestsBase.g.cs | 4 +- .../TestsBase/VolumeTestsBase.g.cs | 4 +- .../VolumetricHeatCapacityTestsBase.g.cs | 4 +- .../WarpingMomentOfInertiaTestsBase.g.cs | 4 +- .../LinearQuantityExtensionsTest.cs | 223 +++++++ .../LogarithmicQuantityExtensionsTest.cs | 619 ++++++++++++++++++ UnitsNet/Comparison.cs | 17 + .../Quantities/Temperature.extra.cs | 51 -- .../Extensions/AffineQuantityExtensions.cs | 26 +- .../Extensions/LinearQuantityExtensions.cs | 2 - .../LogarithmicQuantityExtensions.cs | 4 +- .../AbsorbedDoseOfIonizingRadiation.g.cs | 2 +- .../Quantities/Acceleration.g.cs | 2 +- .../Quantities/AmountOfSubstance.g.cs | 2 +- .../Quantities/AmplitudeRatio.g.cs | 2 +- UnitsNet/GeneratedCode/Quantities/Angle.g.cs | 2 +- UnitsNet/GeneratedCode/Quantities/Area.g.cs | 2 +- .../GeneratedCode/Quantities/AreaDensity.g.cs | 2 +- .../Quantities/AreaMomentOfInertia.g.cs | 2 +- .../GeneratedCode/Quantities/BitRate.g.cs | 2 +- .../BrakeSpecificFuelConsumption.g.cs | 2 +- .../CoefficientOfThermalExpansion.g.cs | 2 +- .../Quantities/Compressibility.g.cs | 2 +- .../GeneratedCode/Quantities/Density.g.cs | 2 +- .../Quantities/DoseAreaProduct.g.cs | 2 +- .../GeneratedCode/Quantities/Duration.g.cs | 2 +- .../Quantities/DynamicViscosity.g.cs | 2 +- .../Quantities/ElectricAdmittance.g.cs | 2 +- .../Quantities/ElectricApparentEnergy.g.cs | 2 +- .../Quantities/ElectricApparentPower.g.cs | 2 +- .../Quantities/ElectricCapacitance.g.cs | 2 +- .../Quantities/ElectricCharge.g.cs | 2 +- .../Quantities/ElectricChargeDensity.g.cs | 2 +- .../Quantities/ElectricConductance.g.cs | 2 +- .../Quantities/ElectricConductivity.g.cs | 2 +- .../Quantities/ElectricCurrent.g.cs | 2 +- .../Quantities/ElectricCurrentDensity.g.cs | 2 +- .../Quantities/ElectricCurrentGradient.g.cs | 2 +- .../Quantities/ElectricField.g.cs | 2 +- .../Quantities/ElectricImpedance.g.cs | 2 +- .../Quantities/ElectricInductance.g.cs | 2 +- .../Quantities/ElectricPotential.g.cs | 2 +- .../ElectricPotentialChangeRate.g.cs | 2 +- .../Quantities/ElectricReactance.g.cs | 2 +- .../Quantities/ElectricReactiveEnergy.g.cs | 2 +- .../Quantities/ElectricReactivePower.g.cs | 2 +- .../Quantities/ElectricResistance.g.cs | 2 +- .../Quantities/ElectricResistivity.g.cs | 2 +- .../ElectricSurfaceChargeDensity.g.cs | 2 +- .../Quantities/ElectricSusceptance.g.cs | 2 +- UnitsNet/GeneratedCode/Quantities/Energy.g.cs | 2 +- .../Quantities/EnergyDensity.g.cs | 2 +- .../GeneratedCode/Quantities/Entropy.g.cs | 2 +- .../Quantities/FluidResistance.g.cs | 2 +- UnitsNet/GeneratedCode/Quantities/Force.g.cs | 2 +- .../Quantities/ForceChangeRate.g.cs | 2 +- .../Quantities/ForcePerLength.g.cs | 2 +- .../GeneratedCode/Quantities/Frequency.g.cs | 2 +- .../Quantities/FuelEfficiency.g.cs | 2 +- .../GeneratedCode/Quantities/HeatFlux.g.cs | 2 +- .../Quantities/HeatTransferCoefficient.g.cs | 2 +- .../GeneratedCode/Quantities/Illuminance.g.cs | 2 +- .../GeneratedCode/Quantities/Impulse.g.cs | 2 +- .../GeneratedCode/Quantities/Information.g.cs | 2 +- .../GeneratedCode/Quantities/Irradiance.g.cs | 2 +- .../GeneratedCode/Quantities/Irradiation.g.cs | 2 +- UnitsNet/GeneratedCode/Quantities/Jerk.g.cs | 2 +- .../Quantities/KinematicViscosity.g.cs | 2 +- .../GeneratedCode/Quantities/LeakRate.g.cs | 2 +- UnitsNet/GeneratedCode/Quantities/Length.g.cs | 2 +- UnitsNet/GeneratedCode/Quantities/Level.g.cs | 2 +- .../Quantities/LinearDensity.g.cs | 2 +- .../Quantities/LinearPowerDensity.g.cs | 2 +- .../GeneratedCode/Quantities/Luminance.g.cs | 2 +- .../GeneratedCode/Quantities/Luminosity.g.cs | 2 +- .../Quantities/LuminousFlux.g.cs | 2 +- .../Quantities/LuminousIntensity.g.cs | 2 +- .../Quantities/MagneticField.g.cs | 2 +- .../Quantities/MagneticFlux.g.cs | 2 +- .../Quantities/Magnetization.g.cs | 2 +- UnitsNet/GeneratedCode/Quantities/Mass.g.cs | 2 +- .../Quantities/MassConcentration.g.cs | 2 +- .../GeneratedCode/Quantities/MassFlow.g.cs | 2 +- .../GeneratedCode/Quantities/MassFlux.g.cs | 2 +- .../Quantities/MassFraction.g.cs | 2 +- .../Quantities/MassMomentOfInertia.g.cs | 2 +- .../GeneratedCode/Quantities/Molality.g.cs | 2 +- .../GeneratedCode/Quantities/MolarEnergy.g.cs | 2 +- .../Quantities/MolarEntropy.g.cs | 2 +- .../GeneratedCode/Quantities/MolarFlow.g.cs | 2 +- .../GeneratedCode/Quantities/MolarMass.g.cs | 2 +- .../GeneratedCode/Quantities/Molarity.g.cs | 2 +- .../Quantities/Permeability.g.cs | 2 +- .../Quantities/Permittivity.g.cs | 2 +- .../Quantities/PorousMediumPermeability.g.cs | 2 +- UnitsNet/GeneratedCode/Quantities/Power.g.cs | 2 +- .../Quantities/PowerDensity.g.cs | 2 +- .../GeneratedCode/Quantities/PowerRatio.g.cs | 2 +- .../GeneratedCode/Quantities/Pressure.g.cs | 2 +- .../Quantities/PressureChangeRate.g.cs | 2 +- .../Quantities/RadiationEquivalentDose.g.cs | 2 +- .../RadiationEquivalentDoseRate.g.cs | 2 +- .../Quantities/RadiationExposure.g.cs | 2 +- .../Quantities/Radioactivity.g.cs | 2 +- UnitsNet/GeneratedCode/Quantities/Ratio.g.cs | 2 +- .../Quantities/RatioChangeRate.g.cs | 2 +- .../Quantities/ReciprocalArea.g.cs | 2 +- .../Quantities/ReciprocalLength.g.cs | 2 +- .../Quantities/RelativeHumidity.g.cs | 2 +- .../Quantities/RotationalAcceleration.g.cs | 2 +- .../Quantities/RotationalSpeed.g.cs | 2 +- .../Quantities/RotationalStiffness.g.cs | 2 +- .../RotationalStiffnessPerLength.g.cs | 2 +- UnitsNet/GeneratedCode/Quantities/Scalar.g.cs | 2 +- .../GeneratedCode/Quantities/SolidAngle.g.cs | 2 +- .../Quantities/SpecificEnergy.g.cs | 2 +- .../Quantities/SpecificEntropy.g.cs | 2 +- .../Quantities/SpecificFuelConsumption.g.cs | 2 +- .../Quantities/SpecificVolume.g.cs | 2 +- .../Quantities/SpecificWeight.g.cs | 2 +- UnitsNet/GeneratedCode/Quantities/Speed.g.cs | 2 +- .../Quantities/StandardVolumeFlow.g.cs | 2 +- .../GeneratedCode/Quantities/Temperature.g.cs | 2 +- .../Quantities/TemperatureChangeRate.g.cs | 2 +- .../Quantities/TemperatureDelta.g.cs | 2 +- .../Quantities/TemperatureGradient.g.cs | 2 +- .../Quantities/ThermalConductivity.g.cs | 2 +- .../Quantities/ThermalInsulance.g.cs | 2 +- .../Quantities/ThermalResistance.g.cs | 2 +- UnitsNet/GeneratedCode/Quantities/Torque.g.cs | 2 +- .../GeneratedCode/Quantities/Turbidity.g.cs | 2 +- .../GeneratedCode/Quantities/VitaminA.g.cs | 2 +- UnitsNet/GeneratedCode/Quantities/Volume.g.cs | 2 +- .../Quantities/VolumeConcentration.g.cs | 2 +- .../GeneratedCode/Quantities/VolumeFlow.g.cs | 2 +- .../Quantities/VolumeFlowPerArea.g.cs | 2 +- .../Quantities/VolumePerLength.g.cs | 2 +- .../Quantities/VolumetricHeatCapacity.g.cs | 2 +- .../Quantities/WarpingMomentOfInertia.g.cs | 2 +- 269 files changed, 1508 insertions(+), 536 deletions(-) create mode 100644 UnitsNet.Tests/AffineQuantityExtensionsTest.cs create mode 100644 UnitsNet.Tests/LinearQuantityExtensionsTest.cs create mode 100644 UnitsNet.Tests/LogarithmicQuantityExtensionsTest.cs diff --git a/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs b/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs index d2ff4a76f7..d8e6578d75 100644 --- a/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs +++ b/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs @@ -342,7 +342,7 @@ private void GenerateStaticProperties() /// public static {_quantity.Name} Zero => Info.Zero; "); - + if (_quantity.Logarithmic) { Writer.WL($@" @@ -351,7 +351,7 @@ private void GenerateStaticProperties() "); } - Writer.WL($@" + Writer.WL(@" #endregion "); } @@ -405,7 +405,7 @@ private void GenerateProperties() "); } - Writer.WL($@" + Writer.WL(@" #endregion #endregion @@ -692,7 +692,12 @@ public static bool TryParseUnit([NotNullWhen(true)]string? str, IFormatProvider? private void GenerateArithmeticOperators() { - if (_quantity.IsAffine) return; + if (_quantity.IsAffine) + { + // the generation of arithmetic operators with affine quantities, such as Temperature + TemperatureDelta, is currently not supported + // TODO see about handling this case using the UnitRelations + return; + } // Logarithmic units required different arithmetic if (_quantity.Logarithmic) @@ -959,7 +964,7 @@ public bool Equals({_quantity.Name} other) /// A hash code for the current {_quantity.Name}. public override int GetHashCode() {{ - return new {{ Info.Name, Value, Unit }}.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); }} /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/CodeGen/Generators/UnitsNetGen/UnitTestBaseClassGenerator.cs b/CodeGen/Generators/UnitsNetGen/UnitTestBaseClassGenerator.cs index 6504e3eb85..3a1398a998 100644 --- a/CodeGen/Generators/UnitsNetGen/UnitTestBaseClassGenerator.cs +++ b/CodeGen/Generators/UnitsNetGen/UnitTestBaseClassGenerator.cs @@ -1000,7 +1000,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_Logarithmic_WithTolerance(double firstValue, double secondValue) {{ var quantity = {_quantity.Name}.From{_baseUnit.PluralName}(firstValue); var otherQuantity = {_quantity.Name}.From{_baseUnit.PluralName}(secondValue); @@ -1016,7 +1016,7 @@ public void Equals_WithTolerance_IsImplemented(double firstValue, double secondV }} [Fact] - public void Equals_WithNegativeTolerance_DoesNotThrowArgumentOutOfRangeException() + public void Equals_Logarithmic_WithNegativeTolerance_DoesNotThrowArgumentOutOfRangeException() {{ // note: unlike with vector quantities- a small tolerance maybe positive in one unit and negative in another var quantity = {_quantity.Name}.From{_baseUnit.PluralName}(1); @@ -1033,7 +1033,7 @@ public void Equals_WithNegativeTolerance_DoesNotThrowArgumentOutOfRangeException [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) {{ var quantity = {_quantity.Name}.From{_baseUnit.PluralName}(firstValue); var otherQuantity = {_quantity.Name}.From{_baseUnit.PluralName}(secondValue); @@ -1165,7 +1165,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() {{ var quantity = {_quantity.Name}.From{_baseUnit.PluralName}(1.0); - Assert.Equal(new {{{_quantity.Name}.Info.Name, quantity.Value, quantity.Unit}}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); }} "); diff --git a/CodeGen/JsonTypes/Quantity.cs b/CodeGen/JsonTypes/Quantity.cs index ac92ed51d8..3ac77e59ce 100644 --- a/CodeGen/JsonTypes/Quantity.cs +++ b/CodeGen/JsonTypes/Quantity.cs @@ -14,8 +14,6 @@ internal record Quantity public BaseDimensions BaseDimensions = new(); // Default to empty public string BaseUnit = null!; - [Obsolete] - public bool GenerateArithmetic = true; public string? AffineOffsetType; public bool IsAffine => !string.IsNullOrEmpty(AffineOffsetType); public bool Logarithmic = false; diff --git a/UnitsNet.Benchmark/Operators/Additions/SumOfTemperatureDeltasWithRandomUnitsBenchmarks.cs b/UnitsNet.Benchmark/Operators/Additions/SumOfTemperatureDeltasWithRandomUnitsBenchmarks.cs index cd9877e6bc..1927f8b70f 100644 --- a/UnitsNet.Benchmark/Operators/Additions/SumOfTemperatureDeltasWithRandomUnitsBenchmarks.cs +++ b/UnitsNet.Benchmark/Operators/Additions/SumOfTemperatureDeltasWithRandomUnitsBenchmarks.cs @@ -10,8 +10,8 @@ namespace UnitsNet.Benchmark.Operators.Additions; [MemoryDiagnoser] -[SimpleJob(RuntimeMoniker.Net48)] -[SimpleJob(RuntimeMoniker.Net80)] +// [SimpleJob(RuntimeMoniker.Net48)] +[SimpleJob(RuntimeMoniker.Net90)] public class SumOfTemperatureDeltasWithRandomUnitsBenchmarks { private static readonly double Value = 1.23; @@ -29,7 +29,13 @@ public void PrepareQuantities() } [Benchmark(Baseline = true)] - public TemperatureDelta SumOfDeltas() + public TemperatureDelta SumOfTemperatureDeltas() + { + return _quantities.Sum(); + } + + [Benchmark(Baseline = false)] + public TemperatureDelta GenericSumOfTemperatureDeltas() { #if NET return UnitsNet.GenericMath.GenericMathExtensions.Sum(_quantities); @@ -45,7 +51,7 @@ public TemperatureDelta SumOfDeltas() } [Benchmark(Baseline = false)] - public TemperatureDelta SumOfVolumesInBaseUnit() + public TemperatureDelta SumOfTemperatureDeltasInBaseUnit() { return _quantities.Sum(TemperatureDelta.BaseUnit); } diff --git a/UnitsNet.Tests/AffineQuantityExtensionsTest.cs b/UnitsNet.Tests/AffineQuantityExtensionsTest.cs new file mode 100644 index 0000000000..971a503737 --- /dev/null +++ b/UnitsNet.Tests/AffineQuantityExtensionsTest.cs @@ -0,0 +1,225 @@ +// 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. + +namespace UnitsNet.Tests; + +public class AffineQuantityExtensionsTest +{ + [Theory] + [InlineData(25.0, 25.0, 0.1, true)] // Equal values + // [InlineData(25.0, 25.1, 0.1, true)] // Within tolerance (but fails due to rounding) + [InlineData(25.0, 25.1, 0.10001, true)] // Within tolerance + [InlineData(25.0, 25.2, 0.1, false)] // Outside tolerance + [InlineData(25.0, 25.0, 0.0, true)] // Zero tolerance, equal values + [InlineData(25.0, 25.1, 0.0, false)] // Zero tolerance, different values + public void Equals_Temperature_TemperatureDelta(double value1, double value2, double toleranceValue, bool expected) + { + var temperature1 = Temperature.FromDegreesCelsius(value1); + var temperature2 = Temperature.FromDegreesCelsius(value2); + var tolerance = TemperatureDelta.FromDegreesCelsius(toleranceValue); + + var result = temperature1.Equals(temperature2, tolerance); + + Assert.Equal(expected, result); + } + + [Fact] + public void Equals_WithToleranceAtTheLimit_ReturnsTrue() + { + var quantity = Temperature.FromDegreesCelsius(1); + var otherQuantity = Temperature.FromMillidegreesCelsius(999); + var tolerance = TemperatureDelta.FromMillidegreesCelsius(1); + + Assert.Multiple(() => + { + Assert.True(quantity.Equals(otherQuantity, tolerance), "Difference == Tolerance"); + Assert.True(quantity.Equals(otherQuantity, tolerance * 2), "Difference < Tolerance"); + Assert.False(quantity.Equals(otherQuantity, tolerance / 2), "Difference > Tolerance"); + }, + () => + { + Assert.True(otherQuantity.Equals(quantity, tolerance), "Difference == Tolerance"); + Assert.True(otherQuantity.Equals(quantity, tolerance * 2), "Difference < Tolerance"); + Assert.False(otherQuantity.Equals(quantity, tolerance / 2), "Difference > Tolerance"); + }); + } + + [Fact] + public void Equals_Temperature_TemperatureDelta_ThrowsArgumentOutOfRangeException_ForNegativeTolerance() + { + var temperature1 = Temperature.FromDegreesCelsius(25.0); + var temperature2 = Temperature.FromDegreesCelsius(25.0); + var negativeTolerance = TemperatureDelta.FromDegreesCelsius(-0.1); + + Assert.Throws(() => temperature1.Equals(temperature2, negativeTolerance)); + } + + [Theory] + [InlineData(25.0, 25.0, 0.1, true)] // Equal values + // [InlineData(25.0, 25.1, 0.1, true)] // Within tolerance (but fails due to rounding) + [InlineData(25.0, 25.1, 0.10001, true)] // Within tolerance + [InlineData(25.0, 25.2, 0.1, false)] // Outside tolerance + [InlineData(25.0, 25.0, 0.0, true)] // Zero tolerance, equal values + [InlineData(25.0, 25.1, 0.0, false)] // Zero tolerance, different values + public void Equals_Temperature_IQuantity(double value1, double value2, double toleranceValue, bool expected) + { + var temperature1 = Temperature.FromDegreesCelsius(value1); + IQuantity temperature2 = Temperature.FromDegreesCelsius(value2); + var tolerance = TemperatureDelta.FromDegreesCelsius(toleranceValue); + + var result = temperature1.Equals(temperature2, tolerance); + + Assert.Equal(expected, result); + } + + [Fact] + public void Equals_Temperature_IQuantity_WithDifferentType_ReturnsFalse() + { + var temperature1 = Temperature.FromDegreesCelsius(25.0); + IQuantity length = Length.From(1, LengthUnit.Meter); + var tolerance = TemperatureDelta.FromDegreesCelsius(1); + + var result = temperature1.Equals(length, tolerance); + + Assert.False(result); + } + + [Fact] + public void Equals_WithNullOther_ReturnsFalse() + { + var quantity = Temperature.FromDegreesCelsius(25); + IQuantity? other = null; + var tolerance = TemperatureDelta.FromDegreesCelsius(25); + + var result = quantity.Equals(other, tolerance); + + Assert.False(result); + } + + [Fact] + public void Equals_IQuantity_WithNullOther_ReturnsFalse() + { + var quantity = Temperature.FromDegreesCelsius(25.0); + var tolerance = TemperatureDelta.FromDegreesCelsius(25.0); + + var result = quantity.Equals(null, tolerance); + + Assert.False(result); + } + + [Theory] + [InlineData(25.0, 25.0, 0.1, true)] // Equal values + // [InlineData(25.0, 25.1, 0.1, true)] // Within tolerance (but fails due to rounding) + [InlineData(25.0, 25.1, 0.10001, true)] // Within tolerance + [InlineData(25.0, 25.2, 0.1, false)] // Outside tolerance + [InlineData(25.0, 25.0, 0.0, true)] // Zero tolerance, equal values + [InlineData(25.0, 25.1, 0.0, false)] // Zero tolerance, different values + public void EqualsAbsolute_Temperature_TemperatureDelta(double value1, double value2, double toleranceValue, bool expected) + { + var temperature1 = Temperature.FromDegreesCelsius(value1); + var temperature2 = Temperature.FromDegreesCelsius(value2); + var tolerance = TemperatureDelta.FromDegreesCelsius(toleranceValue); + + var result = temperature1.EqualsAbsolute(temperature2, tolerance); + + Assert.Equal(expected, result); + } + + [Fact] + public void EqualsAbsolute_Temperature_TemperatureDelta_ThrowsArgumentOutOfRangeException_ForNegativeTolerance() + { + var temperature1 = Temperature.FromDegreesCelsius(25.0); + var temperature2 = Temperature.FromDegreesCelsius(25.0); + var negativeTolerance = TemperatureDelta.FromDegreesCelsius(-0.1); + + Assert.Throws(() => temperature1.EqualsAbsolute(temperature2, negativeTolerance)); + } + + [Theory] + [InlineData(new[] { 25.0, 30.0, 35.0 }, 30.0)] // Average of three values + [InlineData(new[] { 25.0 }, 25.0)] // Single value + public void Average_Temperature(double[] values, double expectedAverage) + { + Temperature[] temperatures = Array.ConvertAll(values, value => Temperature.FromDegreesCelsius(value)); + + Temperature result = temperatures.Average(); + + Assert.Equal(expectedAverage, result.Value); + Assert.Equal(TemperatureUnit.DegreeCelsius, result.Unit); + } + + [Fact] + public void Average_TemperaturesWithDifferentUnits() + { + Temperature[] temperatures = + [ + Temperature.FromDegreesCelsius(25.0), + Temperature.FromDegreesFahrenheit(77.0), // equivalent to 25.0°C + Temperature.FromKelvins(298.15) // equivalent to 25.0°C + ]; + + Temperature result = temperatures.Average(); + + Assert.Equal(25, result.Value); + Assert.Equal(TemperatureUnit.DegreeCelsius, result.Unit); + } + + [Fact] + public void Average_Temperature_ThrowsArgumentNullException_ForNullCollection() + { + IEnumerable temperatures = null!; + + Assert.Throws(() => temperatures.Average()); + } + + [Fact] + public void Average_Temperature_ThrowsInvalidOperationException_ForEmptyCollection() + { + Temperature[] temperatures = []; + + Assert.Throws(() => temperatures.Average()); + } + + [Theory] + [InlineData(new[] { 25.0, 30.0, 35.0 }, TemperatureUnit.DegreeCelsius, 30.0)] // Average in Celsius + [InlineData(new[] { 77.0, 86.0, 95.0 }, TemperatureUnit.DegreeFahrenheit, 86.0)] // Average in Fahrenheit + public void Average_Temperature_WithUnit(double[] values, TemperatureUnit unit, double expectedAverage) + { + Temperature[] temperatures = Array.ConvertAll(values, value => Temperature.From(value, unit)); + + Temperature result = temperatures.Average(unit); + + Assert.Equal(expectedAverage, result.Value); + Assert.Equal(unit, result.Unit); + } + + [Fact] + public void Average_TemperaturesWithDifferentUnits_WithTargetUnit() + { + Temperature[] temperatures = + [ + Temperature.FromKelvins(298.15), // equivalent to 25.0°C + Temperature.FromDegreesCelsius(25.0), + Temperature.FromDegreesFahrenheit(77.0) // equivalent to 25.0°C + ]; + + Temperature result = temperatures.Average(TemperatureUnit.DegreeCelsius); + + Assert.Equal(25, result.Value); + Assert.Equal(TemperatureUnit.DegreeCelsius, result.Unit); + } + + [Fact] + public void Average_Temperature_WithUnit_ThrowsArgumentNullException_ForNullCollection() + { + IEnumerable temperatures = null!; + + Assert.Throws(() => temperatures.Average(TemperatureUnit.DegreeCelsius)); + } + + [Fact] + public void Average_Temperature_WithUnit_ThrowsInvalidOperationException_ForEmptyCollection() + { + Assert.Throws(() => Array.Empty().Average(TemperatureUnit.DegreeCelsius)); + } +} diff --git a/UnitsNet.Tests/CustomCode/TemperatureTests.cs b/UnitsNet.Tests/CustomCode/TemperatureTests.cs index c71845b64d..b75e306809 100644 --- a/UnitsNet.Tests/CustomCode/TemperatureTests.cs +++ b/UnitsNet.Tests/CustomCode/TemperatureTests.cs @@ -31,52 +31,6 @@ public void AllBaseQuantityUnitsAreBaseUnits() Assert.All(Temperature.Info.UnitInfos, unitInfo => Assert.Equal(new BaseUnits(temperature: unitInfo.Value), unitInfo.BaseUnits)); } - public static IEnumerable DividedByTemperatureDeltaEqualsTemperatureData { get; } = - [ - [(10d, TemperatureUnit.DegreeCelsius), 1d, (10d, TemperatureUnit.DegreeCelsius)], - [(10d, TemperatureUnit.DegreeCelsius), 5d, (2d, TemperatureUnit.DegreeCelsius)], - [(10d, TemperatureUnit.DegreeCelsius), -10d, (-1d, TemperatureUnit.DegreeCelsius)], - [(10d, TemperatureUnit.DegreeFahrenheit), 1d, (10d, TemperatureUnit.DegreeFahrenheit)], - [(10d, TemperatureUnit.DegreeFahrenheit), 5d, (2d, TemperatureUnit.DegreeFahrenheit)], - [(10d, TemperatureUnit.DegreeFahrenheit), -10d, (-1d, TemperatureUnit.DegreeFahrenheit)] - ]; - - [Theory] - [MemberData(nameof(DividedByTemperatureDeltaEqualsTemperatureData))] - public void DividedByTemperatureDeltaEqualsTemperature((double Value, TemperatureUnit Unit) temperature, double divisor, - (double Value, TemperatureUnit Unit) expected) - { - var temp = new Temperature(temperature.Value, temperature.Unit); - var expectedTemperature = new Temperature(expected.Value, expected.Unit); - - Temperature result = temp.Divide(divisor, temperature.Unit); - - Assert.True(expectedTemperature.Equals(result, Temperature.FromKelvins(KelvinsTolerance))); - } - - public static IEnumerable MultiplyByTemperatureDeltaEqualsTemperatureData { get; } = - [ - [(10d, TemperatureUnit.DegreeCelsius), 0d, (0d, TemperatureUnit.DegreeCelsius)], - [(10d, TemperatureUnit.DegreeCelsius), 5d, (50d, TemperatureUnit.DegreeCelsius)], - [(10d, TemperatureUnit.DegreeCelsius), -5d, (-50d, TemperatureUnit.DegreeCelsius)], - [(10d, TemperatureUnit.DegreeFahrenheit), 0d, (0d, TemperatureUnit.DegreeFahrenheit)], - [(10d, TemperatureUnit.DegreeFahrenheit), 5d, (50d, TemperatureUnit.DegreeFahrenheit)], - [(10d, TemperatureUnit.DegreeFahrenheit), -5d, (-50d, TemperatureUnit.DegreeFahrenheit)] - ]; - - [Theory] - [MemberData(nameof(MultiplyByTemperatureDeltaEqualsTemperatureData))] - public void MultiplyByTemperatureDeltaEqualsTemperature((double Value, TemperatureUnit Unit) temperature, double factor, - (double Value, TemperatureUnit Unit) expected) - { - var temp = new Temperature(temperature.Value, temperature.Unit); - var expectedTemperature = new Temperature(expected.Value, expected.Unit); - - Temperature result = temp.Multiply(factor, temperature.Unit); - - Assert.True(expectedTemperature.Equals(result, Temperature.FromKelvins(KelvinsTolerance))); - } - public static IEnumerable TemperatureDeltaPlusTemperatureEqualsTemperatureData { get; } = [ [-10d, TemperatureUnit.DegreeCelsius, 0d, TemperatureDeltaUnit.DegreeCelsius, -10d, TemperatureUnit.DegreeCelsius], @@ -95,10 +49,10 @@ public void TemperatureDeltaPlusTemperatureEqualsTemperature(double temperatureV var temperature = new Temperature(temperatureValue, temperatureUnit); var temperatureDelta = new TemperatureDelta(deltaValue, deltaUnit); var expectedTemperature = new Temperature(expectedValue, expectedUnit); - + Temperature result = temperature + temperatureDelta; - - Assert.True(expectedTemperature.Equals(result, Temperature.FromKelvins(KelvinsTolerance))); + + Assert.True(expectedTemperature.Equals(result, TemperatureDelta.FromKelvins(KelvinsTolerance))); } public static IEnumerable TemperatureMinusTemperatureDeltaEqualsTemperatureData { get; } = @@ -119,10 +73,10 @@ public void TemperatureMinusTemperatureDeltaEqualsTemperature(double temperature var temp = new Temperature(temperatureValue, temperatureUnit); var delta = new TemperatureDelta(deltaValue, deltaUnit); var expectedTemperature = new Temperature(expectedValue, expectedUnit); - + Temperature result = temp - delta; - - Assert.True(expectedTemperature.Equals(result, Temperature.FromKelvins(KelvinsTolerance))); + + Assert.True(expectedTemperature.Equals(result, TemperatureDelta.FromKelvins(KelvinsTolerance))); } public static IEnumerable TemperaturePlusTemperatureDeltaEqualsTemperatureData { get; } = @@ -143,9 +97,9 @@ public void TemperaturePlusTemperatureDeltaEqualsTemperature(double temperatureV var temp = new Temperature(temperatureValue, temperatureUnit); var delta = new TemperatureDelta(deltaValue, deltaUnit); var expectedTemperature = new Temperature(expectedValue, expectedUnit); - + Temperature result = temp + delta; - - Assert.True(expectedTemperature.Equals(result, Temperature.FromKelvins(KelvinsTolerance))); + + Assert.True(expectedTemperature.Equals(result, TemperatureDelta.FromKelvins(KelvinsTolerance))); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AbsorbedDoseOfIonizingRadiationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AbsorbedDoseOfIonizingRadiationTestsBase.g.cs index a3802c7c1b..8e3cc985e8 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AbsorbedDoseOfIonizingRadiationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AbsorbedDoseOfIonizingRadiationTestsBase.g.cs @@ -1273,7 +1273,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = AbsorbedDoseOfIonizingRadiation.FromGrays(firstValue); var otherQuantity = AbsorbedDoseOfIonizingRadiation.FromGrays(secondValue); @@ -1405,7 +1405,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = AbsorbedDoseOfIonizingRadiation.FromGrays(1.0); - Assert.Equal(new {AbsorbedDoseOfIonizingRadiation.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AccelerationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AccelerationTestsBase.g.cs index f2f34d4775..e3b70124ea 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AccelerationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AccelerationTestsBase.g.cs @@ -1198,7 +1198,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = Acceleration.FromMetersPerSecondSquared(firstValue); var otherQuantity = Acceleration.FromMetersPerSecondSquared(secondValue); @@ -1324,7 +1324,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = Acceleration.FromMetersPerSecondSquared(1.0); - Assert.Equal(new {Acceleration.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AmountOfSubstanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AmountOfSubstanceTestsBase.g.cs index 1525e1ac31..a0ce32cd78 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AmountOfSubstanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AmountOfSubstanceTestsBase.g.cs @@ -1044,7 +1044,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = AmountOfSubstance.FromMoles(firstValue); var otherQuantity = AmountOfSubstance.FromMoles(secondValue); @@ -1176,7 +1176,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = AmountOfSubstance.FromMoles(1.0); - Assert.Equal(new {AmountOfSubstance.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AmplitudeRatioTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AmplitudeRatioTestsBase.g.cs index 868f742e67..ac71490003 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AmplitudeRatioTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AmplitudeRatioTestsBase.g.cs @@ -584,7 +584,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_Logarithmic_WithTolerance(double firstValue, double secondValue) { var quantity = AmplitudeRatio.FromDecibelVolts(firstValue); var otherQuantity = AmplitudeRatio.FromDecibelVolts(secondValue); @@ -600,7 +600,7 @@ public void Equals_WithTolerance_IsImplemented(double firstValue, double secondV } [Fact] - public void Equals_WithNegativeTolerance_DoesNotThrowArgumentOutOfRangeException() + public void Equals_Logarithmic_WithNegativeTolerance_DoesNotThrowArgumentOutOfRangeException() { // note: unlike with vector quantities- a small tolerance maybe positive in one unit and negative in another var quantity = AmplitudeRatio.FromDecibelVolts(1); @@ -692,7 +692,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = AmplitudeRatio.FromDecibelVolts(1.0); - Assert.Equal(new {AmplitudeRatio.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AngleTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AngleTestsBase.g.cs index d47d722c1a..d71fb268ae 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AngleTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AngleTestsBase.g.cs @@ -1346,7 +1346,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = Angle.FromRadians(firstValue); var otherQuantity = Angle.FromRadians(secondValue); @@ -1474,7 +1474,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = Angle.FromRadians(1.0); - Assert.Equal(new {Angle.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaDensityTestsBase.g.cs index 00891c8b6f..20a0330f46 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaDensityTestsBase.g.cs @@ -629,7 +629,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = AreaDensity.FromKilogramsPerSquareMeter(firstValue); var otherQuantity = AreaDensity.FromKilogramsPerSquareMeter(secondValue); @@ -733,7 +733,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = AreaDensity.FromKilogramsPerSquareMeter(1.0); - Assert.Equal(new {AreaDensity.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaMomentOfInertiaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaMomentOfInertiaTestsBase.g.cs index 448ee85799..0044d99d57 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaMomentOfInertiaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaMomentOfInertiaTestsBase.g.cs @@ -704,7 +704,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = AreaMomentOfInertia.FromMetersToTheFourth(firstValue); var otherQuantity = AreaMomentOfInertia.FromMetersToTheFourth(secondValue); @@ -814,7 +814,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = AreaMomentOfInertia.FromMetersToTheFourth(1.0); - Assert.Equal(new {AreaMomentOfInertia.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaTestsBase.g.cs index 2421ef2f4f..dd04d9cf62 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaTestsBase.g.cs @@ -1413,7 +1413,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = Area.FromSquareMeters(firstValue); var otherQuantity = Area.FromSquareMeters(secondValue); @@ -1539,7 +1539,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = Area.FromSquareMeters(1.0); - Assert.Equal(new {Area.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/BitRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/BitRateTestsBase.g.cs index d2a26f6627..36f31056ba 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/BitRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/BitRateTestsBase.g.cs @@ -2033,7 +2033,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = BitRate.FromBitsPerSecond(firstValue); var otherQuantity = BitRate.FromBitsPerSecond(secondValue); @@ -2209,7 +2209,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = BitRate.FromBitsPerSecond(1.0); - Assert.Equal(new {BitRate.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/BrakeSpecificFuelConsumptionTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/BrakeSpecificFuelConsumptionTestsBase.g.cs index 8e9cc99bd0..a3438949a5 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/BrakeSpecificFuelConsumptionTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/BrakeSpecificFuelConsumptionTestsBase.g.cs @@ -608,7 +608,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(firstValue); var otherQuantity = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(secondValue); @@ -712,7 +712,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1.0); - Assert.Equal(new {BrakeSpecificFuelConsumption.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/CoefficientOfThermalExpansionTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/CoefficientOfThermalExpansionTestsBase.g.cs index e7420018a6..c1368f45f7 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/CoefficientOfThermalExpansionTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/CoefficientOfThermalExpansionTestsBase.g.cs @@ -704,7 +704,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = CoefficientOfThermalExpansion.FromPerKelvin(firstValue); var otherQuantity = CoefficientOfThermalExpansion.FromPerKelvin(secondValue); @@ -814,7 +814,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = CoefficientOfThermalExpansion.FromPerKelvin(1.0); - Assert.Equal(new {CoefficientOfThermalExpansion.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/CompressibilityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/CompressibilityTestsBase.g.cs index f4024ae93c..956a2d79e0 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/CompressibilityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/CompressibilityTestsBase.g.cs @@ -883,7 +883,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = Compressibility.FromInversePascals(firstValue); var otherQuantity = Compressibility.FromInversePascals(secondValue); @@ -995,7 +995,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = Compressibility.FromInversePascals(1.0); - Assert.Equal(new {Compressibility.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/DensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/DensityTestsBase.g.cs index 1f56da3a97..d26ef28f79 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/DensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/DensityTestsBase.g.cs @@ -2498,7 +2498,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = Density.FromKilogramsPerCubicMeter(firstValue); var otherQuantity = Density.FromKilogramsPerCubicMeter(secondValue); @@ -2708,7 +2708,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = Density.FromKilogramsPerCubicMeter(1.0); - Assert.Equal(new {Density.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/DoseAreaProductTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/DoseAreaProductTestsBase.g.cs index c143f12f0e..7db4f8a369 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/DoseAreaProductTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/DoseAreaProductTestsBase.g.cs @@ -1737,7 +1737,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = DoseAreaProduct.FromGraySquareMeters(firstValue); var otherQuantity = DoseAreaProduct.FromGraySquareMeters(secondValue); @@ -1885,7 +1885,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = DoseAreaProduct.FromGraySquareMeters(1.0); - Assert.Equal(new {DoseAreaProduct.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/DurationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/DurationTestsBase.g.cs index ee72161019..5f376a33d4 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/DurationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/DurationTestsBase.g.cs @@ -2011,7 +2011,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = Duration.FromSeconds(firstValue); var otherQuantity = Duration.FromSeconds(secondValue); @@ -2135,7 +2135,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = Duration.FromSeconds(1.0); - Assert.Equal(new {Duration.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/DynamicViscosityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/DynamicViscosityTestsBase.g.cs index c34b4bfbf3..c97f72a439 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/DynamicViscosityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/DynamicViscosityTestsBase.g.cs @@ -895,7 +895,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = DynamicViscosity.FromNewtonSecondsPerMeterSquared(firstValue); var otherQuantity = DynamicViscosity.FromNewtonSecondsPerMeterSquared(secondValue); @@ -1013,7 +1013,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = DynamicViscosity.FromNewtonSecondsPerMeterSquared(1.0); - Assert.Equal(new {DynamicViscosity.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricAdmittanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricAdmittanceTestsBase.g.cs index 1c26420706..608dd2600b 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricAdmittanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricAdmittanceTestsBase.g.cs @@ -1000,7 +1000,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = ElectricAdmittance.FromSiemens(firstValue); var otherQuantity = ElectricAdmittance.FromSiemens(secondValue); @@ -1130,7 +1130,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = ElectricAdmittance.FromSiemens(1.0); - Assert.Equal(new {ElectricAdmittance.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricApparentEnergyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricApparentEnergyTestsBase.g.cs index 740eff4eb3..a572ad05c9 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricApparentEnergyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricApparentEnergyTestsBase.g.cs @@ -608,7 +608,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = ElectricApparentEnergy.FromVoltampereHours(firstValue); var otherQuantity = ElectricApparentEnergy.FromVoltampereHours(secondValue); @@ -712,7 +712,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = ElectricApparentEnergy.FromVoltampereHours(1.0); - Assert.Equal(new {ElectricApparentEnergy.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricApparentPowerTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricApparentPowerTestsBase.g.cs index e646f22d37..8fc3a0fcd5 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricApparentPowerTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricApparentPowerTestsBase.g.cs @@ -692,7 +692,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = ElectricApparentPower.FromVoltamperes(firstValue); var otherQuantity = ElectricApparentPower.FromVoltamperes(secondValue); @@ -802,7 +802,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = ElectricApparentPower.FromVoltamperes(1.0); - Assert.Equal(new {ElectricApparentPower.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCapacitanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCapacitanceTestsBase.g.cs index d7d1a1f7ce..250e0b0516 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCapacitanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCapacitanceTestsBase.g.cs @@ -724,7 +724,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = ElectricCapacitance.FromFarads(firstValue); var otherQuantity = ElectricCapacitance.FromFarads(secondValue); @@ -836,7 +836,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = ElectricCapacitance.FromFarads(1.0); - Assert.Equal(new {ElectricCapacitance.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeDensityTestsBase.g.cs index c5ca052a05..663bed3173 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeDensityTestsBase.g.cs @@ -543,7 +543,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = ElectricChargeDensity.FromCoulombsPerCubicMeter(firstValue); var otherQuantity = ElectricChargeDensity.FromCoulombsPerCubicMeter(secondValue); @@ -643,7 +643,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = ElectricChargeDensity.FromCoulombsPerCubicMeter(1.0); - Assert.Equal(new {ElectricChargeDensity.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeTestsBase.g.cs index a230db093b..5c1d6f7622 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeTestsBase.g.cs @@ -912,7 +912,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = ElectricCharge.FromCoulombs(firstValue); var otherQuantity = ElectricCharge.FromCoulombs(secondValue); @@ -1032,7 +1032,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = ElectricCharge.FromCoulombs(1.0); - Assert.Equal(new {ElectricCharge.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductanceTestsBase.g.cs index 5d2940a3f5..0d3e7aea80 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductanceTestsBase.g.cs @@ -1000,7 +1000,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = ElectricConductance.FromSiemens(firstValue); var otherQuantity = ElectricConductance.FromSiemens(secondValue); @@ -1130,7 +1130,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = ElectricConductance.FromSiemens(1.0); - Assert.Equal(new {ElectricConductance.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductivityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductivityTestsBase.g.cs index ce63ef0041..388beb29b6 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductivityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductivityTestsBase.g.cs @@ -704,7 +704,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = ElectricConductivity.FromSiemensPerMeter(firstValue); var otherQuantity = ElectricConductivity.FromSiemensPerMeter(secondValue); @@ -814,7 +814,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = ElectricConductivity.FromSiemensPerMeter(1.0); - Assert.Equal(new {ElectricConductivity.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentDensityTestsBase.g.cs index 88276f17d5..898978631a 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentDensityTestsBase.g.cs @@ -608,7 +608,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = ElectricCurrentDensity.FromAmperesPerSquareMeter(firstValue); var otherQuantity = ElectricCurrentDensity.FromAmperesPerSquareMeter(secondValue); @@ -712,7 +712,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = ElectricCurrentDensity.FromAmperesPerSquareMeter(1.0); - Assert.Equal(new {ElectricCurrentDensity.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentGradientTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentGradientTestsBase.g.cs index 22bbae351a..ef9b65263f 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentGradientTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentGradientTestsBase.g.cs @@ -736,7 +736,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = ElectricCurrentGradient.FromAmperesPerSecond(firstValue); var otherQuantity = ElectricCurrentGradient.FromAmperesPerSecond(secondValue); @@ -848,7 +848,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = ElectricCurrentGradient.FromAmperesPerSecond(1.0); - Assert.Equal(new {ElectricCurrentGradient.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentTestsBase.g.cs index fdf1051a4d..484cef4b74 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentTestsBase.g.cs @@ -788,7 +788,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = ElectricCurrent.FromAmperes(firstValue); var otherQuantity = ElectricCurrent.FromAmperes(secondValue); @@ -904,7 +904,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = ElectricCurrent.FromAmperes(1.0); - Assert.Equal(new {ElectricCurrent.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricFieldTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricFieldTestsBase.g.cs index 8dfefedb0c..8e8fce8ab2 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricFieldTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricFieldTestsBase.g.cs @@ -543,7 +543,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = ElectricField.FromVoltsPerMeter(firstValue); var otherQuantity = ElectricField.FromVoltsPerMeter(secondValue); @@ -643,7 +643,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = ElectricField.FromVoltsPerMeter(1.0); - Assert.Equal(new {ElectricField.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricImpedanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricImpedanceTestsBase.g.cs index 993fa6dee3..2d2346dbe5 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricImpedanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricImpedanceTestsBase.g.cs @@ -756,7 +756,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = ElectricImpedance.FromOhms(firstValue); var otherQuantity = ElectricImpedance.FromOhms(secondValue); @@ -870,7 +870,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = ElectricImpedance.FromOhms(1.0); - Assert.Equal(new {ElectricImpedance.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricInductanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricInductanceTestsBase.g.cs index b7889cf3c3..172a3b4291 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricInductanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricInductanceTestsBase.g.cs @@ -672,7 +672,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = ElectricInductance.FromHenries(firstValue); var otherQuantity = ElectricInductance.FromHenries(secondValue); @@ -780,7 +780,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = ElectricInductance.FromHenries(1.0); - Assert.Equal(new {ElectricInductance.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialChangeRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialChangeRateTestsBase.g.cs index c7ff162b51..4e188ad061 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialChangeRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialChangeRateTestsBase.g.cs @@ -1104,7 +1104,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = ElectricPotentialChangeRate.FromVoltsPerSecond(firstValue); var otherQuantity = ElectricPotentialChangeRate.FromVoltsPerSecond(secondValue); @@ -1242,7 +1242,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = ElectricPotentialChangeRate.FromVoltsPerSecond(1.0); - Assert.Equal(new {ElectricPotentialChangeRate.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialTestsBase.g.cs index 6ca4aa9a8c..511b5128d8 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialTestsBase.g.cs @@ -782,7 +782,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = ElectricPotential.FromVolts(firstValue); var otherQuantity = ElectricPotential.FromVolts(secondValue); @@ -892,7 +892,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = ElectricPotential.FromVolts(1.0); - Assert.Equal(new {ElectricPotential.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricReactanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricReactanceTestsBase.g.cs index 9e24b6efe3..6ae9f0d83e 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricReactanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricReactanceTestsBase.g.cs @@ -756,7 +756,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = ElectricReactance.FromOhms(firstValue); var otherQuantity = ElectricReactance.FromOhms(secondValue); @@ -870,7 +870,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = ElectricReactance.FromOhms(1.0); - Assert.Equal(new {ElectricReactance.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricReactiveEnergyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricReactiveEnergyTestsBase.g.cs index 9e3d00362e..fcb7824435 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricReactiveEnergyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricReactiveEnergyTestsBase.g.cs @@ -608,7 +608,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = ElectricReactiveEnergy.FromVoltampereReactiveHours(firstValue); var otherQuantity = ElectricReactiveEnergy.FromVoltampereReactiveHours(secondValue); @@ -712,7 +712,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = ElectricReactiveEnergy.FromVoltampereReactiveHours(1.0); - Assert.Equal(new {ElectricReactiveEnergy.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricReactivePowerTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricReactivePowerTestsBase.g.cs index 02aa73c09f..e9f82663f7 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricReactivePowerTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricReactivePowerTestsBase.g.cs @@ -640,7 +640,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = ElectricReactivePower.FromVoltamperesReactive(firstValue); var otherQuantity = ElectricReactivePower.FromVoltamperesReactive(secondValue); @@ -746,7 +746,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = ElectricReactivePower.FromVoltamperesReactive(1.0); - Assert.Equal(new {ElectricReactivePower.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistanceTestsBase.g.cs index 408555f9cb..3c77a26670 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistanceTestsBase.g.cs @@ -756,7 +756,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = ElectricResistance.FromOhms(firstValue); var otherQuantity = ElectricResistance.FromOhms(secondValue); @@ -870,7 +870,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = ElectricResistance.FromOhms(1.0); - Assert.Equal(new {ElectricResistance.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistivityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistivityTestsBase.g.cs index c5086b7fda..442a56c8de 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistivityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistivityTestsBase.g.cs @@ -936,7 +936,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = ElectricResistivity.FromOhmMeters(firstValue); var otherQuantity = ElectricResistivity.FromOhmMeters(secondValue); @@ -1062,7 +1062,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = ElectricResistivity.FromOhmMeters(1.0); - Assert.Equal(new {ElectricResistivity.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricSurfaceChargeDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricSurfaceChargeDensityTestsBase.g.cs index 1962e6b00f..449540b52a 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricSurfaceChargeDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricSurfaceChargeDensityTestsBase.g.cs @@ -608,7 +608,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(firstValue); var otherQuantity = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(secondValue); @@ -712,7 +712,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1.0); - Assert.Equal(new {ElectricSurfaceChargeDensity.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricSusceptanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricSusceptanceTestsBase.g.cs index 542de39a01..015f67d905 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricSusceptanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricSusceptanceTestsBase.g.cs @@ -1000,7 +1000,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = ElectricSusceptance.FromSiemens(firstValue); var otherQuantity = ElectricSusceptance.FromSiemens(secondValue); @@ -1130,7 +1130,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = ElectricSusceptance.FromSiemens(1.0); - Assert.Equal(new {ElectricSusceptance.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/EnergyDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/EnergyDensityTestsBase.g.cs index 9bf463ecdd..225e932afe 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/EnergyDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/EnergyDensityTestsBase.g.cs @@ -896,7 +896,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = EnergyDensity.FromJoulesPerCubicMeter(firstValue); var otherQuantity = EnergyDensity.FromJoulesPerCubicMeter(secondValue); @@ -1018,7 +1018,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = EnergyDensity.FromJoulesPerCubicMeter(1.0); - Assert.Equal(new {EnergyDensity.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/EnergyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/EnergyTestsBase.g.cs index e8735945b6..1b9ed93de8 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/EnergyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/EnergyTestsBase.g.cs @@ -2137,7 +2137,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = Energy.FromJoules(firstValue); var otherQuantity = Energy.FromJoules(secondValue); @@ -2315,7 +2315,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = Energy.FromJoules(1.0); - Assert.Equal(new {Energy.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/EntropyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/EntropyTestsBase.g.cs index a467238862..d751f12a6a 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/EntropyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/EntropyTestsBase.g.cs @@ -736,7 +736,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = Entropy.FromJoulesPerKelvin(firstValue); var otherQuantity = Entropy.FromJoulesPerKelvin(secondValue); @@ -848,7 +848,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = Entropy.FromJoulesPerKelvin(1.0); - Assert.Equal(new {Entropy.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/FluidResistanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/FluidResistanceTestsBase.g.cs index a6db98697c..6822d0092e 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/FluidResistanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/FluidResistanceTestsBase.g.cs @@ -1519,7 +1519,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = FluidResistance.FromPascalSecondsPerCubicMeter(firstValue); var otherQuantity = FluidResistance.FromPascalSecondsPerCubicMeter(secondValue); @@ -1655,7 +1655,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = FluidResistance.FromPascalSecondsPerCubicMeter(1.0); - Assert.Equal(new {FluidResistance.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ForceChangeRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ForceChangeRateTestsBase.g.cs index a7907ea8d8..f7ac3890cc 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ForceChangeRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ForceChangeRateTestsBase.g.cs @@ -1076,7 +1076,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = ForceChangeRate.FromNewtonsPerSecond(firstValue); var otherQuantity = ForceChangeRate.FromNewtonsPerSecond(secondValue); @@ -1204,7 +1204,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = ForceChangeRate.FromNewtonsPerSecond(1.0); - Assert.Equal(new {ForceChangeRate.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ForcePerLengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ForcePerLengthTestsBase.g.cs index 6be0f104a1..06ff37ad62 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ForcePerLengthTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ForcePerLengthTestsBase.g.cs @@ -1878,7 +1878,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = ForcePerLength.FromNewtonsPerMeter(firstValue); var otherQuantity = ForcePerLength.FromNewtonsPerMeter(secondValue); @@ -2052,7 +2052,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = ForcePerLength.FromNewtonsPerMeter(1.0); - Assert.Equal(new {ForcePerLength.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ForceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ForceTestsBase.g.cs index 078d781861..17a3e7e665 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ForceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ForceTestsBase.g.cs @@ -1322,7 +1322,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = Force.FromNewtons(firstValue); var otherQuantity = Force.FromNewtons(secondValue); @@ -1450,7 +1450,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = Force.FromNewtons(1.0); - Assert.Equal(new {Force.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/FrequencyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/FrequencyTestsBase.g.cs index 15ec9aef68..4e23e4b0df 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/FrequencyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/FrequencyTestsBase.g.cs @@ -1025,7 +1025,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = Frequency.FromHertz(firstValue); var otherQuantity = Frequency.FromHertz(secondValue); @@ -1147,7 +1147,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = Frequency.FromHertz(1.0); - Assert.Equal(new {Frequency.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/FuelEfficiencyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/FuelEfficiencyTestsBase.g.cs index e0a49af9b6..c55399150b 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/FuelEfficiencyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/FuelEfficiencyTestsBase.g.cs @@ -640,7 +640,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = FuelEfficiency.FromKilometersPerLiter(firstValue); var otherQuantity = FuelEfficiency.FromKilometersPerLiter(secondValue); @@ -746,7 +746,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = FuelEfficiency.FromKilometersPerLiter(1.0); - Assert.Equal(new {FuelEfficiency.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/HeatFluxTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/HeatFluxTestsBase.g.cs index 4ae644c6b0..48257d98c7 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/HeatFluxTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/HeatFluxTestsBase.g.cs @@ -1109,7 +1109,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = HeatFlux.FromWattsPerSquareMeter(firstValue); var otherQuantity = HeatFlux.FromWattsPerSquareMeter(secondValue); @@ -1243,7 +1243,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = HeatFlux.FromWattsPerSquareMeter(1.0); - Assert.Equal(new {HeatFlux.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/HeatTransferCoefficientTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/HeatTransferCoefficientTestsBase.g.cs index 04f8e48266..83b3fbe368 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/HeatTransferCoefficientTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/HeatTransferCoefficientTestsBase.g.cs @@ -861,7 +861,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(firstValue); var otherQuantity = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(secondValue); @@ -969,7 +969,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(1.0); - Assert.Equal(new {HeatTransferCoefficient.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/IlluminanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/IlluminanceTestsBase.g.cs index dd3045fcc8..5b0ba7c8cf 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/IlluminanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/IlluminanceTestsBase.g.cs @@ -628,7 +628,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = Illuminance.FromLux(firstValue); var otherQuantity = Illuminance.FromLux(secondValue); @@ -734,7 +734,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = Illuminance.FromLux(1.0); - Assert.Equal(new {Illuminance.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ImpulseTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ImpulseTestsBase.g.cs index 1fc469f050..3ec18a9645 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ImpulseTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ImpulseTestsBase.g.cs @@ -916,7 +916,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = Impulse.FromNewtonSeconds(firstValue); var otherQuantity = Impulse.FromNewtonSeconds(secondValue); @@ -1040,7 +1040,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = Impulse.FromNewtonSeconds(1.0); - Assert.Equal(new {Impulse.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/InformationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/InformationTestsBase.g.cs index f53661ad89..83e590606a 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/InformationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/InformationTestsBase.g.cs @@ -1544,7 +1544,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = Information.FromBits(firstValue); var otherQuantity = Information.FromBits(secondValue); @@ -1720,7 +1720,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = Information.FromBits(1.0); - Assert.Equal(new {Information.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/IrradianceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/IrradianceTestsBase.g.cs index 64649485e0..380de827db 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/IrradianceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/IrradianceTestsBase.g.cs @@ -936,7 +936,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = Irradiance.FromWattsPerSquareMeter(firstValue); var otherQuantity = Irradiance.FromWattsPerSquareMeter(secondValue); @@ -1062,7 +1062,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = Irradiance.FromWattsPerSquareMeter(1.0); - Assert.Equal(new {Irradiance.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/IrradiationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/IrradiationTestsBase.g.cs index 7bcb25e38d..27256ede70 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/IrradiationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/IrradiationTestsBase.g.cs @@ -800,7 +800,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = Irradiation.FromJoulesPerSquareMeter(firstValue); var otherQuantity = Irradiation.FromJoulesPerSquareMeter(secondValue); @@ -916,7 +916,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = Irradiation.FromJoulesPerSquareMeter(1.0); - Assert.Equal(new {Irradiation.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/JerkTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/JerkTestsBase.g.cs index 536de9d86d..5e7fd2cfc1 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/JerkTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/JerkTestsBase.g.cs @@ -1051,7 +1051,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = Jerk.FromMetersPerSecondCubed(firstValue); var otherQuantity = Jerk.FromMetersPerSecondCubed(secondValue); @@ -1171,7 +1171,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = Jerk.FromMetersPerSecondCubed(1.0); - Assert.Equal(new {Jerk.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/KinematicViscosityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/KinematicViscosityTestsBase.g.cs index 5745d607dc..bf9af661b2 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/KinematicViscosityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/KinematicViscosityTestsBase.g.cs @@ -936,7 +936,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = KinematicViscosity.FromSquareMetersPerSecond(firstValue); var otherQuantity = KinematicViscosity.FromSquareMetersPerSecond(secondValue); @@ -1052,7 +1052,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = KinematicViscosity.FromSquareMetersPerSecond(1.0); - Assert.Equal(new {KinematicViscosity.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LeakRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LeakRateTestsBase.g.cs index ee5fbe2c9c..df59a8c89d 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LeakRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LeakRateTestsBase.g.cs @@ -608,7 +608,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = LeakRate.FromPascalCubicMetersPerSecond(firstValue); var otherQuantity = LeakRate.FromPascalCubicMetersPerSecond(secondValue); @@ -712,7 +712,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = LeakRate.FromPascalCubicMetersPerSecond(1.0); - Assert.Equal(new {LeakRate.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LengthTestsBase.g.cs index 1cd46b6ab4..b481970b3c 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LengthTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LengthTestsBase.g.cs @@ -2678,7 +2678,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = Length.FromMeters(firstValue); var otherQuantity = Length.FromMeters(secondValue); @@ -2860,7 +2860,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = Length.FromMeters(1.0); - Assert.Equal(new {Length.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LevelTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LevelTestsBase.g.cs index bf429a014a..cc30b50e01 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LevelTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LevelTestsBase.g.cs @@ -520,7 +520,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_Logarithmic_WithTolerance(double firstValue, double secondValue) { var quantity = Level.FromDecibels(firstValue); var otherQuantity = Level.FromDecibels(secondValue); @@ -536,7 +536,7 @@ public void Equals_WithTolerance_IsImplemented(double firstValue, double secondV } [Fact] - public void Equals_WithNegativeTolerance_DoesNotThrowArgumentOutOfRangeException() + public void Equals_Logarithmic_WithNegativeTolerance_DoesNotThrowArgumentOutOfRangeException() { // note: unlike with vector quantities- a small tolerance maybe positive in one unit and negative in another var quantity = Level.FromDecibels(1); @@ -624,7 +624,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = Level.FromDecibels(1.0); - Assert.Equal(new {Level.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LinearDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LinearDensityTestsBase.g.cs index 1b60488d3d..bc36573102 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LinearDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LinearDensityTestsBase.g.cs @@ -1088,7 +1088,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = LinearDensity.FromKilogramsPerMeter(firstValue); var otherQuantity = LinearDensity.FromKilogramsPerMeter(secondValue); @@ -1222,7 +1222,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = LinearDensity.FromKilogramsPerMeter(1.0); - Assert.Equal(new {LinearDensity.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LinearPowerDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LinearPowerDensityTestsBase.g.cs index 955f9566fd..95d84a9bfd 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LinearPowerDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LinearPowerDensityTestsBase.g.cs @@ -1252,7 +1252,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = LinearPowerDensity.FromWattsPerMeter(firstValue); var otherQuantity = LinearPowerDensity.FromWattsPerMeter(secondValue); @@ -1400,7 +1400,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = LinearPowerDensity.FromWattsPerMeter(1.0); - Assert.Equal(new {LinearPowerDensity.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminanceTestsBase.g.cs index e02d8489ae..c531bdedce 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminanceTestsBase.g.cs @@ -832,7 +832,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = Luminance.FromCandelasPerSquareMeter(firstValue); var otherQuantity = Luminance.FromCandelasPerSquareMeter(secondValue); @@ -950,7 +950,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = Luminance.FromCandelasPerSquareMeter(1.0); - Assert.Equal(new {Luminance.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminosityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminosityTestsBase.g.cs index a86d408057..6f12ed330f 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminosityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminosityTestsBase.g.cs @@ -936,7 +936,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = Luminosity.FromWatts(firstValue); var otherQuantity = Luminosity.FromWatts(secondValue); @@ -1062,7 +1062,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = Luminosity.FromWatts(1.0); - Assert.Equal(new {Luminosity.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousFluxTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousFluxTestsBase.g.cs index 87b0b13626..454a1cad7a 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousFluxTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousFluxTestsBase.g.cs @@ -543,7 +543,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = LuminousFlux.FromLumens(firstValue); var otherQuantity = LuminousFlux.FromLumens(secondValue); @@ -643,7 +643,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = LuminousFlux.FromLumens(1.0); - Assert.Equal(new {LuminousFlux.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousIntensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousIntensityTestsBase.g.cs index 83fa504238..1d27198571 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousIntensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousIntensityTestsBase.g.cs @@ -543,7 +543,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = LuminousIntensity.FromCandela(firstValue); var otherQuantity = LuminousIntensity.FromCandela(secondValue); @@ -643,7 +643,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = LuminousIntensity.FromCandela(1.0); - Assert.Equal(new {LuminousIntensity.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFieldTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFieldTestsBase.g.cs index ba52810f02..a78cb1a83d 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFieldTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFieldTestsBase.g.cs @@ -704,7 +704,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = MagneticField.FromTeslas(firstValue); var otherQuantity = MagneticField.FromTeslas(secondValue); @@ -814,7 +814,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = MagneticField.FromTeslas(1.0); - Assert.Equal(new {MagneticField.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFluxTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFluxTestsBase.g.cs index b512b1596c..b19986b1f1 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFluxTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFluxTestsBase.g.cs @@ -543,7 +543,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = MagneticFlux.FromWebers(firstValue); var otherQuantity = MagneticFlux.FromWebers(secondValue); @@ -643,7 +643,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = MagneticFlux.FromWebers(1.0); - Assert.Equal(new {MagneticFlux.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MagnetizationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MagnetizationTestsBase.g.cs index 1299b3c87c..655578aff6 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MagnetizationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MagnetizationTestsBase.g.cs @@ -543,7 +543,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = Magnetization.FromAmperesPerMeter(firstValue); var otherQuantity = Magnetization.FromAmperesPerMeter(secondValue); @@ -643,7 +643,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = Magnetization.FromAmperesPerMeter(1.0); - Assert.Equal(new {Magnetization.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassConcentrationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassConcentrationTestsBase.g.cs index b8b5389b3c..dcd3ed415a 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassConcentrationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassConcentrationTestsBase.g.cs @@ -2148,7 +2148,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = MassConcentration.FromKilogramsPerCubicMeter(firstValue); var otherQuantity = MassConcentration.FromKilogramsPerCubicMeter(secondValue); @@ -2344,7 +2344,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = MassConcentration.FromKilogramsPerCubicMeter(1.0); - Assert.Equal(new {MassConcentration.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFlowTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFlowTestsBase.g.cs index 7dfeedcde7..37cf772ff7 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFlowTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFlowTestsBase.g.cs @@ -1779,7 +1779,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = MassFlow.FromGramsPerSecond(firstValue); var otherQuantity = MassFlow.FromGramsPerSecond(secondValue); @@ -1943,7 +1943,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = MassFlow.FromGramsPerSecond(1.0); - Assert.Equal(new {MassFlow.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFluxTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFluxTestsBase.g.cs index 4c8aa41cf6..fd540d202f 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFluxTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFluxTestsBase.g.cs @@ -896,7 +896,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = MassFlux.FromKilogramsPerSecondPerSquareMeter(firstValue); var otherQuantity = MassFlux.FromKilogramsPerSecondPerSquareMeter(secondValue); @@ -1018,7 +1018,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = MassFlux.FromKilogramsPerSecondPerSquareMeter(1.0); - Assert.Equal(new {MassFlux.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFractionTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFractionTestsBase.g.cs index a193c68d56..40cd0738f8 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFractionTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFractionTestsBase.g.cs @@ -1241,7 +1241,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = MassFraction.FromDecimalFractions(firstValue); var otherQuantity = MassFraction.FromDecimalFractions(secondValue); @@ -1387,7 +1387,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = MassFraction.FromDecimalFractions(1.0); - Assert.Equal(new {MassFraction.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassMomentOfInertiaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassMomentOfInertiaTestsBase.g.cs index d9dccc3b91..5c891fb2ee 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassMomentOfInertiaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassMomentOfInertiaTestsBase.g.cs @@ -1408,7 +1408,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = MassMomentOfInertia.FromKilogramSquareMeters(firstValue); var otherQuantity = MassMomentOfInertia.FromKilogramSquareMeters(secondValue); @@ -1562,7 +1562,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = MassMomentOfInertia.FromKilogramSquareMeters(1.0); - Assert.Equal(new {MassMomentOfInertia.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassTestsBase.g.cs index 4fcd256ce4..eb2095bde4 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassTestsBase.g.cs @@ -2202,7 +2202,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = Mass.FromKilograms(firstValue); var otherQuantity = Mass.FromKilograms(secondValue); @@ -2354,7 +2354,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = Mass.FromKilograms(1.0); - Assert.Equal(new {Mass.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MolalityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MolalityTestsBase.g.cs index 46f1f77af4..d43020fbbb 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MolalityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MolalityTestsBase.g.cs @@ -608,7 +608,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = Molality.FromMolesPerKilogram(firstValue); var otherQuantity = Molality.FromMolesPerKilogram(secondValue); @@ -712,7 +712,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = Molality.FromMolesPerKilogram(1.0); - Assert.Equal(new {Molality.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEnergyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEnergyTestsBase.g.cs index ee3bde5c94..0b21561c2d 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEnergyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEnergyTestsBase.g.cs @@ -608,7 +608,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = MolarEnergy.FromJoulesPerMole(firstValue); var otherQuantity = MolarEnergy.FromJoulesPerMole(secondValue); @@ -712,7 +712,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = MolarEnergy.FromJoulesPerMole(1.0); - Assert.Equal(new {MolarEnergy.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEntropyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEntropyTestsBase.g.cs index 2bfd7c8f4c..29a3d514a0 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEntropyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEntropyTestsBase.g.cs @@ -608,7 +608,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = MolarEntropy.FromJoulesPerMoleKelvin(firstValue); var otherQuantity = MolarEntropy.FromJoulesPerMoleKelvin(secondValue); @@ -712,7 +712,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = MolarEntropy.FromJoulesPerMoleKelvin(1.0); - Assert.Equal(new {MolarEntropy.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarFlowTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarFlowTestsBase.g.cs index fa1bd670ab..3c586037da 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarFlowTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarFlowTestsBase.g.cs @@ -800,7 +800,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = MolarFlow.FromMolesPerSecond(firstValue); var otherQuantity = MolarFlow.FromMolesPerSecond(secondValue); @@ -916,7 +916,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = MolarFlow.FromMolesPerSecond(1.0); - Assert.Equal(new {MolarFlow.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarMassTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarMassTestsBase.g.cs index 352d3d1f71..c22c8d769a 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarMassTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarMassTestsBase.g.cs @@ -1132,7 +1132,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = MolarMass.FromKilogramsPerMole(firstValue); var otherQuantity = MolarMass.FromKilogramsPerMole(secondValue); @@ -1256,7 +1256,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = MolarMass.FromKilogramsPerMole(1.0); - Assert.Equal(new {MolarMass.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarityTestsBase.g.cs index 2afa67a0c2..415b5b7ed5 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarityTestsBase.g.cs @@ -1032,7 +1032,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = Molarity.FromMolesPerCubicMeter(firstValue); var otherQuantity = Molarity.FromMolesPerCubicMeter(secondValue); @@ -1152,7 +1152,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = Molarity.FromMolesPerCubicMeter(1.0); - Assert.Equal(new {Molarity.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PermeabilityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PermeabilityTestsBase.g.cs index 52ac867bb1..ec9705876d 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PermeabilityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PermeabilityTestsBase.g.cs @@ -543,7 +543,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = Permeability.FromHenriesPerMeter(firstValue); var otherQuantity = Permeability.FromHenriesPerMeter(secondValue); @@ -643,7 +643,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = Permeability.FromHenriesPerMeter(1.0); - Assert.Equal(new {Permeability.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PermittivityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PermittivityTestsBase.g.cs index 3a80e3e997..a24cc3d2f9 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PermittivityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PermittivityTestsBase.g.cs @@ -543,7 +543,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = Permittivity.FromFaradsPerMeter(firstValue); var otherQuantity = Permittivity.FromFaradsPerMeter(secondValue); @@ -643,7 +643,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = Permittivity.FromFaradsPerMeter(1.0); - Assert.Equal(new {Permittivity.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PorousMediumPermeabilityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PorousMediumPermeabilityTestsBase.g.cs index 1b245ff09a..590bcb32a1 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PorousMediumPermeabilityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PorousMediumPermeabilityTestsBase.g.cs @@ -672,7 +672,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = PorousMediumPermeability.FromSquareMeters(firstValue); var otherQuantity = PorousMediumPermeability.FromSquareMeters(secondValue); @@ -780,7 +780,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = PorousMediumPermeability.FromSquareMeters(1.0); - Assert.Equal(new {PorousMediumPermeability.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerDensityTestsBase.g.cs index b64437df26..490df866f7 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerDensityTestsBase.g.cs @@ -1872,7 +1872,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = PowerDensity.FromWattsPerCubicMeter(firstValue); var otherQuantity = PowerDensity.FromWattsPerCubicMeter(secondValue); @@ -2058,7 +2058,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = PowerDensity.FromWattsPerCubicMeter(1.0); - Assert.Equal(new {PowerDensity.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerRatioTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerRatioTestsBase.g.cs index 62c90725f7..978840a687 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerRatioTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerRatioTestsBase.g.cs @@ -541,7 +541,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_Logarithmic_WithTolerance(double firstValue, double secondValue) { var quantity = PowerRatio.FromDecibelWatts(firstValue); var otherQuantity = PowerRatio.FromDecibelWatts(secondValue); @@ -557,7 +557,7 @@ public void Equals_WithTolerance_IsImplemented(double firstValue, double secondV } [Fact] - public void Equals_WithNegativeTolerance_DoesNotThrowArgumentOutOfRangeException() + public void Equals_Logarithmic_WithNegativeTolerance_DoesNotThrowArgumentOutOfRangeException() { // note: unlike with vector quantities- a small tolerance maybe positive in one unit and negative in another var quantity = PowerRatio.FromDecibelWatts(1); @@ -645,7 +645,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = PowerRatio.FromDecibelWatts(1.0); - Assert.Equal(new {PowerRatio.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerTestsBase.g.cs index 3132574950..e52b5e05bf 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerTestsBase.g.cs @@ -1403,7 +1403,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = Power.FromWatts(firstValue); var otherQuantity = Power.FromWatts(secondValue); @@ -1555,7 +1555,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = Power.FromWatts(1.0); - Assert.Equal(new {Power.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PressureChangeRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PressureChangeRateTestsBase.g.cs index c6551c372d..2179259fbf 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PressureChangeRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PressureChangeRateTestsBase.g.cs @@ -1622,7 +1622,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = PressureChangeRate.FromPascalsPerSecond(firstValue); var otherQuantity = PressureChangeRate.FromPascalsPerSecond(secondValue); @@ -1756,7 +1756,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = PressureChangeRate.FromPascalsPerSecond(1.0); - Assert.Equal(new {PressureChangeRate.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PressureTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PressureTestsBase.g.cs index 007eb4777d..46001e1746 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PressureTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PressureTestsBase.g.cs @@ -2832,7 +2832,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = Pressure.FromPascals(firstValue); var otherQuantity = Pressure.FromPascals(secondValue); @@ -3024,7 +3024,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = Pressure.FromPascals(1.0); - Assert.Equal(new {Pressure.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RadiationEquivalentDoseRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RadiationEquivalentDoseRateTestsBase.g.cs index 768c34fea8..be295dc149 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RadiationEquivalentDoseRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RadiationEquivalentDoseRateTestsBase.g.cs @@ -968,7 +968,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = RadiationEquivalentDoseRate.FromSievertsPerSecond(firstValue); var otherQuantity = RadiationEquivalentDoseRate.FromSievertsPerSecond(secondValue); @@ -1086,7 +1086,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = RadiationEquivalentDoseRate.FromSievertsPerSecond(1.0); - Assert.Equal(new {RadiationEquivalentDoseRate.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RadiationEquivalentDoseTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RadiationEquivalentDoseTestsBase.g.cs index 08e4636d0c..32cfe349fe 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RadiationEquivalentDoseTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RadiationEquivalentDoseTestsBase.g.cs @@ -772,7 +772,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = RadiationEquivalentDose.FromSieverts(firstValue); var otherQuantity = RadiationEquivalentDose.FromSieverts(secondValue); @@ -882,7 +882,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = RadiationEquivalentDose.FromSieverts(1.0); - Assert.Equal(new {RadiationEquivalentDose.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RadiationExposureTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RadiationExposureTestsBase.g.cs index 706a7547be..e53b0eabfb 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RadiationExposureTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RadiationExposureTestsBase.g.cs @@ -768,7 +768,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = RadiationExposure.FromCoulombsPerKilogram(firstValue); var otherQuantity = RadiationExposure.FromCoulombsPerKilogram(secondValue); @@ -882,7 +882,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = RadiationExposure.FromCoulombsPerKilogram(1.0); - Assert.Equal(new {RadiationExposure.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RadioactivityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RadioactivityTestsBase.g.cs index 252b9371ef..516d7f6411 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RadioactivityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RadioactivityTestsBase.g.cs @@ -1837,7 +1837,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = Radioactivity.FromBecquerels(firstValue); var otherQuantity = Radioactivity.FromBecquerels(secondValue); @@ -1993,7 +1993,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = Radioactivity.FromBecquerels(1.0); - Assert.Equal(new {Radioactivity.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RatioChangeRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RatioChangeRateTestsBase.g.cs index 201653a03b..a48254c7fa 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RatioChangeRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RatioChangeRateTestsBase.g.cs @@ -576,7 +576,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = RatioChangeRate.FromDecimalFractionsPerSecond(firstValue); var otherQuantity = RatioChangeRate.FromDecimalFractionsPerSecond(secondValue); @@ -678,7 +678,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = RatioChangeRate.FromDecimalFractionsPerSecond(1.0); - Assert.Equal(new {RatioChangeRate.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RatioTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RatioTestsBase.g.cs index 252448f697..3bdf72344e 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RatioTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RatioTestsBase.g.cs @@ -644,7 +644,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = Ratio.FromDecimalFractions(firstValue); var otherQuantity = Ratio.FromDecimalFractions(secondValue); @@ -754,7 +754,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = Ratio.FromDecimalFractions(1.0); - Assert.Equal(new {Ratio.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalAreaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalAreaTestsBase.g.cs index b6488b71ad..103070d342 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalAreaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalAreaTestsBase.g.cs @@ -864,7 +864,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = ReciprocalArea.FromInverseSquareMeters(firstValue); var otherQuantity = ReciprocalArea.FromInverseSquareMeters(secondValue); @@ -984,7 +984,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = ReciprocalArea.FromInverseSquareMeters(1.0); - Assert.Equal(new {ReciprocalArea.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalLengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalLengthTestsBase.g.cs index a1787eb848..d784d957ed 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalLengthTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalLengthTestsBase.g.cs @@ -1042,7 +1042,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = ReciprocalLength.FromInverseMeters(firstValue); var otherQuantity = ReciprocalLength.FromInverseMeters(secondValue); @@ -1160,7 +1160,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = ReciprocalLength.FromInverseMeters(1.0); - Assert.Equal(new {ReciprocalLength.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RelativeHumidityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RelativeHumidityTestsBase.g.cs index 23d78769a9..b5400b0e2a 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RelativeHumidityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RelativeHumidityTestsBase.g.cs @@ -483,7 +483,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = RelativeHumidity.FromPercent(firstValue); var otherQuantity = RelativeHumidity.FromPercent(secondValue); @@ -583,7 +583,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = RelativeHumidity.FromPercent(1.0); - Assert.Equal(new {RelativeHumidity.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalAccelerationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalAccelerationTestsBase.g.cs index 12f85b5b77..0fe36eef90 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalAccelerationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalAccelerationTestsBase.g.cs @@ -661,7 +661,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = RotationalAcceleration.FromRadiansPerSecondSquared(firstValue); var otherQuantity = RotationalAcceleration.FromRadiansPerSecondSquared(secondValue); @@ -767,7 +767,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = RotationalAcceleration.FromRadiansPerSecondSquared(1.0); - Assert.Equal(new {RotationalAcceleration.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalSpeedTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalSpeedTestsBase.g.cs index e595a61724..7663c63644 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalSpeedTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalSpeedTestsBase.g.cs @@ -1258,7 +1258,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = RotationalSpeed.FromRadiansPerSecond(firstValue); var otherQuantity = RotationalSpeed.FromRadiansPerSecond(secondValue); @@ -1382,7 +1382,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = RotationalSpeed.FromRadiansPerSecond(1.0); - Assert.Equal(new {RotationalSpeed.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessPerLengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessPerLengthTestsBase.g.cs index 6b4c69d5ae..cf6bb6f212 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessPerLengthTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessPerLengthTestsBase.g.cs @@ -840,7 +840,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(firstValue); var otherQuantity = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(secondValue); @@ -948,7 +948,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(1.0); - Assert.Equal(new {RotationalStiffnessPerLength.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessTestsBase.g.cs index 2975af62e7..8dfb1e7703 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessTestsBase.g.cs @@ -2939,7 +2939,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = RotationalStiffness.FromNewtonMetersPerRadian(firstValue); var otherQuantity = RotationalStiffness.FromNewtonMetersPerRadian(secondValue); @@ -3103,7 +3103,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = RotationalStiffness.FromNewtonMetersPerRadian(1.0); - Assert.Equal(new {RotationalStiffness.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ScalarTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ScalarTestsBase.g.cs index f4cc851e6e..e10f2477ba 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ScalarTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ScalarTestsBase.g.cs @@ -483,7 +483,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = Scalar.FromAmount(firstValue); var otherQuantity = Scalar.FromAmount(secondValue); @@ -583,7 +583,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = Scalar.FromAmount(1.0); - Assert.Equal(new {Scalar.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SolidAngleTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SolidAngleTestsBase.g.cs index 615b63f972..af05f94c81 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SolidAngleTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SolidAngleTestsBase.g.cs @@ -483,7 +483,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = SolidAngle.FromSteradians(firstValue); var otherQuantity = SolidAngle.FromSteradians(secondValue); @@ -583,7 +583,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = SolidAngle.FromSteradians(1.0); - Assert.Equal(new {SolidAngle.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEnergyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEnergyTestsBase.g.cs index 073dcb5177..66ece56c3b 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEnergyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEnergyTestsBase.g.cs @@ -1472,7 +1472,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = SpecificEnergy.FromJoulesPerKilogram(firstValue); var otherQuantity = SpecificEnergy.FromJoulesPerKilogram(secondValue); @@ -1630,7 +1630,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = SpecificEnergy.FromJoulesPerKilogram(1.0); - Assert.Equal(new {SpecificEnergy.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEntropyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEntropyTestsBase.g.cs index 4a6c3dd94a..cba5df0f86 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEntropyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEntropyTestsBase.g.cs @@ -821,7 +821,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = SpecificEntropy.FromJoulesPerKilogramKelvin(firstValue); var otherQuantity = SpecificEntropy.FromJoulesPerKilogramKelvin(secondValue); @@ -937,7 +937,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = SpecificEntropy.FromJoulesPerKilogramKelvin(1.0); - Assert.Equal(new {SpecificEntropy.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificFuelConsumptionTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificFuelConsumptionTestsBase.g.cs index ae24b2d820..7162d9f636 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificFuelConsumptionTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificFuelConsumptionTestsBase.g.cs @@ -640,7 +640,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = SpecificFuelConsumption.FromGramsPerKilonewtonSecond(firstValue); var otherQuantity = SpecificFuelConsumption.FromGramsPerKilonewtonSecond(secondValue); @@ -746,7 +746,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = SpecificFuelConsumption.FromGramsPerKilonewtonSecond(1.0); - Assert.Equal(new {SpecificFuelConsumption.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificVolumeTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificVolumeTestsBase.g.cs index d84d1055d3..b3e0c1b7aa 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificVolumeTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificVolumeTestsBase.g.cs @@ -608,7 +608,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = SpecificVolume.FromCubicMetersPerKilogram(firstValue); var otherQuantity = SpecificVolume.FromCubicMetersPerKilogram(secondValue); @@ -712,7 +712,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = SpecificVolume.FromCubicMetersPerKilogram(1.0); - Assert.Equal(new {SpecificVolume.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificWeightTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificWeightTestsBase.g.cs index 4bdb9d9db4..e2ea1a595d 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificWeightTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificWeightTestsBase.g.cs @@ -1056,7 +1056,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = SpecificWeight.FromNewtonsPerCubicMeter(firstValue); var otherQuantity = SpecificWeight.FromNewtonsPerCubicMeter(secondValue); @@ -1188,7 +1188,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = SpecificWeight.FromNewtonsPerCubicMeter(1.0); - Assert.Equal(new {SpecificWeight.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SpeedTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SpeedTestsBase.g.cs index d4a4320a20..efcdf26559 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SpeedTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SpeedTestsBase.g.cs @@ -2102,7 +2102,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = Speed.FromMetersPerSecond(firstValue); var otherQuantity = Speed.FromMetersPerSecond(secondValue); @@ -2266,7 +2266,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = Speed.FromMetersPerSecond(1.0); - Assert.Equal(new {Speed.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/StandardVolumeFlowTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/StandardVolumeFlowTestsBase.g.cs index 5afa97b3a1..8d33c4b6c1 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/StandardVolumeFlowTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/StandardVolumeFlowTestsBase.g.cs @@ -800,7 +800,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = StandardVolumeFlow.FromStandardCubicMetersPerSecond(firstValue); var otherQuantity = StandardVolumeFlow.FromStandardCubicMetersPerSecond(secondValue); @@ -916,7 +916,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = StandardVolumeFlow.FromStandardCubicMetersPerSecond(1.0); - Assert.Equal(new {StandardVolumeFlow.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureChangeRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureChangeRateTestsBase.g.cs index c9124c12d1..44847272f9 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureChangeRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureChangeRateTestsBase.g.cs @@ -1056,7 +1056,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = TemperatureChangeRate.FromDegreesCelsiusPerSecond(firstValue); var otherQuantity = TemperatureChangeRate.FromDegreesCelsiusPerSecond(secondValue); @@ -1188,7 +1188,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = TemperatureChangeRate.FromDegreesCelsiusPerSecond(1.0); - Assert.Equal(new {TemperatureChangeRate.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureDeltaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureDeltaTestsBase.g.cs index 1451a1e1c5..ec53eda92c 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureDeltaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureDeltaTestsBase.g.cs @@ -800,7 +800,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = TemperatureDelta.FromKelvins(firstValue); var otherQuantity = TemperatureDelta.FromKelvins(secondValue); @@ -916,7 +916,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = TemperatureDelta.FromKelvins(1.0); - Assert.Equal(new {TemperatureDelta.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureGradientTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureGradientTestsBase.g.cs index b80f4e9fb1..d5c322a1ec 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureGradientTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureGradientTestsBase.g.cs @@ -640,7 +640,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = TemperatureGradient.FromKelvinsPerMeter(firstValue); var otherQuantity = TemperatureGradient.FromKelvinsPerMeter(secondValue); @@ -746,7 +746,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = TemperatureGradient.FromKelvinsPerMeter(1.0); - Assert.Equal(new {TemperatureGradient.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureTestsBase.g.cs index dd136cc364..57f4c75e23 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureTestsBase.g.cs @@ -820,7 +820,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = Temperature.FromKelvins(firstValue); var otherQuantity = Temperature.FromKelvins(secondValue); @@ -938,7 +938,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = Temperature.FromKelvins(1.0); - Assert.Equal(new {Temperature.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalConductivityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalConductivityTestsBase.g.cs index f7ea4e76b2..00c8ed3189 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalConductivityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalConductivityTestsBase.g.cs @@ -576,7 +576,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = ThermalConductivity.FromWattsPerMeterKelvin(firstValue); var otherQuantity = ThermalConductivity.FromWattsPerMeterKelvin(secondValue); @@ -678,7 +678,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = ThermalConductivity.FromWattsPerMeterKelvin(1.0); - Assert.Equal(new {ThermalConductivity.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalInsulanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalInsulanceTestsBase.g.cs index db92152e20..f9ab6883a9 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalInsulanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalInsulanceTestsBase.g.cs @@ -736,7 +736,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = ThermalInsulance.FromSquareMeterKelvinsPerKilowatt(firstValue); var otherQuantity = ThermalInsulance.FromSquareMeterKelvinsPerKilowatt(secondValue); @@ -848,7 +848,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = ThermalInsulance.FromSquareMeterKelvinsPerKilowatt(1.0); - Assert.Equal(new {ThermalInsulance.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalResistanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalResistanceTestsBase.g.cs index dad96683d0..f804492e93 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalResistanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalResistanceTestsBase.g.cs @@ -576,7 +576,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = ThermalResistance.FromKelvinsPerWatt(firstValue); var otherQuantity = ThermalResistance.FromKelvinsPerWatt(secondValue); @@ -678,7 +678,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = ThermalResistance.FromKelvinsPerWatt(1.0); - Assert.Equal(new {ThermalResistance.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TorqueTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TorqueTestsBase.g.cs index f9d792a450..e26bed5c83 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TorqueTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TorqueTestsBase.g.cs @@ -1363,7 +1363,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = Torque.FromNewtonMeters(firstValue); var otherQuantity = Torque.FromNewtonMeters(secondValue); @@ -1511,7 +1511,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = Torque.FromNewtonMeters(1.0); - Assert.Equal(new {Torque.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TurbidityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TurbidityTestsBase.g.cs index 083f8e0465..0061f4e643 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TurbidityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TurbidityTestsBase.g.cs @@ -483,7 +483,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = Turbidity.FromNTU(firstValue); var otherQuantity = Turbidity.FromNTU(secondValue); @@ -583,7 +583,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = Turbidity.FromNTU(1.0); - Assert.Equal(new {Turbidity.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VitaminATestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VitaminATestsBase.g.cs index 087400f798..a819e6a5de 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VitaminATestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VitaminATestsBase.g.cs @@ -483,7 +483,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = VitaminA.FromInternationalUnits(firstValue); var otherQuantity = VitaminA.FromInternationalUnits(secondValue); @@ -583,7 +583,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = VitaminA.FromInternationalUnits(1.0); - Assert.Equal(new {VitaminA.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeConcentrationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeConcentrationTestsBase.g.cs index bfdb3ce196..4947a83201 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeConcentrationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeConcentrationTestsBase.g.cs @@ -1113,7 +1113,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = VolumeConcentration.FromDecimalFractions(firstValue); var otherQuantity = VolumeConcentration.FromDecimalFractions(secondValue); @@ -1251,7 +1251,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = VolumeConcentration.FromDecimalFractions(1.0); - Assert.Equal(new {VolumeConcentration.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowPerAreaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowPerAreaTestsBase.g.cs index 90041ee2a7..efb03abde1 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowPerAreaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowPerAreaTestsBase.g.cs @@ -576,7 +576,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = VolumeFlowPerArea.FromCubicMetersPerSecondPerSquareMeter(firstValue); var otherQuantity = VolumeFlowPerArea.FromCubicMetersPerSecondPerSquareMeter(secondValue); @@ -678,7 +678,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = VolumeFlowPerArea.FromCubicMetersPerSecondPerSquareMeter(1.0); - Assert.Equal(new {VolumeFlowPerArea.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowTestsBase.g.cs index 73c2401b5f..50400c4d87 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowTestsBase.g.cs @@ -4619,7 +4619,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = VolumeFlow.FromCubicMetersPerSecond(firstValue); var otherQuantity = VolumeFlow.FromCubicMetersPerSecond(secondValue); @@ -4867,7 +4867,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = VolumeFlow.FromCubicMetersPerSecond(1.0); - Assert.Equal(new {VolumeFlow.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumePerLengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumePerLengthTestsBase.g.cs index b95c6ab159..8e91c9a85d 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumePerLengthTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumePerLengthTestsBase.g.cs @@ -800,7 +800,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = VolumePerLength.FromCubicMetersPerMeter(firstValue); var otherQuantity = VolumePerLength.FromCubicMetersPerMeter(secondValue); @@ -916,7 +916,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = VolumePerLength.FromCubicMetersPerMeter(1.0); - Assert.Equal(new {VolumePerLength.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeTestsBase.g.cs index a70847bebd..4b459af7f0 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeTestsBase.g.cs @@ -3135,7 +3135,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = Volume.FromCubicMeters(firstValue); var otherQuantity = Volume.FromCubicMeters(secondValue); @@ -3341,7 +3341,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = Volume.FromCubicMeters(1.0); - Assert.Equal(new {Volume.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumetricHeatCapacityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumetricHeatCapacityTestsBase.g.cs index 6b733d5655..95012da5d0 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumetricHeatCapacityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumetricHeatCapacityTestsBase.g.cs @@ -800,7 +800,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = VolumetricHeatCapacity.FromJoulesPerCubicMeterKelvin(firstValue); var otherQuantity = VolumetricHeatCapacity.FromJoulesPerCubicMeterKelvin(secondValue); @@ -916,7 +916,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = VolumetricHeatCapacity.FromJoulesPerCubicMeterKelvin(1.0); - Assert.Equal(new {VolumetricHeatCapacity.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/WarpingMomentOfInertiaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/WarpingMomentOfInertiaTestsBase.g.cs index 8e49634c81..bf2d1ba25e 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/WarpingMomentOfInertiaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/WarpingMomentOfInertiaTestsBase.g.cs @@ -704,7 +704,7 @@ public void EqualsReturnsFalseOnNull() [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_WithTolerance_IsImplemented(double firstValue, double secondValue) + public void Equals_WithTolerance(double firstValue, double secondValue) { var quantity = WarpingMomentOfInertia.FromMetersToTheSixth(firstValue); var otherQuantity = WarpingMomentOfInertia.FromMetersToTheSixth(secondValue); @@ -814,7 +814,7 @@ public void ToString_NullProvider_EqualsCurrentCulture(string format) public void GetHashCode_Equals() { var quantity = WarpingMomentOfInertia.FromMetersToTheSixth(1.0); - Assert.Equal(new {WarpingMomentOfInertia.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Comparison.GetHashCode(quantity.Unit, quantity.Value), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/LinearQuantityExtensionsTest.cs b/UnitsNet.Tests/LinearQuantityExtensionsTest.cs new file mode 100644 index 0000000000..29da21c322 --- /dev/null +++ b/UnitsNet.Tests/LinearQuantityExtensionsTest.cs @@ -0,0 +1,223 @@ +// 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. + +namespace UnitsNet.Tests; + +public class LinearQuantityExtensionsTest +{ + [Theory] + [InlineData(2.0, 2.0, 0.1, true)] + // [InlineData(2.0, 2.1, 0.1, true)] // should be equal but fails due to rounding + [InlineData(2.0, 2.1, 0.10001, true)] + [InlineData(2.0, 2.2, 0.1, false)] + [InlineData(2.0, 2.0, 0.0, true)] + [InlineData(2.0, 2.1, 0.0, false)] + public void Equals_WithTolerance_ReturnsExpectedResult(double value1, double value2, double tolerance, bool expected) + { + var quantity1 = Length.FromMeters(value1); + var quantity2 = Length.FromMeters(value2); + var toleranceQuantity = Length.FromMeters(tolerance); + + var result = quantity1.Equals(quantity2, toleranceQuantity); + + Assert.Equal(expected, result); + } + + [Fact(Skip = "Fails due to rounding")] + public void Equals_WithToleranceAtTheLimit_ReturnsTrue() + { + var quantity = Length.FromMeters(1); + var otherQuantity = Length.FromCentimeters(99); + var tolerance = Length.FromMillimeters(10); + + Assert.Multiple(() => + { + Assert.True(quantity.Equals(otherQuantity, tolerance), "Difference == Tolerance"); + Assert.True(quantity.Equals(otherQuantity, tolerance * 2), "Difference < Tolerance"); + Assert.False(quantity.Equals(otherQuantity, tolerance / 2), "Difference > Tolerance"); + }, + () => + { + Assert.True(otherQuantity.Equals(quantity, tolerance), "Difference == Tolerance"); + Assert.True(otherQuantity.Equals(quantity, tolerance * 2), "Difference < Tolerance"); + Assert.False(otherQuantity.Equals(quantity, tolerance / 2), "Difference > Tolerance"); + }); + } + + [Theory] + [InlineData(2.0, 2.0, 0.1, true)] + // [InlineData(2.0, 2.1, 0.1, true)] // should be equal but fails due to rounding + [InlineData(2.0, 2.1, 0.10001, true)] + [InlineData(2.0, 2.2, 0.1, false)] + [InlineData(2.0, 2.0, 0.0, true)] + [InlineData(2.0, 2.1, 0.0, false)] + public void Equals_IQuantityWithTolerance_ReturnsExpectedResult(double value1, double value2, double tolerance, bool expected) + { + var quantity1 = Length.FromMeters(value1); + IQuantity quantity2 = Length.FromMeters(value2); + IQuantity toleranceQuantity = Length.FromMeters(tolerance); + + var result = quantity1.Equals(quantity2, toleranceQuantity); + + Assert.Equal(expected, result); + } + + [Fact] + public void Equals_WithNullOther_ReturnsFalse() + { + var quantity = Length.FromMeters(2.0); + Length? otherQuantity = null; + var tolerance = Length.FromMeters(0.1); + + var result = quantity.Equals(otherQuantity, tolerance); + + Assert.False(result); + } + + [Fact] + public void Equals_IQuantity_WithNullOther_ReturnsFalse() + { + var quantity = Length.FromMeters(2.0); + var tolerance = Length.FromMeters(0.1); + + var result = quantity.Equals(null, tolerance); + + Assert.False(result); + } + + [Fact] + public void Equals_WithDifferentTypeTolerance_ThrowsArgumentException() + { + var quantity = Length.FromMeters(2.0); + var other = Length.FromMeters(2.0); + var tolerance = Mass.FromKilograms(0.1); + + Assert.Throws(() => quantity.Equals(other, tolerance)); + } + + [Fact(Skip = "Currently throws a NotImplementedException")] + public void Equals_TQuantity_TQuantity_WithUnknownUnits_ThrowsUnitNotFoundException() + { + var quantity = Length.FromMeters(1); + var invalidQuantity = new Length(1, (LengthUnit)(-1)); + Assert.Throws(() => invalidQuantity.Equals(quantity, quantity)); + Assert.Throws(() => quantity.Equals(invalidQuantity, quantity)); + Assert.Throws(() => quantity.Equals(quantity, invalidQuantity)); + } + + [Fact(Skip = "Currently throws a NotImplementedException")] + public void Equals_IQuantity_IQuantity_WithUnknownUnits_ThrowsUnitNotFoundException() + { + var quantity = Length.FromMeters(1); + var invalidQuantity = new Length(1, (LengthUnit)(-1)); + Assert.Throws(() => invalidQuantity.Equals((IQuantity)quantity, quantity)); + Assert.Throws(() => quantity.Equals((IQuantity)invalidQuantity, quantity)); + Assert.Throws(() => quantity.Equals((IQuantity)quantity, invalidQuantity)); + } + + [Fact] + public void EqualsAbsolute_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() + { + var quantity = Length.FromMeters(2.0); + var other = Length.FromMeters(2.0); + var tolerance = Length.FromMeters(-0.1); + + Assert.Throws(() => quantity.EqualsAbsolute(other, tolerance)); + } + + [Fact] + public void Sum_WithEmptyCollection_ReturnsZero() + { + Length[] quantities = []; + + Length result = quantities.Sum(); + + Assert.Equal(Length.Zero, result); + } + + [Fact] + public void Sum_WithQuantities_ReturnsExpectedSum() + { + Length[] quantities = [Length.FromMeters(1.0), Length.FromCentimeters(200), Length.FromMeters(3.0)]; + + Length result = quantities.Sum(); + + Assert.Equal(Length.FromMeters(6.0), result); + } + + [Fact] + public void Sum_WithSelector_ReturnsExpectedSum() + { + Length[] quantities = [Length.FromMeters(1.0), Length.FromCentimeters(200), Length.FromMeters(3.0)]; + + Length result = quantities.Sum(length => length); + + Assert.Equal(Length.FromMeters(6.0), result); + } + + [Fact] + public void Sum_WithSelectorAndUnit_ReturnsExpectedSum() + { + Length[] quantities = [Length.FromMeters(1.0), Length.FromCentimeters(200), Length.FromMeters(3.0)]; + + Length result = quantities.Sum(length => length, LengthUnit.Centimeter); + + Assert.Equal(600, result.Value); + Assert.Equal(LengthUnit.Centimeter, result.Unit); + } + + [Fact] + public void Average_WithEmptyCollection_ThrowsInvalidOperationException() + { + Length[] quantities = []; + + Assert.Throws(() => quantities.Average()); + } + + [Fact] + public void Average_WithSelector_ThrowsOnEmptyCollection() + { + Length[] quantities = []; + + Assert.Throws(() => quantities.Average(length => length)); + } + + [Fact] + public void Average_WithSelectorAndUnit_ThrowsOnEmptyCollection() + { + Length[] quantities = []; + + Assert.Throws(() => quantities.Average(length => length, LengthUnit.Centimeter)); + } + + [Fact] + public void Average_WithQuantities_ReturnsExpectedAverage() + { + Length[] quantities = [Length.FromMeters(1.0), Length.FromMeters(2.0), Length.FromMeters(3.0)]; + + Length result = quantities.Average(); + + Assert.Equal(Length.FromMeters(2.0), result); + } + + [Fact] + public void Average_WithSelector_ReturnsExpectedAverage() + { + Length[] quantities = [Length.FromMeters(1.0), Length.FromCentimeters(200), Length.FromMeters(3.0)]; + + Length result = quantities.Average(length => length); + + Assert.Equal(Length.FromMeters(2.0), result); + } + + [Fact] + public void Average_WithSelectorAndUnit_ReturnsExpectedAverage() + { + Length[] quantities = [Length.FromMeters(1.0), Length.FromCentimeters(200), Length.FromMeters(3.0)]; + + Length result = quantities.Average(length => length, LengthUnit.Centimeter); + + Assert.Equal(200, result.Value); + Assert.Equal(LengthUnit.Centimeter, result.Unit); + } +} diff --git a/UnitsNet.Tests/LogarithmicQuantityExtensionsTest.cs b/UnitsNet.Tests/LogarithmicQuantityExtensionsTest.cs new file mode 100644 index 0000000000..e808d6fc21 --- /dev/null +++ b/UnitsNet.Tests/LogarithmicQuantityExtensionsTest.cs @@ -0,0 +1,619 @@ +// 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. + + +namespace UnitsNet.Tests; + +public class LogarithmicQuantityExtensionsTest +{ + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_TQuantity_TOther_TTolerance_ComparesInLinearSpace(double firstValue, double secondValue) + { + var quantity = PowerRatio.FromDecibelWatts(firstValue); + var otherQuantity = PowerRatio.FromDecibelWatts(secondValue); + PowerRatio maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + PowerRatio largerTolerance = maxTolerance * 1.1; + PowerRatio smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals(quantity, PowerRatio.Zero)); + Assert.True(quantity.Equals(quantity, maxTolerance)); + Assert.True(quantity.Equals(otherQuantity, largerTolerance)); + Assert.False(quantity.Equals(otherQuantity, smallerTolerance)); + // note: it's currently not possible to test this due to the rounding error from (quantity - otherQuantity) + // Assert.True(quantity.Equals(otherQuantity, maxTolerance)); + } + + [Theory] + [InlineData(1, 2)] + [InlineData(100, 110)] + [InlineData(100, 90)] + public void Equals_TQuantity_IQuantity_IQuantity_ComparesInLinearSpace(double firstValue, double secondValue) + { + var quantity = PowerRatio.FromDecibelWatts(firstValue); + var otherQuantity = PowerRatio.FromDecibelWatts(secondValue); + PowerRatio maxTolerance = quantity > otherQuantity ? quantity - otherQuantity : otherQuantity - quantity; + PowerRatio largerTolerance = maxTolerance * 1.1; + PowerRatio smallerTolerance = maxTolerance / 1.1; + Assert.True(quantity.Equals((IQuantity)quantity, PowerRatio.Zero)); + Assert.True(quantity.Equals((IQuantity)quantity, maxTolerance)); + Assert.True(quantity.Equals((IQuantity)otherQuantity, largerTolerance)); + Assert.False(quantity.Equals((IQuantity)otherQuantity, smallerTolerance)); + // note: it's currently not possible to test this due to the rounding error from (quantity - otherQuantity) + // Assert.True(quantity.Equals((IQuantity)otherQuantity, maxTolerance)); + } + + [Fact] + public void Equals_NullQuantity_ReturnsFalse() + { + var quantity = PowerRatio.FromDecibelWatts(1); + var tolerance = PowerRatio.FromDecibelWatts(1); + Assert.False(quantity.Equals(null, tolerance)); + } + + [Fact] + public void Equals_NullQuantity_And_NullTolerance_ReturnsFalse() + { + var quantity = PowerRatio.FromDecibelWatts(1); + var tolerance = PowerRatio.FromDecibelWatts(1); + Assert.False(quantity.Equals(null, tolerance)); + } + + [Fact] + public void Equals_NullQuantity_And_AnotherToleranceType_ReturnsFalse() + { + var quantity = PowerRatio.FromDecibelWatts(1); + var tolerance = AmplitudeRatio.FromDecibelVolts(1); + Assert.False(quantity.Equals(null, tolerance)); + } + + [Fact] + public void Equals_IQuantity_And_AnotherToleranceType_ThrowsArgumentException() + { + var quantity = PowerRatio.FromDecibelWatts(1); + var tolerance = AmplitudeRatio.FromDecibelVolts(1); + Assert.Throws(() => quantity.Equals(quantity, tolerance)); + } + + [Fact(Skip = "Currently throws a NotImplementedException")] + public void Equals_TQuantity_TQuantity_WithUnknownUnits_ThrowsUnitNotFoundException() + { + var quantity = PowerRatio.FromDecibelWatts(1); + var invalidQuantity = new PowerRatio(1, (PowerRatioUnit)(-1)); + Assert.Throws(() => invalidQuantity.Equals(quantity, quantity)); + Assert.Throws(() => quantity.Equals(invalidQuantity, quantity)); + Assert.Throws(() => quantity.Equals(quantity, invalidQuantity)); + } + + [Fact(Skip = "Currently throws a NotImplementedException")] + public void Equals_IQuantity_IQuantity_WithUnknownUnits_ThrowsUnitNotFoundException() + { + var quantity = PowerRatio.FromDecibelWatts(1); + var invalidQuantity = new PowerRatio(1, (PowerRatioUnit)(-1)); + Assert.Throws(() => invalidQuantity.Equals((IQuantity)quantity, quantity)); + Assert.Throws(() => quantity.Equals((IQuantity)invalidQuantity, quantity)); + Assert.Throws(() => quantity.Equals((IQuantity)quantity, invalidQuantity)); + } + + [Fact] + public void Equals_WithNegativeTolerance_DoesNotThrowArgumentOutOfRangeException() + { + // note: unlike with vector quantities- a small tolerance maybe positive in one unit and negative in another + var quantity = PowerRatio.FromDecibelWatts(1); + var negativeTolerance = PowerRatio.FromDecibelWatts(-1); + Assert.True(quantity.Equals(quantity, negativeTolerance)); + } + + [Fact] + public void Sum_ThrowsOnEmptyCollection() + { + PowerRatio[] quantities = []; + + Assert.Throws(() => quantities.Sum()); + } + + [Fact] + public void Sum_WithSelector_ThrowsOnEmptyCollection() + { + PowerRatio[] quantities = []; + + Assert.Throws(() => quantities.Sum(x => x)); + } + + [Fact] + public void Sum_WithUnit_ThrowsOnEmptyCollection() + { + PowerRatio[] quantities = []; + + Assert.Throws(() => quantities.Sum(PowerRatioUnit.DecibelWatt)); + } + + [Fact] + public void Sum_WithSelectorAndUnit_ThrowsOnEmptyCollection() + { + PowerRatio[] quantities = []; + + Assert.Throws(() => quantities.Sum(x => x, PowerRatioUnit.DecibelWatt)); + } + + [Fact] + public void Sum_WithNullSequence_ThrowsArgumentNullException() + { + PowerRatio[] quantities = null!; + + Assert.Throws(() => quantities.Sum()); + } + + [Fact] + public void Sum_WithNullSequenceAndUnit_ThrowsArgumentNullException() + { + PowerRatio[] quantities = null!; + + Assert.Throws(() => quantities.Sum(PowerRatioUnit.DecibelWatt)); + } + + [Fact] + public void Sum_WithNullSelector_ThrowsArgumentNullException() + { + PowerRatio[] quantities = null!; + + Assert.Throws(() => quantities.Sum(x => x, PowerRatioUnit.DecibelWatt)); + } + + [Theory] + [InlineData(0, PowerRatioUnit.DecibelMilliwatt)] + [InlineData(1, PowerRatioUnit.DecibelWatt)] + [InlineData(double.NaN, PowerRatioUnit.DecibelMilliwatt)] + [InlineData(double.PositiveInfinity, PowerRatioUnit.DecibelMilliwatt)] + [InlineData(double.NegativeInfinity, PowerRatioUnit.DecibelMilliwatt)] + public void Sum_SingleQuantity_ReturnsCorrectSum(double value, PowerRatioUnit unit) + { + var quantity = new PowerRatio(value, unit); + IEnumerable quantities = new List { quantity }; + + PowerRatio result = quantities.Sum(); + + Assert.Equal(quantity.Value, result.Value, 1e-5); + Assert.Equal(quantity.Unit, result.Unit); + } + + [Theory] + [InlineData(0, PowerRatioUnit.DecibelMilliwatt)] + [InlineData(1, PowerRatioUnit.DecibelWatt)] + [InlineData(double.NaN, PowerRatioUnit.DecibelMilliwatt)] + [InlineData(double.PositiveInfinity, PowerRatioUnit.DecibelMilliwatt)] + [InlineData(double.NegativeInfinity, PowerRatioUnit.DecibelMilliwatt)] + public void Sum_SingleQuantity_WithSelector_ReturnsCorrectSum(double value, PowerRatioUnit unit) + { + var quantity = new PowerRatio(value, unit); + IEnumerable quantities = new List { quantity }; + + PowerRatio result = quantities.Sum(x => x); + + Assert.Equal(quantity.Value, result.Value, 1e-5); + Assert.Equal(quantity.Unit, result.Unit); + } + + [Theory] + [InlineData(0, PowerRatioUnit.DecibelMilliwatt, 1, PowerRatioUnit.DecibelMilliwatt)] + [InlineData(0, PowerRatioUnit.DecibelWatt, 1, PowerRatioUnit.DecibelMilliwatt)] + [InlineData(1, PowerRatioUnit.DecibelMilliwatt, 1, PowerRatioUnit.DecibelWatt)] + [InlineData(1, PowerRatioUnit.DecibelMilliwatt, -1, PowerRatioUnit.DecibelWatt)] + [InlineData(2, PowerRatioUnit.DecibelMilliwatt, -10, PowerRatioUnit.DecibelMilliwatt)] + [InlineData(2, PowerRatioUnit.DecibelMilliwatt, -2, PowerRatioUnit.DecibelMilliwatt)] + [InlineData(10, PowerRatioUnit.DecibelWatt, 100, PowerRatioUnit.DecibelMilliwatt)] + [InlineData(-10, PowerRatioUnit.DecibelMilliwatt, 20, PowerRatioUnit.DecibelMilliwatt)] + [InlineData(double.NaN, PowerRatioUnit.DecibelMilliwatt, 1, PowerRatioUnit.DecibelWatt)] + [InlineData(double.PositiveInfinity, PowerRatioUnit.DecibelMilliwatt, 1, PowerRatioUnit.DecibelWatt)] + [InlineData(double.NegativeInfinity, PowerRatioUnit.DecibelMilliwatt, 1, PowerRatioUnit.DecibelWatt)] + [InlineData(1, PowerRatioUnit.DecibelMilliwatt, double.NaN, PowerRatioUnit.DecibelWatt)] + [InlineData(1, PowerRatioUnit.DecibelMilliwatt, double.PositiveInfinity, PowerRatioUnit.DecibelWatt)] + [InlineData(1, PowerRatioUnit.DecibelMilliwatt, double.NegativeInfinity, PowerRatioUnit.DecibelWatt)] + public void Sum_ReturnsCorrectSum(double value1, PowerRatioUnit unit1, double value2, PowerRatioUnit unit2) + { + var quantity1 = new PowerRatio(value1, unit1); + var quantity2 = new PowerRatio(value2, unit2); + IEnumerable quantities = new List { quantity1, quantity2 }; + PowerRatio expectedValue = quantity1 + quantity2; + + PowerRatio result = quantities.Sum(); + + Assert.Equal(expectedValue.Value, result.Value, 1e-5); + Assert.Equal(unit1, result.Unit); + } + + [Theory] + [InlineData(0, PowerRatioUnit.DecibelMilliwatt, 1, PowerRatioUnit.DecibelMilliwatt)] + [InlineData(0, PowerRatioUnit.DecibelWatt, 1, PowerRatioUnit.DecibelMilliwatt)] + [InlineData(1, PowerRatioUnit.DecibelMilliwatt, 1, PowerRatioUnit.DecibelWatt)] + [InlineData(1, PowerRatioUnit.DecibelMilliwatt, -1, PowerRatioUnit.DecibelWatt)] + [InlineData(2, PowerRatioUnit.DecibelMilliwatt, -10, PowerRatioUnit.DecibelMilliwatt)] + [InlineData(2, PowerRatioUnit.DecibelMilliwatt, -2, PowerRatioUnit.DecibelMilliwatt)] + [InlineData(10, PowerRatioUnit.DecibelWatt, 100, PowerRatioUnit.DecibelMilliwatt)] + [InlineData(-10, PowerRatioUnit.DecibelMilliwatt, 20, PowerRatioUnit.DecibelMilliwatt)] + [InlineData(double.NaN, PowerRatioUnit.DecibelMilliwatt, 1, PowerRatioUnit.DecibelWatt)] + [InlineData(double.PositiveInfinity, PowerRatioUnit.DecibelMilliwatt, 1, PowerRatioUnit.DecibelWatt)] + [InlineData(double.NegativeInfinity, PowerRatioUnit.DecibelMilliwatt, 1, PowerRatioUnit.DecibelWatt)] + [InlineData(1, PowerRatioUnit.DecibelMilliwatt, double.NaN, PowerRatioUnit.DecibelWatt)] + [InlineData(1, PowerRatioUnit.DecibelMilliwatt, double.PositiveInfinity, PowerRatioUnit.DecibelWatt)] + [InlineData(1, PowerRatioUnit.DecibelMilliwatt, double.NegativeInfinity, PowerRatioUnit.DecibelWatt)] + public void Sum_WithSelector_ReturnsCorrectSum(double value1, PowerRatioUnit unit1, double value2, PowerRatioUnit unit2) + { + var quantity1 = new PowerRatio(value1, unit1); + var quantity2 = new PowerRatio(value2, unit2); + IEnumerable quantities = new List { quantity1, quantity2 }; + PowerRatio expectedValue = quantity1 + quantity2; + + PowerRatio result = quantities.Sum(x => x); + + Assert.Equal(expectedValue.Value, result.Value, 1e-5); + Assert.Equal(unit1, result.Unit); + } + + [Theory] + [InlineData(0, PowerRatioUnit.DecibelMilliwatt, 1, PowerRatioUnit.DecibelMilliwatt)] + [InlineData(0, PowerRatioUnit.DecibelWatt, 1, PowerRatioUnit.DecibelMilliwatt)] + [InlineData(1, PowerRatioUnit.DecibelMilliwatt, 1, PowerRatioUnit.DecibelWatt)] + [InlineData(1, PowerRatioUnit.DecibelMilliwatt, -1, PowerRatioUnit.DecibelWatt)] + [InlineData(2, PowerRatioUnit.DecibelMilliwatt, -10, PowerRatioUnit.DecibelMilliwatt)] + [InlineData(2, PowerRatioUnit.DecibelMilliwatt, -2, PowerRatioUnit.DecibelMilliwatt)] + [InlineData(10, PowerRatioUnit.DecibelWatt, 100, PowerRatioUnit.DecibelMilliwatt)] + [InlineData(-10, PowerRatioUnit.DecibelMilliwatt, 20, PowerRatioUnit.DecibelMilliwatt)] + [InlineData(double.NaN, PowerRatioUnit.DecibelMilliwatt, 1, PowerRatioUnit.DecibelWatt)] + [InlineData(double.PositiveInfinity, PowerRatioUnit.DecibelMilliwatt, 1, PowerRatioUnit.DecibelWatt)] + [InlineData(double.NegativeInfinity, PowerRatioUnit.DecibelMilliwatt, 1, PowerRatioUnit.DecibelWatt)] + [InlineData(1, PowerRatioUnit.DecibelMilliwatt, double.NaN, PowerRatioUnit.DecibelWatt)] + [InlineData(1, PowerRatioUnit.DecibelMilliwatt, double.PositiveInfinity, PowerRatioUnit.DecibelWatt)] + [InlineData(1, PowerRatioUnit.DecibelMilliwatt, double.NegativeInfinity, PowerRatioUnit.DecibelWatt)] + public void Sum_WithSelectorAndUnit_ReturnsCorrectSum(double value1, PowerRatioUnit unit1, double value2, PowerRatioUnit unit2) + { + var quantity1 = new PowerRatio(value1, unit1); + var quantity2 = new PowerRatio(value2, unit2); + IEnumerable quantities = new List { quantity1, quantity2 }; + PowerRatio expectedValue = quantity1 + quantity2; + + PowerRatio result = quantities.Sum(x => x, unit1); + + Assert.Equal(expectedValue.Value, result.Value, 1e-5); + Assert.Equal(unit1, result.Unit); + } + + [Fact] + public void ArithmeticMean_ThrowsOnEmptyCollection() + { + PowerRatio[] quantities = []; + + Assert.Throws(() => LogarithmicQuantityExtensions.ArithmeticMean(quantities)); + } + + [Fact] + public void ArithmeticMean_WithSelector_ThrowsOnEmptyCollection() + { + PowerRatio[] quantities = []; + + Assert.Throws(() => quantities.ArithmeticMean(x => x)); + } + + [Fact] + public void ArithmeticMean_WithSelectorAndUnit_ThrowsOnEmptyCollection() + { + PowerRatio[] quantities = []; + + Assert.Throws(() => quantities.ArithmeticMean(x => x, PowerRatioUnit.DecibelWatt)); + } + + [Fact] + public void ArithmeticMean_WithNullSequence_ThrowsArgumentNullException() + { + PowerRatio[] quantities = null!; + + Assert.Throws(() => LogarithmicQuantityExtensions.ArithmeticMean(quantities)); + } + + [Fact] + public void ArithmeticMean_WithNullSequenceAndUnit_ThrowsArgumentNullException() + { + PowerRatio[] quantities = null!; + + Assert.Throws(() => LogarithmicQuantityExtensions.ArithmeticMean(quantities, PowerRatioUnit.DecibelWatt)); + } + + [Fact] + public void ArithmeticMean_WithNullSelector_ThrowsArgumentNullException() + { + PowerRatio[] quantities = null!; + + Assert.Throws(() => quantities.ArithmeticMean(x => x, PowerRatioUnit.DecibelWatt)); + } + + [Theory] + [InlineData(0, PowerRatioUnit.DecibelMilliwatt)] + [InlineData(1, PowerRatioUnit.DecibelWatt)] + [InlineData(double.NaN, PowerRatioUnit.DecibelMilliwatt)] + [InlineData(double.PositiveInfinity, PowerRatioUnit.DecibelMilliwatt)] + [InlineData(double.NegativeInfinity, PowerRatioUnit.DecibelMilliwatt)] + public void ArithmeticMean_SingleQuantity_ReturnsCorrectMean(double value, PowerRatioUnit unit) + { + var quantity = new PowerRatio(value, unit); + IEnumerable quantities = new List { quantity }; + + PowerRatio result = LogarithmicQuantityExtensions.ArithmeticMean(quantities); + + Assert.Equal(quantity.Value, result.Value, 1e-5); + Assert.Equal(quantity.Unit, result.Unit); + } + + [Theory] + [InlineData(0, PowerRatioUnit.DecibelMilliwatt)] + [InlineData(1, PowerRatioUnit.DecibelWatt)] + [InlineData(double.NaN, PowerRatioUnit.DecibelMilliwatt)] + [InlineData(double.PositiveInfinity, PowerRatioUnit.DecibelMilliwatt)] + [InlineData(double.NegativeInfinity, PowerRatioUnit.DecibelMilliwatt)] + public void ArithmeticMean_SingleQuantity_WithSelector_ReturnsCorrectMean(double value, PowerRatioUnit unit) + { + var quantity = new PowerRatio(value, unit); + IEnumerable quantities = new List { quantity }; + + PowerRatio result = quantities.ArithmeticMean(x => x); + + Assert.Equal(quantity.Value, result.Value, 1e-5); + Assert.Equal(quantity.Unit, result.Unit); + } + + [Theory] + [InlineData(0, PowerRatioUnit.DecibelMilliwatt, 1, PowerRatioUnit.DecibelMilliwatt)] + [InlineData(0, PowerRatioUnit.DecibelWatt, 1, PowerRatioUnit.DecibelMilliwatt)] + [InlineData(1, PowerRatioUnit.DecibelMilliwatt, 1, PowerRatioUnit.DecibelWatt)] + [InlineData(1, PowerRatioUnit.DecibelMilliwatt, -1, PowerRatioUnit.DecibelWatt)] + [InlineData(2, PowerRatioUnit.DecibelMilliwatt, -10, PowerRatioUnit.DecibelMilliwatt)] + [InlineData(2, PowerRatioUnit.DecibelMilliwatt, -2, PowerRatioUnit.DecibelMilliwatt)] + [InlineData(10, PowerRatioUnit.DecibelWatt, 100, PowerRatioUnit.DecibelMilliwatt)] + [InlineData(-10, PowerRatioUnit.DecibelMilliwatt, 20, PowerRatioUnit.DecibelMilliwatt)] + [InlineData(double.NaN, PowerRatioUnit.DecibelMilliwatt, 1, PowerRatioUnit.DecibelWatt)] + [InlineData(double.PositiveInfinity, PowerRatioUnit.DecibelMilliwatt, 1, PowerRatioUnit.DecibelWatt)] + [InlineData(double.NegativeInfinity, PowerRatioUnit.DecibelMilliwatt, 1, PowerRatioUnit.DecibelWatt)] + [InlineData(1, PowerRatioUnit.DecibelMilliwatt, double.NaN, PowerRatioUnit.DecibelWatt)] + [InlineData(1, PowerRatioUnit.DecibelMilliwatt, double.PositiveInfinity, PowerRatioUnit.DecibelWatt)] + [InlineData(1, PowerRatioUnit.DecibelMilliwatt, double.NegativeInfinity, PowerRatioUnit.DecibelWatt)] + public void ArithmeticMean_ReturnsCorrectMean(double value1, PowerRatioUnit unit1, double value2, PowerRatioUnit unit2) + { + var quantity1 = new PowerRatio(value1, unit1); + var quantity2 = new PowerRatio(value2, unit2); + IEnumerable quantities = new List { quantity1, quantity2 }; + var scalingFactor = PowerRatio.LogarithmicScalingFactor; + var expectedValue = + ((quantity1.Value.ToLinearSpace(scalingFactor) + quantity2.As(unit1).ToLinearSpace(scalingFactor)) / 2).ToLogSpace(scalingFactor); + + PowerRatio result = LogarithmicQuantityExtensions.ArithmeticMean(quantities); + + Assert.Equal(expectedValue, result.Value, 1e-5); + Assert.Equal(unit1, result.Unit); + } + + [Theory] + [InlineData(0, PowerRatioUnit.DecibelMilliwatt, 1, PowerRatioUnit.DecibelMilliwatt)] + [InlineData(0, PowerRatioUnit.DecibelWatt, 1, PowerRatioUnit.DecibelMilliwatt)] + [InlineData(1, PowerRatioUnit.DecibelMilliwatt, 1, PowerRatioUnit.DecibelWatt)] + [InlineData(1, PowerRatioUnit.DecibelMilliwatt, -1, PowerRatioUnit.DecibelWatt)] + [InlineData(2, PowerRatioUnit.DecibelMilliwatt, -10, PowerRatioUnit.DecibelMilliwatt)] + [InlineData(2, PowerRatioUnit.DecibelMilliwatt, -2, PowerRatioUnit.DecibelMilliwatt)] + [InlineData(10, PowerRatioUnit.DecibelWatt, 100, PowerRatioUnit.DecibelMilliwatt)] + [InlineData(-10, PowerRatioUnit.DecibelMilliwatt, 20, PowerRatioUnit.DecibelMilliwatt)] + [InlineData(double.NaN, PowerRatioUnit.DecibelMilliwatt, 1, PowerRatioUnit.DecibelWatt)] + [InlineData(double.PositiveInfinity, PowerRatioUnit.DecibelMilliwatt, 1, PowerRatioUnit.DecibelWatt)] + [InlineData(double.NegativeInfinity, PowerRatioUnit.DecibelMilliwatt, 1, PowerRatioUnit.DecibelWatt)] + [InlineData(1, PowerRatioUnit.DecibelMilliwatt, double.NaN, PowerRatioUnit.DecibelWatt)] + [InlineData(1, PowerRatioUnit.DecibelMilliwatt, double.PositiveInfinity, PowerRatioUnit.DecibelWatt)] + [InlineData(1, PowerRatioUnit.DecibelMilliwatt, double.NegativeInfinity, PowerRatioUnit.DecibelWatt)] + public void ArithmeticMean_WithSelector_ReturnsCorrectMean(double value1, PowerRatioUnit unit1, double value2, PowerRatioUnit unit2) + { + var quantity1 = new PowerRatio(value1, unit1); + var quantity2 = new PowerRatio(value2, unit2); + IEnumerable quantities = new List { quantity1, quantity2 }; + var scalingFactor = PowerRatio.LogarithmicScalingFactor; + var expectedValue = + ((quantity1.Value.ToLinearSpace(scalingFactor) + quantity2.As(unit1).ToLinearSpace(scalingFactor)) / 2).ToLogSpace(scalingFactor); + + PowerRatio result = quantities.ArithmeticMean(x => x); + + Assert.Equal(expectedValue, result.Value, 1e-5); + Assert.Equal(unit1, result.Unit); + } + + [Theory] + [InlineData(0, PowerRatioUnit.DecibelMilliwatt, 1, PowerRatioUnit.DecibelMilliwatt)] + [InlineData(0, PowerRatioUnit.DecibelWatt, 1, PowerRatioUnit.DecibelMilliwatt)] + [InlineData(1, PowerRatioUnit.DecibelMilliwatt, 1, PowerRatioUnit.DecibelWatt)] + [InlineData(1, PowerRatioUnit.DecibelMilliwatt, -1, PowerRatioUnit.DecibelWatt)] + [InlineData(2, PowerRatioUnit.DecibelMilliwatt, -10, PowerRatioUnit.DecibelMilliwatt)] + [InlineData(2, PowerRatioUnit.DecibelMilliwatt, -2, PowerRatioUnit.DecibelMilliwatt)] + [InlineData(10, PowerRatioUnit.DecibelWatt, 100, PowerRatioUnit.DecibelMilliwatt)] + [InlineData(-10, PowerRatioUnit.DecibelMilliwatt, 20, PowerRatioUnit.DecibelMilliwatt)] + [InlineData(double.NaN, PowerRatioUnit.DecibelMilliwatt, 1, PowerRatioUnit.DecibelWatt)] + [InlineData(double.PositiveInfinity, PowerRatioUnit.DecibelMilliwatt, 1, PowerRatioUnit.DecibelWatt)] + [InlineData(double.NegativeInfinity, PowerRatioUnit.DecibelMilliwatt, 1, PowerRatioUnit.DecibelWatt)] + [InlineData(1, PowerRatioUnit.DecibelMilliwatt, double.NaN, PowerRatioUnit.DecibelWatt)] + [InlineData(1, PowerRatioUnit.DecibelMilliwatt, double.PositiveInfinity, PowerRatioUnit.DecibelWatt)] + [InlineData(1, PowerRatioUnit.DecibelMilliwatt, double.NegativeInfinity, PowerRatioUnit.DecibelWatt)] + public void ArithmeticMean_WithSelectorAndUnit_ReturnsCorrectMean(double value1, PowerRatioUnit unit1, double value2, PowerRatioUnit unit2) + { + var quantity1 = new PowerRatio(value1, unit1); + var quantity2 = new PowerRatio(value2, unit2); + IEnumerable quantities = new List { quantity1, quantity2 }; + var scalingFactor = PowerRatio.LogarithmicScalingFactor; + var expectedValue = + ((quantity1.Value.ToLinearSpace(scalingFactor) + quantity2.As(unit1).ToLinearSpace(scalingFactor)) / 2).ToLogSpace(scalingFactor); + + PowerRatio result = quantities.ArithmeticMean(x => x, unit1); + + Assert.Equal(expectedValue, result.Value, 1e-5); + Assert.Equal(unit1, result.Unit); + } + + [Fact] + public void GeometricMean_ThrowsOnEmptyCollection() + { + PowerRatio[] quantities = []; + + Assert.Throws(() => quantities.GeometricMean()); + } + + [Fact] + public void GeometricMean_WithSelector_ThrowsOnEmptyCollection() + { + PowerRatio[] quantities = []; + + Assert.Throws(() => quantities.GeometricMean(x => x)); + } + + [Fact] + public void GeometricMean_WithUnitAndSelector_ThrowsOnEmptyCollection() + { + PowerRatio[] quantities = []; + + Assert.Throws(() => quantities.GeometricMean(x => x, PowerRatioUnit.DecibelWatt)); + } + + [Fact] + public void GeometricMean_WithNullSequence_ThrowsArgumentNullException() + { + PowerRatio[] quantities = null!; + + Assert.Throws(() => quantities.GeometricMean()); + } + + [Fact] + public void GeometricMean_WithNullSequenceAndUnit_ThrowsArgumentNullException() + { + PowerRatio[] quantities = null!; + + Assert.Throws(() => quantities.GeometricMean(PowerRatioUnit.DecibelWatt)); + } + + [Fact] + public void GeometricMean_WithNullSelector_ThrowsArgumentNullException() + { + PowerRatio[] quantities = null!; + + Assert.Throws(() => quantities.GeometricMean(x => x, PowerRatioUnit.DecibelWatt)); + } + + [Theory] + [InlineData(0, PowerRatioUnit.DecibelMilliwatt)] + [InlineData(1, PowerRatioUnit.DecibelWatt)] + [InlineData(double.NaN, PowerRatioUnit.DecibelMilliwatt)] + [InlineData(double.PositiveInfinity, PowerRatioUnit.DecibelMilliwatt)] + [InlineData(double.NegativeInfinity, PowerRatioUnit.DecibelMilliwatt)] + public void GeometricMean_SingleQuantity_ReturnsCorrectMean(double value, PowerRatioUnit unit) + { + var quantity = new PowerRatio(value, unit); + IEnumerable quantities = new List { quantity }; + + PowerRatio result = quantities.GeometricMean(); + + Assert.Equal(quantity.Value, result.Value, 1e-5); + Assert.Equal(quantity.Unit, result.Unit); + } + + [Theory] + [InlineData(0, PowerRatioUnit.DecibelMilliwatt)] + [InlineData(1, PowerRatioUnit.DecibelWatt)] + [InlineData(double.NaN, PowerRatioUnit.DecibelMilliwatt)] + [InlineData(double.PositiveInfinity, PowerRatioUnit.DecibelMilliwatt)] + [InlineData(double.NegativeInfinity, PowerRatioUnit.DecibelMilliwatt)] + public void GeometricMean_SingleQuantity_WithSelector_ReturnsCorrectMean(double value, PowerRatioUnit unit) + { + var quantity = new PowerRatio(value, unit); + IEnumerable quantities = new List { quantity }; + + PowerRatio result = quantities.GeometricMean(x => x); + + Assert.Equal(quantity.Value, result.Value, 1e-5); + Assert.Equal(quantity.Unit, result.Unit); + } + + [Theory] + [InlineData(0, PowerRatioUnit.DecibelMilliwatt, 1, PowerRatioUnit.DecibelMilliwatt)] + [InlineData(0, PowerRatioUnit.DecibelWatt, 1, PowerRatioUnit.DecibelMilliwatt)] + [InlineData(1, PowerRatioUnit.DecibelMilliwatt, 1, PowerRatioUnit.DecibelWatt)] + [InlineData(1, PowerRatioUnit.DecibelMilliwatt, -1, PowerRatioUnit.DecibelWatt)] + [InlineData(2, PowerRatioUnit.DecibelMilliwatt, -10, PowerRatioUnit.DecibelMilliwatt)] + [InlineData(2, PowerRatioUnit.DecibelMilliwatt, -2, PowerRatioUnit.DecibelMilliwatt)] + [InlineData(10, PowerRatioUnit.DecibelWatt, 100, PowerRatioUnit.DecibelMilliwatt)] + [InlineData(-10, PowerRatioUnit.DecibelMilliwatt, 20, PowerRatioUnit.DecibelMilliwatt)] + [InlineData(double.NaN, PowerRatioUnit.DecibelMilliwatt, 1, PowerRatioUnit.DecibelWatt)] + [InlineData(double.PositiveInfinity, PowerRatioUnit.DecibelMilliwatt, 1, PowerRatioUnit.DecibelWatt)] + [InlineData(double.NegativeInfinity, PowerRatioUnit.DecibelMilliwatt, 1, PowerRatioUnit.DecibelWatt)] + [InlineData(1, PowerRatioUnit.DecibelMilliwatt, double.NaN, PowerRatioUnit.DecibelWatt)] + [InlineData(1, PowerRatioUnit.DecibelMilliwatt, double.PositiveInfinity, PowerRatioUnit.DecibelWatt)] + [InlineData(1, PowerRatioUnit.DecibelMilliwatt, double.NegativeInfinity, PowerRatioUnit.DecibelWatt)] + public void GeometricMean_ReturnsCorrectMean(double value1, PowerRatioUnit unit1, double value2, PowerRatioUnit unit2) + { + var quantity1 = new PowerRatio(value1, unit1); + var quantity2 = new PowerRatio(value2, unit2); + IEnumerable quantities = new List { quantity1, quantity2 }; + var expectedValue = double.RootN(quantity1.Value + quantity2.As(unit1), 2); + + PowerRatio result = quantities.GeometricMean(); + + Assert.Equal(expectedValue, result.Value, 1e-5); + Assert.Equal(unit1, result.Unit); + } + + [Theory] + [InlineData(0, PowerRatioUnit.DecibelMilliwatt, 1, PowerRatioUnit.DecibelMilliwatt)] + [InlineData(0, PowerRatioUnit.DecibelWatt, 1, PowerRatioUnit.DecibelMilliwatt)] + [InlineData(1, PowerRatioUnit.DecibelMilliwatt, 1, PowerRatioUnit.DecibelWatt)] + [InlineData(1, PowerRatioUnit.DecibelMilliwatt, -1, PowerRatioUnit.DecibelWatt)] + [InlineData(2, PowerRatioUnit.DecibelMilliwatt, -10, PowerRatioUnit.DecibelMilliwatt)] + [InlineData(2, PowerRatioUnit.DecibelMilliwatt, -2, PowerRatioUnit.DecibelMilliwatt)] + [InlineData(10, PowerRatioUnit.DecibelWatt, 100, PowerRatioUnit.DecibelMilliwatt)] + [InlineData(-10, PowerRatioUnit.DecibelMilliwatt, 20, PowerRatioUnit.DecibelMilliwatt)] + [InlineData(double.NaN, PowerRatioUnit.DecibelMilliwatt, 1, PowerRatioUnit.DecibelWatt)] + [InlineData(double.PositiveInfinity, PowerRatioUnit.DecibelMilliwatt, 1, PowerRatioUnit.DecibelWatt)] + [InlineData(double.NegativeInfinity, PowerRatioUnit.DecibelMilliwatt, 1, PowerRatioUnit.DecibelWatt)] + [InlineData(1, PowerRatioUnit.DecibelMilliwatt, double.NaN, PowerRatioUnit.DecibelWatt)] + [InlineData(1, PowerRatioUnit.DecibelMilliwatt, double.PositiveInfinity, PowerRatioUnit.DecibelWatt)] + [InlineData(1, PowerRatioUnit.DecibelMilliwatt, double.NegativeInfinity, PowerRatioUnit.DecibelWatt)] + public void GeometricMean_WithSelector_ReturnsCorrectMean(double value1, PowerRatioUnit unit1, double value2, PowerRatioUnit unit2) + { + var quantity1 = new PowerRatio(value1, unit1); + var quantity2 = new PowerRatio(value2, unit2); + IEnumerable quantities = new List { quantity1, quantity2 }; + var expectedValue = double.RootN(quantity1.Value + quantity2.As(unit1), 2); + + PowerRatio result = quantities.GeometricMean(x => x); + + Assert.Equal(expectedValue, result.Value, 1e-5); + Assert.Equal(unit1, result.Unit); + } + + [Theory] + [InlineData(0, PowerRatioUnit.DecibelMilliwatt, 1, PowerRatioUnit.DecibelMilliwatt)] + [InlineData(0, PowerRatioUnit.DecibelWatt, 1, PowerRatioUnit.DecibelMilliwatt)] + [InlineData(1, PowerRatioUnit.DecibelMilliwatt, 1, PowerRatioUnit.DecibelWatt)] + [InlineData(1, PowerRatioUnit.DecibelMilliwatt, -1, PowerRatioUnit.DecibelWatt)] + [InlineData(2, PowerRatioUnit.DecibelMilliwatt, -10, PowerRatioUnit.DecibelMilliwatt)] + [InlineData(2, PowerRatioUnit.DecibelMilliwatt, -2, PowerRatioUnit.DecibelMilliwatt)] + [InlineData(10, PowerRatioUnit.DecibelWatt, 100, PowerRatioUnit.DecibelMilliwatt)] + [InlineData(-10, PowerRatioUnit.DecibelMilliwatt, 20, PowerRatioUnit.DecibelMilliwatt)] + [InlineData(double.NaN, PowerRatioUnit.DecibelMilliwatt, 1, PowerRatioUnit.DecibelWatt)] + [InlineData(double.PositiveInfinity, PowerRatioUnit.DecibelMilliwatt, 1, PowerRatioUnit.DecibelWatt)] + [InlineData(double.NegativeInfinity, PowerRatioUnit.DecibelMilliwatt, 1, PowerRatioUnit.DecibelWatt)] + [InlineData(1, PowerRatioUnit.DecibelMilliwatt, double.NaN, PowerRatioUnit.DecibelWatt)] + [InlineData(1, PowerRatioUnit.DecibelMilliwatt, double.PositiveInfinity, PowerRatioUnit.DecibelWatt)] + [InlineData(1, PowerRatioUnit.DecibelMilliwatt, double.NegativeInfinity, PowerRatioUnit.DecibelWatt)] + public void GeometricMean_WithUnitAndSelector_ReturnsCorrectMean(double value1, PowerRatioUnit unit1, double value2, PowerRatioUnit unit2) + { + var quantity1 = new PowerRatio(value1, unit1); + var quantity2 = new PowerRatio(value2, unit2); + IEnumerable quantities = new List { quantity1, quantity2 }; + var expectedValue = double.RootN(quantity1.Value + quantity2.As(unit1), 2); + + PowerRatio result = quantities.GeometricMean(x => x, unit1); + + Assert.Equal(expectedValue, result.Value, 1e-5); + Assert.Equal(unit1, result.Unit); + } +} diff --git a/UnitsNet/Comparison.cs b/UnitsNet/Comparison.cs index 8971906b04..3c38a83672 100644 --- a/UnitsNet/Comparison.cs +++ b/UnitsNet/Comparison.cs @@ -121,5 +121,22 @@ public static bool EqualsAbsolute(double value1, double value2, double tolerance return Math.Abs(value1 - value2) <= tolerance; } + + internal static int GetHashCode(TUnit unit, double value) + where TUnit : struct, Enum + { +#if NET7_0_OR_GREATER + return HashCode.Combine(typeof(TUnit), unit, value); +#else + unchecked + { + var hash = 17; + hash = hash * 23 + typeof(TUnit).GetHashCode(); + hash = hash * 23 + unit.GetHashCode(); + hash = hash * 23 + value.GetHashCode(); + return hash; + } +#endif + } } } diff --git a/UnitsNet/CustomCode/Quantities/Temperature.extra.cs b/UnitsNet/CustomCode/Quantities/Temperature.extra.cs index aa5434819b..a105bfd9d1 100644 --- a/UnitsNet/CustomCode/Quantities/Temperature.extra.cs +++ b/UnitsNet/CustomCode/Quantities/Temperature.extra.cs @@ -1,8 +1,6 @@ // 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 UnitsNet.Units; - namespace UnitsNet { public partial struct Temperature @@ -46,54 +44,5 @@ public partial struct Temperature { return new TemperatureDelta(left.Kelvins - right.Kelvins, TemperatureDeltaUnit.Kelvin); } - - /// - /// Multiply temperature with a in a given . - /// - /// - /// Due to different temperature units having different zero points, we cannot simply - /// multiply or divide a temperature by a factor. We must first convert to the desired unit, then perform the - /// calculation. - /// - /// Factor to multiply by. - /// Unit to perform multiplication in. - /// The resulting . - [Obsolete("Affine quantities, such as the Temperate, cannot be multiplied directly: consider using the TemperatureDelta type instead.")] - public Temperature Multiply(double factor, TemperatureUnit unit) - { - double resultInUnit = As(unit) * factor; - return From(resultInUnit, unit); - } - - /// - /// Divide temperature by a in a given . - /// - /// - /// Due to different temperature units having different zero points, we cannot simply - /// multiply or divide a temperature by a factor. We must first convert to the desired unit, then perform the - /// calculation. - /// - /// Factor to multiply by. - /// Unit to perform multiplication in. - /// The resulting . - [Obsolete("Affine quantities, such as the Temperate, cannot be divided directly: consider using the TemperatureDelta type instead.")] - public Temperature Divide(double divisor, TemperatureUnit unit) - { - double resultInUnit = As(unit) / divisor; - return From(resultInUnit, unit); - } - - /// /> - [Obsolete("Affine quantities, such as the Temperate, should use an offset-based tolerance: consider using the TemperatureDelta type instead.")] - public bool Equals(Temperature other, Temperature tolerance) - { - if (tolerance.Value < 0) - { - throw ExceptionHelper.CreateArgumentOutOfRangeExceptionForNegativeTolerance(nameof(tolerance)); - } - - var unitKey = UnitKey.ForUnit(tolerance.Unit); - return Comparison.EqualsAbsolute(this.GetValue(unitKey), other.GetValue(unitKey), tolerance.Value); - } } } diff --git a/UnitsNet/Extensions/AffineQuantityExtensions.cs b/UnitsNet/Extensions/AffineQuantityExtensions.cs index 196a5588f6..cf92c648ae 100644 --- a/UnitsNet/Extensions/AffineQuantityExtensions.cs +++ b/UnitsNet/Extensions/AffineQuantityExtensions.cs @@ -35,18 +35,7 @@ public static bool Equals(this TQuantity quantity, IQuantity where TQuantity : IAffineQuantity, ISubtractionOperators where TOffset : IQuantityInstance, IAdditiveIdentity { - if (other is not TQuantity otherInstance) - { - return false; - } - - // // TODO see about this (I think the exception should take precedence to the null check, but the QuantityTests disagree) - // if (tolerance is not TOffset toleranceQuantity) - // { - // throw ExceptionHelper.CreateArgumentException(tolerance, nameof(tolerance)); - // } - - return quantity.EqualsAbsolute(otherInstance, tolerance); + return other is TQuantity otherInstance && quantity.EqualsAbsolute(otherInstance, tolerance); } /// @@ -103,18 +92,7 @@ public static bool Equals(this Temperature quantity, Temperature other, Temperat /// public static bool Equals(this Temperature quantity, IQuantity? other, TemperatureDelta tolerance) { - if (other is not Temperature otherInstance) - { - return false; - } - - // TODO see about this (I think the exception should take precedence to the null check, but the QuantityTests disagree) - // if (tolerance is not TemperatureDelta toleranceQuantity) - // { - // throw ExceptionHelper.CreateArgumentException(tolerance, nameof(tolerance)); - // } - - return quantity.EqualsAbsolute(otherInstance, tolerance); + return other is Temperature otherInstance && quantity.EqualsAbsolute(otherInstance, tolerance); } /// diff --git a/UnitsNet/Extensions/LinearQuantityExtensions.cs b/UnitsNet/Extensions/LinearQuantityExtensions.cs index a8b8cf88e8..1f4ed5da7f 100644 --- a/UnitsNet/Extensions/LinearQuantityExtensions.cs +++ b/UnitsNet/Extensions/LinearQuantityExtensions.cs @@ -1,8 +1,6 @@ // 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.Collections.Generic; using System.Linq; namespace UnitsNet; diff --git a/UnitsNet/Extensions/LogarithmicQuantityExtensions.cs b/UnitsNet/Extensions/LogarithmicQuantityExtensions.cs index 14f22cc983..3419e1dbf0 100644 --- a/UnitsNet/Extensions/LogarithmicQuantityExtensions.cs +++ b/UnitsNet/Extensions/LogarithmicQuantityExtensions.cs @@ -11,12 +11,12 @@ namespace UnitsNet; /// public static class LogarithmicQuantityExtensions { - private static double ToLinearSpace(this double logValue, double scalingFactor) + internal static double ToLinearSpace(this double logValue, double scalingFactor) { return Math.Pow(10, logValue / scalingFactor); } - private static double ToLogSpace(this double value, double scalingFactor) + internal static double ToLogSpace(this double value, double scalingFactor) { return scalingFactor * Math.Log10(value); } diff --git a/UnitsNet/GeneratedCode/Quantities/AbsorbedDoseOfIonizingRadiation.g.cs b/UnitsNet/GeneratedCode/Quantities/AbsorbedDoseOfIonizingRadiation.g.cs index d56dfc09c4..5871359a7b 100644 --- a/UnitsNet/GeneratedCode/Quantities/AbsorbedDoseOfIonizingRadiation.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AbsorbedDoseOfIonizingRadiation.g.cs @@ -816,7 +816,7 @@ public bool Equals(AbsorbedDoseOfIonizingRadiation other) /// A hash code for the current AbsorbedDoseOfIonizingRadiation. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs b/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs index 595136ac7b..33973b687f 100644 --- a/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs @@ -806,7 +806,7 @@ public bool Equals(Acceleration other) /// A hash code for the current Acceleration. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs b/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs index 68d7835094..f9d4c7823e 100644 --- a/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs @@ -861,7 +861,7 @@ public bool Equals(AmountOfSubstance other) /// A hash code for the current AmountOfSubstance. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.g.cs b/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.g.cs index e291328a91..e78867732b 100644 --- a/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.g.cs @@ -606,7 +606,7 @@ public bool Equals(AmplitudeRatio other) /// A hash code for the current AmplitudeRatio. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/Angle.g.cs b/UnitsNet/GeneratedCode/Quantities/Angle.g.cs index 05d06ab6df..eeaa8cd628 100644 --- a/UnitsNet/GeneratedCode/Quantities/Angle.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Angle.g.cs @@ -794,7 +794,7 @@ public bool Equals(Angle other) /// A hash code for the current Angle. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/Area.g.cs b/UnitsNet/GeneratedCode/Quantities/Area.g.cs index 1bb1b69dc3..1a7dad3f73 100644 --- a/UnitsNet/GeneratedCode/Quantities/Area.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Area.g.cs @@ -890,7 +890,7 @@ public bool Equals(Area other) /// A hash code for the current Area. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs index fe9756dbce..25f2561cf7 100644 --- a/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs @@ -602,7 +602,7 @@ public bool Equals(AreaDensity other) /// A hash code for the current AreaDensity. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs b/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs index 6c4e0dba13..0263a177a1 100644 --- a/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs @@ -657,7 +657,7 @@ public bool Equals(AreaMomentOfInertia other) /// A hash code for the current AreaMomentOfInertia. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs b/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs index fc98e4a110..9ad0f15a26 100644 --- a/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs @@ -1168,7 +1168,7 @@ public bool Equals(BitRate other) /// A hash code for the current BitRate. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs b/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs index 45c4649ef4..27fb0e9437 100644 --- a/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs @@ -615,7 +615,7 @@ public bool Equals(BrakeSpecificFuelConsumption other) /// A hash code for the current BrakeSpecificFuelConsumption. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs b/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs index c804336738..a6aab41baa 100644 --- a/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs @@ -650,7 +650,7 @@ public bool Equals(CoefficientOfThermalExpansion other) /// A hash code for the current CoefficientOfThermalExpansion. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/Compressibility.g.cs b/UnitsNet/GeneratedCode/Quantities/Compressibility.g.cs index 84984a7f30..3c9d8b1e7f 100644 --- a/UnitsNet/GeneratedCode/Quantities/Compressibility.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Compressibility.g.cs @@ -653,7 +653,7 @@ public bool Equals(Compressibility other) /// A hash code for the current Compressibility. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/Density.g.cs b/UnitsNet/GeneratedCode/Quantities/Density.g.cs index 4a928507dd..d71409b39b 100644 --- a/UnitsNet/GeneratedCode/Quantities/Density.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Density.g.cs @@ -1502,7 +1502,7 @@ public bool Equals(Density other) /// A hash code for the current Density. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/DoseAreaProduct.g.cs b/UnitsNet/GeneratedCode/Quantities/DoseAreaProduct.g.cs index 53aa54a5eb..ace5fa5d9e 100644 --- a/UnitsNet/GeneratedCode/Quantities/DoseAreaProduct.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/DoseAreaProduct.g.cs @@ -944,7 +944,7 @@ public bool Equals(DoseAreaProduct other) /// A hash code for the current DoseAreaProduct. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/Duration.g.cs b/UnitsNet/GeneratedCode/Quantities/Duration.g.cs index e1d8f1e42d..3ce53590e2 100644 --- a/UnitsNet/GeneratedCode/Quantities/Duration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Duration.g.cs @@ -860,7 +860,7 @@ public bool Equals(Duration other) /// A hash code for the current Duration. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs b/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs index 2300eda9bd..408869cd60 100644 --- a/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs @@ -724,7 +724,7 @@ public bool Equals(DynamicViscosity other) /// A hash code for the current DynamicViscosity. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.g.cs index 86bbd5ec5a..19d973148e 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.g.cs @@ -801,7 +801,7 @@ public bool Equals(ElectricAdmittance other) /// A hash code for the current ElectricAdmittance. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricApparentEnergy.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricApparentEnergy.g.cs index 5eb0d3fab8..9b065fc9ba 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricApparentEnergy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricApparentEnergy.g.cs @@ -589,7 +589,7 @@ public bool Equals(ElectricApparentEnergy other) /// A hash code for the current ElectricApparentEnergy. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricApparentPower.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricApparentPower.g.cs index 45e093512b..29940a6ac9 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricApparentPower.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricApparentPower.g.cs @@ -640,7 +640,7 @@ public bool Equals(ElectricApparentPower other) /// A hash code for the current ElectricApparentPower. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCapacitance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCapacitance.g.cs index 24bd261f78..46ca93d4e6 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCapacitance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCapacitance.g.cs @@ -656,7 +656,7 @@ public bool Equals(ElectricCapacitance other) /// A hash code for the current ElectricCapacitance. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs index 18fde1fe69..0d041cff41 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs @@ -747,7 +747,7 @@ public bool Equals(ElectricCharge other) /// A hash code for the current ElectricCharge. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.g.cs index 4d1083c921..b91c6dba22 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.g.cs @@ -560,7 +560,7 @@ public bool Equals(ElectricChargeDensity other) /// A hash code for the current ElectricChargeDensity. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricConductance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricConductance.g.cs index ebb5454f0e..0c55e99a2d 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricConductance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricConductance.g.cs @@ -800,7 +800,7 @@ public bool Equals(ElectricConductance other) /// A hash code for the current ElectricConductance. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs index 59e69259ec..6faedfcd7d 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs @@ -651,7 +651,7 @@ public bool Equals(ElectricConductivity other) /// A hash code for the current ElectricConductivity. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs index da3daf01d4..c5700c30e0 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs @@ -729,7 +729,7 @@ public bool Equals(ElectricCurrent other) /// A hash code for the current ElectricCurrent. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs index 1f164f74be..c24785a1f0 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs @@ -592,7 +592,7 @@ public bool Equals(ElectricCurrentDensity other) /// A hash code for the current ElectricCurrentDensity. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs index 8bcae0bedf..8c0e6a6707 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs @@ -666,7 +666,7 @@ public bool Equals(ElectricCurrentGradient other) /// A hash code for the current ElectricCurrentGradient. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricField.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricField.g.cs index 928d371956..0eaf4ef823 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricField.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricField.g.cs @@ -560,7 +560,7 @@ public bool Equals(ElectricField other) /// A hash code for the current ElectricField. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricImpedance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricImpedance.g.cs index 50073bb733..ba64c2803f 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricImpedance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricImpedance.g.cs @@ -673,7 +673,7 @@ public bool Equals(ElectricImpedance other) /// A hash code for the current ElectricImpedance. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricInductance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricInductance.g.cs index 3cf1ff0b61..66f973b0ed 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricInductance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricInductance.g.cs @@ -624,7 +624,7 @@ public bool Equals(ElectricInductance other) /// A hash code for the current ElectricInductance. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs index 3febd51304..57d914e429 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs @@ -674,7 +674,7 @@ public bool Equals(ElectricPotential other) /// A hash code for the current ElectricPotential. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs index 73ff2247a4..297dfac804 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs @@ -861,7 +861,7 @@ public bool Equals(ElectricPotentialChangeRate other) /// A hash code for the current ElectricPotentialChangeRate. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricReactance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricReactance.g.cs index c3f0b483ff..b5eb0e93b5 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricReactance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricReactance.g.cs @@ -672,7 +672,7 @@ public bool Equals(ElectricReactance other) /// A hash code for the current ElectricReactance. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricReactiveEnergy.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricReactiveEnergy.g.cs index 39965edd45..7d7621d0cd 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricReactiveEnergy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricReactiveEnergy.g.cs @@ -589,7 +589,7 @@ public bool Equals(ElectricReactiveEnergy other) /// A hash code for the current ElectricReactiveEnergy. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricReactivePower.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricReactivePower.g.cs index 29d735bda3..c29d0356de 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricReactivePower.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricReactivePower.g.cs @@ -608,7 +608,7 @@ public bool Equals(ElectricReactivePower other) /// A hash code for the current ElectricReactivePower. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs index 1750a38f29..cca61636ab 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs @@ -685,7 +685,7 @@ public bool Equals(ElectricResistance other) /// A hash code for the current ElectricResistance. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs index b612229a41..517efc3871 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs @@ -779,7 +779,7 @@ public bool Equals(ElectricResistivity other) /// A hash code for the current ElectricResistivity. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs index bb44f0c29e..1d8c51bf5d 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs @@ -592,7 +592,7 @@ public bool Equals(ElectricSurfaceChargeDensity other) /// A hash code for the current ElectricSurfaceChargeDensity. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricSusceptance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricSusceptance.g.cs index 8adbf61f2e..547cecbcd7 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricSusceptance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricSusceptance.g.cs @@ -800,7 +800,7 @@ public bool Equals(ElectricSusceptance other) /// A hash code for the current ElectricSusceptance. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/Energy.g.cs b/UnitsNet/GeneratedCode/Quantities/Energy.g.cs index ceb56502f2..f85626fd6e 100644 --- a/UnitsNet/GeneratedCode/Quantities/Energy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Energy.g.cs @@ -1278,7 +1278,7 @@ public bool Equals(Energy other) /// A hash code for the current Energy. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/EnergyDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/EnergyDensity.g.cs index 12ecd7d423..3aad9da18a 100644 --- a/UnitsNet/GeneratedCode/Quantities/EnergyDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/EnergyDensity.g.cs @@ -746,7 +746,7 @@ public bool Equals(EnergyDensity other) /// A hash code for the current EnergyDensity. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs b/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs index a4319be7e5..f33f70ea30 100644 --- a/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs @@ -680,7 +680,7 @@ public bool Equals(Entropy other) /// A hash code for the current Entropy. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/FluidResistance.g.cs b/UnitsNet/GeneratedCode/Quantities/FluidResistance.g.cs index dcce633bf0..befa267edd 100644 --- a/UnitsNet/GeneratedCode/Quantities/FluidResistance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/FluidResistance.g.cs @@ -848,7 +848,7 @@ public bool Equals(FluidResistance other) /// A hash code for the current FluidResistance. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/Force.g.cs b/UnitsNet/GeneratedCode/Quantities/Force.g.cs index bd65a4fa2d..809caf640e 100644 --- a/UnitsNet/GeneratedCode/Quantities/Force.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Force.g.cs @@ -871,7 +871,7 @@ public bool Equals(Force other) /// A hash code for the current Force. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs index a91bc92d37..6c757eb615 100644 --- a/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs @@ -794,7 +794,7 @@ public bool Equals(ForceChangeRate other) /// A hash code for the current ForceChangeRate. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs b/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs index 026376cd4b..c168b064b7 100644 --- a/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs @@ -1218,7 +1218,7 @@ public bool Equals(ForcePerLength other) /// A hash code for the current ForcePerLength. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs b/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs index 753a06cfa9..8c15522dde 100644 --- a/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs @@ -746,7 +746,7 @@ public bool Equals(Frequency other) /// A hash code for the current Frequency. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/FuelEfficiency.g.cs b/UnitsNet/GeneratedCode/Quantities/FuelEfficiency.g.cs index 643569172c..d33e750671 100644 --- a/UnitsNet/GeneratedCode/Quantities/FuelEfficiency.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/FuelEfficiency.g.cs @@ -608,7 +608,7 @@ public bool Equals(FuelEfficiency other) /// A hash code for the current FuelEfficiency. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs b/UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs index 0b66ebc27a..bea9c2ebb1 100644 --- a/UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs @@ -842,7 +842,7 @@ public bool Equals(HeatFlux other) /// A hash code for the current HeatFlux. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs b/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs index ce12dfb985..123c332821 100644 --- a/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs @@ -621,7 +621,7 @@ public bool Equals(HeatTransferCoefficient other) /// A hash code for the current HeatTransferCoefficient. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/Illuminance.g.cs b/UnitsNet/GeneratedCode/Quantities/Illuminance.g.cs index df428b789b..b61e3707da 100644 --- a/UnitsNet/GeneratedCode/Quantities/Illuminance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Illuminance.g.cs @@ -621,7 +621,7 @@ public bool Equals(Illuminance other) /// A hash code for the current Illuminance. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/Impulse.g.cs b/UnitsNet/GeneratedCode/Quantities/Impulse.g.cs index 4e3232afa3..88cb8ef68f 100644 --- a/UnitsNet/GeneratedCode/Quantities/Impulse.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Impulse.g.cs @@ -749,7 +749,7 @@ public bool Equals(Impulse other) /// A hash code for the current Impulse. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/Information.g.cs b/UnitsNet/GeneratedCode/Quantities/Information.g.cs index 52c9cd1ed9..8ab4591f9d 100644 --- a/UnitsNet/GeneratedCode/Quantities/Information.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Information.g.cs @@ -1151,7 +1151,7 @@ public bool Equals(Information other) /// A hash code for the current Information. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/Irradiance.g.cs b/UnitsNet/GeneratedCode/Quantities/Irradiance.g.cs index 6b5c8fd64f..94600cfda5 100644 --- a/UnitsNet/GeneratedCode/Quantities/Irradiance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Irradiance.g.cs @@ -765,7 +765,7 @@ public bool Equals(Irradiance other) /// A hash code for the current Irradiance. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/Irradiation.g.cs b/UnitsNet/GeneratedCode/Quantities/Irradiation.g.cs index fabf415f5c..5f76e3ffc7 100644 --- a/UnitsNet/GeneratedCode/Quantities/Irradiation.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Irradiation.g.cs @@ -688,7 +688,7 @@ public bool Equals(Irradiation other) /// A hash code for the current Irradiation. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/Jerk.g.cs b/UnitsNet/GeneratedCode/Quantities/Jerk.g.cs index 587a30b7d9..b05491901a 100644 --- a/UnitsNet/GeneratedCode/Quantities/Jerk.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Jerk.g.cs @@ -730,7 +730,7 @@ public bool Equals(Jerk other) /// A hash code for the current Jerk. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs b/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs index 997068d838..559b191971 100644 --- a/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs @@ -722,7 +722,7 @@ public bool Equals(KinematicViscosity other) /// A hash code for the current KinematicViscosity. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/LeakRate.g.cs b/UnitsNet/GeneratedCode/Quantities/LeakRate.g.cs index 2508364f74..dca6a225dc 100644 --- a/UnitsNet/GeneratedCode/Quantities/LeakRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LeakRate.g.cs @@ -592,7 +592,7 @@ public bool Equals(LeakRate other) /// A hash code for the current LeakRate. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/Length.g.cs b/UnitsNet/GeneratedCode/Quantities/Length.g.cs index 2bf95d97b2..d918a18e9d 100644 --- a/UnitsNet/GeneratedCode/Quantities/Length.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Length.g.cs @@ -1352,7 +1352,7 @@ public bool Equals(Length other) /// A hash code for the current Length. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/Level.g.cs b/UnitsNet/GeneratedCode/Quantities/Level.g.cs index 9ecf241a5e..8d7e453301 100644 --- a/UnitsNet/GeneratedCode/Quantities/Level.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Level.g.cs @@ -574,7 +574,7 @@ public bool Equals(Level other) /// A hash code for the current Level. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/LinearDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/LinearDensity.g.cs index 5e73ea53d5..3a309625b8 100644 --- a/UnitsNet/GeneratedCode/Quantities/LinearDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LinearDensity.g.cs @@ -859,7 +859,7 @@ public bool Equals(LinearDensity other) /// A hash code for the current LinearDensity. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/LinearPowerDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/LinearPowerDensity.g.cs index cec08e04aa..10c7785dec 100644 --- a/UnitsNet/GeneratedCode/Quantities/LinearPowerDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LinearPowerDensity.g.cs @@ -944,7 +944,7 @@ public bool Equals(LinearPowerDensity other) /// A hash code for the current LinearPowerDensity. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/Luminance.g.cs b/UnitsNet/GeneratedCode/Quantities/Luminance.g.cs index 2977781af1..a1e4d9421c 100644 --- a/UnitsNet/GeneratedCode/Quantities/Luminance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Luminance.g.cs @@ -717,7 +717,7 @@ public bool Equals(Luminance other) /// A hash code for the current Luminance. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/Luminosity.g.cs b/UnitsNet/GeneratedCode/Quantities/Luminosity.g.cs index 73d70755fe..3cba77d27d 100644 --- a/UnitsNet/GeneratedCode/Quantities/Luminosity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Luminosity.g.cs @@ -768,7 +768,7 @@ public bool Equals(Luminosity other) /// A hash code for the current Luminosity. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/LuminousFlux.g.cs b/UnitsNet/GeneratedCode/Quantities/LuminousFlux.g.cs index e28603d44e..db7eae72c1 100644 --- a/UnitsNet/GeneratedCode/Quantities/LuminousFlux.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LuminousFlux.g.cs @@ -580,7 +580,7 @@ public bool Equals(LuminousFlux other) /// A hash code for the current LuminousFlux. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.g.cs b/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.g.cs index 71287d4141..25688b2f46 100644 --- a/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.g.cs @@ -580,7 +580,7 @@ public bool Equals(LuminousIntensity other) /// A hash code for the current LuminousIntensity. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/MagneticField.g.cs b/UnitsNet/GeneratedCode/Quantities/MagneticField.g.cs index 3908d3cc70..4ec638af33 100644 --- a/UnitsNet/GeneratedCode/Quantities/MagneticField.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MagneticField.g.cs @@ -640,7 +640,7 @@ public bool Equals(MagneticField other) /// A hash code for the current MagneticField. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/MagneticFlux.g.cs b/UnitsNet/GeneratedCode/Quantities/MagneticFlux.g.cs index 3538af7760..efff5575c1 100644 --- a/UnitsNet/GeneratedCode/Quantities/MagneticFlux.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MagneticFlux.g.cs @@ -560,7 +560,7 @@ public bool Equals(MagneticFlux other) /// A hash code for the current MagneticFlux. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/Magnetization.g.cs b/UnitsNet/GeneratedCode/Quantities/Magnetization.g.cs index c0618365f4..fd6a4147ce 100644 --- a/UnitsNet/GeneratedCode/Quantities/Magnetization.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Magnetization.g.cs @@ -560,7 +560,7 @@ public bool Equals(Magnetization other) /// A hash code for the current Magnetization. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/Mass.g.cs b/UnitsNet/GeneratedCode/Quantities/Mass.g.cs index a82bdcce00..ebb018d6b1 100644 --- a/UnitsNet/GeneratedCode/Quantities/Mass.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Mass.g.cs @@ -1091,7 +1091,7 @@ public bool Equals(Mass other) /// A hash code for the current Mass. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/MassConcentration.g.cs b/UnitsNet/GeneratedCode/Quantities/MassConcentration.g.cs index c60db148da..e3ea9907c6 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassConcentration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassConcentration.g.cs @@ -1369,7 +1369,7 @@ public bool Equals(MassConcentration other) /// A hash code for the current MassConcentration. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs b/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs index 739a1c7592..8ea6a93468 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs @@ -1145,7 +1145,7 @@ public bool Equals(MassFlow other) /// A hash code for the current MassFlow. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs b/UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs index 8f9b707a34..de77b0ce03 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs @@ -760,7 +760,7 @@ public bool Equals(MassFlux other) /// A hash code for the current MassFlux. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/MassFraction.g.cs b/UnitsNet/GeneratedCode/Quantities/MassFraction.g.cs index 07757ec170..8e09be88ea 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassFraction.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassFraction.g.cs @@ -927,7 +927,7 @@ public bool Equals(MassFraction other) /// A hash code for the current MassFraction. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.g.cs b/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.g.cs index 97668bdec0..9ed52a1275 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.g.cs @@ -989,7 +989,7 @@ public bool Equals(MassMomentOfInertia other) /// A hash code for the current MassMomentOfInertia. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/Molality.g.cs b/UnitsNet/GeneratedCode/Quantities/Molality.g.cs index 72da45f445..6069504995 100644 --- a/UnitsNet/GeneratedCode/Quantities/Molality.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Molality.g.cs @@ -592,7 +592,7 @@ public bool Equals(Molality other) /// A hash code for the current Molality. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/MolarEnergy.g.cs b/UnitsNet/GeneratedCode/Quantities/MolarEnergy.g.cs index de2260cdb5..f6e8a7658f 100644 --- a/UnitsNet/GeneratedCode/Quantities/MolarEnergy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MolarEnergy.g.cs @@ -602,7 +602,7 @@ public bool Equals(MolarEnergy other) /// A hash code for the current MolarEnergy. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs b/UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs index 7e43d6aa6a..30f5568438 100644 --- a/UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs @@ -589,7 +589,7 @@ public bool Equals(MolarEntropy other) /// A hash code for the current MolarEntropy. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/MolarFlow.g.cs b/UnitsNet/GeneratedCode/Quantities/MolarFlow.g.cs index 03d2f533d9..e8129a5112 100644 --- a/UnitsNet/GeneratedCode/Quantities/MolarFlow.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MolarFlow.g.cs @@ -719,7 +719,7 @@ public bool Equals(MolarFlow other) /// A hash code for the current MolarFlow. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs b/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs index 231953d887..736652a421 100644 --- a/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs @@ -776,7 +776,7 @@ public bool Equals(MolarMass other) /// A hash code for the current MolarMass. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs b/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs index 90f88e2078..e5404675a1 100644 --- a/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs @@ -761,7 +761,7 @@ public bool Equals(Molarity other) /// A hash code for the current Molarity. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/Permeability.g.cs b/UnitsNet/GeneratedCode/Quantities/Permeability.g.cs index d141d3a044..a6abc55963 100644 --- a/UnitsNet/GeneratedCode/Quantities/Permeability.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Permeability.g.cs @@ -560,7 +560,7 @@ public bool Equals(Permeability other) /// A hash code for the current Permeability. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/Permittivity.g.cs b/UnitsNet/GeneratedCode/Quantities/Permittivity.g.cs index 29191ab18d..3d1fe94806 100644 --- a/UnitsNet/GeneratedCode/Quantities/Permittivity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Permittivity.g.cs @@ -560,7 +560,7 @@ public bool Equals(Permittivity other) /// A hash code for the current Permittivity. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/PorousMediumPermeability.g.cs b/UnitsNet/GeneratedCode/Quantities/PorousMediumPermeability.g.cs index af9ec2463c..255f7dd31a 100644 --- a/UnitsNet/GeneratedCode/Quantities/PorousMediumPermeability.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/PorousMediumPermeability.g.cs @@ -624,7 +624,7 @@ public bool Equals(PorousMediumPermeability other) /// A hash code for the current PorousMediumPermeability. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/Power.g.cs b/UnitsNet/GeneratedCode/Quantities/Power.g.cs index 53c4b85425..bc730df565 100644 --- a/UnitsNet/GeneratedCode/Quantities/Power.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Power.g.cs @@ -1077,7 +1077,7 @@ public bool Equals(Power other) /// A hash code for the current Power. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/PowerDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/PowerDensity.g.cs index 11fe91bfa6..254d42bd53 100644 --- a/UnitsNet/GeneratedCode/Quantities/PowerDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/PowerDensity.g.cs @@ -1245,7 +1245,7 @@ public bool Equals(PowerDensity other) /// A hash code for the current PowerDensity. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/PowerRatio.g.cs b/UnitsNet/GeneratedCode/Quantities/PowerRatio.g.cs index 96a9d66b9c..f414118cb9 100644 --- a/UnitsNet/GeneratedCode/Quantities/PowerRatio.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/PowerRatio.g.cs @@ -574,7 +574,7 @@ public bool Equals(PowerRatio other) /// A hash code for the current PowerRatio. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/Pressure.g.cs b/UnitsNet/GeneratedCode/Quantities/Pressure.g.cs index b30fd6938c..a6b17ca554 100644 --- a/UnitsNet/GeneratedCode/Quantities/Pressure.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Pressure.g.cs @@ -1369,7 +1369,7 @@ public bool Equals(Pressure other) /// A hash code for the current Pressure. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.g.cs index 17a385eb99..d00a06a6b8 100644 --- a/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.g.cs @@ -842,7 +842,7 @@ public bool Equals(PressureChangeRate other) /// A hash code for the current PressureChangeRate. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/RadiationEquivalentDose.g.cs b/UnitsNet/GeneratedCode/Quantities/RadiationEquivalentDose.g.cs index 7d1beb68af..da4d1c8222 100644 --- a/UnitsNet/GeneratedCode/Quantities/RadiationEquivalentDose.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RadiationEquivalentDose.g.cs @@ -657,7 +657,7 @@ public bool Equals(RadiationEquivalentDose other) /// A hash code for the current RadiationEquivalentDose. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/RadiationEquivalentDoseRate.g.cs b/UnitsNet/GeneratedCode/Quantities/RadiationEquivalentDoseRate.g.cs index ed54bb9869..0ea15d4b33 100644 --- a/UnitsNet/GeneratedCode/Quantities/RadiationEquivalentDoseRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RadiationEquivalentDoseRate.g.cs @@ -714,7 +714,7 @@ public bool Equals(RadiationEquivalentDoseRate other) /// A hash code for the current RadiationEquivalentDoseRate. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/RadiationExposure.g.cs b/UnitsNet/GeneratedCode/Quantities/RadiationExposure.g.cs index feb0a03356..010d1f9c72 100644 --- a/UnitsNet/GeneratedCode/Quantities/RadiationExposure.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RadiationExposure.g.cs @@ -669,7 +669,7 @@ public bool Equals(RadiationExposure other) /// A hash code for the current RadiationExposure. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/Radioactivity.g.cs b/UnitsNet/GeneratedCode/Quantities/Radioactivity.g.cs index 3bd5c96307..2ab55b2a4c 100644 --- a/UnitsNet/GeneratedCode/Quantities/Radioactivity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Radioactivity.g.cs @@ -1005,7 +1005,7 @@ public bool Equals(Radioactivity other) /// A hash code for the current Radioactivity. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/Ratio.g.cs b/UnitsNet/GeneratedCode/Quantities/Ratio.g.cs index e3d516ac9e..4c7b90af0c 100644 --- a/UnitsNet/GeneratedCode/Quantities/Ratio.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Ratio.g.cs @@ -623,7 +623,7 @@ public bool Equals(Ratio other) /// A hash code for the current Ratio. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/RatioChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/RatioChangeRate.g.cs index f60298a01d..e1df1e7b55 100644 --- a/UnitsNet/GeneratedCode/Quantities/RatioChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RatioChangeRate.g.cs @@ -573,7 +573,7 @@ public bool Equals(RatioChangeRate other) /// A hash code for the current RatioChangeRate. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/ReciprocalArea.g.cs b/UnitsNet/GeneratedCode/Quantities/ReciprocalArea.g.cs index 648acae51f..4edfaafc51 100644 --- a/UnitsNet/GeneratedCode/Quantities/ReciprocalArea.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ReciprocalArea.g.cs @@ -768,7 +768,7 @@ public bool Equals(ReciprocalArea other) /// A hash code for the current ReciprocalArea. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/ReciprocalLength.g.cs b/UnitsNet/GeneratedCode/Quantities/ReciprocalLength.g.cs index 90f97170d5..5f89fc4314 100644 --- a/UnitsNet/GeneratedCode/Quantities/ReciprocalLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ReciprocalLength.g.cs @@ -766,7 +766,7 @@ public bool Equals(ReciprocalLength other) /// A hash code for the current ReciprocalLength. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/RelativeHumidity.g.cs b/UnitsNet/GeneratedCode/Quantities/RelativeHumidity.g.cs index 9db3c616df..753144dd44 100644 --- a/UnitsNet/GeneratedCode/Quantities/RelativeHumidity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RelativeHumidity.g.cs @@ -543,7 +543,7 @@ public bool Equals(RelativeHumidity other) /// A hash code for the current RelativeHumidity. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalAcceleration.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalAcceleration.g.cs index 7e8867c607..28a6467e19 100644 --- a/UnitsNet/GeneratedCode/Quantities/RotationalAcceleration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RotationalAcceleration.g.cs @@ -605,7 +605,7 @@ public bool Equals(RotationalAcceleration other) /// A hash code for the current RotationalAcceleration. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.g.cs index 726c1ed3df..a46dd24e1c 100644 --- a/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.g.cs @@ -769,7 +769,7 @@ public bool Equals(RotationalSpeed other) /// A hash code for the current RotationalSpeed. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.g.cs index 27a9381aca..d4e7b1f21d 100644 --- a/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.g.cs @@ -1096,7 +1096,7 @@ public bool Equals(RotationalStiffness other) /// A hash code for the current RotationalStiffness. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs index 036faeba54..93b03b7562 100644 --- a/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs @@ -634,7 +634,7 @@ public bool Equals(RotationalStiffnessPerLength other) /// A hash code for the current RotationalStiffnessPerLength. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/Scalar.g.cs b/UnitsNet/GeneratedCode/Quantities/Scalar.g.cs index d8c79a77f8..8cba945512 100644 --- a/UnitsNet/GeneratedCode/Quantities/Scalar.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Scalar.g.cs @@ -543,7 +543,7 @@ public bool Equals(Scalar other) /// A hash code for the current Scalar. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/SolidAngle.g.cs b/UnitsNet/GeneratedCode/Quantities/SolidAngle.g.cs index 7f5f6e0ced..aefca11d43 100644 --- a/UnitsNet/GeneratedCode/Quantities/SolidAngle.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SolidAngle.g.cs @@ -546,7 +546,7 @@ public bool Equals(SolidAngle other) /// A hash code for the current SolidAngle. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.g.cs index 4b6f1058db..91dea9772b 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.g.cs @@ -1078,7 +1078,7 @@ public bool Equals(SpecificEnergy other) /// A hash code for the current SpecificEnergy. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.g.cs index 0c61990840..0a51a42cf4 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.g.cs @@ -705,7 +705,7 @@ public bool Equals(SpecificEntropy other) /// A hash code for the current SpecificEntropy. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs index 05f6bf02d9..e0d5f6a61e 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs @@ -608,7 +608,7 @@ public bool Equals(SpecificFuelConsumption other) /// A hash code for the current SpecificFuelConsumption. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs index 007359f236..69a357c204 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs @@ -609,7 +609,7 @@ public bool Equals(SpecificVolume other) /// A hash code for the current SpecificVolume. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificWeight.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificWeight.g.cs index e6b5997a68..277424f8a3 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificWeight.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificWeight.g.cs @@ -850,7 +850,7 @@ public bool Equals(SpecificWeight other) /// A hash code for the current SpecificWeight. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/Speed.g.cs b/UnitsNet/GeneratedCode/Quantities/Speed.g.cs index d239be94c2..72143237fe 100644 --- a/UnitsNet/GeneratedCode/Quantities/Speed.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Speed.g.cs @@ -1131,7 +1131,7 @@ public bool Equals(Speed other) /// A hash code for the current Speed. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/StandardVolumeFlow.g.cs b/UnitsNet/GeneratedCode/Quantities/StandardVolumeFlow.g.cs index a724bfcc7d..729abd7b03 100644 --- a/UnitsNet/GeneratedCode/Quantities/StandardVolumeFlow.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/StandardVolumeFlow.g.cs @@ -685,7 +685,7 @@ public bool Equals(StandardVolumeFlow other) /// A hash code for the current StandardVolumeFlow. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/Temperature.g.cs b/UnitsNet/GeneratedCode/Quantities/Temperature.g.cs index 00e544ea4d..b27abdb70f 100644 --- a/UnitsNet/GeneratedCode/Quantities/Temperature.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Temperature.g.cs @@ -655,7 +655,7 @@ public bool Equals(Temperature other) /// A hash code for the current Temperature. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.g.cs index 260f7aaa18..731f83a1cd 100644 --- a/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.g.cs @@ -826,7 +826,7 @@ public bool Equals(TemperatureChangeRate other) /// A hash code for the current TemperatureChangeRate. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs b/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs index 7a7a225532..1e02e2fc53 100644 --- a/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs @@ -740,7 +740,7 @@ public bool Equals(TemperatureDelta other) /// A hash code for the current TemperatureDelta. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/TemperatureGradient.g.cs b/UnitsNet/GeneratedCode/Quantities/TemperatureGradient.g.cs index 4fa3d32e69..8f579c80d1 100644 --- a/UnitsNet/GeneratedCode/Quantities/TemperatureGradient.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/TemperatureGradient.g.cs @@ -618,7 +618,7 @@ public bool Equals(TemperatureGradient other) /// A hash code for the current TemperatureGradient. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/ThermalConductivity.g.cs b/UnitsNet/GeneratedCode/Quantities/ThermalConductivity.g.cs index 28c8bf9809..f9f52d86b4 100644 --- a/UnitsNet/GeneratedCode/Quantities/ThermalConductivity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ThermalConductivity.g.cs @@ -576,7 +576,7 @@ public bool Equals(ThermalConductivity other) /// A hash code for the current ThermalConductivity. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/ThermalInsulance.g.cs b/UnitsNet/GeneratedCode/Quantities/ThermalInsulance.g.cs index 2df6ea38a1..e682d4c65c 100644 --- a/UnitsNet/GeneratedCode/Quantities/ThermalInsulance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ThermalInsulance.g.cs @@ -653,7 +653,7 @@ public bool Equals(ThermalInsulance other) /// A hash code for the current ThermalInsulance. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/ThermalResistance.g.cs b/UnitsNet/GeneratedCode/Quantities/ThermalResistance.g.cs index 1257be0638..4d8b33fa81 100644 --- a/UnitsNet/GeneratedCode/Quantities/ThermalResistance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ThermalResistance.g.cs @@ -573,7 +573,7 @@ public bool Equals(ThermalResistance other) /// A hash code for the current ThermalResistance. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/Torque.g.cs b/UnitsNet/GeneratedCode/Quantities/Torque.g.cs index c1e4597788..656c8ecd12 100644 --- a/UnitsNet/GeneratedCode/Quantities/Torque.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Torque.g.cs @@ -996,7 +996,7 @@ public bool Equals(Torque other) /// A hash code for the current Torque. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/Turbidity.g.cs b/UnitsNet/GeneratedCode/Quantities/Turbidity.g.cs index a133506a51..5fbeea5558 100644 --- a/UnitsNet/GeneratedCode/Quantities/Turbidity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Turbidity.g.cs @@ -546,7 +546,7 @@ public bool Equals(Turbidity other) /// A hash code for the current Turbidity. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/VitaminA.g.cs b/UnitsNet/GeneratedCode/Quantities/VitaminA.g.cs index 09c4904e53..a6cca1429a 100644 --- a/UnitsNet/GeneratedCode/Quantities/VitaminA.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VitaminA.g.cs @@ -543,7 +543,7 @@ public bool Equals(VitaminA other) /// A hash code for the current VitaminA. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/Volume.g.cs b/UnitsNet/GeneratedCode/Quantities/Volume.g.cs index 676672f58a..9ccdfa62c1 100644 --- a/UnitsNet/GeneratedCode/Quantities/Volume.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Volume.g.cs @@ -1502,7 +1502,7 @@ public bool Equals(Volume other) /// A hash code for the current Volume. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/VolumeConcentration.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumeConcentration.g.cs index 4a93f47b3c..29642e3a09 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumeConcentration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumeConcentration.g.cs @@ -870,7 +870,7 @@ public bool Equals(VolumeConcentration other) /// A hash code for the current VolumeConcentration. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs index f482c6a26f..07431e2ba7 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs @@ -1782,7 +1782,7 @@ public bool Equals(VolumeFlow other) /// A hash code for the current VolumeFlow. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/VolumeFlowPerArea.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumeFlowPerArea.g.cs index 5aeb638a71..2abcfa15af 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumeFlowPerArea.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumeFlowPerArea.g.cs @@ -573,7 +573,7 @@ public bool Equals(VolumeFlowPerArea other) /// A hash code for the current VolumeFlowPerArea. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/VolumePerLength.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumePerLength.g.cs index d5c295c893..2c80031e1f 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumePerLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumePerLength.g.cs @@ -685,7 +685,7 @@ public bool Equals(VolumePerLength other) /// A hash code for the current VolumePerLength. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs index 63e358667d..2f9eaba537 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs @@ -688,7 +688,7 @@ public bool Equals(VolumetricHeatCapacity other) /// A hash code for the current VolumetricHeatCapacity. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. diff --git a/UnitsNet/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs b/UnitsNet/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs index ce5f88386a..c1f898b072 100644 --- a/UnitsNet/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs @@ -637,7 +637,7 @@ public bool Equals(WarpingMomentOfInertia other) /// A hash code for the current WarpingMomentOfInertia. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Comparison.GetHashCode(Unit, Value); } /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. From f9976bab76adee651ce58d6952572c8fdb79aeac Mon Sep 17 00:00:00 2001 From: lipchev Date: Wed, 30 Jul 2025 19:17:29 +0300 Subject: [PATCH 5/8] splitting the IQuantity interface definitions into separate files --- UnitsNet/IAffineQuantity.cs | 47 ++++++++++++++ UnitsNet/ILogarithmicQuantity.cs | 69 ++++++++++++++++++++ UnitsNet/IQuantity.cs | 106 ------------------------------- 3 files changed, 116 insertions(+), 106 deletions(-) create mode 100644 UnitsNet/IAffineQuantity.cs create mode 100644 UnitsNet/ILogarithmicQuantity.cs diff --git a/UnitsNet/IAffineQuantity.cs b/UnitsNet/IAffineQuantity.cs new file mode 100644 index 0000000000..056b75120d --- /dev/null +++ b/UnitsNet/IAffineQuantity.cs @@ -0,0 +1,47 @@ +// 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. + +#if NET7_0_OR_GREATER +using System.Numerics; +#endif + +namespace UnitsNet; + +/// +/// An that (in .NET 7+) implements generic math interfaces for arithmetic operations. +/// +/// The type itself, for the CRT pattern. +/// The underlying unit enum type. +/// +public interface IAffineQuantity : IQuantity, IAffineQuantity +#if NET7_0_OR_GREATER + , IAdditionOperators + , ISubtractionOperators + where TOffset : IAdditiveIdentity +#endif + where TSelf : IAffineQuantity + where TUnitType : struct, Enum +{ +} + +/// +/// An that (in .NET 7+) implements generic math interfaces for arithmetic operations. +/// +/// The type itself, for the CRT pattern. +/// +public interface IAffineQuantity : IQuantityInstance +#if NET7_0_OR_GREATER + , IAdditiveIdentity + where TOffset : IAdditiveIdentity +#endif + where TSelf : IAffineQuantity +{ +#if NET7_0_OR_GREATER + /// + /// The zero value of this quantity. + /// + static abstract TSelf Zero { get; } + + static TOffset IAdditiveIdentity.AdditiveIdentity => TOffset.AdditiveIdentity; +#endif +} diff --git a/UnitsNet/ILogarithmicQuantity.cs b/UnitsNet/ILogarithmicQuantity.cs new file mode 100644 index 0000000000..9c6b0cd0c6 --- /dev/null +++ b/UnitsNet/ILogarithmicQuantity.cs @@ -0,0 +1,69 @@ +// 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. + +#if NET7_0_OR_GREATER +using System.Numerics; +#endif + +namespace UnitsNet; + +/// +/// The type itself, for the CRT pattern. +/// The underlying unit enum type. +public interface ILogarithmicQuantity : IQuantity, ILogarithmicQuantity +#if NET7_0_OR_GREATER + , IAdditionOperators + , ISubtractionOperators + , IMultiplyOperators + , IDivisionOperators + , IUnaryNegationOperators +#endif + where TSelf : ILogarithmicQuantity + where TUnitType : struct, Enum +{ +} + +/// +/// Represents a logarithmic quantity that supports arithmetic operations and implements generic math interfaces +/// (in .NET 7+). This interface is designed for quantities that are logarithmic in nature, such as decibels. +/// +/// The type itself, for the CRT pattern. +/// +/// Logarithmic quantities are different from linear quantities in that they represent values on a logarithmic scale. +/// This interface extends and provides additional functionality specific +/// to logarithmic quantities, including arithmetic operations and a logarithmic scaling factor. +/// The logarithmic scale assumed here is base-10. +/// +public interface ILogarithmicQuantity : IQuantityInstance +#if NET7_0_OR_GREATER + , IMultiplicativeIdentity +#endif + where TSelf : ILogarithmicQuantity +{ +#if NET7_0_OR_GREATER + /// + /// Gets the logarithmic scaling factor used to convert between linear and logarithmic units. + /// This factor is typically 10, but there are exceptions such as the PowerRatio, which uses 20. + /// + /// + /// The logarithmic scaling factor. + /// + static abstract double LogarithmicScalingFactor { get; } + + /// + /// The zero value of this quantity. + /// + static abstract TSelf Zero { get; } + + static TSelf IMultiplicativeIdentity.MultiplicativeIdentity => TSelf.Zero; +#else + /// + /// Gets the logarithmic scaling factor used to convert between linear and logarithmic units. + /// This factor is typically 10, but there are exceptions such as the PowerRatio, which uses 20. + /// + /// + /// The logarithmic scaling factor. + /// + double LogarithmicScalingFactor { get; } +#endif +} diff --git a/UnitsNet/IQuantity.cs b/UnitsNet/IQuantity.cs index 214368f272..e4c24adca9 100644 --- a/UnitsNet/IQuantity.cs +++ b/UnitsNet/IQuantity.cs @@ -1,11 +1,6 @@ // 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. -#if NET7_0_OR_GREATER -using System.Numerics; - -#endif - namespace UnitsNet { /// @@ -194,105 +189,4 @@ IQuantity IQuantity.ToUnit(UnitSystem unitSystem) #endif } - - /// - /// An that (in .NET 7+) implements generic math interfaces for arithmetic operations. - /// - /// The type itself, for the CRT pattern. - /// - public interface IAffineQuantity : IQuantityInstance - #if NET7_0_OR_GREATER - , IAdditiveIdentity - where TOffset : IAdditiveIdentity - #endif - where TSelf : IAffineQuantity - { - #if NET7_0_OR_GREATER - /// - /// The zero value of this quantity. - /// - static abstract TSelf Zero { get; } - - static TOffset IAdditiveIdentity.AdditiveIdentity => TOffset.AdditiveIdentity; - #endif - } - - /// - /// An that (in .NET 7+) implements generic math interfaces for arithmetic operations. - /// - /// The type itself, for the CRT pattern. - /// The underlying unit enum type. - /// - public interface IAffineQuantity : IQuantity, IAffineQuantity - #if NET7_0_OR_GREATER - , IAdditionOperators - , ISubtractionOperators - where TOffset : IAdditiveIdentity - #endif - where TSelf : IAffineQuantity - where TUnitType : struct, Enum - { - } - - - /// - /// Represents a logarithmic quantity that supports arithmetic operations and implements generic math interfaces - /// (in .NET 7+). This interface is designed for quantities that are logarithmic in nature, such as decibels. - /// - /// The type itself, for the CRT pattern. - /// - /// Logarithmic quantities are different from linear quantities in that they represent values on a logarithmic scale. - /// This interface extends and provides additional functionality specific - /// to logarithmic quantities, including arithmetic operations and a logarithmic scaling factor. - /// The logarithmic scale assumed here is base-10. - /// - public interface ILogarithmicQuantity : IQuantityInstance - #if NET7_0_OR_GREATER - , IMultiplicativeIdentity - #endif - where TSelf : ILogarithmicQuantity - { - #if NET7_0_OR_GREATER - /// - /// Gets the logarithmic scaling factor used to convert between linear and logarithmic units. - /// This factor is typically 10, but there are exceptions such as the PowerRatio, which uses 20. - /// - /// - /// The logarithmic scaling factor. - /// - static abstract double LogarithmicScalingFactor { get; } - - /// - /// The zero value of this quantity. - /// - static abstract TSelf Zero { get; } - - static TSelf IMultiplicativeIdentity.MultiplicativeIdentity => TSelf.Zero; - #else - /// - /// Gets the logarithmic scaling factor used to convert between linear and logarithmic units. - /// This factor is typically 10, but there are exceptions such as the PowerRatio, which uses 20. - /// - /// - /// The logarithmic scaling factor. - /// - double LogarithmicScalingFactor { get; } - #endif - } - - /// - /// The type itself, for the CRT pattern. - /// The underlying unit enum type. - public interface ILogarithmicQuantity : IQuantity, ILogarithmicQuantity - #if NET7_0_OR_GREATER - , IAdditionOperators - , ISubtractionOperators - , IMultiplyOperators - , IDivisionOperators - , IUnaryNegationOperators - #endif - where TSelf : ILogarithmicQuantity - where TUnitType : struct, Enum - { - } } From bdf04d54a62054c91fb6e8aac637d7cea5eaacbf Mon Sep 17 00:00:00 2001 From: lipchev Date: Sun, 3 Aug 2025 09:15:53 +0300 Subject: [PATCH 6/8] - renamed IQuantityInstance to IQuantityOfType - replaced the type of the tolerance parameter of the Equals extension with the concrete quantity type --- .../UnitsNetGen/QuantityGenerator.cs | 2 +- .../AffineQuantityExtensionsTest.cs | 35 +---------- .../LinearQuantityExtensionsTest.cs | 33 ++--------- .../LogarithmicQuantityExtensionsTest.cs | 33 ++--------- .../Extensions/AffineQuantityExtensions.cs | 58 +++++++------------ .../Extensions/LinearQuantityExtensions.cs | 30 +++------- .../LogarithmicQuantityExtensions.cs | 30 +++------- UnitsNet/Extensions/QuantityExtensions.cs | 2 +- .../AbsorbedDoseOfIonizingRadiation.g.cs | 2 +- .../Quantities/Acceleration.g.cs | 2 +- .../Quantities/AmountOfSubstance.g.cs | 2 +- .../Quantities/AmplitudeRatio.g.cs | 2 +- UnitsNet/GeneratedCode/Quantities/Angle.g.cs | 2 +- UnitsNet/GeneratedCode/Quantities/Area.g.cs | 2 +- .../GeneratedCode/Quantities/AreaDensity.g.cs | 2 +- .../Quantities/AreaMomentOfInertia.g.cs | 2 +- .../GeneratedCode/Quantities/BitRate.g.cs | 2 +- .../BrakeSpecificFuelConsumption.g.cs | 2 +- .../CoefficientOfThermalExpansion.g.cs | 2 +- .../Quantities/Compressibility.g.cs | 2 +- .../GeneratedCode/Quantities/Density.g.cs | 2 +- .../Quantities/DoseAreaProduct.g.cs | 2 +- .../GeneratedCode/Quantities/Duration.g.cs | 2 +- .../Quantities/DynamicViscosity.g.cs | 2 +- .../Quantities/ElectricAdmittance.g.cs | 2 +- .../Quantities/ElectricApparentEnergy.g.cs | 2 +- .../Quantities/ElectricApparentPower.g.cs | 2 +- .../Quantities/ElectricCapacitance.g.cs | 2 +- .../Quantities/ElectricCharge.g.cs | 2 +- .../Quantities/ElectricChargeDensity.g.cs | 2 +- .../Quantities/ElectricConductance.g.cs | 2 +- .../Quantities/ElectricConductivity.g.cs | 2 +- .../Quantities/ElectricCurrent.g.cs | 2 +- .../Quantities/ElectricCurrentDensity.g.cs | 2 +- .../Quantities/ElectricCurrentGradient.g.cs | 2 +- .../Quantities/ElectricField.g.cs | 2 +- .../Quantities/ElectricImpedance.g.cs | 2 +- .../Quantities/ElectricInductance.g.cs | 2 +- .../Quantities/ElectricPotential.g.cs | 2 +- .../ElectricPotentialChangeRate.g.cs | 2 +- .../Quantities/ElectricReactance.g.cs | 2 +- .../Quantities/ElectricReactiveEnergy.g.cs | 2 +- .../Quantities/ElectricReactivePower.g.cs | 2 +- .../Quantities/ElectricResistance.g.cs | 2 +- .../Quantities/ElectricResistivity.g.cs | 2 +- .../ElectricSurfaceChargeDensity.g.cs | 2 +- .../Quantities/ElectricSusceptance.g.cs | 2 +- UnitsNet/GeneratedCode/Quantities/Energy.g.cs | 2 +- .../Quantities/EnergyDensity.g.cs | 2 +- .../GeneratedCode/Quantities/Entropy.g.cs | 2 +- .../Quantities/FluidResistance.g.cs | 2 +- UnitsNet/GeneratedCode/Quantities/Force.g.cs | 2 +- .../Quantities/ForceChangeRate.g.cs | 2 +- .../Quantities/ForcePerLength.g.cs | 2 +- .../GeneratedCode/Quantities/Frequency.g.cs | 2 +- .../Quantities/FuelEfficiency.g.cs | 2 +- .../GeneratedCode/Quantities/HeatFlux.g.cs | 2 +- .../Quantities/HeatTransferCoefficient.g.cs | 2 +- .../GeneratedCode/Quantities/Illuminance.g.cs | 2 +- .../GeneratedCode/Quantities/Impulse.g.cs | 2 +- .../GeneratedCode/Quantities/Information.g.cs | 2 +- .../GeneratedCode/Quantities/Irradiance.g.cs | 2 +- .../GeneratedCode/Quantities/Irradiation.g.cs | 2 +- UnitsNet/GeneratedCode/Quantities/Jerk.g.cs | 2 +- .../Quantities/KinematicViscosity.g.cs | 2 +- .../GeneratedCode/Quantities/LeakRate.g.cs | 2 +- UnitsNet/GeneratedCode/Quantities/Length.g.cs | 2 +- UnitsNet/GeneratedCode/Quantities/Level.g.cs | 2 +- .../Quantities/LinearDensity.g.cs | 2 +- .../Quantities/LinearPowerDensity.g.cs | 2 +- .../GeneratedCode/Quantities/Luminance.g.cs | 2 +- .../GeneratedCode/Quantities/Luminosity.g.cs | 2 +- .../Quantities/LuminousFlux.g.cs | 2 +- .../Quantities/LuminousIntensity.g.cs | 2 +- .../Quantities/MagneticField.g.cs | 2 +- .../Quantities/MagneticFlux.g.cs | 2 +- .../Quantities/Magnetization.g.cs | 2 +- UnitsNet/GeneratedCode/Quantities/Mass.g.cs | 2 +- .../Quantities/MassConcentration.g.cs | 2 +- .../GeneratedCode/Quantities/MassFlow.g.cs | 2 +- .../GeneratedCode/Quantities/MassFlux.g.cs | 2 +- .../Quantities/MassFraction.g.cs | 2 +- .../Quantities/MassMomentOfInertia.g.cs | 2 +- .../GeneratedCode/Quantities/Molality.g.cs | 2 +- .../GeneratedCode/Quantities/MolarEnergy.g.cs | 2 +- .../Quantities/MolarEntropy.g.cs | 2 +- .../GeneratedCode/Quantities/MolarFlow.g.cs | 2 +- .../GeneratedCode/Quantities/MolarMass.g.cs | 2 +- .../GeneratedCode/Quantities/Molarity.g.cs | 2 +- .../Quantities/Permeability.g.cs | 2 +- .../Quantities/Permittivity.g.cs | 2 +- .../Quantities/PorousMediumPermeability.g.cs | 2 +- UnitsNet/GeneratedCode/Quantities/Power.g.cs | 2 +- .../Quantities/PowerDensity.g.cs | 2 +- .../GeneratedCode/Quantities/PowerRatio.g.cs | 2 +- .../GeneratedCode/Quantities/Pressure.g.cs | 2 +- .../Quantities/PressureChangeRate.g.cs | 2 +- .../Quantities/RadiationEquivalentDose.g.cs | 2 +- .../RadiationEquivalentDoseRate.g.cs | 2 +- .../Quantities/RadiationExposure.g.cs | 2 +- .../Quantities/Radioactivity.g.cs | 2 +- UnitsNet/GeneratedCode/Quantities/Ratio.g.cs | 2 +- .../Quantities/RatioChangeRate.g.cs | 2 +- .../Quantities/ReciprocalArea.g.cs | 2 +- .../Quantities/ReciprocalLength.g.cs | 2 +- .../Quantities/RelativeHumidity.g.cs | 2 +- .../Quantities/RotationalAcceleration.g.cs | 2 +- .../Quantities/RotationalSpeed.g.cs | 2 +- .../Quantities/RotationalStiffness.g.cs | 2 +- .../RotationalStiffnessPerLength.g.cs | 2 +- UnitsNet/GeneratedCode/Quantities/Scalar.g.cs | 2 +- .../GeneratedCode/Quantities/SolidAngle.g.cs | 2 +- .../Quantities/SpecificEnergy.g.cs | 2 +- .../Quantities/SpecificEntropy.g.cs | 2 +- .../Quantities/SpecificFuelConsumption.g.cs | 2 +- .../Quantities/SpecificVolume.g.cs | 2 +- .../Quantities/SpecificWeight.g.cs | 2 +- UnitsNet/GeneratedCode/Quantities/Speed.g.cs | 2 +- .../Quantities/StandardVolumeFlow.g.cs | 2 +- .../GeneratedCode/Quantities/Temperature.g.cs | 2 +- .../Quantities/TemperatureChangeRate.g.cs | 2 +- .../Quantities/TemperatureDelta.g.cs | 2 +- .../Quantities/TemperatureGradient.g.cs | 2 +- .../Quantities/ThermalConductivity.g.cs | 2 +- .../Quantities/ThermalInsulance.g.cs | 2 +- .../Quantities/ThermalResistance.g.cs | 2 +- UnitsNet/GeneratedCode/Quantities/Torque.g.cs | 2 +- .../GeneratedCode/Quantities/Turbidity.g.cs | 2 +- .../GeneratedCode/Quantities/VitaminA.g.cs | 2 +- UnitsNet/GeneratedCode/Quantities/Volume.g.cs | 2 +- .../Quantities/VolumeConcentration.g.cs | 2 +- .../GeneratedCode/Quantities/VolumeFlow.g.cs | 2 +- .../Quantities/VolumeFlowPerArea.g.cs | 2 +- .../Quantities/VolumePerLength.g.cs | 2 +- .../Quantities/VolumetricHeatCapacity.g.cs | 2 +- .../Quantities/WarpingMomentOfInertia.g.cs | 2 +- UnitsNet/IAffineQuantity.cs | 2 +- UnitsNet/IArithmeticQuantity.cs | 2 +- UnitsNet/ILogarithmicQuantity.cs | 2 +- UnitsNet/IQuantity.cs | 6 +- 140 files changed, 186 insertions(+), 305 deletions(-) diff --git a/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs b/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs index d8e6578d75..25b4024433 100644 --- a/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs +++ b/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs @@ -393,7 +393,7 @@ private void GenerateProperties() #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo<{_quantity.Name}> IQuantityInstance<{_quantity.Name}>.QuantityInfo => Info; + IQuantityInstanceInfo<{_quantity.Name}> IQuantityOfType<{_quantity.Name}>.QuantityInfo => Info; #endif "); if (_quantity.Logarithmic) diff --git a/UnitsNet.Tests/AffineQuantityExtensionsTest.cs b/UnitsNet.Tests/AffineQuantityExtensionsTest.cs index 971a503737..5da68a2030 100644 --- a/UnitsNet.Tests/AffineQuantityExtensionsTest.cs +++ b/UnitsNet.Tests/AffineQuantityExtensionsTest.cs @@ -86,18 +86,6 @@ public void Equals_Temperature_IQuantity_WithDifferentType_ReturnsFalse() [Fact] public void Equals_WithNullOther_ReturnsFalse() - { - var quantity = Temperature.FromDegreesCelsius(25); - IQuantity? other = null; - var tolerance = TemperatureDelta.FromDegreesCelsius(25); - - var result = quantity.Equals(other, tolerance); - - Assert.False(result); - } - - [Fact] - public void Equals_IQuantity_WithNullOther_ReturnsFalse() { var quantity = Temperature.FromDegreesCelsius(25.0); var tolerance = TemperatureDelta.FromDegreesCelsius(25.0); @@ -107,32 +95,15 @@ public void Equals_IQuantity_WithNullOther_ReturnsFalse() Assert.False(result); } - [Theory] - [InlineData(25.0, 25.0, 0.1, true)] // Equal values - // [InlineData(25.0, 25.1, 0.1, true)] // Within tolerance (but fails due to rounding) - [InlineData(25.0, 25.1, 0.10001, true)] // Within tolerance - [InlineData(25.0, 25.2, 0.1, false)] // Outside tolerance - [InlineData(25.0, 25.0, 0.0, true)] // Zero tolerance, equal values - [InlineData(25.0, 25.1, 0.0, false)] // Zero tolerance, different values - public void EqualsAbsolute_Temperature_TemperatureDelta(double value1, double value2, double toleranceValue, bool expected) - { - var temperature1 = Temperature.FromDegreesCelsius(value1); - var temperature2 = Temperature.FromDegreesCelsius(value2); - var tolerance = TemperatureDelta.FromDegreesCelsius(toleranceValue); - - var result = temperature1.EqualsAbsolute(temperature2, tolerance); - - Assert.Equal(expected, result); - } - [Fact] - public void EqualsAbsolute_Temperature_TemperatureDelta_ThrowsArgumentOutOfRangeException_ForNegativeTolerance() + public void Equals_ThrowsArgumentOutOfRangeException_ForNegativeTolerance() { var temperature1 = Temperature.FromDegreesCelsius(25.0); var temperature2 = Temperature.FromDegreesCelsius(25.0); var negativeTolerance = TemperatureDelta.FromDegreesCelsius(-0.1); - Assert.Throws(() => temperature1.EqualsAbsolute(temperature2, negativeTolerance)); + Assert.Throws(() => temperature1.Equals(temperature2, negativeTolerance)); + Assert.Throws(() => temperature1.Equals((IQuantity)temperature2, negativeTolerance)); } [Theory] diff --git a/UnitsNet.Tests/LinearQuantityExtensionsTest.cs b/UnitsNet.Tests/LinearQuantityExtensionsTest.cs index 29da21c322..55305f4c7d 100644 --- a/UnitsNet.Tests/LinearQuantityExtensionsTest.cs +++ b/UnitsNet.Tests/LinearQuantityExtensionsTest.cs @@ -55,7 +55,7 @@ public void Equals_IQuantityWithTolerance_ReturnsExpectedResult(double value1, d { var quantity1 = Length.FromMeters(value1); IQuantity quantity2 = Length.FromMeters(value2); - IQuantity toleranceQuantity = Length.FromMeters(tolerance); + var toleranceQuantity = Length.FromMeters(tolerance); var result = quantity1.Equals(quantity2, toleranceQuantity); @@ -64,18 +64,6 @@ public void Equals_IQuantityWithTolerance_ReturnsExpectedResult(double value1, d [Fact] public void Equals_WithNullOther_ReturnsFalse() - { - var quantity = Length.FromMeters(2.0); - Length? otherQuantity = null; - var tolerance = Length.FromMeters(0.1); - - var result = quantity.Equals(otherQuantity, tolerance); - - Assert.False(result); - } - - [Fact] - public void Equals_IQuantity_WithNullOther_ReturnsFalse() { var quantity = Length.FromMeters(2.0); var tolerance = Length.FromMeters(0.1); @@ -84,19 +72,9 @@ public void Equals_IQuantity_WithNullOther_ReturnsFalse() Assert.False(result); } - - [Fact] - public void Equals_WithDifferentTypeTolerance_ThrowsArgumentException() - { - var quantity = Length.FromMeters(2.0); - var other = Length.FromMeters(2.0); - var tolerance = Mass.FromKilograms(0.1); - - Assert.Throws(() => quantity.Equals(other, tolerance)); - } [Fact(Skip = "Currently throws a NotImplementedException")] - public void Equals_TQuantity_TQuantity_WithUnknownUnits_ThrowsUnitNotFoundException() + public void Equals_TQuantity_WithUnknownUnits_ThrowsUnitNotFoundException() { var quantity = Length.FromMeters(1); var invalidQuantity = new Length(1, (LengthUnit)(-1)); @@ -106,7 +84,7 @@ public void Equals_TQuantity_TQuantity_WithUnknownUnits_ThrowsUnitNotFoundExcept } [Fact(Skip = "Currently throws a NotImplementedException")] - public void Equals_IQuantity_IQuantity_WithUnknownUnits_ThrowsUnitNotFoundException() + public void Equals_IQuantity_WithUnknownUnits_ThrowsUnitNotFoundException() { var quantity = Length.FromMeters(1); var invalidQuantity = new Length(1, (LengthUnit)(-1)); @@ -116,13 +94,14 @@ public void Equals_IQuantity_IQuantity_WithUnknownUnits_ThrowsUnitNotFoundExcept } [Fact] - public void EqualsAbsolute_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() + public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException() { var quantity = Length.FromMeters(2.0); var other = Length.FromMeters(2.0); var tolerance = Length.FromMeters(-0.1); - Assert.Throws(() => quantity.EqualsAbsolute(other, tolerance)); + Assert.Throws(() => quantity.Equals(other, tolerance)); + Assert.Throws(() => quantity.Equals((IQuantity)other, tolerance)); } [Fact] diff --git a/UnitsNet.Tests/LogarithmicQuantityExtensionsTest.cs b/UnitsNet.Tests/LogarithmicQuantityExtensionsTest.cs index e808d6fc21..a77ae31b8c 100644 --- a/UnitsNet.Tests/LogarithmicQuantityExtensionsTest.cs +++ b/UnitsNet.Tests/LogarithmicQuantityExtensionsTest.cs @@ -10,7 +10,7 @@ public class LogarithmicQuantityExtensionsTest [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_TQuantity_TOther_TTolerance_ComparesInLinearSpace(double firstValue, double secondValue) + public void Equals_TQuantity_ComparesInLinearSpace(double firstValue, double secondValue) { var quantity = PowerRatio.FromDecibelWatts(firstValue); var otherQuantity = PowerRatio.FromDecibelWatts(secondValue); @@ -29,7 +29,7 @@ public void Equals_TQuantity_TOther_TTolerance_ComparesInLinearSpace(double firs [InlineData(1, 2)] [InlineData(100, 110)] [InlineData(100, 90)] - public void Equals_TQuantity_IQuantity_IQuantity_ComparesInLinearSpace(double firstValue, double secondValue) + public void Equals_IQuantity_ComparesInLinearSpace(double firstValue, double secondValue) { var quantity = PowerRatio.FromDecibelWatts(firstValue); var otherQuantity = PowerRatio.FromDecibelWatts(secondValue); @@ -51,33 +51,9 @@ public void Equals_NullQuantity_ReturnsFalse() var tolerance = PowerRatio.FromDecibelWatts(1); Assert.False(quantity.Equals(null, tolerance)); } - - [Fact] - public void Equals_NullQuantity_And_NullTolerance_ReturnsFalse() - { - var quantity = PowerRatio.FromDecibelWatts(1); - var tolerance = PowerRatio.FromDecibelWatts(1); - Assert.False(quantity.Equals(null, tolerance)); - } - - [Fact] - public void Equals_NullQuantity_And_AnotherToleranceType_ReturnsFalse() - { - var quantity = PowerRatio.FromDecibelWatts(1); - var tolerance = AmplitudeRatio.FromDecibelVolts(1); - Assert.False(quantity.Equals(null, tolerance)); - } - - [Fact] - public void Equals_IQuantity_And_AnotherToleranceType_ThrowsArgumentException() - { - var quantity = PowerRatio.FromDecibelWatts(1); - var tolerance = AmplitudeRatio.FromDecibelVolts(1); - Assert.Throws(() => quantity.Equals(quantity, tolerance)); - } [Fact(Skip = "Currently throws a NotImplementedException")] - public void Equals_TQuantity_TQuantity_WithUnknownUnits_ThrowsUnitNotFoundException() + public void Equals_TQuantity_WithUnknownUnits_ThrowsUnitNotFoundException() { var quantity = PowerRatio.FromDecibelWatts(1); var invalidQuantity = new PowerRatio(1, (PowerRatioUnit)(-1)); @@ -87,7 +63,7 @@ public void Equals_TQuantity_TQuantity_WithUnknownUnits_ThrowsUnitNotFoundExcept } [Fact(Skip = "Currently throws a NotImplementedException")] - public void Equals_IQuantity_IQuantity_WithUnknownUnits_ThrowsUnitNotFoundException() + public void Equals_IQuantity_WithUnknownUnits_ThrowsUnitNotFoundException() { var quantity = PowerRatio.FromDecibelWatts(1); var invalidQuantity = new PowerRatio(1, (PowerRatioUnit)(-1)); @@ -103,6 +79,7 @@ public void Equals_WithNegativeTolerance_DoesNotThrowArgumentOutOfRangeException var quantity = PowerRatio.FromDecibelWatts(1); var negativeTolerance = PowerRatio.FromDecibelWatts(-1); Assert.True(quantity.Equals(quantity, negativeTolerance)); + Assert.True(quantity.Equals((IQuantity)quantity, negativeTolerance)); } [Fact] diff --git a/UnitsNet/Extensions/AffineQuantityExtensions.cs b/UnitsNet/Extensions/AffineQuantityExtensions.cs index cf92c648ae..3477b5b47e 100644 --- a/UnitsNet/Extensions/AffineQuantityExtensions.cs +++ b/UnitsNet/Extensions/AffineQuantityExtensions.cs @@ -1,10 +1,6 @@ // 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.Collections.Generic; -using UnitsNet.Units; -using UnitsNet; #if NET using System.Numerics; #endif @@ -21,19 +17,15 @@ public static class AffineQuantityExtensions /// public static bool Equals(this TQuantity quantity, TQuantity? other, TOffset tolerance) where TQuantity : IAffineQuantity, ISubtractionOperators - where TOffset : IQuantityInstance, IAdditiveIdentity + where TOffset : IQuantityOfType, IAdditiveIdentity { return other != null && quantity.EqualsAbsolute(other, tolerance); } - + /// - /// - /// Thrown when the is not of the same type as the - /// . - /// public static bool Equals(this TQuantity quantity, IQuantity? other, TOffset tolerance) where TQuantity : IAffineQuantity, ISubtractionOperators - where TOffset : IQuantityInstance, IAdditiveIdentity + where TOffset : IQuantityOfType, IAdditiveIdentity { return other is TQuantity otherInstance && quantity.EqualsAbsolute(otherInstance, tolerance); } @@ -44,13 +36,14 @@ public static bool Equals(this TQuantity quantity, IQuantity /// 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). + /// In this example, the two temperatures will be considered equal if the value of b is within 0.5 degrees Celsius + /// of a. /// - /// 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 - /// + /// var a = Temperature.FromDegreesCelsius(25); + /// var b = Temperature.FromDegreesCelsius(25.4); + /// var tolerance = TemperatureDelta.FromDegreesCelsius(0.5); + /// a.Equals(b, tolerance); // true, 25°C equals 25.4°C +/- 0.5°C + /// /// /// /// The type of the quantity being compared. @@ -65,9 +58,9 @@ public static bool Equals(this TQuantity quantity, IQuantity /// It is generally advised against specifying "zero" tolerance, preferring the use of the default equality /// comparer, which is significantly more performant. /// - public static bool EqualsAbsolute(this TQuantity quantity, TQuantity other, TOffset tolerance) + private static bool EqualsAbsolute(this TQuantity quantity, TQuantity other, TOffset tolerance) where TQuantity : IAffineQuantity, ISubtractionOperators - where TOffset : IQuantityInstance, IAdditiveIdentity + where TOffset : IQuantityOfType, IAdditiveIdentity { if (double.IsNegative(tolerance.Value)) { @@ -78,23 +71,6 @@ public static bool EqualsAbsolute(this TQuantity quantity, T return double.Abs(difference.Value) <= tolerance.GetValue(difference.UnitKey); } #else - /// - public static bool Equals(this Temperature quantity, Temperature other, TemperatureDelta tolerance) - { - return quantity.EqualsAbsolute(other, tolerance); - // return other.HasValue && quantity.EqualsAbsolute(other.Value, tolerance); - } - - /// - /// - /// Thrown when the is not of the same type as the - /// . - /// - public static bool Equals(this Temperature quantity, IQuantity? other, TemperatureDelta tolerance) - { - return other is Temperature otherInstance && quantity.EqualsAbsolute(otherInstance, tolerance); - } - /// /// /// Compare equality to given a for the maximum allowed +/- @@ -108,7 +84,7 @@ public static bool Equals(this Temperature quantity, IQuantity? other, Temperatu /// var b = Temperature.FromDegreesCelsius(25.4); /// var tolerance = TemperatureDelta.FromDegreesCelsius(0.5); /// a.Equals(b, tolerance); // true, 25°C equals 25.4°C +/- 0.5°C - /// + /// /// /// /// The quantity to compare. @@ -121,7 +97,7 @@ public static bool Equals(this Temperature quantity, IQuantity? other, Temperatu /// It is generally advised against specifying "zero" tolerance, preferring the use of the default equality /// comparer, which is significantly more performant. /// - public static bool EqualsAbsolute(this Temperature quantity, Temperature other, TemperatureDelta tolerance) + public static bool Equals(this Temperature quantity, Temperature other, TemperatureDelta tolerance) { if (tolerance.Value < 0) { @@ -131,6 +107,12 @@ public static bool EqualsAbsolute(this Temperature quantity, Temperature other, TemperatureDelta difference = quantity - other; return Math.Abs(difference.Value) <= tolerance.GetValue(UnitKey.ForUnit(difference.Unit)); } + + /// + public static bool Equals(this Temperature quantity, IQuantity? other, TemperatureDelta tolerance) + { + return other is Temperature otherInstance && quantity.Equals(otherInstance, tolerance); + } #endif /// diff --git a/UnitsNet/Extensions/LinearQuantityExtensions.cs b/UnitsNet/Extensions/LinearQuantityExtensions.cs index 1f4ed5da7f..c029459908 100644 --- a/UnitsNet/Extensions/LinearQuantityExtensions.cs +++ b/UnitsNet/Extensions/LinearQuantityExtensions.cs @@ -14,32 +14,18 @@ public static class LinearQuantityExtensions /// public static bool Equals(this TQuantity quantity, TOther? other, TTolerance tolerance) where TQuantity : ILinearQuantity - where TOther : IQuantityInstance - where TTolerance : IQuantityInstance + where TOther : IQuantityOfType + where TTolerance : IQuantityOfType { return other != null && quantity.EqualsAbsolute(other, tolerance); } /// - /// - /// Thrown when the is not of the same type as the - /// . - /// - public static bool Equals(this TQuantity quantity, IQuantity? other, IQuantity tolerance) + public static bool Equals(this TQuantity quantity, IQuantity? other, TTolerance tolerance) where TQuantity : ILinearQuantity + where TTolerance : IQuantityOfType { - if (other is not TQuantity otherInstance) - { - return false; - } - - // TODO see about this (I think the exception should take precedence to the null check, but the QuantityTests disagree) - if (tolerance is not TQuantity toleranceQuantity) - { - throw ExceptionHelper.CreateArgumentException(tolerance, nameof(tolerance)); - } - - return quantity.EqualsAbsolute(otherInstance, toleranceQuantity); + return other is TQuantity otherInstance && quantity.EqualsAbsolute(otherInstance, tolerance); } /// @@ -70,10 +56,10 @@ public static bool Equals(this TQuantity quantity, IQuantity? other, /// It is generally advised against specifying "zero" tolerance, preferring the use of the default equality /// comparer, which is significantly more performant. /// - public static bool EqualsAbsolute(this TQuantity quantity, TOther other, TTolerance tolerance) + private static bool EqualsAbsolute(this TQuantity quantity, TOther other, TTolerance tolerance) where TQuantity : ILinearQuantity - where TOther : IQuantityInstance - where TTolerance : IQuantityInstance + where TOther : IQuantityOfType + where TTolerance : IQuantityOfType { UnitKey quantityUnit = quantity.UnitKey; return Comparison.EqualsAbsolute(quantity.Value, other.GetValue(quantityUnit), tolerance.GetValue(quantityUnit)); diff --git a/UnitsNet/Extensions/LogarithmicQuantityExtensions.cs b/UnitsNet/Extensions/LogarithmicQuantityExtensions.cs index 3419e1dbf0..7f28720e05 100644 --- a/UnitsNet/Extensions/LogarithmicQuantityExtensions.cs +++ b/UnitsNet/Extensions/LogarithmicQuantityExtensions.cs @@ -33,32 +33,18 @@ private static double RootN(double number, int n) /// public static bool Equals(this TQuantity quantity, TOther? other, TTolerance tolerance) where TQuantity : ILogarithmicQuantity - where TOther : IQuantityInstance - where TTolerance : IQuantityInstance + where TOther : IQuantityOfType + where TTolerance : IQuantityOfType { return other is not null && quantity.EqualsAbsolute(other, tolerance); } /// - /// - /// Thrown when the is not of the same type as the - /// . - /// - public static bool Equals(this TQuantity quantity, IQuantity? other, IQuantity tolerance) + public static bool Equals(this TQuantity quantity, IQuantity? other, TTolerance tolerance) where TQuantity : ILogarithmicQuantity + where TTolerance : IQuantityOfType { - if (other is not TQuantity otherInstance) - { - return false; - } - - // TODO see about this (I think the exception should take precedence to the null check, but the QuantityTests disagree) - if (tolerance is not TQuantity toleranceQuantity) - { - throw ExceptionHelper.CreateArgumentException(tolerance, nameof(tolerance)); - } - - return quantity.EqualsAbsolute(otherInstance, toleranceQuantity); + return other is TQuantity otherInstance && quantity.EqualsAbsolute(otherInstance, tolerance); } /// @@ -93,10 +79,10 @@ public static bool Equals(this TQuantity quantity, IQuantity? other, /// comparer, which is significantly more performant. /// /// - public static bool EqualsAbsolute(this TQuantity quantity, TOther other, TTolerance tolerance) + private static bool EqualsAbsolute(this TQuantity quantity, TOther other, TTolerance tolerance) where TQuantity : ILogarithmicQuantity - where TOther : IQuantityInstance - where TTolerance : IQuantityInstance + where TOther : IQuantityOfType + where TTolerance : IQuantityOfType { UnitKey quantityUnit = quantity.UnitKey; #if NET diff --git a/UnitsNet/Extensions/QuantityExtensions.cs b/UnitsNet/Extensions/QuantityExtensions.cs index 8bb9e03cdd..41f2ace803 100644 --- a/UnitsNet/Extensions/QuantityExtensions.cs +++ b/UnitsNet/Extensions/QuantityExtensions.cs @@ -65,7 +65,7 @@ public static string ToString(this TQuantity quantity, string? format /// Thrown when the collection is null. /// Thrown when the collection is empty. internal static TQuantity ArithmeticMean(this IEnumerable quantities) - where TQuantity : IQuantityInstance + where TQuantity : IQuantityOfType { if (quantities is null) { diff --git a/UnitsNet/GeneratedCode/Quantities/AbsorbedDoseOfIonizingRadiation.g.cs b/UnitsNet/GeneratedCode/Quantities/AbsorbedDoseOfIonizingRadiation.g.cs index 5871359a7b..d8cd6c0cba 100644 --- a/UnitsNet/GeneratedCode/Quantities/AbsorbedDoseOfIonizingRadiation.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AbsorbedDoseOfIonizingRadiation.g.cs @@ -237,7 +237,7 @@ public AbsorbedDoseOfIonizingRadiation(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs b/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs index 33973b687f..3021853af1 100644 --- a/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs @@ -238,7 +238,7 @@ public Acceleration(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs b/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs index f9d4c7823e..6877cfdc14 100644 --- a/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs @@ -242,7 +242,7 @@ public AmountOfSubstance(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.g.cs b/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.g.cs index e78867732b..5175ed3456 100644 --- a/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.g.cs @@ -210,7 +210,7 @@ public AmplitudeRatio(double value, AmplitudeRatioUnit unit) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #if NETSTANDARD2_0 diff --git a/UnitsNet/GeneratedCode/Quantities/Angle.g.cs b/UnitsNet/GeneratedCode/Quantities/Angle.g.cs index eeaa8cd628..a4e7c4c147 100644 --- a/UnitsNet/GeneratedCode/Quantities/Angle.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Angle.g.cs @@ -223,7 +223,7 @@ public Angle(double value, AngleUnit unit) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Area.g.cs b/UnitsNet/GeneratedCode/Quantities/Area.g.cs index 1a7dad3f73..8f9c8d8841 100644 --- a/UnitsNet/GeneratedCode/Quantities/Area.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Area.g.cs @@ -249,7 +249,7 @@ public Area(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs index 25f2561cf7..b855045c9c 100644 --- a/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs @@ -223,7 +223,7 @@ public AreaDensity(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs b/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs index 0263a177a1..d4701c9049 100644 --- a/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs @@ -227,7 +227,7 @@ public AreaMomentOfInertia(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs b/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs index 9ad0f15a26..0d5c5f5fba 100644 --- a/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs @@ -259,7 +259,7 @@ public BitRate(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs b/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs index 27fb0e9437..6a9397214e 100644 --- a/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs @@ -224,7 +224,7 @@ public BrakeSpecificFuelConsumption(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs b/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs index a6aab41baa..7e402258c8 100644 --- a/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs @@ -226,7 +226,7 @@ public CoefficientOfThermalExpansion(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Compressibility.g.cs b/UnitsNet/GeneratedCode/Quantities/Compressibility.g.cs index 3c9d8b1e7f..91aa768652 100644 --- a/UnitsNet/GeneratedCode/Quantities/Compressibility.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Compressibility.g.cs @@ -224,7 +224,7 @@ public Compressibility(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Density.g.cs b/UnitsNet/GeneratedCode/Quantities/Density.g.cs index d71409b39b..7d6f1bc76b 100644 --- a/UnitsNet/GeneratedCode/Quantities/Density.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Density.g.cs @@ -285,7 +285,7 @@ public Density(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/DoseAreaProduct.g.cs b/UnitsNet/GeneratedCode/Quantities/DoseAreaProduct.g.cs index ace5fa5d9e..eee8f230e0 100644 --- a/UnitsNet/GeneratedCode/Quantities/DoseAreaProduct.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/DoseAreaProduct.g.cs @@ -245,7 +245,7 @@ public DoseAreaProduct(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Duration.g.cs b/UnitsNet/GeneratedCode/Quantities/Duration.g.cs index 3ce53590e2..cdcc34f7dd 100644 --- a/UnitsNet/GeneratedCode/Quantities/Duration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Duration.g.cs @@ -247,7 +247,7 @@ public Duration(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs b/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs index 408869cd60..d5162ae75c 100644 --- a/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs @@ -234,7 +234,7 @@ public DynamicViscosity(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.g.cs index 19d973148e..98f1b56b3a 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.g.cs @@ -237,7 +237,7 @@ public ElectricAdmittance(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricApparentEnergy.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricApparentEnergy.g.cs index 9b065fc9ba..5f81b30658 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricApparentEnergy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricApparentEnergy.g.cs @@ -220,7 +220,7 @@ public ElectricApparentEnergy(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricApparentPower.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricApparentPower.g.cs index 29940a6ac9..64a2016ca8 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricApparentPower.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricApparentPower.g.cs @@ -226,7 +226,7 @@ public ElectricApparentPower(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCapacitance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCapacitance.g.cs index 46ca93d4e6..3df2dd87e6 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCapacitance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCapacitance.g.cs @@ -227,7 +227,7 @@ public ElectricCapacitance(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs index 0d041cff41..65fd92bcb7 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs @@ -236,7 +236,7 @@ public ElectricCharge(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.g.cs index b91c6dba22..f216d7055a 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.g.cs @@ -221,7 +221,7 @@ public ElectricChargeDensity(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricConductance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricConductance.g.cs index 0c55e99a2d..f1fb620106 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricConductance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricConductance.g.cs @@ -236,7 +236,7 @@ public ElectricConductance(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs index 6faedfcd7d..c4adf6fc4e 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs @@ -226,7 +226,7 @@ public ElectricConductivity(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs index c5700c30e0..3dfbea61a7 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs @@ -236,7 +236,7 @@ public ElectricCurrent(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs index c24785a1f0..9c03fdc85a 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs @@ -223,7 +223,7 @@ public ElectricCurrentDensity(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs index 8c0e6a6707..6e85b7e861 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs @@ -227,7 +227,7 @@ public ElectricCurrentGradient(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricField.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricField.g.cs index 0eaf4ef823..98af052ac8 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricField.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricField.g.cs @@ -221,7 +221,7 @@ public ElectricField(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricImpedance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricImpedance.g.cs index ba64c2803f..afc91880e4 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricImpedance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricImpedance.g.cs @@ -229,7 +229,7 @@ public ElectricImpedance(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricInductance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricInductance.g.cs index 66f973b0ed..2934605e90 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricInductance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricInductance.g.cs @@ -225,7 +225,7 @@ public ElectricInductance(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs index 57d914e429..15f10d5d6e 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs @@ -232,7 +232,7 @@ public ElectricPotential(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs index 297dfac804..08a36d7cd7 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs @@ -237,7 +237,7 @@ public ElectricPotentialChangeRate(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricReactance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricReactance.g.cs index b5eb0e93b5..62daceb753 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricReactance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricReactance.g.cs @@ -228,7 +228,7 @@ public ElectricReactance(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricReactiveEnergy.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricReactiveEnergy.g.cs index 7d7621d0cd..a84798b932 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricReactiveEnergy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricReactiveEnergy.g.cs @@ -220,7 +220,7 @@ public ElectricReactiveEnergy(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricReactivePower.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricReactivePower.g.cs index c29d0356de..e34eb13f87 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricReactivePower.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricReactivePower.g.cs @@ -224,7 +224,7 @@ public ElectricReactivePower(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs index cca61636ab..357c8263f1 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs @@ -231,7 +231,7 @@ public ElectricResistance(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs index 517efc3871..0afea7f612 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs @@ -234,7 +234,7 @@ public ElectricResistivity(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs index 1d8c51bf5d..a8a941f14c 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs @@ -223,7 +223,7 @@ public ElectricSurfaceChargeDensity(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricSusceptance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricSusceptance.g.cs index 547cecbcd7..180475555d 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricSusceptance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricSusceptance.g.cs @@ -236,7 +236,7 @@ public ElectricSusceptance(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Energy.g.cs b/UnitsNet/GeneratedCode/Quantities/Energy.g.cs index f85626fd6e..c77f2cbcc1 100644 --- a/UnitsNet/GeneratedCode/Quantities/Energy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Energy.g.cs @@ -272,7 +272,7 @@ public Energy(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/EnergyDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/EnergyDensity.g.cs index 3aad9da18a..a3e04bcba3 100644 --- a/UnitsNet/GeneratedCode/Quantities/EnergyDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/EnergyDensity.g.cs @@ -232,7 +232,7 @@ public EnergyDensity(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs b/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs index f33f70ea30..37a709ec56 100644 --- a/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs @@ -229,7 +229,7 @@ public Entropy(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/FluidResistance.g.cs b/UnitsNet/GeneratedCode/Quantities/FluidResistance.g.cs index befa267edd..5fb95c91fe 100644 --- a/UnitsNet/GeneratedCode/Quantities/FluidResistance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/FluidResistance.g.cs @@ -239,7 +239,7 @@ public FluidResistance(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Force.g.cs b/UnitsNet/GeneratedCode/Quantities/Force.g.cs index 809caf640e..123e190978 100644 --- a/UnitsNet/GeneratedCode/Quantities/Force.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Force.g.cs @@ -246,7 +246,7 @@ public Force(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs index 6c757eb615..a3bbf5e333 100644 --- a/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs @@ -235,7 +235,7 @@ public ForceChangeRate(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs b/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs index c168b064b7..bcb7f5058a 100644 --- a/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs @@ -266,7 +266,7 @@ public ForcePerLength(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs b/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs index 8c15522dde..82f3b0812b 100644 --- a/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs @@ -232,7 +232,7 @@ public Frequency(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/FuelEfficiency.g.cs b/UnitsNet/GeneratedCode/Quantities/FuelEfficiency.g.cs index d33e750671..61640d31a7 100644 --- a/UnitsNet/GeneratedCode/Quantities/FuelEfficiency.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/FuelEfficiency.g.cs @@ -224,7 +224,7 @@ public FuelEfficiency(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs b/UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs index bea9c2ebb1..0ad71fd567 100644 --- a/UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs @@ -238,7 +238,7 @@ public HeatFlux(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs b/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs index 123c332821..cdb0b0644d 100644 --- a/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs @@ -222,7 +222,7 @@ public HeatTransferCoefficient(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Illuminance.g.cs b/UnitsNet/GeneratedCode/Quantities/Illuminance.g.cs index b61e3707da..0eb0f48792 100644 --- a/UnitsNet/GeneratedCode/Quantities/Illuminance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Illuminance.g.cs @@ -227,7 +227,7 @@ public Illuminance(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Impulse.g.cs b/UnitsNet/GeneratedCode/Quantities/Impulse.g.cs index 88cb8ef68f..e91d1011a9 100644 --- a/UnitsNet/GeneratedCode/Quantities/Impulse.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Impulse.g.cs @@ -230,7 +230,7 @@ public Impulse(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Information.g.cs b/UnitsNet/GeneratedCode/Quantities/Information.g.cs index 8ab4591f9d..8f51e5f001 100644 --- a/UnitsNet/GeneratedCode/Quantities/Information.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Information.g.cs @@ -242,7 +242,7 @@ public Information(double value, InformationUnit unit) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Irradiance.g.cs b/UnitsNet/GeneratedCode/Quantities/Irradiance.g.cs index 94600cfda5..5034166e9f 100644 --- a/UnitsNet/GeneratedCode/Quantities/Irradiance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Irradiance.g.cs @@ -231,7 +231,7 @@ public Irradiance(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Irradiation.g.cs b/UnitsNet/GeneratedCode/Quantities/Irradiation.g.cs index 5f76e3ffc7..149b97c159 100644 --- a/UnitsNet/GeneratedCode/Quantities/Irradiation.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Irradiation.g.cs @@ -229,7 +229,7 @@ public Irradiation(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Jerk.g.cs b/UnitsNet/GeneratedCode/Quantities/Jerk.g.cs index b05491901a..25eb18aed0 100644 --- a/UnitsNet/GeneratedCode/Quantities/Jerk.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Jerk.g.cs @@ -231,7 +231,7 @@ public Jerk(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs b/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs index 559b191971..8ec6aa1e4e 100644 --- a/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs @@ -235,7 +235,7 @@ public KinematicViscosity(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/LeakRate.g.cs b/UnitsNet/GeneratedCode/Quantities/LeakRate.g.cs index 75b48befae..35997198e6 100644 --- a/UnitsNet/GeneratedCode/Quantities/LeakRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LeakRate.g.cs @@ -224,7 +224,7 @@ public LeakRate(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Length.g.cs b/UnitsNet/GeneratedCode/Quantities/Length.g.cs index d918a18e9d..903bd1d83a 100644 --- a/UnitsNet/GeneratedCode/Quantities/Length.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Length.g.cs @@ -279,7 +279,7 @@ public Length(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Level.g.cs b/UnitsNet/GeneratedCode/Quantities/Level.g.cs index 8d7e453301..72329ad9f4 100644 --- a/UnitsNet/GeneratedCode/Quantities/Level.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Level.g.cs @@ -208,7 +208,7 @@ public Level(double value, LevelUnit unit) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #if NETSTANDARD2_0 diff --git a/UnitsNet/GeneratedCode/Quantities/LinearDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/LinearDensity.g.cs index 3a309625b8..717e62ea3d 100644 --- a/UnitsNet/GeneratedCode/Quantities/LinearDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LinearDensity.g.cs @@ -243,7 +243,7 @@ public LinearDensity(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/LinearPowerDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/LinearPowerDensity.g.cs index 10c7785dec..9d28cc0ea9 100644 --- a/UnitsNet/GeneratedCode/Quantities/LinearPowerDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LinearPowerDensity.g.cs @@ -245,7 +245,7 @@ public LinearPowerDensity(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Luminance.g.cs b/UnitsNet/GeneratedCode/Quantities/Luminance.g.cs index a1e4d9421c..18cb8b346f 100644 --- a/UnitsNet/GeneratedCode/Quantities/Luminance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Luminance.g.cs @@ -233,7 +233,7 @@ public Luminance(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Luminosity.g.cs b/UnitsNet/GeneratedCode/Quantities/Luminosity.g.cs index 3cba77d27d..33ab3cc86b 100644 --- a/UnitsNet/GeneratedCode/Quantities/Luminosity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Luminosity.g.cs @@ -234,7 +234,7 @@ public Luminosity(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/LuminousFlux.g.cs b/UnitsNet/GeneratedCode/Quantities/LuminousFlux.g.cs index db7eae72c1..5cb17e6792 100644 --- a/UnitsNet/GeneratedCode/Quantities/LuminousFlux.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LuminousFlux.g.cs @@ -225,7 +225,7 @@ public LuminousFlux(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.g.cs b/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.g.cs index 25688b2f46..0613426cc3 100644 --- a/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.g.cs @@ -225,7 +225,7 @@ public LuminousIntensity(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/MagneticField.g.cs b/UnitsNet/GeneratedCode/Quantities/MagneticField.g.cs index 4ec638af33..ecd596b7d2 100644 --- a/UnitsNet/GeneratedCode/Quantities/MagneticField.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MagneticField.g.cs @@ -226,7 +226,7 @@ public MagneticField(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/MagneticFlux.g.cs b/UnitsNet/GeneratedCode/Quantities/MagneticFlux.g.cs index efff5575c1..50dcf999b1 100644 --- a/UnitsNet/GeneratedCode/Quantities/MagneticFlux.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MagneticFlux.g.cs @@ -221,7 +221,7 @@ public MagneticFlux(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Magnetization.g.cs b/UnitsNet/GeneratedCode/Quantities/Magnetization.g.cs index fd6a4147ce..df89aa1da7 100644 --- a/UnitsNet/GeneratedCode/Quantities/Magnetization.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Magnetization.g.cs @@ -221,7 +221,7 @@ public Magnetization(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Mass.g.cs b/UnitsNet/GeneratedCode/Quantities/Mass.g.cs index ebb018d6b1..92dcb393cd 100644 --- a/UnitsNet/GeneratedCode/Quantities/Mass.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Mass.g.cs @@ -262,7 +262,7 @@ public Mass(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/MassConcentration.g.cs b/UnitsNet/GeneratedCode/Quantities/MassConcentration.g.cs index e3ea9907c6..789b09c5c9 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassConcentration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassConcentration.g.cs @@ -276,7 +276,7 @@ public MassConcentration(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs b/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs index 8ea6a93468..929c89ca73 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs @@ -262,7 +262,7 @@ public MassFlow(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs b/UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs index de77b0ce03..d9a7303940 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs @@ -234,7 +234,7 @@ public MassFlux(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/MassFraction.g.cs b/UnitsNet/GeneratedCode/Quantities/MassFraction.g.cs index 8e09be88ea..e36c763699 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassFraction.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassFraction.g.cs @@ -233,7 +233,7 @@ public MassFraction(double value, MassFractionUnit unit) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.g.cs b/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.g.cs index 9ed52a1275..10c70791dd 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.g.cs @@ -245,7 +245,7 @@ public MassMomentOfInertia(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Molality.g.cs b/UnitsNet/GeneratedCode/Quantities/Molality.g.cs index 6069504995..f68962f216 100644 --- a/UnitsNet/GeneratedCode/Quantities/Molality.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Molality.g.cs @@ -223,7 +223,7 @@ public Molality(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/MolarEnergy.g.cs b/UnitsNet/GeneratedCode/Quantities/MolarEnergy.g.cs index f6e8a7658f..159ad2e9f7 100644 --- a/UnitsNet/GeneratedCode/Quantities/MolarEnergy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MolarEnergy.g.cs @@ -223,7 +223,7 @@ public MolarEnergy(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs b/UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs index 30f5568438..1cedb3803e 100644 --- a/UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs @@ -220,7 +220,7 @@ public MolarEntropy(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/MolarFlow.g.cs b/UnitsNet/GeneratedCode/Quantities/MolarFlow.g.cs index e8129a5112..6180afaf0f 100644 --- a/UnitsNet/GeneratedCode/Quantities/MolarFlow.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MolarFlow.g.cs @@ -232,7 +232,7 @@ public MolarFlow(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs b/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs index 736652a421..e8b80ef894 100644 --- a/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs @@ -235,7 +235,7 @@ public MolarMass(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs b/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs index e5404675a1..86febc78f1 100644 --- a/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs @@ -238,7 +238,7 @@ public Molarity(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Permeability.g.cs b/UnitsNet/GeneratedCode/Quantities/Permeability.g.cs index a6abc55963..6e8d29a4e4 100644 --- a/UnitsNet/GeneratedCode/Quantities/Permeability.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Permeability.g.cs @@ -221,7 +221,7 @@ public Permeability(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Permittivity.g.cs b/UnitsNet/GeneratedCode/Quantities/Permittivity.g.cs index 3d1fe94806..65dd10196d 100644 --- a/UnitsNet/GeneratedCode/Quantities/Permittivity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Permittivity.g.cs @@ -221,7 +221,7 @@ public Permittivity(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/PorousMediumPermeability.g.cs b/UnitsNet/GeneratedCode/Quantities/PorousMediumPermeability.g.cs index 255f7dd31a..394608e69f 100644 --- a/UnitsNet/GeneratedCode/Quantities/PorousMediumPermeability.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/PorousMediumPermeability.g.cs @@ -225,7 +225,7 @@ public PorousMediumPermeability(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Power.g.cs b/UnitsNet/GeneratedCode/Quantities/Power.g.cs index bc730df565..17a9807981 100644 --- a/UnitsNet/GeneratedCode/Quantities/Power.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Power.g.cs @@ -260,7 +260,7 @@ public Power(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/PowerDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/PowerDensity.g.cs index 254d42bd53..00a0924c65 100644 --- a/UnitsNet/GeneratedCode/Quantities/PowerDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/PowerDensity.g.cs @@ -261,7 +261,7 @@ public PowerDensity(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/PowerRatio.g.cs b/UnitsNet/GeneratedCode/Quantities/PowerRatio.g.cs index f414118cb9..6ff54fdf38 100644 --- a/UnitsNet/GeneratedCode/Quantities/PowerRatio.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/PowerRatio.g.cs @@ -208,7 +208,7 @@ public PowerRatio(double value, PowerRatioUnit unit) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #if NETSTANDARD2_0 diff --git a/UnitsNet/GeneratedCode/Quantities/Pressure.g.cs b/UnitsNet/GeneratedCode/Quantities/Pressure.g.cs index a6b17ca554..0045eb0958 100644 --- a/UnitsNet/GeneratedCode/Quantities/Pressure.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Pressure.g.cs @@ -276,7 +276,7 @@ public Pressure(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.g.cs index d00a06a6b8..312619ab43 100644 --- a/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.g.cs @@ -238,7 +238,7 @@ public PressureChangeRate(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/RadiationEquivalentDose.g.cs b/UnitsNet/GeneratedCode/Quantities/RadiationEquivalentDose.g.cs index da4d1c8222..bd6b9421fb 100644 --- a/UnitsNet/GeneratedCode/Quantities/RadiationEquivalentDose.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RadiationEquivalentDose.g.cs @@ -227,7 +227,7 @@ public RadiationEquivalentDose(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/RadiationEquivalentDoseRate.g.cs b/UnitsNet/GeneratedCode/Quantities/RadiationEquivalentDoseRate.g.cs index 0ea15d4b33..50e7f0b9de 100644 --- a/UnitsNet/GeneratedCode/Quantities/RadiationEquivalentDoseRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RadiationEquivalentDoseRate.g.cs @@ -230,7 +230,7 @@ public RadiationEquivalentDoseRate(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/RadiationExposure.g.cs b/UnitsNet/GeneratedCode/Quantities/RadiationExposure.g.cs index 010d1f9c72..1721e3f846 100644 --- a/UnitsNet/GeneratedCode/Quantities/RadiationExposure.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RadiationExposure.g.cs @@ -225,7 +225,7 @@ public RadiationExposure(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Radioactivity.g.cs b/UnitsNet/GeneratedCode/Quantities/Radioactivity.g.cs index 2ab55b2a4c..9418dc8289 100644 --- a/UnitsNet/GeneratedCode/Quantities/Radioactivity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Radioactivity.g.cs @@ -246,7 +246,7 @@ public Radioactivity(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Ratio.g.cs b/UnitsNet/GeneratedCode/Quantities/Ratio.g.cs index 4c7b90af0c..a633215a7a 100644 --- a/UnitsNet/GeneratedCode/Quantities/Ratio.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Ratio.g.cs @@ -209,7 +209,7 @@ public Ratio(double value, RatioUnit unit) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/RatioChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/RatioChangeRate.g.cs index e1df1e7b55..fb7577a59a 100644 --- a/UnitsNet/GeneratedCode/Quantities/RatioChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RatioChangeRate.g.cs @@ -219,7 +219,7 @@ public RatioChangeRate(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ReciprocalArea.g.cs b/UnitsNet/GeneratedCode/Quantities/ReciprocalArea.g.cs index 4edfaafc51..c816c09c06 100644 --- a/UnitsNet/GeneratedCode/Quantities/ReciprocalArea.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ReciprocalArea.g.cs @@ -238,7 +238,7 @@ public ReciprocalArea(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ReciprocalLength.g.cs b/UnitsNet/GeneratedCode/Quantities/ReciprocalLength.g.cs index 5f89fc4314..e7ad5fb875 100644 --- a/UnitsNet/GeneratedCode/Quantities/ReciprocalLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ReciprocalLength.g.cs @@ -239,7 +239,7 @@ public ReciprocalLength(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/RelativeHumidity.g.cs b/UnitsNet/GeneratedCode/Quantities/RelativeHumidity.g.cs index 753144dd44..effd4bbba5 100644 --- a/UnitsNet/GeneratedCode/Quantities/RelativeHumidity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RelativeHumidity.g.cs @@ -204,7 +204,7 @@ public RelativeHumidity(double value, RelativeHumidityUnit unit) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalAcceleration.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalAcceleration.g.cs index 28a6467e19..5c7dee22e3 100644 --- a/UnitsNet/GeneratedCode/Quantities/RotationalAcceleration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RotationalAcceleration.g.cs @@ -221,7 +221,7 @@ public RotationalAcceleration(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.g.cs index a46dd24e1c..b444910b36 100644 --- a/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.g.cs @@ -234,7 +234,7 @@ public RotationalSpeed(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.g.cs index d4e7b1f21d..9195e1a5d1 100644 --- a/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.g.cs @@ -255,7 +255,7 @@ public RotationalStiffness(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs index 93b03b7562..ac3655b3e4 100644 --- a/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs @@ -225,7 +225,7 @@ public RotationalStiffnessPerLength(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Scalar.g.cs b/UnitsNet/GeneratedCode/Quantities/Scalar.g.cs index 8cba945512..818c01cfbc 100644 --- a/UnitsNet/GeneratedCode/Quantities/Scalar.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Scalar.g.cs @@ -204,7 +204,7 @@ public Scalar(double value, ScalarUnit unit) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/SolidAngle.g.cs b/UnitsNet/GeneratedCode/Quantities/SolidAngle.g.cs index aefca11d43..64dc7aab4c 100644 --- a/UnitsNet/GeneratedCode/Quantities/SolidAngle.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SolidAngle.g.cs @@ -207,7 +207,7 @@ public SolidAngle(double value, SolidAngleUnit unit) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.g.cs index 91dea9772b..1de82afbb4 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.g.cs @@ -258,7 +258,7 @@ public SpecificEnergy(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.g.cs index 0a51a42cf4..8e35a5ae5f 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.g.cs @@ -230,7 +230,7 @@ public SpecificEntropy(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs index e0d5f6a61e..59ed43ac53 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs @@ -224,7 +224,7 @@ public SpecificFuelConsumption(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs index 69a357c204..44ee742aaf 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs @@ -223,7 +223,7 @@ public SpecificVolume(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificWeight.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificWeight.g.cs index 277424f8a3..6aa9854f07 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificWeight.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificWeight.g.cs @@ -243,7 +243,7 @@ public SpecificWeight(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Speed.g.cs b/UnitsNet/GeneratedCode/Quantities/Speed.g.cs index 72143237fe..348926a43d 100644 --- a/UnitsNet/GeneratedCode/Quantities/Speed.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Speed.g.cs @@ -260,7 +260,7 @@ public Speed(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/StandardVolumeFlow.g.cs b/UnitsNet/GeneratedCode/Quantities/StandardVolumeFlow.g.cs index 729abd7b03..6e3c2f95af 100644 --- a/UnitsNet/GeneratedCode/Quantities/StandardVolumeFlow.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/StandardVolumeFlow.g.cs @@ -226,7 +226,7 @@ public StandardVolumeFlow(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Temperature.g.cs b/UnitsNet/GeneratedCode/Quantities/Temperature.g.cs index b27abdb70f..820fc2a0d6 100644 --- a/UnitsNet/GeneratedCode/Quantities/Temperature.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Temperature.g.cs @@ -227,7 +227,7 @@ public Temperature(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.g.cs index 731f83a1cd..6ac1ad6fd7 100644 --- a/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.g.cs @@ -237,7 +237,7 @@ public TemperatureChangeRate(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs b/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs index 1e02e2fc53..3f9d21e7f5 100644 --- a/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs @@ -235,7 +235,7 @@ public TemperatureDelta(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/TemperatureGradient.g.cs b/UnitsNet/GeneratedCode/Quantities/TemperatureGradient.g.cs index 8f579c80d1..0ca317aae8 100644 --- a/UnitsNet/GeneratedCode/Quantities/TemperatureGradient.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/TemperatureGradient.g.cs @@ -224,7 +224,7 @@ public TemperatureGradient(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ThermalConductivity.g.cs b/UnitsNet/GeneratedCode/Quantities/ThermalConductivity.g.cs index f9f52d86b4..89d2c53cd2 100644 --- a/UnitsNet/GeneratedCode/Quantities/ThermalConductivity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ThermalConductivity.g.cs @@ -222,7 +222,7 @@ public ThermalConductivity(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ThermalInsulance.g.cs b/UnitsNet/GeneratedCode/Quantities/ThermalInsulance.g.cs index e682d4c65c..2ab6174c8a 100644 --- a/UnitsNet/GeneratedCode/Quantities/ThermalInsulance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ThermalInsulance.g.cs @@ -224,7 +224,7 @@ public ThermalInsulance(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ThermalResistance.g.cs b/UnitsNet/GeneratedCode/Quantities/ThermalResistance.g.cs index 4d8b33fa81..c67f808f54 100644 --- a/UnitsNet/GeneratedCode/Quantities/ThermalResistance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ThermalResistance.g.cs @@ -219,7 +219,7 @@ public ThermalResistance(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Torque.g.cs b/UnitsNet/GeneratedCode/Quantities/Torque.g.cs index 656c8ecd12..c4c822186b 100644 --- a/UnitsNet/GeneratedCode/Quantities/Torque.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Torque.g.cs @@ -251,7 +251,7 @@ public Torque(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Turbidity.g.cs b/UnitsNet/GeneratedCode/Quantities/Turbidity.g.cs index 5fbeea5558..cd115023c4 100644 --- a/UnitsNet/GeneratedCode/Quantities/Turbidity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Turbidity.g.cs @@ -207,7 +207,7 @@ public Turbidity(double value, TurbidityUnit unit) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/VitaminA.g.cs b/UnitsNet/GeneratedCode/Quantities/VitaminA.g.cs index a6cca1429a..44d94958e4 100644 --- a/UnitsNet/GeneratedCode/Quantities/VitaminA.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VitaminA.g.cs @@ -204,7 +204,7 @@ public VitaminA(double value, VitaminAUnit unit) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Volume.g.cs b/UnitsNet/GeneratedCode/Quantities/Volume.g.cs index 9ccdfa62c1..fbdc1012a8 100644 --- a/UnitsNet/GeneratedCode/Quantities/Volume.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Volume.g.cs @@ -286,7 +286,7 @@ public Volume(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/VolumeConcentration.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumeConcentration.g.cs index 29642e3a09..093fbd2ad8 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumeConcentration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumeConcentration.g.cs @@ -230,7 +230,7 @@ public VolumeConcentration(double value, VolumeConcentrationUnit unit) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs index 07431e2ba7..ea15e25de3 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs @@ -299,7 +299,7 @@ public VolumeFlow(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/VolumeFlowPerArea.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumeFlowPerArea.g.cs index 2abcfa15af..b465c49f3c 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumeFlowPerArea.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumeFlowPerArea.g.cs @@ -219,7 +219,7 @@ public VolumeFlowPerArea(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/VolumePerLength.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumePerLength.g.cs index 2c80031e1f..f638113e95 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumePerLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumePerLength.g.cs @@ -226,7 +226,7 @@ public VolumePerLength(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs index 2f9eaba537..e9ee8936e8 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs @@ -229,7 +229,7 @@ public VolumetricHeatCapacity(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs b/UnitsNet/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs index c1f898b072..3a6ee827df 100644 --- a/UnitsNet/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs @@ -223,7 +223,7 @@ public WarpingMomentOfInertia(double value, UnitSystem unitSystem) #if NETSTANDARD2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] - IQuantityInstanceInfo IQuantityInstance.QuantityInfo => Info; + IQuantityInstanceInfo IQuantityOfType.QuantityInfo => Info; #endif #endregion diff --git a/UnitsNet/IAffineQuantity.cs b/UnitsNet/IAffineQuantity.cs index 056b75120d..0a8028f784 100644 --- a/UnitsNet/IAffineQuantity.cs +++ b/UnitsNet/IAffineQuantity.cs @@ -29,7 +29,7 @@ public interface IAffineQuantity : IQuantity /// The type itself, for the CRT pattern. /// -public interface IAffineQuantity : IQuantityInstance +public interface IAffineQuantity : IQuantityOfType #if NET7_0_OR_GREATER , IAdditiveIdentity where TOffset : IAdditiveIdentity diff --git a/UnitsNet/IArithmeticQuantity.cs b/UnitsNet/IArithmeticQuantity.cs index 6ecfc1adb4..d9d075d19e 100644 --- a/UnitsNet/IArithmeticQuantity.cs +++ b/UnitsNet/IArithmeticQuantity.cs @@ -26,7 +26,7 @@ namespace UnitsNet; /// /// /// The type that implements this interface. -public interface ILinearQuantity : IQuantityInstance +public interface ILinearQuantity : IQuantityOfType #if NET7_0_OR_GREATER , IAdditiveIdentity #endif diff --git a/UnitsNet/ILogarithmicQuantity.cs b/UnitsNet/ILogarithmicQuantity.cs index 9c6b0cd0c6..eb35775ac1 100644 --- a/UnitsNet/ILogarithmicQuantity.cs +++ b/UnitsNet/ILogarithmicQuantity.cs @@ -34,7 +34,7 @@ public interface ILogarithmicQuantity : IQuantity -public interface ILogarithmicQuantity : IQuantityInstance +public interface ILogarithmicQuantity : IQuantityOfType #if NET7_0_OR_GREATER , IMultiplicativeIdentity #endif diff --git a/UnitsNet/IQuantity.cs b/UnitsNet/IQuantity.cs index e4c24adca9..42debad321 100644 --- a/UnitsNet/IQuantity.cs +++ b/UnitsNet/IQuantity.cs @@ -141,7 +141,7 @@ Enum IQuantity.Unit /// methods, without having to include the unit type as additional generic parameter. /// /// - public interface IQuantityInstance : IQuantity + public interface IQuantityOfType : IQuantity where TQuantity : IQuantity { #if NET @@ -157,7 +157,7 @@ public interface IQuantityInstance : IQuantity /// /// The type itself, for the CRT pattern. /// The underlying unit enum type. - public interface IQuantity : IQuantityInstance, IQuantity + public interface IQuantity : IQuantityOfType, IQuantity where TSelf : IQuantity where TUnitType : struct, Enum { @@ -173,7 +173,7 @@ public interface IQuantity : IQuantityInstance, IQuanti /// An instance of the quantity with the specified value and unit. static abstract TSelf From(double value, TUnitType unit); - static TSelf IQuantityInstance.Create(double value, UnitKey unit) => TSelf.From(value, unit.ToUnit()); + static TSelf IQuantityOfType.Create(double value, UnitKey unit) => TSelf.From(value, unit.ToUnit()); IQuantity IQuantity.ToUnit(TUnitType unit) { From a6fffc79e252d16816f452bed964fb09f6fd0aab Mon Sep 17 00:00:00 2001 From: lipchev Date: Sun, 3 Aug 2025 09:38:13 +0300 Subject: [PATCH 7/8] making the GenericMathExtensions class obsolete and replacing the relevant usages from the benchmarks --- .../SumOfMassesWithRandomUnitsBenchmarks.cs | 12 +---- .../SumOfMassesWithSameUnitsBenchmarks.cs | 12 +---- ...emperatureDeltasWithSameUnitsBenchmarks.cs | 6 +++ .../SumOfVolumesWithRandomUnitsBenchmarks.cs | 12 +---- ...esWithRandomUnitsWithIteratorBenchmarks.cs | 6 +-- .../SumOfVolumesWithSameUnitsBenchmarks.cs | 12 +---- ...lumesWithSimilarImperialUnitsBenchmarks.cs | 12 +---- ...umOfVolumesWithSimilarSIUnitsBenchmarks.cs | 12 +---- UnitsNet/GenericMath/GenericMathExtensions.cs | 45 ++++++++++++++----- 9 files changed, 46 insertions(+), 83 deletions(-) diff --git a/UnitsNet.Benchmark/Operators/Additions/SumOfMassesWithRandomUnitsBenchmarks.cs b/UnitsNet.Benchmark/Operators/Additions/SumOfMassesWithRandomUnitsBenchmarks.cs index 3a59f6b6ca..03271079ff 100644 --- a/UnitsNet.Benchmark/Operators/Additions/SumOfMassesWithRandomUnitsBenchmarks.cs +++ b/UnitsNet.Benchmark/Operators/Additions/SumOfMassesWithRandomUnitsBenchmarks.cs @@ -31,17 +31,7 @@ public void PrepareQuantities() [Benchmark(Baseline = true)] public Mass SumOfMasses() { -#if NET - return UnitsNet.GenericMath.GenericMathExtensions.Sum(_quantities); -#else - Mass sum = Mass.Zero; - foreach (var quantity in _quantities) - { - sum = quantity + sum; - } - - return sum; -#endif + return _quantities.Sum(); } [Benchmark(Baseline = false)] diff --git a/UnitsNet.Benchmark/Operators/Additions/SumOfMassesWithSameUnitsBenchmarks.cs b/UnitsNet.Benchmark/Operators/Additions/SumOfMassesWithSameUnitsBenchmarks.cs index 2080183fa9..1a151e88e0 100644 --- a/UnitsNet.Benchmark/Operators/Additions/SumOfMassesWithSameUnitsBenchmarks.cs +++ b/UnitsNet.Benchmark/Operators/Additions/SumOfMassesWithSameUnitsBenchmarks.cs @@ -32,17 +32,7 @@ public void PrepareQuantities() [Benchmark(Baseline = true)] public Mass SumOfMasses() { -#if NET - return UnitsNet.GenericMath.GenericMathExtensions.Sum(_quantities); -#else - Mass sum = Mass.Zero; - foreach (var quantity in _quantities) - { - sum = quantity + sum; - } - - return sum; -#endif + return _quantities.Sum(); } [Benchmark(Baseline = false)] diff --git a/UnitsNet.Benchmark/Operators/Additions/SumOfTemperatureDeltasWithSameUnitsBenchmarks.cs b/UnitsNet.Benchmark/Operators/Additions/SumOfTemperatureDeltasWithSameUnitsBenchmarks.cs index 5625d53c58..e87bc37506 100644 --- a/UnitsNet.Benchmark/Operators/Additions/SumOfTemperatureDeltasWithSameUnitsBenchmarks.cs +++ b/UnitsNet.Benchmark/Operators/Additions/SumOfTemperatureDeltasWithSameUnitsBenchmarks.cs @@ -31,6 +31,12 @@ public void PrepareQuantities() [Benchmark(Baseline = true)] public TemperatureDelta SumOfDeltas() + { + return _quantities.Sum(); + } + + [Benchmark(Baseline = false)] + public TemperatureDelta GenericSumOfDeltas() { #if NET return UnitsNet.GenericMath.GenericMathExtensions.Sum(_quantities); diff --git a/UnitsNet.Benchmark/Operators/Additions/SumOfVolumesWithRandomUnitsBenchmarks.cs b/UnitsNet.Benchmark/Operators/Additions/SumOfVolumesWithRandomUnitsBenchmarks.cs index c7bf590527..a1b78a6852 100644 --- a/UnitsNet.Benchmark/Operators/Additions/SumOfVolumesWithRandomUnitsBenchmarks.cs +++ b/UnitsNet.Benchmark/Operators/Additions/SumOfVolumesWithRandomUnitsBenchmarks.cs @@ -33,17 +33,7 @@ public void PrepareQuantities() [Benchmark(Baseline = true)] public Volume SumOfVolumes() { -#if NET - return UnitsNet.GenericMath.GenericMathExtensions.Sum(_quantities); -#else - Volume sum = Volume.Zero; - foreach (var quantity in _quantities) - { - sum = quantity + sum; - } - - return sum; -#endif + return _quantities.Sum(); } [Benchmark(Baseline = false)] diff --git a/UnitsNet.Benchmark/Operators/Additions/SumOfVolumesWithRandomUnitsWithIteratorBenchmarks.cs b/UnitsNet.Benchmark/Operators/Additions/SumOfVolumesWithRandomUnitsWithIteratorBenchmarks.cs index 2cf21ae684..9daf113943 100644 --- a/UnitsNet.Benchmark/Operators/Additions/SumOfVolumesWithRandomUnitsWithIteratorBenchmarks.cs +++ b/UnitsNet.Benchmark/Operators/Additions/SumOfVolumesWithRandomUnitsWithIteratorBenchmarks.cs @@ -32,10 +32,6 @@ public void PrepareQuantities() [Benchmark(Baseline = true)] public Volume SumOfVolumes() { -#if NET - return UnitsNet.GenericMath.GenericMathExtensions.Sum(_quantities); -#else - throw new NotImplementedException(); -#endif + return _quantities.Sum(); } } diff --git a/UnitsNet.Benchmark/Operators/Additions/SumOfVolumesWithSameUnitsBenchmarks.cs b/UnitsNet.Benchmark/Operators/Additions/SumOfVolumesWithSameUnitsBenchmarks.cs index 94f4765f4e..6f28c0e0c5 100644 --- a/UnitsNet.Benchmark/Operators/Additions/SumOfVolumesWithSameUnitsBenchmarks.cs +++ b/UnitsNet.Benchmark/Operators/Additions/SumOfVolumesWithSameUnitsBenchmarks.cs @@ -32,17 +32,7 @@ public void PrepareQuantities() [Benchmark(Baseline = true)] public Volume SumOfVolumes() { -#if NET - return UnitsNet.GenericMath.GenericMathExtensions.Sum(_quantities); -#else - Volume sum = Volume.Zero; - foreach (var quantity in _quantities) - { - sum = quantity + sum; - } - - return sum; -#endif + return _quantities.Sum(); } [Benchmark(Baseline = false)] diff --git a/UnitsNet.Benchmark/Operators/Additions/SumOfVolumesWithSimilarImperialUnitsBenchmarks.cs b/UnitsNet.Benchmark/Operators/Additions/SumOfVolumesWithSimilarImperialUnitsBenchmarks.cs index a9cec2e553..224ffdb61f 100644 --- a/UnitsNet.Benchmark/Operators/Additions/SumOfVolumesWithSimilarImperialUnitsBenchmarks.cs +++ b/UnitsNet.Benchmark/Operators/Additions/SumOfVolumesWithSimilarImperialUnitsBenchmarks.cs @@ -39,17 +39,7 @@ public void PrepareQuantities() [Benchmark(Baseline = true)] public Volume SumOfVolumes() { -#if NET - return UnitsNet.GenericMath.GenericMathExtensions.Sum(_quantities); -#else - Volume sum = Volume.Zero; - foreach (var quantity in _quantities) - { - sum = quantity + sum; - } - - return sum; -#endif + return _quantities.Sum(); } [Benchmark(Baseline = false)] diff --git a/UnitsNet.Benchmark/Operators/Additions/SumOfVolumesWithSimilarSIUnitsBenchmarks.cs b/UnitsNet.Benchmark/Operators/Additions/SumOfVolumesWithSimilarSIUnitsBenchmarks.cs index 39a69e3076..e499491c78 100644 --- a/UnitsNet.Benchmark/Operators/Additions/SumOfVolumesWithSimilarSIUnitsBenchmarks.cs +++ b/UnitsNet.Benchmark/Operators/Additions/SumOfVolumesWithSimilarSIUnitsBenchmarks.cs @@ -39,17 +39,7 @@ public void PrepareQuantities() [Benchmark(Baseline = true)] public Volume SumOfVolumes() { -#if NET - return UnitsNet.GenericMath.GenericMathExtensions.Sum(_quantities); -#else - Volume sum = Volume.Zero; - foreach (var quantity in _quantities) - { - sum = quantity + sum; - } - - return sum; -#endif + return _quantities.Sum(); } [Benchmark(Baseline = false)] diff --git a/UnitsNet/GenericMath/GenericMathExtensions.cs b/UnitsNet/GenericMath/GenericMathExtensions.cs index 2cd4c2623f..239f85c299 100644 --- a/UnitsNet/GenericMath/GenericMathExtensions.cs +++ b/UnitsNet/GenericMath/GenericMathExtensions.cs @@ -2,8 +2,6 @@ // Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. #if NET7_0_OR_GREATER -using System; -using System.Collections.Generic; using System.Numerics; namespace UnitsNet.GenericMath; @@ -11,6 +9,13 @@ namespace UnitsNet.GenericMath; /// /// Provides generic math operations using the generic math interfaces implemented in .NET7 for UnitsNet. /// +/// +/// Unless you're using a custom quantity which requires a custom implementation for the interface, you +/// should consider switching to one of the more performant versions of this extension, found in the +/// , and +/// . +/// +[Obsolete("Replaced by the LinearQuantityExtensions, LogarithmicQuantityExtensions and AffineQuantityExtensions")] public static class GenericMathExtensions { /// @@ -20,11 +25,19 @@ public static class GenericMathExtensions /// The type of the quantity elements in the source sequence. /// The sum of the quantities, using the unit of the first element in the sequence. /// - /// Note that the generic math LINQ support is still missing in the BCL, but is being worked on: - /// - /// API Proposal: Generic LINQ Numeric Operators · Issue - /// #64031 · dotnet/runtime - /// + /// Unless + /// + /// requires a custom implementation for the interface, you + /// should consider switching to one of the more performant versions of this extension, found in the + /// , and + /// . + /// + /// Note that the generic math LINQ support is still missing in the BCL, but is being worked on: + /// + /// API Proposal: Generic LINQ Numeric Operators · Issue + /// #64031 · dotnet/runtime + /// + /// /// public static TQuantity Sum(this IEnumerable source) where TQuantity : IQuantity, IAdditionOperators, IAdditiveIdentity @@ -52,11 +65,19 @@ public static TQuantity Sum(this IEnumerable source) /// The average of the quantities, using the unit of the first element in the sequence. /// Thrown when the sequence is empty. /// - /// Note that the generic math LINQ support is still missing in the BCL, but is being worked on: - /// - /// API Proposal: Generic LINQ Numeric Operators · Issue - /// #64031 · dotnet/runtime - /// + /// Unless + /// + /// requires a custom implementation for the interface, you + /// should consider switching to one of the more performant versions of this extension, found in the + /// , and + /// . + /// + /// Note that the generic math LINQ support is still missing in the BCL, but is being worked on: + /// + /// API Proposal: Generic LINQ Numeric Operators · Issue + /// #64031 · dotnet/runtime + /// + /// /// public static TQuantity Average(this IEnumerable source) where TQuantity : IQuantity, IAdditionOperators, IAdditiveIdentity, From 5d25e1da5dce54c9e9461f5645079f7baca93816 Mon Sep 17 00:00:00 2001 From: lipchev Date: Sun, 3 Aug 2025 09:45:27 +0300 Subject: [PATCH 8/8] remove the GenerateArithmetic from the Temperature.json --- Common/UnitDefinitions/Temperature.json | 1 - 1 file changed, 1 deletion(-) diff --git a/Common/UnitDefinitions/Temperature.json b/Common/UnitDefinitions/Temperature.json index 625bffa81e..598f560bb3 100644 --- a/Common/UnitDefinitions/Temperature.json +++ b/Common/UnitDefinitions/Temperature.json @@ -2,7 +2,6 @@ "Name": "Temperature", "BaseUnit": "Kelvin", "XmlDocSummary": "A temperature is a numerical measure of hot or cold. Its measurement is by detection of heat radiation or particle velocity or kinetic energy, or by the bulk behavior of a thermometric material. It may be calibrated in any of various temperature scales, Celsius, Fahrenheit, Kelvin, etc. The fundamental physical definition of temperature is provided by thermodynamics.", - "GenerateArithmetic": false, "AffineOffsetType": "TemperatureDelta", "BaseDimensions": { "Θ": 1